From 0f7392bd616e0bd256b5ec241ad52d7230bcc454 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/group_cmd.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/group_cmd.cpp') diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 16f3d5cb7..b04d2ad7a 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -52,7 +52,7 @@ Group::Group(PlayerID owner) Group::~Group() { - DeleteName(this->string_id); + free(this->name); this->owner = INVALID_PLAYER; } @@ -186,19 +186,13 @@ CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!IsUniqueGroupName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); - /* Create the name */ - StringID str = AllocateName(_cmd_text, 0); - if (str == STR_NULL) return CMD_ERROR; - if (flags & DC_EXEC) { /* Delete the old name */ - DeleteName(g->string_id); + free(g->name); /* Assign the new one */ - g->string_id = str; + g->name = strdup(_cmd_text); InvalidateWindowData(GetWCForVT(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_player); - } else { - DeleteName(str); } return CommandCost(); @@ -433,7 +427,8 @@ void RemoveAllGroupsForPlayer(const PlayerID p) static const SaveLoad _group_desc[] = { - SLE_VAR(Group, string_id, SLE_UINT16), + SLE_CONDVAR(Group, name, SLE_NAME, 0, 83), + SLE_CONDSTR(Group, name, SLE_STR, 0, 84, SL_MAX_VERSION), SLE_VAR(Group, num_vehicle, SLE_UINT16), SLE_VAR(Group, owner, SLE_UINT8), SLE_VAR(Group, vehicle_type, SLE_UINT8), -- cgit v1.2.3-54-g00ecf