Changeset - r27253:40edbcd483e2
[Not reviewed]
master
0 1 0
Peter Nelson - 13 months ago 2023-04-30 09:00:43
peter1138@openttd.org
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.
1 file changed with 23 insertions and 23 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -5642,10 +5642,10 @@ static void VehicleMapSpriteGroup(ByteRe
 

	
 
static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount)
 
{
 
	std::vector<CanalFeature> cfs;
 
	std::vector<uint16_t> 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(ByteRe
 
		return;
 
	}
 

	
 
	std::vector<uint8> stations;
 
	std::vector<uint16_t> 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(Byte
 
		return;
 
	}
 

	
 
	std::vector<uint8> houses;
 
	std::vector<uint16_t> 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(ByteR
 
		return;
 
	}
 

	
 
	std::vector<uint8> industries;
 
	std::vector<uint16_t> 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(B
 
		return;
 
	}
 

	
 
	std::vector<uint8> indtiles;
 
	std::vector<uint16_t> 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(B
 

	
 
static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount)
 
{
 
	std::vector<CargoID> cargoes;
 
	std::vector<uint16_t> 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(ByteRea
 
		return;
 
	}
 

	
 
	std::vector<uint8> objects;
 
	std::vector<uint16_t> 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(ByteR
 
	std::vector<uint8> 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(ByteR
 
	std::vector<uint8> 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(ByteRe
 
		return;
 
	}
 

	
 
	std::vector<uint8> airports;
 
	std::vector<uint16_t> 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(By
 
		return;
 
	}
 

	
 
	std::vector<uint8> airptiles;
 
	std::vector<uint16_t> 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(ByteR
 
		return;
 
	}
 

	
 
	std::vector<uint8> roadstops;
 
	std::vector<uint16_t> 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(ByteRe
 
	 * 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)
0 comments (0 inline, 0 general)