Merge lp:~widelands-dev/widelands/fleet_update into lp:widelands
- fleet_update
- Merge into trunk
Proposed by
TiborB
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 7580 | ||||
Proposed branch: | lp:~widelands-dev/widelands/fleet_update | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
690 lines (+131/-134) 15 files modified
campaigns/atl01.wmf/scripting/mission_thread.lua (+2/-24) src/economy/fleet.cc (+6/-1) src/logic/ship.cc (+4/-7) test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua (+18/-12) test/maps/ship_transportation.wmf/scripting/init.lua (+4/-4) test/maps/ship_transportation.wmf/scripting/test_rip_farm_with_ware_and_worker_in_transit.lua (+6/-6) test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_ware_in_portdock.lua (+6/-6) test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_worker_in_portdock.lua (+6/-6) test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua (+16/-16) test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_ware_in_transit.lua (+9/-9) test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_worker_in_transit.lua (+9/-9) test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_ware_in_portdock.lua (+9/-9) test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua (+26/-15) test/maps/ship_transportation.wmf/scripting/test_rip_ship_before_picking_up_transporting_ware.lua (+5/-5) test/maps/ship_transportation.wmf/scripting/test_rip_ship_while_transporting_ware.lua (+5/-5) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/fleet_update | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GunChleoc | Approve | ||
Review via email: mp+276457@code.launchpad.net |
Commit message
Description of the change
Small redesign when fleet update is triggered. I partially undo previous changes (too frequent updates and some behaviour was disabled by mistake). Fleet is now updated also after port removal.
This fixes also linked bug.
Modification of regression test to test also situation when a ship is put on shore - mimics building of new ship.
Modification of one campaing lua file - just simplification of code.
Regression tests run OK.
To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote : | # |
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
Tested and LGTM. +1 for the renaming :)
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'campaigns/atl01.wmf/scripting/mission_thread.lua' |
2 | --- campaigns/atl01.wmf/scripting/mission_thread.lua 2014-10-31 11:36:29 +0000 |
3 | +++ campaigns/atl01.wmf/scripting/mission_thread.lua 2015-11-03 10:40:10 +0000 |
4 | @@ -169,30 +169,8 @@ |
5 | |
6 | function check_for_ships() |
7 | -- Check if the ships are done, then the mission ends successfully |
8 | - local lake_fields = Set:new() |
9 | - for idx,f in ipairs(map:get_field(75,80):region(12)) do |
10 | - if f:has_caps("swimmable") then |
11 | - lake_fields:add(f) |
12 | - end |
13 | - end |
14 | - |
15 | - while true do |
16 | - local nships = 0 |
17 | - -- Count the ships |
18 | - for f in lake_fields:items() do |
19 | - local bobs = f.bobs |
20 | - if #bobs then |
21 | - for idx, b in ipairs(bobs) do |
22 | - if b.descr.type_name == "ship" then |
23 | - nships = nships + 1 |
24 | - end |
25 | - end |
26 | - end |
27 | - end |
28 | - if nships >= 3 then |
29 | - break |
30 | - end |
31 | - sleep(8234) |
32 | + while #p1:get_ships() < 3 do |
33 | + sleep(8234) |
34 | end |
35 | |
36 | -- Success |
37 | |
38 | === modified file 'src/economy/fleet.cc' |
39 | --- src/economy/fleet.cc 2015-10-24 15:42:37 +0000 |
40 | +++ src/economy/fleet.cc 2015-11-03 10:40:10 +0000 |
41 | @@ -578,8 +578,13 @@ |
42 | Economy::check_split(m_ports[0]->base_flag(), port->base_flag()); |
43 | } |
44 | |
45 | - if (m_ships.empty() && m_ports.empty()) |
46 | + if (m_ships.empty() && m_ports.empty()) { |
47 | remove(egbase); |
48 | + } else if (upcast(Game, game, &egbase)) { |
49 | + // Some ship perhaps lose their destination now, so new a destination must be appointed (if any) |
50 | + molog("Port removed from fleet, triggering fleet update\n"); |
51 | + update(egbase); |
52 | + } |
53 | } |
54 | |
55 | /** |
56 | |
57 | === modified file 'src/logic/ship.cc' |
58 | --- src/logic/ship.cc 2015-10-25 07:13:43 +0000 |
59 | +++ src/logic/ship.cc 2015-11-03 10:40:10 +0000 |
60 | @@ -237,17 +237,13 @@ |
61 | } |
62 | |
63 | /// updates a ships tasks in transport mode \returns false if failed to update tasks |
64 | -bool Ship::ship_update_transport(Game& game, Bob::State&) { |
65 | +bool Ship::ship_update_transport(Game& game, Bob::State& state) { |
66 | Map& map = game.map(); |
67 | |
68 | PortDock* dst = get_destination(game); |
69 | if (!dst) { |
70 | - // The ship has lost its destination (port is gone perhaps) so |
71 | - // stop and start being idle |
72 | - start_task_idle(game, descr().main_animation(), 10000); |
73 | - // ...but let the fleet recalcualte ships destinations (this ship |
74 | - // needs new destination) |
75 | - m_fleet->update(game); |
76 | + // The ship has no destination, so let it sleep |
77 | + ship_update_idle(game, state); |
78 | return true; |
79 | } |
80 | |
81 | @@ -455,6 +451,7 @@ |
82 | } |
83 | |
84 | void Ship::ship_update_idle(Game& game, Bob::State& state) { |
85 | + |
86 | if (state.ivar1) { |
87 | // We've just completed one step, so give neighbours |
88 | // a chance to move away first |
89 | |
90 | === modified file 'test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua' |
91 | --- test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua 2015-04-07 13:33:16 +0000 |
92 | +++ test/maps/expedition.wmf/scripting/test_ship_movement_controls.lua 2015-11-03 10:40:10 +0000 |
93 | @@ -1,27 +1,31 @@ |
94 | run(function() |
95 | game.desired_speed = 30 * 1000 |
96 | - p1:place_bob("ship", map:get_field(10, 10)) |
97 | - |
98 | - port = map:get_field(16, 16).immovable |
99 | - port:set_wares("log", 10) -- no sense to wait |
100 | - port:set_wares("blackwood", 10) |
101 | - |
102 | + |
103 | + -- placing a ship on coast |
104 | + p1:place_bob("ship", map:get_field(8, 8)) |
105 | + sleep(1000) |
106 | + |
107 | --getting table with all our ships (single one only) |
108 | ships = p1:get_ships() |
109 | |
110 | - --veryfing that ship is indeed placed where should be :) |
111 | - assert_equal(10,ships[1].field.x) |
112 | - assert_equal(10,ships[1].field.y) |
113 | - |
114 | --ships table should contain 1 item (1 ship) |
115 | assert_equal(1, #ships) |
116 | + |
117 | + --waiting till it is pulled from coast |
118 | + while ships[1].field.x == 8 and ships[1].field.xy == 8 do |
119 | + print ("ship still on coast") |
120 | + sleep(1000) |
121 | + end |
122 | + |
123 | + port = map:get_field(16, 16).immovable |
124 | + port:set_wares("log", 10) -- no sense to wait |
125 | + port:set_wares("blackwood", 10) |
126 | |
127 | --ship has no wares on it |
128 | assert_equal(0,ships[1]:get_wares()) |
129 | |
130 | --no destination is set |
131 | assert(not ships[1].destination) |
132 | - |
133 | --ships in transport state |
134 | assert_equal("transport", ships[1].state) |
135 | |
136 | @@ -33,15 +37,17 @@ |
137 | port:start_expedition() |
138 | sleep (300) |
139 | assert(port.expedition_in_progress) |
140 | + assert(ships[1]) |
141 | |
142 | --ships changes state when exp ready |
143 | while ships[1].state == "transport" do sleep(2000) end |
144 | assert_equal("exp_waiting", ships[1].state) |
145 | - |
146 | --sending NW and verifying |
147 | ships[1].scouting_direction="nw" |
148 | + |
149 | sleep(6000) |
150 | assert_equal("nw", ships[1].scouting_direction) |
151 | + |
152 | assert_equal("exp_scouting", ships[1].state) |
153 | |
154 | while ships[1].scouting_direction == "nw" do |
155 | |
156 | === modified file 'test/maps/ship_transportation.wmf/scripting/init.lua' |
157 | --- test/maps/ship_transportation.wmf/scripting/init.lua 2015-03-09 20:16:18 +0000 |
158 | +++ test/maps/ship_transportation.wmf/scripting/init.lua 2015-11-03 10:40:10 +0000 |
159 | @@ -7,7 +7,7 @@ |
160 | |
161 | p1:allow_workers("all") |
162 | |
163 | -function create_first_port() |
164 | +function create_southern_port() |
165 | prefilled_buildings(p1, |
166 | { "port", 16, 16, |
167 | wares = {}, |
168 | @@ -16,11 +16,11 @@ |
169 | }) |
170 | end |
171 | |
172 | -function port1() |
173 | +function southern_port() |
174 | return map:get_field(16, 16).immovable |
175 | end |
176 | |
177 | -function create_second_port() |
178 | +function create_northern_port() |
179 | prefilled_buildings(p1, |
180 | { "port", 16, 2, |
181 | wares = {}, |
182 | @@ -29,7 +29,7 @@ |
183 | }) |
184 | end |
185 | |
186 | -function port2() |
187 | +function northern_port() |
188 | local o = map:get_field(16, 2).immovable |
189 | if o and o.descr.name == "port" then |
190 | return o |
191 | |
192 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_farm_with_ware_and_worker_in_transit.lua' |
193 | --- test/maps/ship_transportation.wmf/scripting/test_rip_farm_with_ware_and_worker_in_transit.lua 2014-01-18 13:47:32 +0000 |
194 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_farm_with_ware_and_worker_in_transit.lua 2015-11-03 10:40:10 +0000 |
195 | @@ -2,14 +2,14 @@ |
196 | sleep(100) |
197 | game.desired_speed = 10 * 1000 |
198 | |
199 | - create_first_port() |
200 | - create_second_port() |
201 | + create_southern_port() |
202 | + create_northern_port() |
203 | |
204 | start_building_farm() |
205 | - port1():set_wares{ |
206 | + southern_port():set_wares{ |
207 | blackwood = 1, |
208 | } |
209 | - port1():set_workers{ |
210 | + southern_port():set_workers{ |
211 | builder = 1, |
212 | } |
213 | |
214 | @@ -23,8 +23,8 @@ |
215 | -- kill the farm while the blackwood is in transit. |
216 | farm():remove() |
217 | |
218 | - while not (port2():get_wares("blackwood") == 1 |
219 | - and port2():get_workers("builder") == 1) do |
220 | + while not (northern_port():get_wares("blackwood") == 1 |
221 | + and northern_port():get_workers("builder") == 1) do |
222 | sleep(100) |
223 | end |
224 | |
225 | |
226 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_ware_in_portdock.lua' |
227 | --- test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_ware_in_portdock.lua 2014-01-18 13:47:32 +0000 |
228 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_ware_in_portdock.lua 2015-11-03 10:40:10 +0000 |
229 | @@ -2,25 +2,25 @@ |
230 | sleep(100) |
231 | game.desired_speed = 10 * 1000 |
232 | |
233 | - create_first_port() |
234 | + create_southern_port() |
235 | local wh = p1:place_building("warehouse", map:get_field(13, 16), false, false) |
236 | connected_road(p1, wh.flag, "r,r,r", true) |
237 | - create_second_port() |
238 | + create_northern_port() |
239 | |
240 | start_building_farm() |
241 | - port1():set_wares{ |
242 | + southern_port():set_wares{ |
243 | blackwood = 1, |
244 | } |
245 | |
246 | -- Wait till the ware is in the portdock. |
247 | - while port1():get_wares("blackwood") == 1 do |
248 | + while southern_port():get_wares("blackwood") == 1 do |
249 | sleep(200) |
250 | end |
251 | assert_equal(p1:get_wares("blackwood"), 1) |
252 | sleep(8000) |
253 | |
254 | |
255 | - port1():remove() |
256 | + southern_port():remove() |
257 | |
258 | sleep(100) |
259 | assert_equal(p1:get_wares("blackwood"), 0) |
260 | @@ -29,7 +29,7 @@ |
261 | sleep(5000) |
262 | |
263 | -- Create port again. |
264 | - create_first_port() |
265 | + create_southern_port() |
266 | wh:set_wares("blackwood", 1) |
267 | |
268 | sleep(200) |
269 | |
270 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_worker_in_portdock.lua' |
271 | --- test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_worker_in_portdock.lua 2014-01-18 12:40:08 +0000 |
272 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_first_port_with_worker_in_portdock.lua 2015-11-03 10:40:10 +0000 |
273 | @@ -2,23 +2,23 @@ |
274 | sleep(100) |
275 | game.desired_speed = 10 * 1000 |
276 | |
277 | - create_first_port() |
278 | + create_southern_port() |
279 | local wh = p1:place_building("warehouse", map:get_field(13, 16), false, false) |
280 | connected_road(p1, wh.flag, "r,r,r", true) |
281 | - create_second_port() |
282 | + create_northern_port() |
283 | |
284 | start_building_farm() |
285 | - port1():set_workers{ |
286 | + southern_port():set_workers{ |
287 | builder = 1, |
288 | } |
289 | |
290 | -- Wait till the worker transfers to the portdock. |
291 | - while port1():get_workers("builder") == 1 do |
292 | + while southern_port():get_workers("builder") == 1 do |
293 | sleep(200) |
294 | end |
295 | sleep(3000) |
296 | |
297 | - port1():remove() |
298 | + southern_port():remove() |
299 | sleep(100) |
300 | stable_save("port1_just_removed") |
301 | |
302 | @@ -28,7 +28,7 @@ |
303 | end |
304 | |
305 | -- Create port again. |
306 | - create_first_port() |
307 | + create_southern_port() |
308 | |
309 | while ship:get_workers() == 0 do |
310 | sleep(50) |
311 | |
312 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua' |
313 | --- test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua 2015-03-09 20:16:18 +0000 |
314 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_portdock_with_worker_and_ware_in_transit.lua 2015-11-03 10:40:10 +0000 |
315 | @@ -2,52 +2,52 @@ |
316 | sleep(100) |
317 | game.desired_speed = 10 * 1000 |
318 | |
319 | - create_first_port() |
320 | - create_second_port() |
321 | + create_southern_port() |
322 | + create_northern_port() |
323 | |
324 | - --removing builder from port2 |
325 | - port2():set_workers{ |
326 | + --removing builder from northern port |
327 | + northern_port():set_workers{ |
328 | builder = 0, |
329 | } |
330 | |
331 | - assert_equal(port2():get_workers("builder"), 0) |
332 | + assert_equal(northern_port():get_workers("builder"), 0) |
333 | |
334 | start_building_farm() |
335 | - port1():set_workers{ |
336 | + southern_port():set_workers{ |
337 | builder = 1, |
338 | } |
339 | - port1():set_wares{ |
340 | + southern_port():set_wares{ |
341 | blackwood = 1, |
342 | } |
343 | |
344 | - assert_equal(port1():get_workers("builder"), 1) |
345 | - assert_equal(port1():get_wares("blackwood"), 1) |
346 | + assert_equal(southern_port():get_workers("builder"), 1) |
347 | + assert_equal(southern_port():get_wares("blackwood"), 1) |
348 | |
349 | while ship:get_workers() == 0 or ship:get_wares() == 0 do |
350 | sleep(500) |
351 | end |
352 | |
353 | - local flag_oversea = port2().flag |
354 | + local flag_oversea = northern_port().flag |
355 | |
356 | stable_save("restored_port") |
357 | |
358 | -- remove the portdock while the blackwood is in transit. |
359 | - port2_portdock=port2().portdock |
360 | - assert(port2_portdock) |
361 | - port2_portdock:remove() |
362 | + north_port_portdock=northern_port().portdock |
363 | + assert(north_port_portdock) |
364 | + north_port_portdock:remove() |
365 | |
366 | sleep(5000) |
367 | |
368 | assert_equal(p1:get_workers("builder"), 1) |
369 | assert_equal(p1:get_wares("blackwood"), 1) |
370 | - assert_equal(ship.debug_economy, port1().debug_economy) |
371 | + assert_equal(ship.debug_economy, southern_port().debug_economy) |
372 | assert_equal(ship.debug_economy, flag_oversea.debug_economy) |
373 | |
374 | sleep(5000) |
375 | |
376 | - --just wait till everything is gone to port2 |
377 | + --just wait till everything is gone to northern port |
378 | while ship:get_workers() > 0 or ship:get_wares() > 0 or |
379 | - port1():get_workers("builder") > 0 or port1():get_wares("blackwood") > 0 do |
380 | + southern_port():get_workers("builder") > 0 or southern_port():get_wares("blackwood") > 0 do |
381 | sleep(50) |
382 | end |
383 | |
384 | |
385 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_ware_in_transit.lua' |
386 | --- test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_ware_in_transit.lua 2014-01-13 07:42:45 +0000 |
387 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_ware_in_transit.lua 2015-11-03 10:40:10 +0000 |
388 | @@ -2,11 +2,11 @@ |
389 | sleep(100) |
390 | game.desired_speed = 10 * 1000 |
391 | |
392 | - create_first_port() |
393 | - create_second_port() |
394 | + create_southern_port() |
395 | + create_northern_port() |
396 | |
397 | start_building_farm() |
398 | - port1():set_wares{ |
399 | + southern_port():set_wares{ |
400 | blackwood = 1, |
401 | } |
402 | |
403 | @@ -15,17 +15,17 @@ |
404 | assert_equal(p1:get_wares("blackwood"), 1) |
405 | |
406 | -- kill the port while the blackwood is in transit. |
407 | - local flag_oversea = port2().flag |
408 | - port2():remove() |
409 | + local flag_oversea = northern_port().flag |
410 | + northern_port():remove() |
411 | assert_equal(p1:get_wares("blackwood"), 1) |
412 | sleep(1000) |
413 | |
414 | assert_equal(p1:get_wares("blackwood"), 1) |
415 | - assert_equal(ship.debug_economy, port1().debug_economy) |
416 | + assert_equal(ship.debug_economy, southern_port().debug_economy) |
417 | assert_not_equal(ship.debug_economy, flag_oversea.debug_economy) |
418 | |
419 | -- now kill the first port too. |
420 | - port1():remove() |
421 | + southern_port():remove() |
422 | sleep(1000) |
423 | |
424 | stable_save("no_ports") |
425 | @@ -41,12 +41,12 @@ |
426 | sleep(30000) |
427 | |
428 | -- Recreate the first port. |
429 | - create_first_port() |
430 | + create_southern_port() |
431 | sleep(1000) |
432 | assert_equal(p1:get_wares("blackwood"), 1) |
433 | |
434 | -- Wait (and hope) that the ship will eventually return the blackwood. |
435 | - while port1():get_wares("blackwood") == 0 do |
436 | + while southern_port():get_wares("blackwood") == 0 do |
437 | sleep(5000) |
438 | end |
439 | |
440 | |
441 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_worker_in_transit.lua' |
442 | --- test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_worker_in_transit.lua 2014-01-13 07:42:45 +0000 |
443 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_ports_with_worker_in_transit.lua 2015-11-03 10:40:10 +0000 |
444 | @@ -2,11 +2,11 @@ |
445 | sleep(100) |
446 | game.desired_speed = 10 * 1000 |
447 | |
448 | - create_first_port() |
449 | - create_second_port() |
450 | + create_southern_port() |
451 | + create_northern_port() |
452 | |
453 | start_building_farm() |
454 | - port1():set_workers{ |
455 | + southern_port():set_workers{ |
456 | builder = 1, |
457 | } |
458 | |
459 | @@ -15,17 +15,17 @@ |
460 | assert_equal(p1:get_workers("builder"), 1) |
461 | |
462 | -- kill the port while the builder is in transit. |
463 | - local flag_oversea = port2().flag |
464 | - port2():remove() |
465 | + local flag_oversea = northern_port().flag |
466 | + northern_port():remove() |
467 | assert_equal(p1:get_workers("builder"), 1) |
468 | sleep(1000) |
469 | |
470 | assert_equal(p1:get_workers("builder"), 1) |
471 | - assert_equal(ship.debug_economy, port1().debug_economy) |
472 | + assert_equal(ship.debug_economy, southern_port().debug_economy) |
473 | assert_not_equal(ship.debug_economy, flag_oversea.debug_economy) |
474 | |
475 | -- now kill the first port too. |
476 | - port1():remove() |
477 | + southern_port():remove() |
478 | sleep(1000) |
479 | |
480 | stable_save("no_ports") |
481 | @@ -41,12 +41,12 @@ |
482 | sleep(30000) |
483 | |
484 | -- Recreate the first port. |
485 | - create_first_port() |
486 | + create_southern_port() |
487 | sleep(1000) |
488 | assert_equal(p1:get_workers("builder"), 1) |
489 | |
490 | -- Wait (and hope) that the ship will eventually return the builder. |
491 | - while port1():get_workers("builder") == 0 do |
492 | + while southern_port():get_workers("builder") == 0 do |
493 | sleep(5000) |
494 | end |
495 | |
496 | |
497 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_ware_in_portdock.lua' |
498 | --- test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_ware_in_portdock.lua 2015-10-16 19:36:15 +0000 |
499 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_ware_in_portdock.lua 2015-11-03 10:40:10 +0000 |
500 | @@ -2,11 +2,11 @@ |
501 | sleep(100) |
502 | game.desired_speed = 10 * 1000 |
503 | |
504 | - create_first_port() |
505 | - create_second_port() |
506 | + create_southern_port() |
507 | + create_northern_port() |
508 | |
509 | start_building_farm() |
510 | - port1():set_wares{ |
511 | + southern_port():set_wares{ |
512 | blackwood = 1, |
513 | } |
514 | |
515 | @@ -15,7 +15,7 @@ |
516 | -- The ship should not yet have picked up the ware from the |
517 | -- portdock. |
518 | assert_equal(1, p1:get_wares("blackwood")) |
519 | - assert_equal(0, port1():get_wares("blackwood")) |
520 | + assert_equal(0, southern_port():get_wares("blackwood")) |
521 | |
522 | while ship:get_wares() == 0 do |
523 | -- ship still on the way to the bottom port |
524 | @@ -24,9 +24,9 @@ |
525 | |
526 | --now it is loaded with something and port empty.. |
527 | sleep(2000) |
528 | - assert_equal(0, port1():get_wares("blackwood")) |
529 | + assert_equal(0, southern_port():get_wares("blackwood")) |
530 | -- ...and on the way to the north, so let remove the upper port |
531 | - port2():remove() |
532 | + northern_port():remove() |
533 | sleep(100) |
534 | |
535 | stable_save("ware_in_portdock") |
536 | @@ -34,12 +34,12 @@ |
537 | --ship has to get to the place of former upper port and then return back to the bottom port |
538 | sleep(30000) |
539 | |
540 | - -- Ware should be back in port. |
541 | + -- Ware should be back in port now. |
542 | assert_equal(1, p1:get_wares("blackwood")) |
543 | - assert_equal(1, port1():get_wares("blackwood")) |
544 | + assert_equal(1, southern_port():get_wares("blackwood")) |
545 | |
546 | -- Create port again. |
547 | - create_second_port() |
548 | + create_northern_port() |
549 | |
550 | sleep (10000) |
551 | |
552 | |
553 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua' |
554 | --- test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua 2015-03-10 20:10:31 +0000 |
555 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_second_port_with_worker_in_portdock.lua 2015-11-03 10:40:10 +0000 |
556 | @@ -2,29 +2,36 @@ |
557 | sleep(100) |
558 | game.desired_speed = 10 * 1000 |
559 | |
560 | - create_first_port() |
561 | - create_second_port() |
562 | + create_southern_port() |
563 | + create_northern_port() |
564 | |
565 | --removing portdock first |
566 | - portdock_fields=port2().portdock.fields |
567 | + portdock_fields=northern_port().portdock.fields |
568 | portdock_fields[1].immovable:remove() |
569 | sleep(100) |
570 | --portdock should be back, as port is still there |
571 | assert (portdock_fields[1].immovable) |
572 | |
573 | start_building_farm() |
574 | - port1():set_workers{ |
575 | + southern_port():set_workers{ |
576 | builder = 1, |
577 | } |
578 | - sleep(6000) |
579 | - |
580 | + |
581 | + sleep(2000) |
582 | + |
583 | -- The ship should not yet have picked up the worker from the |
584 | -- portdock. |
585 | - assert_equal(p1:get_workers("builder"), 1) |
586 | - assert_equal(port1():get_workers("builder"), 0) |
587 | - |
588 | - portdock_fields=port2().portdock.fields |
589 | - port2():remove() |
590 | + assert_equal(1, p1:get_workers("builder")) |
591 | + assert_equal(0, southern_port():get_workers("builder")) |
592 | + |
593 | + -- so wait till builder is loaded on ship |
594 | + while (ship:get_workers("builder") == 0) do |
595 | + sleep(100) |
596 | + end |
597 | + sleep(5000) |
598 | + |
599 | + portdock_fields=northern_port().portdock.fields |
600 | + northern_port():remove() |
601 | sleep(100) |
602 | --verify that also portdock was removed |
603 | assert (not portdock_fields[1].immovable) |
604 | @@ -33,14 +40,18 @@ |
605 | |
606 | stable_save("worker_in_portdock") |
607 | |
608 | - sleep(8000) |
609 | + -- Wait till a ship unloads a worked at the souther port |
610 | + while (ship:get_workers("builder") == 1) do |
611 | + sleep(100) |
612 | + end |
613 | + sleep(2000) |
614 | |
615 | - -- Worker should be back in port. |
616 | + -- Worker should be back in the southern port. |
617 | assert_equal(p1:get_workers("builder"), 1) |
618 | - assert_equal(port1():get_workers("builder"), 1) |
619 | + assert_equal(southern_port():get_workers("builder"), 1) |
620 | |
621 | -- Create port again. |
622 | - create_second_port() |
623 | + create_northern_port() |
624 | |
625 | while ship:get_workers() == 0 do |
626 | sleep(50) |
627 | |
628 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_ship_before_picking_up_transporting_ware.lua' |
629 | --- test/maps/ship_transportation.wmf/scripting/test_rip_ship_before_picking_up_transporting_ware.lua 2014-01-15 21:12:05 +0000 |
630 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_ship_before_picking_up_transporting_ware.lua 2015-11-03 10:40:10 +0000 |
631 | @@ -2,14 +2,14 @@ |
632 | sleep(100) |
633 | game.desired_speed = 10 * 1000 |
634 | |
635 | - create_first_port() |
636 | - create_second_port() |
637 | + create_southern_port() |
638 | + create_northern_port() |
639 | |
640 | start_building_farm() |
641 | - port1():set_wares{ |
642 | + southern_port():set_wares{ |
643 | blackwood = 1, |
644 | } |
645 | - port2():set_workers{ |
646 | + northern_port():set_workers{ |
647 | builder = 1, |
648 | } |
649 | |
650 | @@ -23,7 +23,7 @@ |
651 | |
652 | assert_equal(1, p1:get_wares("blackwood")) |
653 | -- It is not in the port (still in the dock) |
654 | - assert_equal(0, port1():get_wares("blackwood")) |
655 | + assert_equal(0, southern_port():get_wares("blackwood")) |
656 | |
657 | local new_ship = p1:place_bob("ship", map:get_field(10, 10)) |
658 | sleep(1000) |
659 | |
660 | === modified file 'test/maps/ship_transportation.wmf/scripting/test_rip_ship_while_transporting_ware.lua' |
661 | --- test/maps/ship_transportation.wmf/scripting/test_rip_ship_while_transporting_ware.lua 2014-01-15 21:12:05 +0000 |
662 | +++ test/maps/ship_transportation.wmf/scripting/test_rip_ship_while_transporting_ware.lua 2015-11-03 10:40:10 +0000 |
663 | @@ -2,14 +2,14 @@ |
664 | sleep(100) |
665 | game.desired_speed = 10 * 1000 |
666 | |
667 | - create_first_port() |
668 | - create_second_port() |
669 | + create_southern_port() |
670 | + create_northern_port() |
671 | |
672 | start_building_farm() |
673 | - port1():set_wares{ |
674 | + southern_port():set_wares{ |
675 | blackwood = 1, |
676 | } |
677 | - port2():set_workers{ |
678 | + northern_port():set_workers{ |
679 | builder = 1, |
680 | } |
681 | |
682 | @@ -27,7 +27,7 @@ |
683 | assert_equal(p1:get_wares("blackwood"), 0) |
684 | |
685 | local new_ship = p1:place_bob("ship", map:get_field(10, 10)) |
686 | - port1():set_wares{ |
687 | + southern_port():set_wares{ |
688 | blackwood = 1, |
689 | } |
690 | sleep(1000) |
Oh, I also changed names for ports - now using northern and souther port - because that port1 and port2 were completely unintuitive when writing test scripts, I hope you will not mind :)