Merge pull request #2303 from myk002/myk_one_zone_please

don't cache dup civzones when scanning buildings
develop
Myk 2022-09-25 16:13:09 -07:00 committed by GitHub
commit 8e9f69a215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
- ``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
- ``dfhack.buildings.findCivzonesAt``: no longer return duplicate civzones after loading a save with existing civzones
## 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.

@ -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> corner2;
static void cacheBuilding(df::building *building) {
static void cacheBuilding(df::building *building, bool is_civzone) {
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 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];
int32_t idx = df::building::binsearch_index(vec, id);
if (idx > -1)
cacheBuilding(vec[idx]);
cacheBuilding(vec[idx], true);
}
nextCivzone = nextBuildingId;
}
@ -1311,8 +1310,9 @@ void Buildings::updateBuildings(color_ostream&, void* ptr)
if (building)
{
if (!corner1.count(id))
cacheBuilding(building);
bool is_civzone = !building->isSettingOccupancy();
if (!corner1.count(id) && !is_civzone)
cacheBuilding(building, false);
}
else if (corner1.count(id))
{