mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-08 15:30:00 +00:00
Fix: Support more than 256 stations/waypoints/roadstops per class. (#10793)
It was already possible to define more than 256 per class, but not possible to use them as the index used in GUI and passed through commands was limited to a byte.
This commit is contained in:
parent
a05ae2497f
commit
882f06bf14
@ -53,8 +53,8 @@
|
|||||||
static RailType _cur_railtype; ///< Rail type of the current build-rail toolbar.
|
static RailType _cur_railtype; ///< Rail type of the current build-rail toolbar.
|
||||||
static bool _remove_button_clicked; ///< Flag whether 'remove' toggle-button is currently enabled
|
static bool _remove_button_clicked; ///< Flag whether 'remove' toggle-button is currently enabled
|
||||||
static DiagDirection _build_depot_direction; ///< Currently selected depot direction
|
static DiagDirection _build_depot_direction; ///< Currently selected depot direction
|
||||||
static byte _waypoint_count = 1; ///< Number of waypoint types
|
static uint16_t _waypoint_count = 1; ///< Number of waypoint types
|
||||||
static byte _cur_waypoint_type; ///< Currently selected waypoint type
|
static uint16_t _cur_waypoint_type; ///< Currently selected waypoint type
|
||||||
static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed
|
static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed
|
||||||
static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
|
static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
|
||||||
static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
|
static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
|
||||||
@ -64,8 +64,8 @@ struct RailStationGUISettings {
|
|||||||
|
|
||||||
bool newstations; ///< Are custom station definitions available?
|
bool newstations; ///< Are custom station definitions available?
|
||||||
StationClassID station_class; ///< Currently selected custom station class (if newstations is \c true )
|
StationClassID station_class; ///< Currently selected custom station class (if newstations is \c true )
|
||||||
byte station_type; ///< %Station type within the currently selected custom station class (if newstations is \c true )
|
uint16_t station_type; ///< %Station type within the currently selected custom station class (if newstations is \c true )
|
||||||
byte station_count; ///< Number of custom stations (if newstations is \c true )
|
uint16_t station_count; ///< Number of custom stations (if newstations is \c true )
|
||||||
};
|
};
|
||||||
static RailStationGUISettings _railstation; ///< Settings of the station builder GUI
|
static RailStationGUISettings _railstation; ///< Settings of the station builder GUI
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ struct BuildRailToolbarWindow : Window {
|
|||||||
TileArea ta(start_tile, end_tile);
|
TileArea ta(start_tile, end_tile);
|
||||||
Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
|
Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
|
||||||
bool adjacent = _ctrl_pressed;
|
bool adjacent = _ctrl_pressed;
|
||||||
byte waypoint_type = _cur_waypoint_type;
|
uint16_t waypoint_type = _cur_waypoint_type;
|
||||||
|
|
||||||
auto proc = [=](bool test, StationID to_join) -> bool {
|
auto proc = [=](bool test, StationID to_join) -> bool {
|
||||||
if (test) {
|
if (test) {
|
||||||
@ -1290,7 +1290,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_BRAS_IMAGE: {
|
case WID_BRAS_IMAGE: {
|
||||||
byte type = GB(widget, 16, 16);
|
uint16_t type = GB(widget, 16, 16);
|
||||||
assert(type < _railstation.station_count);
|
assert(type < _railstation.station_count);
|
||||||
/* Check station availability callback */
|
/* Check station availability callback */
|
||||||
const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
|
const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
|
||||||
@ -1478,7 +1478,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_BRAS_IMAGE: {
|
case WID_BRAS_IMAGE: {
|
||||||
int y = GB(widget, 16, 16);
|
uint16_t y = GB(widget, 16, 16);
|
||||||
if (y >= _railstation.station_count) return;
|
if (y >= _railstation.station_count) return;
|
||||||
|
|
||||||
/* Check station availability callback */
|
/* Check station availability callback */
|
||||||
@ -2041,7 +2041,7 @@ struct BuildRailWaypointWindow : PickerWindowBase {
|
|||||||
{
|
{
|
||||||
switch (GB(widget, 0, 16)) {
|
switch (GB(widget, 0, 16)) {
|
||||||
case WID_BRW_WAYPOINT: {
|
case WID_BRW_WAYPOINT: {
|
||||||
byte type = GB(widget, 16, 16);
|
uint16_t type = GB(widget, 16, 16);
|
||||||
const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
|
const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
|
||||||
|
|
||||||
DrawPixelInfo tmp_dpi;
|
DrawPixelInfo tmp_dpi;
|
||||||
@ -2063,7 +2063,7 @@ struct BuildRailWaypointWindow : PickerWindowBase {
|
|||||||
{
|
{
|
||||||
switch (GB(widget, 0, 16)) {
|
switch (GB(widget, 0, 16)) {
|
||||||
case WID_BRW_WAYPOINT: {
|
case WID_BRW_WAYPOINT: {
|
||||||
byte type = GB(widget, 16, 16);
|
uint16_t type = GB(widget, 16, 16);
|
||||||
this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
|
this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
|
||||||
|
|
||||||
/* Check station availability callback */
|
/* Check station availability callback */
|
||||||
|
@ -34,6 +34,6 @@ DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, 0,
|
|||||||
CommandCallback CcPlaySound_CONSTRUCTION_OTHER;
|
CommandCallback CcPlaySound_CONSTRUCTION_OTHER;
|
||||||
CommandCallback CcBuildRoadTunnel;
|
CommandCallback CcBuildRoadTunnel;
|
||||||
void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir);
|
void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir);
|
||||||
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, byte spec_index, StationID, bool);
|
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool);
|
||||||
|
|
||||||
#endif /* ROAD_CMD_H */
|
#endif /* ROAD_CMD_H */
|
||||||
|
@ -66,8 +66,8 @@ struct RoadStopGUISettings {
|
|||||||
DiagDirection orientation;
|
DiagDirection orientation;
|
||||||
|
|
||||||
RoadStopClassID roadstop_class;
|
RoadStopClassID roadstop_class;
|
||||||
byte roadstop_type;
|
uint16_t roadstop_type;
|
||||||
byte roadstop_count;
|
uint16_t roadstop_count;
|
||||||
};
|
};
|
||||||
static RoadStopGUISettings _roadstop_gui_settings;
|
static RoadStopGUISettings _roadstop_gui_settings;
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadTy
|
|||||||
* @see CmdBuildRoadStop
|
* @see CmdBuildRoadStop
|
||||||
*/
|
*/
|
||||||
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through,
|
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through,
|
||||||
DiagDirection dir, RoadType, RoadStopClassID spec_class, byte spec_index, StationID, bool)
|
DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
|
||||||
{
|
{
|
||||||
if (result.Failed()) return;
|
if (result.Failed()) return;
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType
|
|||||||
bool drive_through = ddir >= DIAGDIR_END;
|
bool drive_through = ddir >= DIAGDIR_END;
|
||||||
if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
|
if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
|
||||||
RoadStopClassID spec_class = _roadstop_gui_settings.roadstop_class;
|
RoadStopClassID spec_class = _roadstop_gui_settings.roadstop_class;
|
||||||
byte spec_index = _roadstop_gui_settings.roadstop_type;
|
uint16_t spec_index = _roadstop_gui_settings.roadstop_type;
|
||||||
|
|
||||||
auto proc = [=](bool test, StationID to_join) -> bool {
|
auto proc = [=](bool test, StationID to_join) -> bool {
|
||||||
if (test) {
|
if (test) {
|
||||||
@ -1459,7 +1459,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_BROS_IMAGE: {
|
case WID_BROS_IMAGE: {
|
||||||
byte type = GB(widget, 16, 16);
|
uint16_t type = GB(widget, 16, 16);
|
||||||
assert(type < _roadstop_gui_settings.roadstop_count);
|
assert(type < _roadstop_gui_settings.roadstop_count);
|
||||||
|
|
||||||
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type);
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type);
|
||||||
@ -1555,7 +1555,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_BROS_IMAGE: {
|
case WID_BROS_IMAGE: {
|
||||||
int y = GB(widget, 16, 16);
|
uint16_t y = GB(widget, 16, 16);
|
||||||
if (y >= _roadstop_gui_settings.roadstop_count) return;
|
if (y >= _roadstop_gui_settings.roadstop_count) return;
|
||||||
|
|
||||||
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y);
|
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y);
|
||||||
|
@ -877,7 +877,7 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo
|
|||||||
* @param numtracks Number of platforms.
|
* @param numtracks Number of platforms.
|
||||||
* @return The cost in case of success, or an error code if it failed.
|
* @return The cost in case of success, or an error code if it failed.
|
||||||
*/
|
*/
|
||||||
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
|
static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, byte plat_len, byte numtracks)
|
||||||
{
|
{
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
int allowed_z = -1;
|
int allowed_z = -1;
|
||||||
@ -1261,7 +1261,7 @@ static void RestoreTrainReservation(Train *v)
|
|||||||
* @param numtracks Number of platforms.
|
* @param numtracks Number of platforms.
|
||||||
* @return The cost in case of success, or an error code if it failed.
|
* @return The cost in case of success, or an error code if it failed.
|
||||||
*/
|
*/
|
||||||
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
|
static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, uint16_t spec_index, byte plat_len, byte numtracks)
|
||||||
{
|
{
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
bool length_price_ready = true;
|
bool length_price_ready = true;
|
||||||
@ -1310,7 +1310,7 @@ static CommandCost CalculateRailStationCost(TileArea tile_area, DoCommandFlag fl
|
|||||||
* @param adjacent allow stations directly adjacent to other stations.
|
* @param adjacent allow stations directly adjacent to other stations.
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
|
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||||
{
|
{
|
||||||
/* Does the authority allow this? */
|
/* Does the authority allow this? */
|
||||||
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags);
|
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags);
|
||||||
@ -1917,7 +1917,7 @@ static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags
|
|||||||
* @return The cost of this operation or an error.
|
* @return The cost of this operation or an error.
|
||||||
*/
|
*/
|
||||||
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through,
|
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through,
|
||||||
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
|
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||||
{
|
{
|
||||||
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= ROADSTOP_END) return CMD_ERROR;
|
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= ROADSTOP_END) return CMD_ERROR;
|
||||||
bool reuse = (station_to_join != NEW_STATION);
|
bool reuse = (station_to_join != NEW_STATION);
|
||||||
|
@ -21,9 +21,9 @@ extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint
|
|||||||
|
|
||||||
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent);
|
CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent);
|
||||||
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent);
|
CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent);
|
||||||
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent);
|
CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||||
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||||
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent);
|
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||||
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road);
|
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road);
|
||||||
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text);
|
CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text);
|
||||||
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id);
|
CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id);
|
||||||
|
@ -172,7 +172,7 @@ extern CommandCost CanExpandRailStation(const BaseStation *st, TileArea &new_ta,
|
|||||||
* @param adjacent allow waypoints directly adjacent to other waypoints.
|
* @param adjacent allow waypoints directly adjacent to other waypoints.
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, byte width, byte height, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
|
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, byte width, byte height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||||
{
|
{
|
||||||
if (!IsValidAxis(axis)) return CMD_ERROR;
|
if (!IsValidAxis(axis)) return CMD_ERROR;
|
||||||
/* Check if the given station class is valid */
|
/* Check if the given station class is valid */
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
enum StationClassID : byte;
|
enum StationClassID : byte;
|
||||||
|
|
||||||
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, byte width, byte height, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent);
|
CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, byte width, byte height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent);
|
||||||
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);
|
||||||
CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile);
|
CommandCost CmdBuildBuoy(DoCommandFlag flags, TileIndex tile);
|
||||||
CommandCost CmdRenameWaypoint(DoCommandFlag flags, StationID waypoint_id, const std::string &text);
|
CommandCost CmdRenameWaypoint(DoCommandFlag flags, StationID waypoint_id, const std::string &text);
|
||||||
|
Loading…
Reference in New Issue
Block a user