From 1a92b0c7c33a981959dfae8268a618119d1a09ea Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 23 Dec 2016 22:13:38 +0000 Subject: [PATCH] (svn r27707) -Fix: Make the result of NewGRF's CARGO_NAME string code reliably print 'Nothing', if an invalid type is provided. --- src/newgrf_text.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 2c9fe65797..df00ef3419 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 */