Changeset - r9913:5ef437117969
[Not reviewed]
master
0 19 0
rubidium - 16 years ago 2008-08-13 06:05:01
rubidium@openttd.org
(svn r14063) -Codechange: replace some "magic" constants with enumified constants.
19 files changed with 48 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1091,7 +1091,7 @@ struct BuildVehicleWindow : Window {
 
						case VEH_AIRCRAFT: str = STR_A039_RENAME_AIRCRAFT_TYPE;      break;
 
					}
 
					SetDParam(0, sel_eng);
 
					ShowQueryString(STR_ENGINE_NAME, str, 31, 160, this, CS_ALPHANUMERAL);
 
					ShowQueryString(STR_ENGINE_NAME, str, MAX_LENGTH_ENGINE_NAME_BYTES, MAX_LENGTH_ENGINE_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				}
 
				break;
 
			}
src/engine_type.h
Show inline comments
 
@@ -140,7 +140,9 @@ enum {
 
};
 

	
 
enum {
 
	NUM_VEHICLE_TYPES = 6
 
	NUM_VEHICLE_TYPES             =   6,
 
	MAX_LENGTH_ENGINE_NAME_BYTES  =  31, ///< The maximum length of an engine name in bytes including '\0'
 
	MAX_LENGTH_ENGINE_NAME_PIXELS = 160, ///< The maximum length of an engine name in pixels
 
};
 

	
 
static const EngineID INVALID_ENGINE = 0xFFFF;
src/group_gui.cpp
Show inline comments
 
@@ -554,7 +554,7 @@ public:
 
				const Group *g = GetGroup(this->group_sel);
 

	
 
				SetDParam(0, g->index);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, 31, 150, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
			} break;
 

	
 

	
src/group_type.h
Show inline comments
 
@@ -11,6 +11,9 @@ enum {
 
	ALL_GROUP     = 0xFFFD,
 
	DEFAULT_GROUP = 0xFFFE, ///< ungrouped vehicles are in this group.
 
	INVALID_GROUP = 0xFFFF,
 

	
 
	MAX_LENGTH_GROUP_NAME_BYTES  =  31, ///< The maximum length of a group name in bytes including '\0'
 
	MAX_LENGTH_GROUP_NAME_PIXELS = 150, ///< The maximum length of a group name in pixels
 
};
 

	
 
struct Group;
src/main_gui.cpp
Show inline comments
 
@@ -145,7 +145,7 @@ void ShowRenameWaypointWindow(const Wayp
 
	_rename_id = id;
 
	_rename_what = 1;
 
	SetDParam(0, id);
 
	ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL);
 
	ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, NULL, CS_ALPHANUMERAL);
 
}
 

	
 

	
src/misc_cmd.cpp
Show inline comments
 
@@ -224,7 +224,7 @@ static bool IsUniqueCompanyName(const ch
 
 */
 
CommandCost CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) > MAX_LENGTH_COMPANY_NAME) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_COMPANY_NAME_BYTES) return CMD_ERROR;
 

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

	
 
@@ -260,7 +260,7 @@ static bool IsUniquePresidentName(const 
 
 */
 
CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) > MAX_LENGTH_PRESIDENT_NAME) return CMD_ERROR;
 
	if (StrEmpty(_cmd_text) || strlen(_cmd_text) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) return CMD_ERROR;
 

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

	
src/network/core/config.h
Show inline comments
 
