From 57a3a2b14793e20fb0a4a6b90de0bb55a850ef2f Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 13 Jul 2013 15:03:42 +0000 Subject: (svn r25605) -Fix [FS#5641]: [Script] If a NewGRF returned station type that could not be built by an AI via callback 18, an unknown error would be thrown instead of falling back to the default station --- src/script/api/script_rail.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/script') diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index fd1e3e920..161007de9 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -186,10 +186,11 @@ if (spec == NULL) { DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename); } else { - p2 |= spec->cls_id | index << 8; + /* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */ + if (ScriptObject::DoCommand(tile, p1, p2 | spec->cls_id | index << 8, CMD_BUILD_RAIL_STATION)) return true; } - } + return ScriptObject::DoCommand(tile, p1, p2, CMD_BUILD_RAIL_STATION); } -- cgit v1.2.3-70-g09d2