From d6b16e4d7fe5617c7b6d69ce2fe6a7ee46d66633 Mon Sep 17 00:00:00 2001 From: Nicholas McDaniel Date: Thu, 6 Feb 2025 19:38:47 -0500 Subject: [PATCH] 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 #5231 --- docs/changelog.txt | 1 + plugins/changevein.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index d521d96745..b421b7042e 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -61,6 +61,7 @@ Template for new versions: ## Fixes - `spectate`: don't allow temporarily modified announcement settings to be written to disk when "auto-unpause" mode is enabled +- `changevein`: fix a crash that could occur when attempting to change a vein into itself ## Misc Improvements - `spectate`: player-set configuration is now stored globally instead of per-fort diff --git a/plugins/changevein.cpp b/plugins/changevein.cpp index a73d9584e9..a8151f348b 100644 --- a/plugins/changevein.cpp +++ b/plugins/changevein.cpp @@ -254,6 +254,12 @@ command_result df_changevein (color_ostream &out, vector & parameters) return CR_FAILURE; } + if (mineral->inorganic_mat == mi.index) + { + out.printerr("Selected tile is already of the target material.\n"); + return CR_FAILURE; + } + VeinEdgeBitmask mask = VeinEdgeBitmask(mineral); mineral->inorganic_mat = mi.index; ChangeSameBlockVeins(block, mineral, mask, mi.index);