Fix #14631, Fix 1cb0cbcb6c: Waypoint customs spec not allocated properly on initial construction. (#14633)

Split AllocateSpecToStation/RoadStop into Allocate and Assign functions, allowing command tests to occur separately.
This commit is contained in:
Peter Nelson
2025-09-21 09:32:25 +01:00
committed by GitHub
parent 030bbc6399
commit 70d4182850
7 changed files with 65 additions and 36 deletions

View File

@@ -1491,7 +1491,7 @@ CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailTy
}
/* Check if we can allocate a custom stationspec to this station */
auto specindex = AllocateSpecToStation(statspec, st, flags.Test(DoCommandFlag::Execute));
auto specindex = AllocateSpecToStation(statspec, st);
if (!specindex.has_value()) return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
if (statspec != nullptr) {
@@ -1514,6 +1514,7 @@ CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailTy
st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
if (specindex.has_value()) AssignSpecToStation(statspec, st, *specindex);
if (statspec != nullptr) {
/* Include this station spec's animation trigger bitmask
* in the station's cached copy. */
@@ -2113,7 +2114,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width
if (ret.Failed()) return ret;
/* Check if we can allocate a custom stationspec to this station */
auto specindex = AllocateSpecToRoadStop(roadstopspec, st, flags.Test(DoCommandFlag::Execute));
auto specindex = AllocateSpecToRoadStop(roadstopspec, st);
if (!specindex.has_value()) return CommandCost(STR_ERROR_TOO_MANY_STATION_SPECS);
if (roadstopspec != nullptr) {
@@ -2127,6 +2128,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlags flags, TileIndex tile, uint8_t width
}
if (flags.Test(DoCommandFlag::Execute)) {
if (specindex.has_value()) AssignSpecToRoadStop(roadstopspec, st, *specindex);
/* Check every tile in the area. */
for (TileIndex cur_tile : roadstop_area) {
/* Get existing road types and owners before any tile clearing */