summaryrefslogtreecommitdiff
path: root/src/group_cmd.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-12 19:58:06 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-12 19:58:06 +0000
commitab8382c0db353d9d1ba6b7a9690d56aa2415258c (patch)
treef23fb584e594e0c9ff5a9ad650d97c493714078d /src/group_cmd.cpp
parenta222fe2e86d2736217f3bba43b28e95297b8d71e (diff)
downloadopenttd-ab8382c0db353d9d1ba6b7a9690d56aa2415258c.tar.xz
(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.
Diffstat (limited to 'src/group_cmd.cpp')
-rw-r--r--src/group_cmd.cpp15
1 files changed, 5 insertions, 10 deletions
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),