Skip to content

Commit

Permalink
don't use cached iterators across map reloads
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Nov 12, 2020
1 parent 923b1b1 commit 3611090
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/buildingplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ struct buildingplan_query_hook : public df::viewscreen_dwarfmodest
}
}

static void invalidateStatics()
{
bld = NULL;
}

bool handleInput(set<df::interface_key> *input)
{
if (!isInPlannedBuildingQueryMode() || Gui::inRenameBuilding())
Expand Down Expand Up @@ -583,6 +588,11 @@ struct buildingplan_place_hook : public df::viewscreen_dwarfmodest
}
}

static void invalidateStatics()
{
key = BuildingTypeKey();
}

bool handleInput(set<df::interface_key> *input)
{
if (!isInPlannedBuildingPlacementMode())
Expand Down Expand Up @@ -959,6 +969,8 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
{
switch (event) {
case SC_MAP_LOADED:
buildingplan_place_hook::invalidateStatics();
buildingplan_query_hook::invalidateStatics();
planner.reset();
roomMonitor.reset(out);
break;
Expand Down

0 comments on commit 3611090

Please sign in to comment.