Merge lp:~widelands-dev/widelands/fix_economy_crash into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 8247
Proposed branch: lp:~widelands-dev/widelands/fix_economy_crash
Merge into: lp:widelands
Diff against target: 127 lines (+50/-39)
1 file modified
data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua (+50/-39)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fix_economy_crash
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+315284@code.launchpad.net

Commit message

Generalize waiting on a window to be opened and a tab to be selected.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1835. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/193891633.
Appveyor build 1673. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fix_economy_crash-1673.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Not tested, code LGTM

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Tested,the crash is gone.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua'
--- data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2016-12-28 22:11:45 +0000
+++ data/campaigns/tutorial04_economy.wmf/scripting/mission_thread.lua 2017-01-20 21:53:31 +0000
@@ -10,6 +10,31 @@
10 burn_tavern_down()10 burn_tavern_down()
11end11end
1212
13function wait_for_window_and_tab_or_complain(
14 window_name,
15 tab_name,
16 objective, complain_msg
17)
18 while true do
19 -- This waits for the window to be opened.
20 if not mv.windows[window_name] then
21 objective.visible = true
22 message_box_objective(plr, complain_msg)
23 while not mv.windows[window_name] do sleep(200) end
24 objective.visible = false
25 end
26
27 -- But it might be closed at any point in time. If it is open and the
28 -- correct tab is active, we terminate the loop.
29 if mv.windows[window_name] and
30 mv.windows[window_name].tabs[tab_name].active
31 then
32 break
33 end
34 sleep(200)
35 end
36end
37
13function burn_tavern_down()38function burn_tavern_down()
14 sleep(500)39 sleep(500)
15 scroll_to_field(tavern_field)40 scroll_to_field(tavern_field)
@@ -26,17 +51,11 @@
26 -- We cannot create several objectives with the same name. Therefore, we create o2 here once and change its visibility51 -- We cannot create several objectives with the same name. Therefore, we create o2 here once and change its visibility
27 local o2 = add_campaign_objective(reopen_building_stat_obj)52 local o2 = add_campaign_objective(reopen_building_stat_obj)
28 o2.visible = false53 o2.visible = false
29 local medium_tab_active = false54 wait_for_window_and_tab_or_complain(
30 while not medium_tab_active do55 "building_statistics",
31 if not mv.windows.building_statistics then56 "building_stats_medium",
32 o2.visible = true57 o2, reopen_building_stat
33 message_box_objective(plr, reopen_building_stat)58 )
34 while not mv.windows.building_statistics do sleep(200) end
35 o2.visible = false
36 end
37 if mv.windows.building_statistics.tabs["building_stats_medium"].active then medium_tab_active = true end
38 sleep(200)
39 end
40 while mv.windows.building_statistics do sleep(100) end59 while mv.windows.building_statistics do sleep(100) end
41 set_objective_done(o, 0)60 set_objective_done(o, 0)
4261
@@ -45,18 +64,16 @@
45 set_objective_done(o, wl.Game().real_speed)64 set_objective_done(o, wl.Game().real_speed)
4665
47 o = message_box_objective(plr, inventory2)66 o = message_box_objective(plr, inventory2)
48 -- We cannot create several objectives with the same name. Therefore, we create o2 here once and change its visibility67 -- We cannot create several objectives with the same name. Therefore, we
68 -- create o2 here once and change its visibility
49 o2 = add_campaign_objective(reopen_stock_menu_obj)69 o2 = add_campaign_objective(reopen_stock_menu_obj)
50 o2.visible = false70 o2.visible = false
51 while not mv.windows.stock_menu.tabs["wares_in_warehouses"].active do71
52 if not mv.windows.stock_menu then72 wait_for_window_and_tab_or_complain(
53 o2.visible = true73 "stock_menu",
54 message_box_objective(plr, reopen_stock_menu)74 "wares_in_warehouses",
55 while not mv.windows.stock_menu do sleep(200) end75 o2, reopen_stock_menu
56 o2.visible = false76 )
57 end
58 sleep(200)
59 end
60 set_objective_done(o, 0)77 set_objective_done(o, 0)
61 message_box_objective(plr, inventory3)78 message_box_objective(plr, inventory3)
6279
@@ -83,29 +100,23 @@
83 o = message_box_objective(plr, ware_stats2)100 o = message_box_objective(plr, ware_stats2)
84 local o2 = add_campaign_objective(reopen_ware_stats1_obj)101 local o2 = add_campaign_objective(reopen_ware_stats1_obj)
85 o2.visible = false102 o2.visible = false
86 while not mv.windows.ware_statistics.tabs["economy_health"].active do103
87 if not mv.windows.ware_statistics then104 wait_for_window_and_tab_or_complain(
88 o2.visible = true105 "ware_statistics",
89 message_box_objective(plr, reopen_ware_stats1)106 "economy_health",
90 while not mv.windows.ware_statistics do sleep(200) end107 o2, reopen_ware_stats1
91 o2.visible = false108 )
92 end
93 sleep(200)
94 end
95 set_objective_done(o, 0)109 set_objective_done(o, 0)
96110
97 o = message_box_objective(plr, ware_stats3)111 o = message_box_objective(plr, ware_stats3)
98 o2 = add_campaign_objective(reopen_ware_stats2_obj)112 o2 = add_campaign_objective(reopen_ware_stats2_obj)
99 o2.visible = false113 o2.visible = false
100 while not mv.windows.ware_statistics.tabs["stock"].active do114
101 if not mv.windows.ware_statistics then115 wait_for_window_and_tab_or_complain(
102 o2.visible = true116 "ware_statistics",
103 message_box_objective(plr, reopen_ware_stats2)117 "stock",
104 while not mv.windows.ware_statistics do sleep(200) end118 o2, reopen_ware_stats2
105 o2.visible = false119 )
106 end
107 sleep(200)
108 end
109 set_objective_done(o, 0)120 set_objective_done(o, 0)
110121
111 o = message_box_objective(plr, ware_stats4)122 o = message_box_objective(plr, ware_stats4)

Subscribers

People subscribed via source and target branches

to status/vote changes: