mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
Fix: Don't restore backed up vehicle name if it's no longer unique. (#10979)
(cherry picked from commit 2097719f26
)
This commit is contained in:
parent
e1cb4d2397
commit
1696ef6446
@ -16,6 +16,7 @@
|
||||
#include "vehicle_base.h"
|
||||
#include "window_func.h"
|
||||
#include "station_map.h"
|
||||
#include "vehicle_func.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@ -98,6 +99,9 @@ void OrderBackup::DoRestore(Vehicle *v)
|
||||
InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
||||
}
|
||||
|
||||
/* Remove backed up name if it's no longer unique. */
|
||||
if (!this->name.empty() && !IsUniqueVehicleName(this->name.c_str())) this->name.clear();
|
||||
|
||||
v->CopyConsistPropertiesFrom(this);
|
||||
|
||||
/* Make sure orders are in range */
|
||||
|
@ -827,7 +827,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
|
||||
* @param name Name to test.
|
||||
* @return True if the name is unique.
|
||||
*/
|
||||
static bool IsUniqueVehicleName(const char *name)
|
||||
bool IsUniqueVehicleName(const char *name)
|
||||
{
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
if (!v->name.empty() && v->name == name) return false;
|
||||
|
@ -267,4 +267,6 @@ void CheckCargoCapacity(Vehicle *v);
|
||||
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2);
|
||||
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2);
|
||||
|
||||
bool IsUniqueVehicleName(const char *name);
|
||||
|
||||
#endif /* VEHICLE_FUNC_H */
|
||||
|
Loading…
Reference in New Issue
Block a user