diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index fd1e3e920c..161007de96 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); }