diff options
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 57dcb41ca..3b0af5517 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -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; |