GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1815664-crash-conquer-tower into lp:widelands.
Commit message: Stop ware dropoff when the target building has been destroyed. This fixes a crash when the enemy conquers a militarysite near a warehouse. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1815664 in widelands: "Crash while conquering tower" https://bugs.launchpad.net/widelands/+bug/1815664 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1815664-crash-conquer-tower/+merge/363296 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1815664-crash-conquer-tower into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/worker.cc' --- src/logic/map_objects/tribes/worker.cc 2019-02-09 12:24:01 +0000 +++ src/logic/map_objects/tribes/worker.cc 2019-02-17 16:53:15 +0000 @@ -2051,9 +2051,17 @@ WareInstance* ware = get_carried_ware(game); BaseImmovable* const location = game.map()[get_position()].get_immovable(); + + // If the building just got destroyed, pop the task + PlayerImmovable* current_location = get_location(game); + if (current_location == nullptr) { + molog("%s: Unable to dropoff ware in building at (%d,%d) - there is no building there\n", descr().name().c_str(), get_position().x, get_position().y); + return pop_task(game); + } + #ifndef NDEBUG - Building& ploc = dynamic_cast<Building&>(*get_location(game)); - assert(&ploc == location || &ploc.base_flag() == location); + Building* ploc = dynamic_cast<Building*>(current_location); + assert(ploc == location || &ploc->base_flag() == location); #endif // Deliver the ware
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp