static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf, RoadType basetype)
{
ChangeInfoResult ret = CIR_SUCCESS;
extern RoadtypeInfo _roadtypes[ROADTYPE_END][ROADSUBTYPE_END];
if (id + numinfo > ROADTYPE_END) {
grfmsg(1, "RoadTypeReserveInfo: Road type %u is invalid, max %u, ignoring", id + numinfo, ROADTYPE_END);
return CIR_INVALID_ID;
}
for (int i = 0; i < numinfo; i++) {
switch (prop) {
case 0x08: // Label of rail type
{
RoadTypeLabel rtl = buf->ReadDWord();
rtl = BSWAP32(rtl);
RoadType rt = GetRoadTypeByLabel(rtl, basetype, false);
if (rt == INVALID_ROADTYPE) {
/* Set up new road type */
rt = AllocateRoadType(rtl, basetype);
}
_cur.grffile->roadtype_map[basetype][id + i] = rt;
break;
}
case 0x09: // Toolbar caption of roadtype
case 0x0A: // Menu text
case 0x0B: // Build window caption
case 0x0C: // Autoreplace text
case 0x0D: // New loco
case 0x13: // Construction cost
case 0x14: // Speed limit
case 0x1B: // Name of roadtype
case 0x1C: // Maintenance cost factor
buf->ReadWord();
break;
case 0x1D: // Alternate road type label list
if (_cur.grffile->roadtype_map[basetype][id + i] != INVALID_ROADTYPE) {
int n = buf->ReadByte();
for (int j = 0; j != n; j++) {
*_roadtypes[basetype][_cur.grffile->roadtype_map[basetype][id + i]].alternate_labels.Append() = BSWAP32(buf->ReadDWord());
}
break;
}
grfmsg(1, "RoadTypeReserveInfo: Ignoring property 1D for road type %u because no label was set", id + i);
/* FALL THROUGH */
case 0x0E: // Compatible roadtype list
case 0x0F: // Powered roadtype list
case 0x18: // Roadtype list required for date introduction
case 0x19: // Introduced roadtype list
for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
break;
case 0x10: // Road Type flags
case 0x11: // Curve speed advantage
case 0x12: // Station graphic
case 0x15: // Acceleration model
case 0x16: // Map colour
case 0x1A: // Sort order
buf->ReadByte();
break;
case 0x17: // Introduction date
buf->ReadDWord();
break;
default:
ret = CIR_UNKNOWN;
break;
}
grfmsg(0, "RoadTypeReserveInfo: Road type property found 0x%02X, num info %u", prop, numinfo);
}
return ret;
}
static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf)
{
return RoadTypeReserveInfo(id, numinfo, prop, buf, ROADTYPE_ROAD);
}
static ChangeInfoResult TramTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf)
{
return RoadTypeReserveInfo(id, numinfo, prop, buf, ROADTYPE_TRAM);
}