← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1786163 into lp:widelands


TiborB has proposed merging lp:~widelands-dev/widelands/bug-1786163 into lp:widelands.

Commit message:
When AI finds a second ship in expedition - it cancels the expedition. AI is written to control only one expedition at once.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:

AI should not start second expedition, but it happened. And this led to crash. I introduced very simple workaround here - just cancel such second expedition. Still it is mystery why this had happened. I introduced a log about this so player will get some more info about what is going on...
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1786163 into lp:widelands.
=== modified file 'src/ai/defaultai_seafaring.cc'
--- src/ai/defaultai_seafaring.cc	2018-04-07 16:59:00 +0000
+++ src/ai/defaultai_seafaring.cc	2018-08-13 05:28:27 +0000
@@ -368,6 +368,15 @@
 void DefaultAI::check_ship_in_expedition(ShipObserver& so, uint32_t const gametime) {
 	PlayerNumber const pn = player_->player_number();
+	// There is theoretical possibility that we have more than one ship in expedition mode,
+	// and this one is not the one listed in expedition_ship_ variable, so we quit expedition of this one
+	if (expedition_ship_ != so.ship->serial() && expedition_ship_ != kNoShip) {
+		log ("%d: WARNING: ship %s in expedition, but we have more then one in expedition mode and this is not supported, cancelling the expedition\n",
+		pn, so.ship->get_shipname().c_str());
+		game().send_player_cancel_expedition_ship(*so.ship);
+		return;
+	}
 	// consistency check
 	assert(expedition_ship_ == so.ship->serial() || expedition_ship_ == kNoShip);
 	uint32_t expedition_time = gametime - persistent_data->expedition_start_time;

Follow ups