summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-05-07 08:14:06 +0000
committertron <tron@openttd.org>2005-05-07 08:14:06 +0000
commitaf427810428e65e9493499931f270c9a1bb3bc74 (patch)
tree6ee34b8db58d571fa1af1e03315fbd06a844c754
parent1a9c87bfe42d2a880a06e7a8593542e3cb1c362a (diff)
downloadopenttd-af427810428e65e9493499931f270c9a1bb3bc74.tar.xz
(svn r2278) When renaming a station, check if the station exists and belongs to the correct player
-rw-r--r--station_cmd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/station_cmd.c b/station_cmd.c
index 9042ce6ed..c4269b9e4 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2650,12 +2650,16 @@ int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
StringID str,old_str;
Station *st;
+ if (!IsStationIndex(p1)) return CMD_ERROR;
+ st = GetStation(p1);
+
+ if (!IsValidStation(st) || !CheckOwnership(st->owner)) return CMD_ERROR;
+
str = AllocateNameUnique((const char*)_decode_parameters, 6);
if (str == 0)
return CMD_ERROR;
if (flags & DC_EXEC) {
- st = GetStation(p1);
old_str = st->string_id;
st->string_id = str;
UpdateStationVirtCoord(st);