summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/autoreplace_cmd.cpp5
-rw-r--r--src/base_consist.cpp8
-rw-r--r--src/base_consist.h4
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_base.h2
5 files changed, 12 insertions, 9 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 1f1717f98..de4bcb00f 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -357,11 +357,6 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head,
/* Last do those things which do never fail (resp. we do not care about), but which are not undo-able */
if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) {
- /* Copy vehicle name */
- if (old_head->name != NULL) {
- DoCommand(0, new_head->index, 0, DC_EXEC | DC_AUTOREPLACE, CMD_RENAME_VEHICLE, old_head->name);
- }
-
/* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */
new_head->CopyVehicleConfigAndStatistics(old_head);
diff --git a/src/base_consist.cpp b/src/base_consist.cpp
index def120fe1..93b97e10e 100644
--- a/src/base_consist.cpp
+++ b/src/base_consist.cpp
@@ -12,6 +12,11 @@
#include "stdafx.h"
#include "base_consist.h"
+BaseConsist::~BaseConsist()
+{
+ free(this->name);
+}
+
/**
* Copy properties of other BaseConsist.
* @param src Source for copying
@@ -20,6 +25,9 @@ void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
{
if (this == src) return;
+ free(this->name);
+ this->name = src->name != NULL ? strdup(src->name) : NULL;
+
this->service_interval = src->service_interval;
this->cur_real_order_index = src->cur_real_order_index;
}
diff --git a/src/base_consist.h b/src/base_consist.h
index 3c1366a6d..68303f4d8 100644
--- a/src/base_consist.h
+++ b/src/base_consist.h
@@ -17,9 +17,13 @@
/** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */
struct BaseConsist {
+ char *name; ///< Name of vehicle
Date service_interval; ///< The interval for (automatic) servicing; either in days or %.
VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order
+ BaseConsist() : name(NULL) {}
+ virtual ~BaseConsist();
+
void CopyConsistPropertiesFrom(const BaseConsist *src);
};
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 8a3d4fe68..be5cf0cdb 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -781,8 +781,6 @@ void Vehicle::PreDestructor()
Vehicle::~Vehicle()
{
- free(this->name);
-
if (CleaningPool()) {
this->cargo.OnCleanPool();
return;
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 545b3404c..98d741948 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -136,8 +136,6 @@ public:
friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the #previous and #first pointers while loading
friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading
- char *name; ///< Name of vehicle
-
TileIndex tile; ///< Current tile index
/**