don't cache dup civzones when scanning buildings

develop
myk002 2022-09-25 16:04:36 -07:00
parent 07d3e70b8a
commit cb80f7dd75
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 6 additions and 5 deletions

@ -49,6 +49,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `dig-now`: Fix direction of smoothed walls when adjacent to a door or floodgate - `dig-now`: Fix direction of smoothed walls when adjacent to a door or floodgate
- ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled - ``job.removeJob()``: ensure jobs are removed from the world list when they are canceled
- `quickfort`: `Dreamfort <quickfort-blueprint-guide>` blueprint set: declare the hospital zone before building the coffer; otherwise DF fails to stock the hospital with materials - `quickfort`: `Dreamfort <quickfort-blueprint-guide>` blueprint set: declare the hospital zone before building the coffer; otherwise DF fails to stock the hospital with materials
- ``dfhack.buildings.findCivzonesAt``: no longer return duplicate civzones after loading a save with existing civzones
## Misc Improvements ## Misc Improvements
- Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically. - Init scripts: ``dfhack.init`` and other init scripts have moved to ``dfhack-config/init/``. If you have customized your ``dfhack.init`` file and want to keep your changes, please move the part that you have customized to the new location at ``dfhack-config/init/dfhack.init``. If you do not have changes that you want to keep, do not copy anything, and the new defaults will be used automatically.

@ -308,9 +308,8 @@ df::building *Buildings::findAtTile(df::coord pos)
static unordered_map<int32_t, df::coord> corner1; static unordered_map<int32_t, df::coord> corner1;
static unordered_map<int32_t, df::coord> corner2; static unordered_map<int32_t, df::coord> corner2;
static void cacheBuilding(df::building *building) { static void cacheBuilding(df::building *building, bool is_civzone) {
int32_t id = building->id; int32_t id = building->id;
bool is_civzone = !building->isSettingOccupancy();
df::coord p1(min(building->x1, building->x2), min(building->y1,building->y2), building->z); df::coord p1(min(building->x1, building->x2), min(building->y1,building->y2), building->z);
df::coord p2(max(building->x1, building->x2), max(building->y1,building->y2), building->z); df::coord p2(max(building->x1, building->x2), max(building->y1,building->y2), building->z);
@ -344,7 +343,7 @@ static void cacheNewCivzones() {
auto &vec = world->buildings.other[buildings_other_id::ANY_ZONE]; auto &vec = world->buildings.other[buildings_other_id::ANY_ZONE];
int32_t idx = df::building::binsearch_index(vec, id); int32_t idx = df::building::binsearch_index(vec, id);
if (idx > -1) if (idx > -1)
cacheBuilding(vec[idx]); cacheBuilding(vec[idx], true);
} }
nextCivzone = nextBuildingId; nextCivzone = nextBuildingId;
} }
@ -1311,8 +1310,9 @@ void Buildings::updateBuildings(color_ostream&, void* ptr)
if (building) if (building)
{ {
if (!corner1.count(id)) bool is_civzone = !building->isSettingOccupancy();
cacheBuilding(building); if (!corner1.count(id) && !is_civzone)
cacheBuilding(building, false);
} }
else if (corner1.count(id)) else if (corner1.count(id))
{ {