@@ -24,7 +24,7 @@ enum {
 
	NETWORK_MASTER_SERVER_VERSION =    1, ///< What version of master-server-protocol do we use?
 

	
 
	NETWORK_NAME_LENGTH           =   80, ///< The maximum length of the server name and map name, in bytes including '\0'
 
	NETWORK_COMPANY_NAME_LENGTH   =   32, ///< The maximum length of the company name, in bytes including '\0'
 
	NETWORK_COMPANY_NAME_LENGTH   =   31, ///< The maximum length of the company name, in bytes including '\0'
 
	NETWORK_HOSTNAME_LENGTH       =   80, ///< The maximum length of the host name, in bytes including '\0'
 
	NETWORK_UNIQUE_ID_LENGTH      =   33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
 
	NETWORK_REVISION_LENGTH       =   15, ///< The maximum length of the revision, in bytes including '\0'
src/network/network.cpp
Show inline comments
 
@@ -72,7 +72,7 @@ uint8 _network_advertise_retries;
 

	
 
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
 
assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
 
assert_compile((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME + 1);
 
assert_compile((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME_BYTES);
 

	
 
// global variables (declared in network_data.h)
 
CommandPacket *_local_command_queue;
src/player_gui.cpp
Show inline comments
 
@@ -1222,7 +1222,7 @@ struct PlayerCompanyWindow : Window
 

	
 
		/* "xxx (Manager)" */
 
		SetDParam(0, p->index);
 
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94);
 
		DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, MAX_LENGTH_PRESIDENT_NAME_PIXELS);
 

	
 
		/* "Inaugurated:" */
 
		SetDParam(0, p->inaugurated_year);
 
@@ -1257,13 +1257,13 @@ struct PlayerCompanyWindow : Window
 
			case PCW_WIDGET_PRESIDENT_NAME:
 
				this->query_widget = PCW_WIDGET_PRESIDENT_NAME;
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME, 94, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_PLAYER_NAME, STR_700B_PRESIDENT_S_NAME, MAX_LENGTH_PRESIDENT_NAME_BYTES, MAX_LENGTH_PRESIDENT_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				break;
 

	
 
			case PCW_WIDGET_COMPANY_NAME:
 
				this->query_widget = PCW_WIDGET_COMPANY_NAME;
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME, 150, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_COMPANY_NAME, STR_700A_COMPANY_NAME, MAX_LENGTH_COMPANY_NAME_BYTES, MAX_LENGTH_COMPANY_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				break;
 

	
 
			case PCW_WIDGET_BUILD_VIEW_HQ: {
src/player_type.h
Show inline comments
 
@@ -31,8 +31,10 @@ enum Owner {
 
DECLARE_POSTFIX_INCREMENT(Owner);
 

	
 
enum {
 
	MAX_LENGTH_PRESIDENT_NAME = 31, ///< The maximum length for a president's name
 
	MAX_LENGTH_COMPANY_NAME   = 31, ///< The maximum length for a company's name
 
	MAX_LENGTH_PRESIDENT_NAME_BYTES  =  31, ///< The maximum length of a president name in bytes including '\0'
 
	MAX_LENGTH_PRESIDENT_NAME_PIXELS =  94, ///< The maximum length of a president name in pixels
 
	MAX_LENGTH_COMPANY_NAME_BYTES    =  31, ///< The maximum length of a company name in bytes including '\0'
 
	MAX_LENGTH_COMPANY_NAME_PIXELS   = 150, ///< The maximum length of a company name in pixels
 
};
 

	
 
/** Define basic enum properties */
src/signs_gui.cpp
Show inline comments
 
@@ -188,7 +188,7 @@ enum QueryEditSignWidgets {
 
struct SignWindow : QueryStringBaseWindow, SignList {
 
	SignID cur_sign;
 

	
 
	SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(31, desc)
 
	SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_BYTES, desc)
 
	{
 
		SetBit(_no_scroll, SCROLL_EDIT);
 
		this->caption = STR_280B_EDIT_SIGN_TEXT;
 
@@ -218,7 +218,7 @@ struct SignWindow : QueryStringBaseWindo
 
		*last_of = '\0';
 

	
 
		this->cur_sign = si->index;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 255);
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_LENGTH_SIGN_NAME_PIXELS);
 

	
 
		this->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
 
	}
src/signs_type.h
Show inline comments
 
@@ -10,6 +10,9 @@ struct Sign;
 

	
 
enum {
 
	INVALID_SIGN = 0xFFFF,
 

	
 
	MAX_LENGTH_SIGN_NAME_BYTES  =  31, ///< The maximum length of a sign name in bytes including '\0'
 
	MAX_LENGTH_SIGN_NAME_PIXELS = 255, ///< The maximum length of a sign name in pixels
 
};
 

	
 
#endif /* SIGNS_TYPE_H */
src/station_gui.cpp
Show inline comments
 
@@ -911,7 +911,7 @@ struct StationViewWindow : public Window
 

	
 
			case SVW_RENAME:
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				break;
 

	
 
			case SVW_TRAINS: { // Show a list of scheduled trains to this station
src/station_type.h
Show inline comments
 
@@ -62,4 +62,9 @@ enum CatchmentArea {
 
	MAX_CATCHMENT      = 10, ///< Airports have a catchment up to this number.
 
};
 

	
 
enum {
 
	MAX_LENGTH_STATION_NAME_BYTES  =  31, ///< The maximum length of a station name in bytes including '\0'
 
	MAX_LENGTH_STATION_NAME_PIXELS = 180, ///< The maximum length of a station name in pixels
 
};
 

	
 
#endif /* STATION_TYPE_H */
src/town_gui.cpp
Show inline comments
 
@@ -370,7 +370,7 @@ public:
 

	
 
			case TVW_CHANGENAME: /* rename */
 
				SetDParam(0, this->window_number);
 
				ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, 31, 130, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_TOWN, STR_2007_RENAME_TOWN, MAX_LENGTH_TOWN_NAME_BYTES, MAX_LENGTH_TOWN_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
				break;
 

	
 
			case TVW_EXPAND: /* expand town - only available on Scenario editor */
src/town_type.h
Show inline comments
 
@@ -81,4 +81,9 @@ enum TownLayout {
 
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
 
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
 

	
 
enum {
 
	MAX_LENGTH_TOWN_NAME_BYTES  =  31, ///< The maximum length of a town name in bytes including '\0'
 
	MAX_LENGTH_TOWN_NAME_PIXELS = 130, ///< The maximum length of a town name in pixels
 
};
 

	
 
#endif /* TOWN_TYPE_H */
src/vehicle_gui.cpp
Show inline comments
 
@@ -1475,7 +1475,7 @@ struct VehicleDetailsWindow : Window {
 
			case VLD_WIDGET_RENAME_VEHICLE: {// rename
 
				const Vehicle *v = GetVehicle(this->window_number);
 
				SetDParam(0, v->index);
 
				ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], 31, 150, this, CS_ALPHANUMERAL);
 
				ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], MAX_LENGTH_VEHICLE_NAME_BYTES, MAX_LENGTH_VEHICLE_NAME_PIXELS, this, CS_ALPHANUMERAL);
 
			} break;
 

	
 
			case VLD_WIDGET_INCREASE_SERVICING_INTERVAL:   // increase int
src/vehicle_type.h
Show inline comments
 
@@ -56,4 +56,9 @@ enum DepotCommand {
 
	DEPOT_COMMAND_MASK  = 0xF,
 
};
 

	
 
enum {
 
	MAX_LENGTH_VEHICLE_NAME_BYTES  =  31, ///< The maximum length of a vehicle name in bytes including '\0'
 
	MAX_LENGTH_VEHICLE_NAME_PIXELS = 150, ///< The maximum length of a vehicle name in pixels
 
};
 

	
 
#endif /* VEHICLE_TYPE_H */
src/waypoint_type.h
Show inline comments
 
@@ -8,4 +8,9 @@
 
typedef uint16 WaypointID;
 
struct Waypoint;
 

	
 
enum {
 
	MAX_LENGTH_WAYPOINT_NAME_BYTES  =  31, ///< The maximum length of a waypoint name in bytes including '\0'
 
	MAX_LENGTH_WAYPOINT_NAME_PIXELS = 180, ///< The maximum length of a waypoint name in pixels
 
};
 

	
 
#endif /* WAYPOINT_TYPE_H */
0 comments (0 inline, 0 general)