summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 076cc7187..066f6bac7 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -608,8 +608,9 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0);
bool nothing_to_do = true;
- if (!Vehicle::IsValidID(p1)) return CMD_ERROR;
- Vehicle *v = Vehicle::Get(p1);
+ Vehicle *v = Vehicle::GetIfValid(p1);
+ if (v == NULL) return CMD_ERROR;
+
if (!CheckOwnership(v->owner)) return CMD_ERROR;
if (!v->IsInDepot()) return CMD_ERROR;
if (HASBITS(v->vehstatus, VS_CRASHED)) return CMD_ERROR;