Index: src/newgrf.cpp =================================================================== --- src/newgrf.cpp (revision 19531) +++ src/newgrf.cpp (working copy) @@ -1456,6 +1456,61 @@ return ret; } +static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader *buf) +{ + ChangeInfoResult ret = CIR_SUCCESS; + + switch (prop) { + case 0x09: + case 0x0B: + case 0x0C: + case 0x0D: + case 0x0E: + case 0x0F: + case 0x11: + case 0x14: + case 0x15: + case 0x16: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1F: + buf->ReadByte(); + break; + + case 0x0A: + case 0x10: + case 0x12: + case 0x13: + case 0x21: + case 0x22: + buf->ReadWord(); + break; + + case 0x1E: + buf->ReadDWord(); + break; + + case 0x17: + for (uint j = 0; j < 4; j++) buf->ReadByte(); + break; + + case 0x20: { + byte count = buf->ReadByte(); + for (byte j = 0; j < count; j++) buf->ReadByte(); + ret = CIR_UNHANDLED; + } break; + + default: + ret = CIR_UNKNOWN; + break; + } + return ret; +} + static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, ByteReader *buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -1474,8 +1529,9 @@ HouseSpec *housespec = _cur_grffile->housespec[hid + i]; if (prop != 0x08 && housespec == NULL) { - grfmsg(2, "TownHouseChangeInfo: Attempt to modify undefined house %u. Ignoring.", hid + i); - return CIR_INVALID_ID; + ChangeInfoResult cir = IgnoreTownHouseProperty(prop, buf); + if (cir > ret) ret = cir; + continue; } switch (prop) { @@ -2062,6 +2118,34 @@ return ret; } +static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader *buf) +{ + ChangeInfoResult ret = CIR_SUCCESS; + + switch (prop) { + case 0x09: + case 0x0D: + case 0x0E: + case 0x10: + case 0x11: + case 0x12: + buf->ReadByte(); + break; + + case 0x0A: + case 0x0B: + case 0x0C: + case 0x0F: + buf->ReadWord(); + break; + + default: + ret = CIR_UNKNOWN; + break; + } + return ret; +} + static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, ByteReader *buf) { ChangeInfoResult ret = CIR_SUCCESS; @@ -2080,8 +2164,9 @@ IndustryTileSpec *tsp = _cur_grffile->indtspec[indtid + i]; if (prop != 0x08 && tsp == NULL) { - grfmsg(2, "IndustryTilesChangeInfo: Attempt to modify undefined industry tile %u. Ignoring.", indtid + i); - return CIR_INVALID_ID; + ChangeInfoResult cir = IgnoreIndustryTileProperty(prop, buf); + if (cir > ret) ret = cir; + continue; } switch (prop) { @@ -2170,6 +2255,83 @@ return ret; } +static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader *buf) +{ + ChangeInfoResult ret = CIR_SUCCESS; + + switch (prop) { + case 0x09: + case 0x0B: + case 0x0F: + case 0x12: + case 0x13: + case 0x14: + case 0x17: + case 0x18: + case 0x19: + case 0x21: + case 0x22: + buf->ReadByte(); + break; + + case 0x0C: + case 0x0D: + case 0x0E: + case 0x10: + case 0x1B: + case 0x1F: + case 0x24: + buf->ReadWord(); + break; + + case 0x1A: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x20: + case 0x23: + buf->ReadDWord(); + break; + + case 0x0A: { + byte num_table = buf->ReadByte(); + for (byte j = 0; j < num_table; j++) { + for (uint k = 0;; k++) { + byte x = buf->ReadByte(); + if (x == 0xFE && k == 0) { + buf->ReadByte(); + buf->ReadByte(); + break; + } + + byte y = buf->ReadByte(); + if (x == 0 && y == 0x80) break; + + byte gfx = buf->ReadByte(); + if (gfx == 0xFE) buf->ReadWord(); + } + } + } break; + + case 0x11: + case 0x16: + for (byte j = 0; j < 3; j++) buf->ReadByte(); + break; + + case 0x15: { + byte number_of_sounds = buf->ReadByte(); + for (uint8 j = 0; j < number_of_sounds; j++) { + buf->ReadByte(); + } + } break; + + default: + ret = CIR_UNKNOWN; + break; + } + return ret; +} + /** * Validate the industry layout; e.g. to prevent duplicate tiles. * @param layout the layout to check @@ -2209,8 +2371,9 @@ IndustrySpec *indsp = _cur_grffile->industryspec[indid + i]; if (prop != 0x08 && indsp == NULL) { - grfmsg(2, "IndustriesChangeInfo: Attempt to modify undefined industry %u. Ignoring.", indid + i); - return CIR_INVALID_ID; + ChangeInfoResult cir = IgnoreIndustryProperty(prop, buf); + if (cir > ret) ret = cir; + continue; } switch (prop) {