Skip to content

Commit d6b16e4

Browse files
committed
Disallow changing a vein into itself
Prevents infinite recursion from occurring while searching for neighboring vein tiles, which would eventually result in a crash. Fixes DFHack#5231
1 parent 80a13e3 commit d6b16e4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Template for new versions:
6161

6262
## Fixes
6363
- `spectate`: don't allow temporarily modified announcement settings to be written to disk when "auto-unpause" mode is enabled
64+
- `changevein`: fix a crash that could occur when attempting to change a vein into itself
6465

6566
## Misc Improvements
6667
- `spectate`: player-set configuration is now stored globally instead of per-fort

plugins/changevein.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ command_result df_changevein (color_ostream &out, vector <string> & parameters)
254254
return CR_FAILURE;
255255
}
256256

257+
if (mineral->inorganic_mat == mi.index)
258+
{
259+
out.printerr("Selected tile is already of the target material.\n");
260+
return CR_FAILURE;
261+
}
262+
257263
VeinEdgeBitmask mask = VeinEdgeBitmask(mineral);
258264
mineral->inorganic_mat = mi.index;
259265
ChangeSameBlockVeins(block, mineral, mask, mi.index);

0 commit comments

Comments
 (0)