Changeset - r10656:1e2ea0b81776
[Not reviewed]
master
0 7 0
smatz - 16 years ago 2009-01-10 15:54:07
smatz@openttd.org
(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).
7 files changed with 9 insertions and 53 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -493,13 +493,10 @@ void EnginesMonthlyLoop()
 

	
 
static bool IsUniqueEngineName(const char *name)
 
{
 
	char buf[512];
 
	const Engine *e;
 

	
 
	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;
src/group_cmd.cpp
Show inline comments
 
@@ -149,12 +149,9 @@ CommandCost CmdDeleteGroup(TileIndex til
 
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;
src/misc_cmd.cpp
Show inline comments
 
@@ -205,12 +205,9 @@ CommandCost CmdDecreaseLoan(TileIndex ti
 
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 t
 
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;
src/station_cmd.cpp
Show inline comments
 
@@ -2895,12 +2895,9 @@ static void UpdateStationWaiting(Station
 
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;
src/town_cmd.cpp
Show inline comments
 
@@ -2103,12 +2103,9 @@ void ClearTownHouse(Town *t, TileIndex t
 
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;
src/vehicle.cpp
Show inline comments
 
@@ -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;
src/waypoint.cpp
Show inline comments
 
@@ -336,12 +336,9 @@ CommandCost CmdRemoveTrainWaypoint(TileI
 
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;
0 comments (0 inline, 0 general)