← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/worker_fetchfromflag_crash into lp:widelands

 

Benedikt Straub has proposed merging lp:~widelands-dev/widelands/worker_fetchfromflag_crash into lp:widelands.

Commit message:
Cancel Worker::fetchfromflag when the building is destroyed/dismantled/enhanced

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/worker_fetchfromflag_crash/+merge/364650

Fix for the segfault reported on the forum (https://wl.widelands.org/forum/topic/2786/?page=26)
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/worker_fetchfromflag_crash into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc	2019-03-02 11:21:02 +0000
+++ src/logic/map_objects/tribes/worker.cc	2019-03-17 10:36:43 +0000
@@ -2140,6 +2140,14 @@
 }
 
 void Worker::fetchfromflag_update(Game& game, State& state) {
+	std::string signal = get_signal();
+	if (signal.size()) {
+		if (signal == "location") {
+			molog("[fetchfromflag]: Building disappeared, become fugitive\n");
+			return pop_task(game);
+		}
+	}
+
 	PlayerImmovable& employer = *get_location(game);
 	PlayerImmovable* const location =
 	   dynamic_cast<PlayerImmovable*>(game.map().get_immovable(get_position()));


Follow ups