summaryrefslogtreecommitdiff
path: root/src/newgrf_text.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2016-12-23 22:13:38 +0000
committerfrosch <frosch@openttd.org>2016-12-23 22:13:38 +0000
commit1a92b0c7c33a981959dfae8268a618119d1a09ea (patch)
treedb53a20235e55ea1ba8e402ec5270239ea101241 /src/newgrf_text.cpp
parentb25afb239a81ef47d2339daed343d3a169d8863a (diff)
downloadopenttd-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.
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r--src/newgrf_text.cpp6
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 */