summaryrefslogtreecommitdiff
path: root/src/waypoint_cmd.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-13 17:11:28 +0000
committeralberth <alberth@openttd.org>2010-03-13 17:11:28 +0000
commit7cc68f493d10ed81d24b9e7a0e9631436643869f (patch)
tree1f7fef2560b9bc81461bd8f17f21bdc1d80c2a91 /src/waypoint_cmd.cpp
parent19afc9fdc0f009c93f31ea8fccdf95ce1372cc58 (diff)
downloadopenttd-7cc68f493d10ed81d24b9e7a0e9631436643869f.tar.xz
(svn r19405) -Codechange: CheckOwnership() returns a CommandCost.
Diffstat (limited to 'src/waypoint_cmd.cpp')
-rw-r--r--src/waypoint_cmd.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 04db4fc93..f9f0b4362 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -178,9 +178,11 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
if (GetAxisForNewWaypoint(tile) != axis) return_cmd_error(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK);
Owner owner = GetTileOwner(tile);
- if (!CheckOwnership(owner)) return CMD_ERROR;
+ CommandCost ret = CheckOwnership(owner);
+ ret.SetGlobalErrorMessage();
+ if (ret.Failed()) return ret;
- CommandCost ret = EnsureNoVehicleOnGround(tile);
+ ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
@@ -445,7 +447,13 @@ static bool IsUniqueWaypointName(const char *name)
CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
Waypoint *wp = Waypoint::GetIfValid(p1);
- if (wp == NULL || !(CheckOwnership(wp->owner) || wp->owner == OWNER_NONE)) return CMD_ERROR;
+ if (wp == NULL) return CMD_ERROR;
+
+ if (wp->owner != OWNER_NONE) {
+ CommandCost ret = CheckOwnership(wp->owner);
+ ret.SetGlobalErrorMessage();
+ if (ret.Failed()) return ret;
+ }
bool reset = StrEmpty(text);