mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: Use vector for waypoint layout. (#12264)
This replaces manual new/delete of byte array, and matches how it is used for station layouts.
This commit is contained in:
parent
2f0fe22d63
commit
8b60fc3d35
@ -258,13 +258,10 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||||||
wp->UpdateVirtCoord();
|
wp->UpdateVirtCoord();
|
||||||
|
|
||||||
const StationSpec *spec = StationClass::Get(spec_class)->GetSpec(spec_index);
|
const StationSpec *spec = StationClass::Get(spec_class)->GetSpec(spec_index);
|
||||||
byte *layout_ptr = new byte[count];
|
std::vector<byte> layout(count);
|
||||||
if (spec == nullptr) {
|
if (spec != nullptr) {
|
||||||
/* The layout must be 0 for the 'normal' waypoints by design. */
|
/* For NewGRF waypoints we like to have their style. */
|
||||||
memset(layout_ptr, 0, count);
|
GetStationLayout(layout.data(), count, 1, spec);
|
||||||
} else {
|
|
||||||
/* But for NewGRF waypoints we like to have their style. */
|
|
||||||
GetStationLayout(layout_ptr, count, 1, spec);
|
|
||||||
}
|
}
|
||||||
byte map_spec_index = AllocateSpecToStation(spec, wp, true);
|
byte map_spec_index = AllocateSpecToStation(spec, wp, true);
|
||||||
|
|
||||||
@ -276,7 +273,7 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||||||
bool reserved = IsTileType(tile, MP_RAILWAY) ?
|
bool reserved = IsTileType(tile, MP_RAILWAY) ?
|
||||||
HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis)) :
|
HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis)) :
|
||||||
HasStationReservation(tile);
|
HasStationReservation(tile);
|
||||||
MakeRailWaypoint(tile, wp->owner, wp->index, axis, layout_ptr[i], GetRailType(tile));
|
MakeRailWaypoint(tile, wp->owner, wp->index, axis, layout[i], GetRailType(tile));
|
||||||
SetCustomStationSpecIndex(tile, map_spec_index);
|
SetCustomStationSpecIndex(tile, map_spec_index);
|
||||||
|
|
||||||
/* Should be the same as layout but axis component could be wrong... */
|
/* Should be the same as layout but axis component could be wrong... */
|
||||||
@ -297,7 +294,6 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
|
|||||||
YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
|
YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
|
||||||
}
|
}
|
||||||
DirtyCompanyInfrastructureWindows(wp->owner);
|
DirtyCompanyInfrastructureWindows(wp->owner);
|
||||||
delete[] layout_ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
|
Loading…
Reference in New Issue
Block a user