|
|
|
@ -280,7 +280,7 @@ TownScopeResolver *StationResolverObject::GetTown()
|
|
|
|
|
case 0x46:
|
|
|
|
|
case 0x47:
|
|
|
|
|
case 0x49: return 0x2110000; // Platforms, tracks & position
|
|
|
|
|
case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
|
|
|
|
|
case 0x42: return GetReverseRailTypeTranslation (this->rt, this->statspec->grf_prop.grffile) << 8; // Rail type
|
|
|
|
|
case 0x43: return GetCompanyInfo(_current_company); // Station owner
|
|
|
|
|
case 0x44: return 2; // PBS status
|
|
|
|
|
case 0x67: // Land info of nearby tile
|
|
|
|
@ -534,14 +534,15 @@ uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable,
|
|
|
|
|
* @param statspec Station (type) specification.
|
|
|
|
|
* @param st Instance of the station.
|
|
|
|
|
* @param tile %Tile of the station.
|
|
|
|
|
* @param rt %RailType of the station (unbuilt stations only).
|
|
|
|
|
* @param callback Callback ID.
|
|
|
|
|
* @param callback_param1 First parameter (var 10) of the callback.
|
|
|
|
|
* @param callback_param2 Second parameter (var 18) of the callback.
|
|
|
|
|
*/
|
|
|
|
|
StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
|
|
|
|
|
StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt,
|
|
|
|
|
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
|
|
|
|
|
: ResolverObject(statspec->grf_prop.grffile, callback, callback_param1, callback_param2),
|
|
|
|
|
station_scope(*this, statspec, st, tile), town_scope(NULL)
|
|
|
|
|
station_scope(*this, statspec, st, tile, rt), town_scope(NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Invalidate all cached vars */
|
|
|
|
|
_svc.valid = 0;
|
|
|
|
@ -583,12 +584,13 @@ StationResolverObject::~StationResolverObject()
|
|
|
|
|
* @param statspec Station spec
|
|
|
|
|
* @param st Station (NULL in GUI)
|
|
|
|
|
* @param tile Station tile being drawn (INVALID_TILE in GUI)
|
|
|
|
|
* @param rt %RailType of the station (unbuilt stations only).
|
|
|
|
|
* @param var10 Value to put in variable 10; normally 0; 1 when resolving the groundsprite and SSF_SEPARATE_GROUND is set.
|
|
|
|
|
* @return First sprite of the Action 1 spriteset to use, minus an offset of 0x42D to accommodate for weird NewGRF specs.
|
|
|
|
|
*/
|
|
|
|
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
|
|
|
|
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt, uint32 var10)
|
|
|
|
|
{
|
|
|
|
|
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, var10);
|
|
|
|
|
StationResolverObject object(statspec, st, tile, rt, CBID_NO_CALLBACK, var10);
|
|
|
|
|
const SpriteGroup *group = object.Resolve();
|
|
|
|
|
if (group == NULL || group->type != SGT_RESULT) return 0;
|
|
|
|
|
return group->GetResult() - 0x42D;
|
|
|
|
@ -606,7 +608,7 @@ SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st
|
|
|
|
|
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
|
|
|
|
|
{
|
|
|
|
|
/* callback_param1 == 2 means we are resolving the foundation sprites. */
|
|
|
|
|
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, 2, layout | (edge_info << 16));
|
|
|
|
|
StationResolverObject object(statspec, st, tile, INVALID_RAILTYPE, CBID_NO_CALLBACK, 2, layout | (edge_info << 16));
|
|
|
|
|
|
|
|
|
|
const SpriteGroup *group = object.Resolve();
|
|
|
|
|
if (group == NULL || group->type != SGT_RESULT) return 0;
|
|
|
|
@ -616,9 +618,9 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile)
|
|
|
|
|
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt)
|
|
|
|
|
{
|
|
|
|
|
StationResolverObject object(statspec, st, tile, callback, param1, param2);
|
|
|
|
|
StationResolverObject object(statspec, st, tile, rt, callback, param1, param2);
|
|
|
|
|
return object.ResolveCallback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -632,12 +634,12 @@ uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, con
|
|
|
|
|
* @param numtracks Number of platforms.
|
|
|
|
|
* @return Succeeded or failed command.
|
|
|
|
|
*/
|
|
|
|
|
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
|
|
|
|
|
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, RailType rt, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
|
|
|
|
|
{
|
|
|
|
|
TileIndexDiff diff = cur_tile - north_tile;
|
|
|
|
|
Slope slope = GetTileSlope(cur_tile);
|
|
|
|
|
|
|
|
|
|
StationResolverObject object(statspec, NULL, cur_tile, CBID_STATION_LAND_SLOPE_CHECK,
|
|
|
|
|
StationResolverObject object(statspec, NULL, cur_tile, rt, CBID_STATION_LAND_SLOPE_CHECK,
|
|
|
|
|
(slope << 4) | (slope ^ (axis == AXIS_Y && HasBit(slope, CORNER_W) != HasBit(slope, CORNER_E) ? SLOPE_EW : 0)),
|
|
|
|
|
(numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff)));
|
|
|
|
|
object.station_scope.axis = axis;
|
|
|
|
@ -771,7 +773,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
|
|
|
|
if (statspec == NULL) return false;
|
|
|
|
|
|
|
|
|
|
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
|
|
|
|
|
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE);
|
|
|
|
|
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE, railtype);
|
|
|
|
|
if (callback != CALLBACK_FAILED) tile = callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -797,7 +799,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
|
|
|
|
uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
|
|
|
|
|
uint8 var10;
|
|
|
|
|
FOR_EACH_SET_BIT(var10, var10_values) {
|
|
|
|
|
uint32 var10_relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, var10);
|
|
|
|
|
uint32 var10_relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, railtype, var10);
|
|
|
|
|
layout->ProcessRegisters(var10, var10_relocation, separate_ground);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -806,9 +808,9 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
|
|
|
|
total_offset = 0;
|
|
|
|
|
} else {
|
|
|
|
|
/* Simple sprite layout */
|
|
|
|
|
ground_relocation = relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, 0);
|
|
|
|
|
ground_relocation = relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, railtype, 0);
|
|
|
|
|
if (HasBit(sprites->ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
|
|
|
|
|
ground_relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, 1);
|
|
|
|
|
ground_relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE, railtype, 1);
|
|
|
|
|
}
|
|
|
|
|
ground_relocation += rti->fallback_railtype;
|
|
|
|
|
}
|
|
|
|
@ -884,7 +886,7 @@ bool CanStationTileHaveWires(TileIndex tile)
|
|
|
|
|
/** Wrapper for animation control, see #GetStationCallback. */
|
|
|
|
|
uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
|
|
|
|
|
{
|
|
|
|
|
return GetStationCallback(callback, param1, param2, statspec, st, tile);
|
|
|
|
|
return GetStationCallback(callback, param1, param2, statspec, st, tile, INVALID_RAILTYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Helper class for animation control. */
|
|
|
|
@ -990,7 +992,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cargo_type == CT_INVALID || HasBit(ss->cargo_triggers, cargo_type)) {
|
|
|
|
|
StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
|
|
|
|
|
StationResolverObject object(ss, st, tile, INVALID_RAILTYPE, CBID_RANDOM_TRIGGER, 0);
|
|
|
|
|
object.waiting_triggers = st->waiting_triggers;
|
|
|
|
|
|
|
|
|
|
const SpriteGroup *group = object.Resolve();
|
|
|
|
|