fix crash in buildingplan

when a player cancels out of placing a building type with plan mode
enabled and then immediately switches to placing a different building
type where plan mode is not enabled, the placement errors array would be
erroneously cleared and allow placement of the building. this would
cause DF to crash if there were no materials available to build the
building with.
develop
Myk Taylor 2022-11-30 04:51:11 -08:00
parent 018bf712d5
commit 8900bc84d8
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes ## Fixes
- `automaterial`: fix the cursor jumping up a z level when clicking quickly after box select - `automaterial`: fix the cursor jumping up a z level when clicking quickly after box select
- `buildingplan`: fix crash when canceling out of placement of a building with plan mode enabled and subsequently attempting to place a building that does not have plan mode enabled and that has no pertinent materials available
- `gui/create-item`: prevent materials list filter from intercepting sublist hotkeys - `gui/create-item`: prevent materials list filter from intercepting sublist hotkeys
- `mousequery`: fix the cursor jumping up z levels sometimes when using TWBT - `mousequery`: fix the cursor jumping up z levels sometimes when using TWBT
- `tiletypes`: no longer resets dig priority to the default when updating other properties of a tile - `tiletypes`: no longer resets dig priority to the default when updating other properties of a tile

@ -734,6 +734,8 @@ struct buildingplan_place_hook : public df::viewscreen_dwarfmodest
DEFINE_VMETHOD_INTERPOSE(void, render, ()) DEFINE_VMETHOD_INTERPOSE(void, render, ())
{ {
initStatics();
bool plannable = isInPlannedBuildingPlacementMode(); bool plannable = isInPlannedBuildingPlacementMode();
if (plannable && is_planmode_enabled(key)) if (plannable && is_planmode_enabled(key))
{ {
@ -759,8 +761,6 @@ struct buildingplan_place_hook : public df::viewscreen_dwarfmodest
if (!plannable) if (!plannable)
return; return;
initStatics();
auto dims = Gui::getDwarfmodeViewDims(); auto dims = Gui::getDwarfmodeViewDims();
int left_margin = dims.menu_x1 + 1; int left_margin = dims.menu_x1 + 1;
int x = left_margin; int x = left_margin;