Add GUI/command support for >255 station types per station class
This commit is contained in:
@@ -50,7 +50,7 @@ CommandProc CmdLandscapeClear;
|
|||||||
|
|
||||||
CommandProc CmdBuildBridge;
|
CommandProc CmdBuildBridge;
|
||||||
|
|
||||||
CommandProc CmdBuildRailStation;
|
CommandProcEx CmdBuildRailStation;
|
||||||
CommandProc CmdRemoveFromRailStation;
|
CommandProc CmdRemoveFromRailStation;
|
||||||
CommandProc CmdConvertRail;
|
CommandProc CmdConvertRail;
|
||||||
|
|
||||||
|
@@ -72,8 +72,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 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 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
|
||||||
|
|
||||||
@@ -212,13 +212,15 @@ static void PlaceRail_Station(TileIndex tile)
|
|||||||
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
|
||||||
} else {
|
} else {
|
||||||
uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
|
uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
|
||||||
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
|
uint32 p2 = _railstation.station_class | INVALID_STATION << 16;
|
||||||
|
uint64 p3 = _railstation.station_type;
|
||||||
|
|
||||||
int w = _settings_client.gui.station_numtracks;
|
int w = _settings_client.gui.station_numtracks;
|
||||||
int h = _settings_client.gui.station_platlength;
|
int h = _settings_client.gui.station_platlength;
|
||||||
if (!_railstation.orientation) Swap(w, h);
|
if (!_railstation.orientation) Swap(w, h);
|
||||||
|
|
||||||
CommandContainer cmdcont = NewCommandContainerBasic(tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation);
|
CommandContainer cmdcont = NewCommandContainerBasic(tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation);
|
||||||
|
cmdcont.p3 = p3;
|
||||||
ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
|
ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1028,9 +1030,11 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
|
|||||||
if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
|
if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
|
||||||
|
|
||||||
uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
|
uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
|
||||||
uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
|
uint32 p2 = _railstation.station_class | INVALID_STATION << 16;
|
||||||
|
uint64 p3 = _railstation.station_type;
|
||||||
|
|
||||||
CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation);
|
CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation);
|
||||||
|
cmdcont.p3 = p3;
|
||||||
ShowSelectStationIfNeeded(cmdcont, ta);
|
ShowSelectStationIfNeeded(cmdcont, ta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -198,7 +198,7 @@
|
|||||||
DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
|
DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
|
||||||
} else {
|
} else {
|
||||||
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
|
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
|
||||||
if (ScriptObject::DoCommand(tile, p1, p2 | spec->cls_id | index << 8, CMD_BUILD_RAIL_STATION)) return true;
|
if (ScriptObject::DoCommandEx(tile, p1, p2 | spec->cls_id, index, CMD_BUILD_RAIL_STATION)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1457,12 +1457,13 @@ static void RestoreTrainReservation(Train *v)
|
|||||||
* - p1 = (bit 24) - allow stations directly adjacent to other stations.
|
* - p1 = (bit 24) - allow stations directly adjacent to other stations.
|
||||||
* @param p2 various bitstuffed elements
|
* @param p2 various bitstuffed elements
|
||||||
* - p2 = (bit 0- 7) - custom station class
|
* - p2 = (bit 0- 7) - custom station class
|
||||||
* - p2 = (bit 8-15) - custom station id
|
|
||||||
* - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)
|
* - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)
|
||||||
|
* @param p3 various bitstuffed elements
|
||||||
|
* - p3 = (bit 0-15) - custom station id
|
||||||
* @param text unused
|
* @param text unused
|
||||||
* @return the cost of this operation or an error
|
* @return the cost of this operation or an error
|
||||||
*/
|
*/
|
||||||
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data)
|
||||||
{
|
{
|
||||||
/* Unpack parameters */
|
/* Unpack parameters */
|
||||||
RailType rt = Extract<RailType, 0, 6>(p1);
|
RailType rt = Extract<RailType, 0, 6>(p1);
|
||||||
@@ -1472,7 +1473,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
|
|||||||
bool adjacent = HasBit(p1, 24);
|
bool adjacent = HasBit(p1, 24);
|
||||||
|
|
||||||
StationClassID spec_class = Extract<StationClassID, 0, 8>(p2);
|
StationClassID spec_class = Extract<StationClassID, 0, 8>(p2);
|
||||||
byte spec_index = GB(p2, 8, 8);
|
byte spec_index = GB(p3, 0, 16);
|
||||||
StationID station_to_join = GB(p2, 16, 16);
|
StationID station_to_join = GB(p2, 16, 16);
|
||||||
|
|
||||||
/* Does the authority allow this? */
|
/* Does the authority allow this? */
|
||||||
|
Reference in New Issue
Block a user