mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r14063) -Codechange: replace some "magic" constants with enumified constants.
This commit is contained in:
parent
08e7da71f5
commit
97c184f8f8
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -145,7 +145,7 @@ void ShowRenameWaypointWindow(const Waypoint *wp)
|
||||
_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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +224,7 @@ static bool IsUniqueCompanyName(const char *name)
|
||||
*/
|
||||
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 char *name)
|
||||
*/
|
||||
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);
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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;
|
||||
|
@ -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: {
|
||||
|
@ -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 */
|
||||
|
@ -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 : QueryStringBaseWindow, SignList {
|
||||
*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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user