Mercurial > hg > openttd
diff src/autoreplace_cmd.cpp @ 8258:6017c5ebeb7e draft
(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.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sat, 12 Jan 2008 19:58:06 +0000 |
parents | 7d580c9c41fb |
children | 2495310e220f |
line wrap: on
line diff
--- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -134,7 +134,7 @@ const UnitID cached_unitnumber = old_v->unitnumber; bool new_front = false; Vehicle *new_v = NULL; - char vehicle_name[32]; + char *vehicle_name = NULL; CargoID replacement_cargo_type; /* If the vehicle belongs to a group, check if the group is protected from the global autoreplace. @@ -240,12 +240,7 @@ MoveVehicleCargo(new_v->type == VEH_TRAIN ? new_v->First() : new_v, old_v); // Get the name of the old vehicle if it has a custom name. - if (!IsCustomName(old_v->string_id)) { - vehicle_name[0] = '\0'; - } else { - SetDParam(0, old_v->index); - GetString(vehicle_name, STR_VEHICLE_NAME, lastof(vehicle_name)); - } + if (old_v->name != NULL) vehicle_name = strdup(old_v->name); } else { // flags & DC_EXEC not set CommandCost tmp_move; @@ -285,9 +280,10 @@ } /* Transfer the name of the old vehicle */ - if ((flags & DC_EXEC) && vehicle_name[0] != '\0') { + if ((flags & DC_EXEC) && vehicle_name != NULL) { _cmd_text = vehicle_name; DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE); + free(vehicle_name); } return cost;