summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-12 17:14:07 +0000
committerrubidium <rubidium@openttd.org>2008-09-12 17:14:07 +0000
commit7f461f0bba5b2d0476a87701e3edc9612a2f9809 (patch)
tree839f3669d1354c636aaa2b50c90e94639c20dd46 /src/strings.cpp
parente9a3ed016d682aed5b89c7f1444d6e751a85e380 (diff)
downloadopenttd-7f461f0bba5b2d0476a87701e3edc9612a2f9809.tar.xz
(svn r14297) -Fix: one could be trying to get the station name of a station that is outside of the pool.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 065b617fb..f12b4beee 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -838,11 +838,18 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
}
case SCC_STATION_NAME: { // {STATION}
- const Station* st = GetStation(GetInt32(&argv));
+ StationID sid = GetInt32(&argv);
- if (!st->IsValid()) { // station doesn't exist anymore
+ if (!IsValidStationID(sid)) {
+ /* The station doesn't exist anymore. The only place where we might
+ * be "drawing" an invalid station is in the case of cargo that is
+ * in transit. */
buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL, last);
- } else if (st->name != NULL) {
+ break;
+ }
+
+ const Station *st = GetStation(sid);
+ if (st->name != NULL) {
buff = strecpy(buff, st->name, last);
} else {
int64 temp[3];