diff options
author | smatz <smatz@openttd.org> | 2009-05-18 16:21:28 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-18 16:21:28 +0000 |
commit | 8808f3beea881af5652716c883a21c8031b5e390 (patch) | |
tree | bc14c65d1e66c407b72d254fc926d105eea2f1e4 /src/town_cmd.cpp | |
parent | 5fe906e14992f7a301ae94c357e80af076ab7a63 (diff) | |
download | openttd-8808f3beea881af5652716c883a21c8031b5e390.tar.xz |
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 76380ded3..2f5efb70d 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2273,7 +2273,8 @@ static bool IsUniqueTownName(const char *name) */ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - if (!Town::IsValidID(p1)) return CMD_ERROR; + Town *t = Town::GetIfValid(p1); + if (t == NULL) return CMD_ERROR; bool reset = StrEmpty(text); @@ -2283,8 +2284,6 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } if (flags & DC_EXEC) { - Town *t = Town::Get(p1); - free(t->name); t->name = reset ? NULL : strdup(text); @@ -2548,9 +2547,8 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t) */ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - if (!Town::IsValidID(p1) || p2 >= lengthof(_town_action_proc)) return CMD_ERROR; - - Town *t = Town::Get(p1); + Town *t = Town::GetIfValid(p1); + if (t == NULL || p2 >= lengthof(_town_action_proc)) return CMD_ERROR; if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR; |