summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-10 15:54:07 +0000
committersmatz <smatz@openttd.org>2009-01-10 15:54:07 +0000
commit0cd41d1dc62386d15960b5a6f990207caf8d9834 (patch)
tree28a83cc48e100e71049922e32b22f54c82c409fb /src
parent07d1c28025749c97473371d3944a4b5be9fb2751 (diff)
downloadopenttd-0cd41d1dc62386d15960b5a6f990207caf8d9834.tar.xz
(svn r14958) -Codechange [FS#1923]: when checking for unique names, compare only with manually set names
There are situations that aren't solvable (because of different language files), so if the user really wants to have duplicated name, allow him to do so. It solves desyncs between server and clients using different languages. It behaves the same in SP and MP, so users won't see the different behaviour as a bug (and even checking in SP could be worked around by the user).
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp7
-rw-r--r--src/group_cmd.cpp5
-rw-r--r--src/misc_cmd.cpp10
-rw-r--r--src/station_cmd.cpp5
-rw-r--r--src/town_cmd.cpp5
-rw-r--r--src/vehicle.cpp25
-rw-r--r--src/waypoint.cpp5
7 files changed, 9 insertions, 53 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index dfe24168b..7e7959e26 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -493,13 +493,10 @@ void EnginesMonthlyLoop()
static bool IsUniqueEngineName(const char *name)
{
- char buf[512];
-
const Engine *e;
+
FOR_ALL_ENGINES(e) {
- SetDParam(0, e->index);
- GetString(buf, STR_ENGINE_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (e->name != NULL && strcmp(e->name, name) == 0) return false;
}
return true;
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index 44e3b6bb3..cea7d33ac 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -149,12 +149,9 @@ CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, c
static bool IsUniqueGroupName(const char *name)
{
const Group *g;
- char buf[512];
FOR_ALL_GROUPS(g) {
- SetDParam(0, g->index);
- GetString(buf, STR_GROUP_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (g->name != NULL && strcmp(g->name, name) == 0) return false;
}
return true;
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 0d6ebf143..dadc73a6d 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -205,12 +205,9 @@ CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
static bool IsUniqueCompanyName(const char *name)
{
const Company *c;
- char buf[512];
FOR_ALL_COMPANIES(c) {
- SetDParam(0, c->index);
- GetString(buf, STR_COMPANY_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (c->name != NULL && strcmp(c->name, name) == 0) return false;
}
return true;
@@ -244,12 +241,9 @@ CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
static bool IsUniquePresidentName(const char *name)
{
const Company *c;
- char buf[512];
FOR_ALL_COMPANIES(c) {
- SetDParam(0, c->index);
- GetString(buf, STR_PRESIDENT_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (c->president_name != NULL && strcmp(c->president_name, name) == 0) return false;
}
return true;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index ca641577b..f9d8d2bdd 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2895,12 +2895,9 @@ static void UpdateStationWaiting(Station *st, CargoID type, uint amount)
static bool IsUniqueStationName(const char *name)
{
const Station *st;
- char buf[512];
FOR_ALL_STATIONS(st) {
- SetDParam(0, st->index);
- GetString(buf, STR_STATION, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (st->name != NULL && strcmp(st->name, name) == 0) return false;
}
return true;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 4b9de5618..1546f8cb3 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2103,12 +2103,9 @@ void ClearTownHouse(Town *t, TileIndex tile)
static bool IsUniqueTownName(const char *name)
{
const Town *t;
- char buf[512];
FOR_ALL_TOWNS(t) {
- SetDParam(0, t->index);
- GetString(buf, STR_TOWN, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (t->name != NULL && strcmp(t->name, name) == 0) return false;
}
return true;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 591bfc8e9..37fd1dd2a 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1525,32 +1525,9 @@ void VehicleEnterDepot(Vehicle *v)
static bool IsUniqueVehicleName(const char *name)
{
const Vehicle *v;
- char buf[512];
FOR_ALL_VEHICLES(v) {
- switch (v->type) {
- case VEH_TRAIN:
- if (!IsTrainEngine(v)) continue;
- break;
-
- case VEH_ROAD:
- if (!IsRoadVehFront(v)) continue;
- break;
-
- case VEH_AIRCRAFT:
- if (!IsNormalAircraft(v)) continue;
- break;
-
- case VEH_SHIP:
- break;
-
- default:
- continue;
- }
-
- SetDParam(0, v->index);
- GetString(buf, STR_VEHICLE_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (v->name != NULL && strcmp(v->name, name) == 0) return false;
}
return true;
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index 061eca795..6ae6aa6b1 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -336,12 +336,9 @@ CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint
static bool IsUniqueWaypointName(const char *name)
{
const Waypoint *wp;
- char buf[512];
FOR_ALL_WAYPOINTS(wp) {
- SetDParam(0, wp->index);
- GetString(buf, STR_WAYPOINT_RAW, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
+ if (wp->name != NULL && strcmp(wp->name, name) == 0) return false;
}
return true;