Merge lp:~widelands-dev/widelands/bug-1727673 into lp:widelands

Proposed by TiborB
Status: Merged
Merged at revision: 8471
Proposed branch: lp:~widelands-dev/widelands/bug-1727673
Merge into: lp:widelands
Diff against target: 64 lines (+24/-9)
1 file modified
src/logic/map_objects/tribes/ship.cc (+24/-9)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1727673
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+332945@code.launchpad.net

Description of the change

This bug is situation when colonization ship is going to land a builder, but another builder is already on the port constructionsite (I dont know how it is possible) and request is thus nullptr. Sometimes it crashes.
The solution is to leave the builder on the ship.

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

Continuous integration builds have changed state:

Travis build 2716. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/293854904.
Appveyor build 2529. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1727673-2529.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, not tested.

What happens to the builder on the ship, will he be transported back and unloaded at a warehouse?

Revision history for this message
TiborB (tiborb95) wrote :

This is exactly the same situation as when port constructionsite disappears during unloading of wares/worker. So yes..

Revision history for this message
GunChleoc (gunchleoc) wrote :

I did some testing now. I don't get a crash in trunk, but the builder would disappear, while this branch will keep the extra builder on the Ship and return him to a port. So, definitely an improvement! I'll assume that the crash is fixed too and close the bug.

@bunnybot merge

Revision history for this message
TiborB (tiborb95) wrote :

BTW, can you tell where the first builder came from?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I tested with a game I created myself, by building an expedition port on my own island and quickly connecting a road to a nearby warehouse. Two Lagoons is a good map for that.

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/ship.cc'
2--- src/logic/map_objects/tribes/ship.cc 2017-08-20 08:34:02 +0000
3+++ src/logic/map_objects/tribes/ship.cc 2017-10-27 19:33:48 +0000
4@@ -612,6 +612,10 @@
5 case ShipStates::kExpeditionColonizing: {
6 assert(!expedition_->seen_port_buildspaces.empty());
7 BaseImmovable* baim = map[expedition_->seen_port_buildspaces.front()].get_immovable();
8+ // Following is a preparation for very rare situation, when colonizing port already have a
9+ // worker (bug-1727673)
10+ // We leave the worker on the ship then
11+ bool leftover_builder = false;
12 if (baim) {
13 upcast(ConstructionSite, cs, baim);
14
15@@ -644,6 +648,16 @@
16 break;
17 } else {
18 assert(worker);
19+ // If constructionsite does not need worker anymore, we must leave it on the ship.
20+ // Also we presume that he is on position 0
21+ if (cs->get_builder_request() == nullptr) {
22+ log("%2d: WARNING: Colonizing ship %s cannot unload the worker to new port at "
23+ "%3dx%3d because the request is no longer active\n",
24+ get_owner()->player_number(), shipname_.c_str(), cs->get_position().x,
25+ cs->get_position().y);
26+ leftover_builder = true;
27+ break; // no more unloading (builder shoud be on position 0)
28+ }
29 worker->set_economy(nullptr);
30 worker->set_location(cs);
31 worker->set_position(game, cs->get_position());
32@@ -661,8 +675,8 @@
33 send_signal(game, "cancel_expedition");
34 }
35
36- if (items_.empty() || !baim) { // we are done, either way
37- ship_state_ = ShipStates::kTransport; // That's it, expedition finished
38+ if (items_.empty() || !baim || leftover_builder) { // we are done, either way
39+ ship_state_ = ShipStates::kTransport; // That's it, expedition finished
40
41 // Bring us back into a fleet and a economy.
42 init_fleet(game);
43@@ -1002,13 +1016,14 @@
44 Bob::log_general_info(egbase);
45
46 molog("Ship belongs to fleet: %u\n destination: %s\n lastdock: %s\n",
47- fleet_ ? fleet_->serial() : 0, (destination_.is_set()) ?
48- (boost::format("%u (%d x %d)") % destination_.serial() %
49- destination_.get(egbase)->get_positions(egbase)[0].x %
50- destination_.get(egbase)->get_positions(egbase)[0].y)
51- .str()
52- .c_str() :
53- "-",
54+ fleet_ ? fleet_->serial() : 0,
55+ (destination_.is_set()) ?
56+ (boost::format("%u (%d x %d)") % destination_.serial() %
57+ destination_.get(egbase)->get_positions(egbase)[0].x %
58+ destination_.get(egbase)->get_positions(egbase)[0].y)
59+ .str()
60+ .c_str() :
61+ "-",
62 (lastdock_.is_set()) ?
63 (boost::format("%u (%d x %d)") % lastdock_.serial() %
64 lastdock_.get(egbase)->get_positions(egbase)[0].x %

Subscribers

People subscribed via source and target branches

to status/vote changes: