From e5c9a3e5270defb4994a3dd7bb3e3e99748496cd Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 30 Apr 2023 10:00:43 +0100 Subject: [PATCH] Change: Read Action 3 IDs as extended-bytes for all features. This can be done because previous the value 0xFF (which indicates an extended byte) was reserved for this purpose. Other features which may not have mentioned reserving 0xFF do not allow this many IDs anyway. This makes Action 3 consistent across all features. The allowable limits for each feature do not change. --- src/newgrf.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 34e307b8d7..93ef97819d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5642,10 +5642,10 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount) { - std::vector cfs; + std::vector cfs; cfs.reserve(idcount); for (uint i = 0; i < idcount; i++) { - cfs.push_back((CanalFeature)buf->ReadByte()); + cfs.push_back(buf->ReadExtendedByte()); } uint8 cidcount = buf->ReadByte(); @@ -5673,10 +5673,10 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector stations; + std::vector stations; stations.reserve(idcount); for (uint i = 0; i < idcount; i++) { - stations.push_back(buf->ReadByte()); + stations.push_back(buf->ReadExtendedByte()); } uint8 cidcount = buf->ReadByte(); @@ -5731,10 +5731,10 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector houses; + std::vector houses; houses.reserve(idcount); for (uint i = 0; i < idcount; i++) { - houses.push_back(buf->ReadByte()); + houses.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -5763,10 +5763,10 @@ static void IndustryMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector industries; + std::vector industries; industries.reserve(idcount); for (uint i = 0; i < idcount; i++) { - industries.push_back(buf->ReadByte()); + industries.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -5795,10 +5795,10 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector indtiles; + std::vector indtiles; indtiles.reserve(idcount); for (uint i = 0; i < idcount; i++) { - indtiles.push_back(buf->ReadByte()); + indtiles.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -5822,10 +5822,10 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) { - std::vector cargoes; + std::vector cargoes; cargoes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - cargoes.push_back((CargoID)buf->ReadByte()); + cargoes.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -5854,10 +5854,10 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector objects; + std::vector objects; objects.reserve(idcount); for (uint i = 0; i < idcount; i++) { - objects.push_back(buf->ReadByte()); + objects.push_back(buf->ReadExtendedByte()); } uint8 cidcount = buf->ReadByte(); @@ -5908,7 +5908,7 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) std::vector railtypes; railtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - uint8 id = buf->ReadByte(); + uint16_t id = buf->ReadExtendedByte(); railtypes.push_back(id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE); } @@ -5942,7 +5942,7 @@ static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8 idcount, RoadTramType std::vector roadtypes; roadtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { - uint8 id = buf->ReadByte(); + uint16_t id = buf->ReadExtendedByte(); roadtypes.push_back(id < ROADTYPE_END ? type_map[id] : INVALID_ROADTYPE); } @@ -5976,10 +5976,10 @@ static void AirportMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector airports; + std::vector airports; airports.reserve(idcount); for (uint i = 0; i < idcount; i++) { - airports.push_back(buf->ReadByte()); + airports.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -6008,10 +6008,10 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector airptiles; + std::vector airptiles; airptiles.reserve(idcount); for (uint i = 0; i < idcount; i++) { - airptiles.push_back(buf->ReadByte()); + airptiles.push_back(buf->ReadExtendedByte()); } /* Skip the cargo type section, we only care about the default group */ @@ -6040,10 +6040,10 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) return; } - std::vector roadstops; + std::vector roadstops; roadstops.reserve(idcount); for (uint i = 0; i < idcount; i++) { - roadstops.push_back(buf->ReadByte()); + roadstops.push_back(buf->ReadExtendedByte()); } uint8 cidcount = buf->ReadByte(); @@ -6100,7 +6100,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) * B feature see action 0 * B n-id bits 0-6: how many IDs this definition applies to * bit 7: if set, this is a wagon override definition (see below) - * B ids the IDs for which this definition applies + * E ids the IDs for which this definition applies * B num-cid number of cargo IDs (sprite group IDs) in this definition * can be zero, in that case the def-cid is used always * B cargo-type type of this cargo type (e.g. mail=2, wood=7, see below)