diff options
author | peter1138 <peter1138@openttd.org> | 2019-03-10 17:45:15 +0000 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-15 17:43:10 +0000 |
commit | fc5f67123acfd977cd74d5e5a8d2d13a049b357a (patch) | |
tree | 9b6b901add621a3c38d5f6fb3e15c44205b79b3c /src/newgrf.cpp | |
parent | b00a861467b9c7ea62bae2df140975f0838e0ea7 (diff) | |
download | openttd-fc5f67123acfd977cd74d5e5a8d2d13a049b357a.tar.xz |
Fix e66cec8f86: Permit loading of industry production callback with invalid cargo type.
It is only an error if the invalid result is actually used. This will be silently ignored at the moment.
It is still an error if a duplicate cargo type is returned.
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index ff1028798..13d1377d0 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5005,7 +5005,12 @@ static void NewSpriteGroup(ByteReader *buf) for (uint i = 0; i < group->num_input; i++) { byte rawcargo = buf->ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); - if (std::find(group->cargo_input, group->cargo_input + i, cargo) != group->cargo_input + i) { + if (cargo == CT_INVALID) { + /* The mapped cargo is invalid. This is permitted at this point, + * as long as the result is not used. Mark it invalid so this + * can be tested later. */ + group->version = 0xFF; + } else if (std::find(group->cargo_input, group->cargo_input + i, cargo) != group->cargo_input + i) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = stredup("duplicate input cargo"); return; @@ -5022,7 +5027,10 @@ static void NewSpriteGroup(ByteReader *buf) for (uint i = 0; i < group->num_output; i++) { byte rawcargo = buf->ReadByte(); CargoID cargo = GetCargoTranslation(rawcargo, _cur.grffile); - if (std::find(group->cargo_output, group->cargo_output + i, cargo) != group->cargo_output + i) { + if (cargo == CT_INVALID) { + /* Mark this result as invalid to use */ + group->version = 0xFF; + } else if (std::find(group->cargo_output, group->cargo_output + i, cargo) != group->cargo_output + i) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_INDPROD_CALLBACK); error->data = stredup("duplicate output cargo"); return; |