summaryrefslogtreecommitdiff
path: root/src/object_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/object_cmd.cpp')
-rw-r--r--src/object_cmd.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index a8e8e5e19..564c9f9a6 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -121,9 +121,9 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
CommandCost cost(EXPENSES_PROPERTY);
ObjectType type = (ObjectType)GB(p1, 0, 8);
- if (type >= OBJECT_MAX) return CMD_ERROR;
-
const ObjectSpec *spec = ObjectSpec::Get(type);
+ if (!spec->enabled) return CMD_ERROR;
+
if (spec->flags & OBJECT_FLAG_ONLY_IN_SCENEDIT && (_game_mode != GM_EDITOR || _current_company != OWNER_NONE)) return CMD_ERROR;
if (spec->flags & OBJECT_FLAG_ONLY_IN_GAME && (_game_mode != GM_NORMAL || _current_company > MAX_COMPANIES)) return CMD_ERROR;
@@ -195,6 +195,10 @@ static void DrawTile_Object(TileInfo *ti)
{
ObjectType type = GetObjectType(ti->tile);
const ObjectSpec *spec = ObjectSpec::Get(type);
+
+ /* Fall back for when the object doesn't exist anymore. */
+ if (!spec->enabled) type = OBJECT_TRANSMITTER;
+
if ((spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) == 0) DrawFoundation(ti, GetFoundation_Object(ti->tile, ti->tileh));
const DrawTileSprites *dts = NULL;