diff options
author | frosch <frosch@openttd.org> | 2016-12-23 22:13:38 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2016-12-23 22:13:38 +0000 |
commit | 1a92b0c7c33a981959dfae8268a618119d1a09ea (patch) | |
tree | db53a20235e55ea1ba8e402ec5270239ea101241 | |
parent | b25afb239a81ef47d2339daed343d3a169d8863a (diff) | |
download | openttd-1a92b0c7c33a981959dfae8268a618119d1a09ea.tar.xz |
(svn r27707) -Fix: Make the result of NewGRF's CARGO_NAME string code reliably print 'Nothing', if an invalid type is provided.
-rw-r--r-- | src/newgrf_text.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 2c9fe6579..df00ef341 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -1062,9 +1062,11 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const *argv = MapGRFStringID(_newgrf_textrefstack.grffile->grfid, _newgrf_textrefstack.PopUnsignedWord()); break; - case SCC_NEWGRF_PRINT_WORD_CARGO_NAME: - *argv = 1 << GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile); + case SCC_NEWGRF_PRINT_WORD_CARGO_NAME: { + CargoID cargo = GetCargoTranslation(_newgrf_textrefstack.PopUnsignedWord(), _newgrf_textrefstack.grffile); + *argv = cargo < NUM_CARGO ? 1 << cargo : 0; break; + } } } else { /* Consume additional parameter characters */ |