From 0b72297d57bda5722299e6049f25f188584177be Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 18 Apr 2023 00:12:34 +0100 Subject: [PATCH] Feature: Increase number of stations/roadstops per NewGRF. --- src/newgrf.cpp | 7 ++++--- src/newgrf_roadstop.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index c91aa489ae..ed619c8a98 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -314,7 +314,8 @@ public: typedef void (*SpecialSpriteHandler)(ByteReader *buf); -static const uint NUM_STATIONS_PER_GRF = 255; ///< Number of StationSpecs per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on. +/** The maximum amount of stations a single GRF is allowed to add */ +static const uint NUM_STATIONS_PER_GRF = UINT16_MAX - 1; /** Temporary engine data used when loading only */ struct GRFTempEngineData { @@ -1988,7 +1989,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } case 0x0A: { // Copy sprite layout - byte srcid = buf->ReadByte(); + uint16_t srcid = buf->ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { @@ -2042,7 +2043,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte break; case 0x0F: { // Copy custom layout - byte srcid = buf->ReadByte(); + uint16_t srcid = buf->ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index 0ee524b0b3..f0d7975d53 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -20,7 +20,7 @@ #include "road.h" /** The maximum amount of roadstops a single GRF is allowed to add */ -static const int NUM_ROADSTOPS_PER_GRF = 255; +static const int NUM_ROADSTOPS_PER_GRF = UINT16_MAX - 1; enum RoadStopClassID : byte { ROADSTOP_CLASS_BEGIN = 0, ///< The lowest valid value