From 32d6257c702dd53f56a53d932f9079dbe5f03ed8 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 20 May 2012 21:58:43 +0400 Subject: [PATCH] DF code analysis uncovered another item-related flag to clear. It turns out, buildings cache their 'site is blocked' state, and won't actually recheck until the flag is cleared. --- library/modules/Maps.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index 3160af75e..3ab156d77 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -41,6 +41,8 @@ using namespace std; #include "Core.h" #include "MiscUtils.h" +#include "modules/Buildings.h" + #include "DataDefs.h" #include "df/world_data.h" #include "df/world_underground_region.h" @@ -1055,7 +1057,21 @@ bool MapExtras::Block::removeItemOnGround(df::item *item) if (--count == 0) { index_tile(occupancy,item->pos).bits.item = false; - index_tile(block->occupancy,item->pos).bits.item = false; + + auto &occ = index_tile(block->occupancy,item->pos); + + occ.bits.item = false; + + // Clear the 'site blocked' flag in the building, if any. + // Otherwise the job would be re-suspended without actually checking items. + if (occ.bits.building == tile_building_occ::Planned) + { + if (auto bld = Buildings::findAtTile(item->pos)) + { + // TODO: maybe recheck other tiles like the game does. + bld->flags.bits.site_blocked = false; + } + } } return true;