From ab8382c0db353d9d1ba6b7a9690d56aa2415258c Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 12 Jan 2008 19:58:06 +0000 Subject: (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is no limit to the amount of names. -Fix: NewGRF engines could not be renamed. --- src/town_cmd.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/town_cmd.cpp') diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 45151d476..f5a1e88ac 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -55,7 +55,7 @@ Town::Town(TileIndex tile) Town::~Town() { - DeleteName(this->townnametype); + free(this->name); if (CleaningPool()) return; @@ -1888,7 +1888,6 @@ static bool IsUniqueTownName(const char *name) */ CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - StringID str; Town *t; if (!IsValidTownID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR; @@ -1897,21 +1896,15 @@ CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!IsUniqueTownName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); - str = AllocateName(_cmd_text, 4); - if (str == 0) return CMD_ERROR; - if (flags & DC_EXEC) { - DeleteName(t->townnametype); - t->townnametype = str; - t->townnamegrfid = 0; + free(t->name); + t->name = strdup(_cmd_text); UpdateTownVirtCoord(t); _town_sort_dirty = true; UpdateAllStationVirtCoord(); UpdateAllWaypointSigns(); MarkWholeScreenDirty(); - } else { - DeleteName(str); } return CommandCost(); } @@ -2417,6 +2410,7 @@ static const SaveLoad _town_desc[] = { SLE_CONDVAR(Town, townnamegrfid, SLE_UINT32, 66, SL_MAX_VERSION), SLE_VAR(Town, townnametype, SLE_UINT16), SLE_VAR(Town, townnameparts, SLE_UINT32), + SLE_CONDSTR(Town, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_VAR(Town, flags12, SLE_UINT8), SLE_VAR(Town, statues, SLE_UINT8), -- cgit v1.2.3-54-g00ecf