Changeset - r16674:a2c7f634c52e
[Not reviewed]
master
0 6 0
rubidium - 14 years ago 2010-12-05 22:25:36
rubidium@openttd.org
(svn r21415) -Codechange: limit station/waypoint name by amount of characters, not bytes
6 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_basestation.cpp
Show inline comments
 
@@ -35,13 +35,13 @@
 
}
 

	
 
/* static */ bool AIBaseStation::SetName(StationID station_id, const char *name)
 
{
 
	EnforcePrecondition(false, IsValidBaseStation(station_id));
 
	EnforcePrecondition(false, !::StrEmpty(name));
 
	EnforcePreconditionCustomError(false, ::strlen(name) < MAX_LENGTH_STATION_NAME_BYTES, AIError::ERR_PRECONDITION_STRING_TOO_LONG);
 
	EnforcePreconditionCustomError(false, ::Utf8StringLength(name) < MAX_LENGTH_STATION_NAME_CHARS, AIError::ERR_PRECONDITION_STRING_TOO_LONG);
 

	
 
	return AIObject::DoCommand(0, station_id, 0, ::Station::IsValidID(station_id) ? CMD_RENAME_STATION : CMD_RENAME_WAYPOINT, name);
 
}
 

	
 
/* static */ TileIndex AIBaseStation::GetLocation(StationID station_id)
 
{
src/station_cmd.cpp
Show inline comments
 
@@ -3253,13 +3253,13 @@ CommandCost CmdRenameStation(TileIndex t
 
	CommandCost ret = CheckOwnership(st->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	bool reset = StrEmpty(text);
 

	
 
	if (!reset) {
 
		if (strlen(text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR;
 
		if (Utf8StringLength(text) >= MAX_LENGTH_STATION_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueStationName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		free(st->name);
 
		st->name = reset ? NULL : strdup(text);
src/station_gui.cpp
Show inline comments
 
@@ -1182,14 +1182,14 @@ struct StationViewWindow : public Window
 
				this->ReInit(0, height_change * FONT_HEIGHT_NORMAL);
 
				break;
 
			}
 

	
 
			case SVW_RENAME:
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_STATION_NAME, STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS,
 
						this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
				ShowQueryString(STR_STATION_NAME, STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_CHARS, MAX_LENGTH_STATION_NAME_PIXELS,
 
						this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
 
				break;
 

	
 
			case SVW_TRAINS:   // Show list of scheduled trains to this station
 
			case SVW_ROADVEHS: // Show list of scheduled road-vehicles to this station
 
			case SVW_SHIPS:    // Show list of scheduled ships to this station
 
			case SVW_PLANES:   // Show list of scheduled aircraft to this station
src/station_type.h
Show inline comments
 
@@ -83,13 +83,13 @@ enum CatchmentArea {
 

	
 
	CA_UNMODIFIED      =  4, ///< Catchment for all stations with "modified catchment" disabled
 

	
 
	MAX_CATCHMENT      = 10, ///< Maximum catchment for airports with "modified catchment" enabled
 
};
 

	
 
static const uint MAX_LENGTH_STATION_NAME_BYTES  =  31; ///< The maximum length of a station name in bytes including '\0'
 
static const uint MAX_LENGTH_STATION_NAME_CHARS  =  31; ///< The maximum length of a station name in characters including '\0'
 
static const uint MAX_LENGTH_STATION_NAME_PIXELS = 180; ///< The maximum length of a station name in pixels
 

	
 
/** List of stations */
 
typedef SmallVector<Station *, 2> StationList;
 

	
 
/**
src/waypoint_cmd.cpp
Show inline comments
 
@@ -397,13 +397,13 @@ CommandCost CmdRenameWaypoint(TileIndex 
 
		if (ret.Failed()) return ret;
 
	}
 

	
 
	bool reset = StrEmpty(text);
 

	
 
	if (!reset) {
 
		if (strlen(text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR;
 
		if (Utf8StringLength(text) >= MAX_LENGTH_STATION_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueWaypointName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		free(wp->name);
 
		wp->name = reset ? NULL : strdup(text);
src/waypoint_gui.cpp
Show inline comments
 
@@ -98,13 +98,13 @@ public:
 
					ScrollMainWindowToTile(this->GetCenterTile());
 
				}
 
				break;
 

	
 
			case WAYPVW_RENAME: // rename
 
				SetDParam(0, this->wp->index);
 
				ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
				ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_STATION_NAME_CHARS, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
 
				break;
 

	
 
			case WAYPVW_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
 
				ShowVehicleListWindow(this->owner, this->vt, this->wp->index);
 
				break;
 
		}
0 comments (0 inline, 0 general)