Changeset - r9914:213bce2115cb
[Not reviewed]
master
0 8 0
rubidium - 16 years ago 2008-08-13 06:22:04
rubidium@openttd.org
(svn r14064) -Fix [FS#1752]: check for the length of strings (in bytes) in the command. Checking for the length in pixels is impossible because that differs per client.
8 files changed with 16 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -487,7 +487,8 @@ static bool IsUniqueEngineName(const cha
 
 */
 
CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsEngineIndex(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 
	if (!IsEngineIndex(p1)) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_ENGINE_NAME_BYTES) return CMD_ERROR;
 

	
 
	if (!IsUniqueEngineName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 

	
src/group_cmd.cpp
Show inline comments
 
@@ -170,7 +170,8 @@ static bool IsUniqueGroupName(const char
 
 */
 
CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidGroupID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_GROUP_NAME_BYTES) return CMD_ERROR;
 

	
 
	Group *g = GetGroup(p1);
 
	if (g->owner != _current_player) return CMD_ERROR;
src/players.cpp
Show inline comments
 
@@ -366,8 +366,7 @@ verify_name:;
 
		}
 

	
 
		GetString(buffer, str, lastof(buffer));
 
		if (strlen(buffer) >= 32 || GetStringBoundingBox(buffer).width >= 150)
 
			goto bad_town_name;
 
		if (strlen(buffer) >= MAX_LENGTH_COMPANY_NAME_BYTES) goto bad_town_name;
 

	
 
set_name:;
 
		p->name_1 = str;
src/signs.cpp
Show inline comments
 
@@ -133,6 +133,8 @@ CommandCost CmdRenameSign(TileIndex tile
 
	/* If _cmd_text 0 means the new text for the sign is non-empty.
 
	 * So rename the sign. If it is empty, it has no name, so delete it */
 
	if (!StrEmpty(_cmd_text)) {
 
		if (strlen(_cmd_text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			Sign *si = GetSign(p1);
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -2809,7 +2809,9 @@ static bool IsUniqueStationName(const ch
 
 */
 
CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidStationID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 
	if (!IsValidStationID(p1))
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR;
 

	
 
	Station *st = GetStation(p1);
 

	
 
	if (!CheckOwnership(st->owner)) return CMD_ERROR;
src/town_cmd.cpp
Show inline comments
 
@@ -1394,7 +1394,7 @@ restart:
 
		}
 

	
 
		/* Check size and width */
 
		if (strlen(buf1) >= 31 || GetStringBoundingBox(buf1).width > 130) continue;
 
		if (strlen(buf1) >= MAX_LENGTH_TOWN_NAME_BYTES || GetStringBoundingBox(buf1).width > MAX_LENGTH_TOWN_NAME_PIXELS) continue;
 

	
 
		FOR_ALL_TOWNS(t2) {
 
			/* We can't just compare the numbers since
 
@@ -2093,7 +2093,8 @@ static bool IsUniqueTownName(const char 
 
 */
 
CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidTownID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 
	if (!IsValidTownID(p1)) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_TOWN_NAME_BYTES) return CMD_ERROR;
 

	
 
	if (!IsUniqueTownName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 

	
src/vehicle.cpp
Show inline comments
 
@@ -1502,7 +1502,8 @@ static bool IsUniqueVehicleName(const ch
 
 */
 
CommandCost CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_VEHICLE_NAME_BYTES) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 

	
src/waypoint.cpp
Show inline comments
 
@@ -389,6 +389,7 @@ CommandCost CmdRenameWaypoint(TileIndex 
 
	if (!CheckTileOwnership(wp->xy)) return CMD_ERROR;
 

	
 
	if (!StrEmpty(_cmd_text)) {
 
		if (strlen(_cmd_text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR;
 
		if (!IsUniqueWaypointName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
 

	
 
		if (flags & DC_EXEC) {
0 comments (0 inline, 0 general)