Codechange: Sprite mapping for objects doesn't involve cargo types. (#10905)
Objects have a default sprite group and an optional purchase list sprite group. There is no need to pretend that these are cargo IDs.
This commit is contained in:
@@ -5504,15 +5504,6 @@ static void NewSpriteGroup(ByteReader *buf)
|
||||
|
||||
static CargoID TranslateCargo(uint8 feature, uint8 ctype)
|
||||
{
|
||||
if (feature == GSF_OBJECTS) {
|
||||
switch (ctype) {
|
||||
case 0: return 0;
|
||||
case 0xFF: return CT_PURCHASE_OBJECT;
|
||||
default:
|
||||
GrfMsg(1, "TranslateCargo: Invalid cargo bitnum {} for objects, skipping.", ctype);
|
||||
return CT_INVALID;
|
||||
}
|
||||
}
|
||||
/* Special cargo types for purchase list and stations */
|
||||
if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return CT_DEFAULT_NA;
|
||||
if (ctype == 0xFF) return CT_PURCHASE;
|
||||
@@ -5878,8 +5869,11 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount)
|
||||
uint16 groupid = buf->ReadWord();
|
||||
if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) continue;
|
||||
|
||||
ctype = TranslateCargo(GSF_OBJECTS, ctype);
|
||||
if (!IsValidCargoID(ctype)) continue;
|
||||
/* The only valid option here is purchase list sprite groups. */
|
||||
if (ctype != 0xFF) {
|
||||
GrfMsg(1, "ObjectMapSpriteGroup: Invalid cargo bitnum {} for objects, skipping.", ctype);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto &object : objects) {
|
||||
ObjectSpec *spec = object >= _cur.grffile->objectspec.size() ? nullptr : _cur.grffile->objectspec[object].get();
|
||||
@@ -5889,7 +5883,7 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount)
|
||||
continue;
|
||||
}
|
||||
|
||||
spec->grf_prop.spritegroup[ctype] = _cur.spritegroups[groupid];
|
||||
spec->grf_prop.spritegroup[OBJECT_SPRITE_GROUP_PURCHASE] = _cur.spritegroups[groupid];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5909,9 +5903,9 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount)
|
||||
continue;
|
||||
}
|
||||
|
||||
spec->grf_prop.spritegroup[0] = _cur.spritegroups[groupid];
|
||||
spec->grf_prop.grffile = _cur.grffile;
|
||||
spec->grf_prop.local_id = object;
|
||||
spec->grf_prop.spritegroup[OBJECT_SPRITE_GROUP_DEFAULT] = _cur.spritegroups[groupid];
|
||||
spec->grf_prop.grffile = _cur.grffile;
|
||||
spec->grf_prop.local_id = object;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user