Add: Houses can accept up to 16 different cargo types via NewGRF.
New Action0 property 23 for feature 07, variable length, format B n*(B B). Initial byte is number of structures following. First byte in structure is cargo id, second is acceptance level in 1/8 units.
This commit is contained in:
@@ -2294,6 +2294,10 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf)
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x23:
|
||||
buf->Skip(buf->ReadByte() * 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = CIR_UNKNOWN;
|
||||
break;
|
||||
@@ -2526,6 +2530,28 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt
|
||||
housespec->max_year = buf->ReadWord();
|
||||
break;
|
||||
|
||||
case 0x23: { // variable length cargo types accepted
|
||||
uint count = buf->ReadByte();
|
||||
if (count > lengthof(housespec->accepts_cargo)) {
|
||||
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG);
|
||||
error->param_value[1] = prop;
|
||||
return CIR_DISABLED;
|
||||
}
|
||||
/* Always write the full accepts_cargo array, and check each index for being inside the
|
||||
* provided data. This ensures all values are properly initialized, and also avoids
|
||||
* any risks of array overrun. */
|
||||
for (uint i = 0; i < lengthof(housespec->accepts_cargo); i++) {
|
||||
if (i < count) {
|
||||
housespec->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile);
|
||||
housespec->cargo_acceptance[i] = buf->ReadByte();
|
||||
} else {
|
||||
housespec->accepts_cargo[i] = CT_INVALID;
|
||||
housespec->cargo_acceptance[i] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ret = CIR_UNKNOWN;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user