summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:25:42 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:25:42 +0000
commit48f75a6a8d497aa0764eb298e9059bd075506a05 (patch)
treef2988aa7ba6d1371dbb0a82cdc86733c76f60a6f
parent449d6792304b1e6aa0ce6581d2f50f223545eff7 (diff)
downloadopenttd-48f75a6a8d497aa0764eb298e9059bd075506a05.tar.xz
(svn r23144) -Change: [NewGRF v8] Consider the 'default cargotype' properties as indices into the cargo translation table.
-rw-r--r--src/newgrf.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index e5d3691e6..f4873e74b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1004,11 +1004,15 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
case 0x15: { // Cargo type
uint8 ctype = buf->ReadByte();
- if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
- ei->cargo_type = ctype;
- } else if (ctype == 0xFF) {
+ if (ctype == 0xFF) {
/* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID;
+ } else if (_cur.grffile->grf_version >= 8) {
+ /* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
+ ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
+ } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ /* Use untranslated cargo. */
+ ei->cargo_type = ctype;
} else {
ei->cargo_type = CT_INVALID;
grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype);
@@ -1214,15 +1218,20 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
break;
case 0x10: { // Cargo type
- uint8 cargo = buf->ReadByte();
+ uint8 ctype = buf->ReadByte();
- if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
- ei->cargo_type = cargo;
- } else if (cargo == 0xFF) {
+ if (ctype == 0xFF) {
+ /* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID;
+ } else if (_cur.grffile->grf_version >= 8) {
+ /* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
+ ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
+ } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ /* Use untranslated cargo. */
+ ei->cargo_type = ctype;
} else {
ei->cargo_type = CT_INVALID;
- grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
+ grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype);
}
break;
}
@@ -1364,15 +1373,20 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
break;
case 0x0C: { // Cargo type
- uint8 cargo = buf->ReadByte();
+ uint8 ctype = buf->ReadByte();
- if (cargo < NUM_CARGO && HasBit(_cargo_mask, cargo)) {
- ei->cargo_type = cargo;
- } else if (cargo == 0xFF) {
+ if (ctype == 0xFF) {
+ /* 0xFF is specified as 'use first refittable' */
ei->cargo_type = CT_INVALID;
+ } else if (_cur.grffile->grf_version >= 8) {
+ /* Use translated cargo. Might result in CT_INVALID (first refittable), if cargo is not defined. */
+ ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile);
+ } else if (ctype < NUM_CARGO && HasBit(_cargo_mask, ctype)) {
+ /* Use untranslated cargo. */
+ ei->cargo_type = ctype;
} else {
ei->cargo_type = CT_INVALID;
- grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo);
+ grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype);
}
break;
}