Add road stop support for Action 3 cargo type groups

This commit is contained in:
Jonathan G Rennison
2022-02-14 19:54:51 +00:00
parent 3b8c73acad
commit 67d967befb

View File

@@ -6408,9 +6408,26 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount)
roadstops[i] = buf->ReadByte();
}
/* Skip the cargo type section, we only care about the default group */
uint8 cidcount = buf->ReadByte();
buf->Skip(cidcount * 3);
for (uint c = 0; c < cidcount; c++) {
uint8 ctype = buf->ReadByte();
uint16 groupid = buf->ReadWord();
if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) continue;
ctype = TranslateCargo(GSF_ROADSTOPS, ctype);
if (ctype == CT_INVALID) continue;
for (uint i = 0; i < idcount; i++) {
RoadStopSpec *roadstopspec = _cur.grffile->roadstops == nullptr ? nullptr : _cur.grffile->roadstops[roadstops[i]];
if (roadstopspec == nullptr) {
grfmsg(1, "RoadStopMapSpriteGroup: Road stop with ID 0x%02X does not exist, skipping", roadstops[i]);
continue;
}
roadstopspec->grf_prop.spritegroup[ctype] = _cur.spritegroups[groupid];
}
}
uint16 groupid = buf->ReadWord();
if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) return;