summaryrefslogtreecommitdiff
path: root/src/waypoint_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/waypoint_cmd.cpp')
-rw-r--r--src/waypoint_cmd.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 301835361..468d216cb 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -314,10 +314,8 @@ static bool IsUniqueWaypointName(const char *name)
*/
CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- if (!Waypoint::IsValidID(p1)) return CMD_ERROR;
-
- Waypoint *wp = Waypoint::Get(p1);
- if (!CheckOwnership(wp->owner)) return CMD_ERROR;
+ Waypoint *wp = Waypoint::GetIfValid(p1);
+ if (wp == NULL || !CheckOwnership(wp->owner)) return CMD_ERROR;
bool reset = StrEmpty(text);