Merge lp:~widelands-dev/widelands/bug-1797213-idle-wares-at-flags-carrier into lp:widelands

Proposed by Notabilis
Status: Merged
Merged at revision: 8903
Proposed branch: lp:~widelands-dev/widelands/bug-1797213-idle-wares-at-flags-carrier
Merge into: lp:widelands
Diff against target: 25 lines (+8/-2)
1 file modified
src/logic/map_objects/tribes/carrier.cc (+8/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1797213-idle-wares-at-flags-carrier
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+357920@code.launchpad.net

Commit message

Fixing ware staying at flag if its destination changes while it is carried.

Description of the change

If a ware ends being requested while it is carried, it will be dropped at the next flag and not touched again. To reproduce:

- Start a new game
- Start building a Quarry and connect it to the warehouse/HQ
- While the carrier is carrying the ware, set the allowed number of trunks in the construction site to zero
- The ware will now be placed at the next flag and won't be moved again (that is: not being transported back to the warehouse)

This can be repeated over and over again in both directions (to construction site / to warehouse):
- Changing the request while the ware is carried will result in the ware getting stuck
- Changing the request while the ware is at a flag will work correctly

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

Continuous integration builds have changed state:

Travis build 4175. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/447516794.
Appveyor build 3973. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1797213_idle_wares_at_flags_carrier-3973.

Revision history for this message
GunChleoc (gunchleoc) wrote :

You're my hero!

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/map_objects/tribes/carrier.cc'
2--- src/logic/map_objects/tribes/carrier.cc 2018-09-04 15:48:47 +0000
3+++ src/logic/map_objects/tribes/carrier.cc 2018-10-28 20:06:36 +0000
4@@ -216,13 +216,19 @@
5 return schedule_act(game, 20);
6 }
7
8- WareInstance* otherware = flag.fetch_pending_ware(game, otherware_idx);
9-
10 if (ware) {
11+ const bool ware_astray = (ware->get_next_move_step(game) == nullptr);
12 // Drop our ware
13 flag.add_ware(game, *fetch_carried_ware(game));
14+ // If the destination of the dropped ware changed while carrying it and we don't have
15+ // anything else we should carry, we might pick it up again immediately, so check again
16+ if (ware_astray && otherware_idx == kNotFoundAppropriate) {
17+ otherware_idx = flag.find_pending_ware(otherflag);
18+ }
19 }
20
21+ WareInstance* otherware = flag.fetch_pending_ware(game, otherware_idx);
22+
23 // Pick up new load, if any
24 if (otherware) {
25 // pay before getting the ware, while checking for road promotion

Subscribers

People subscribed via source and target branches

to status/vote changes: