# HG changeset patch # User Jonathan G Rennison # Date 2023-11-28 21:59:00 # Node ID 545150246005741a6bd67a42849791e9b60043d8 # Parent 306a9b1774feab6b117d4e6a3e7d59fe8d554675 Fix: Deleting towns did not check for waypoints referencing the town diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -17,6 +17,7 @@ #include "command_func.h" #include "industry.h" #include "station_base.h" +#include "waypoint_base.h" #include "station_kdtree.h" #include "company_base.h" #include "news_func.h" @@ -3040,6 +3041,11 @@ CommandCost CmdDeleteTown(DoCommandFlag } } + /* Waypoints refer to towns. */ + for (const Waypoint *wp : Waypoint::Iterate()) { + if (wp->town == t) return CMD_ERROR; + } + /* Depots refer to towns. */ for (const Depot *d : Depot::Iterate()) { if (d->town == t) return CMD_ERROR;