mirror of https://github.com/OpenTTD/OpenTTD
(svn r22453) -Feature(ette): Implement variable 18 for custom station foundations.
parent
930d0c9702
commit
fdd2f8447e
|
@ -604,14 +604,23 @@ SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Bas
|
||||||
return group->GetResult() - 0x42D;
|
return group->GetResult() - 0x42D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile)
|
* Resolve the sprites for custom station foundations.
|
||||||
|
* @param statspec Station spec
|
||||||
|
* @param st Station
|
||||||
|
* @param tile Station tile being drawn
|
||||||
|
* @param layout Spritelayout as returned by previous callback
|
||||||
|
* @param edge_info Information about northern tile edges; whether they need foundations or merge into adjacent tile's foundations.
|
||||||
|
* @return First sprite of a set of foundation sprites for various slopes.
|
||||||
|
*/
|
||||||
|
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile, uint layout, uint edge_info)
|
||||||
{
|
{
|
||||||
const SpriteGroup *group;
|
const SpriteGroup *group;
|
||||||
ResolverObject object;
|
ResolverObject object;
|
||||||
|
|
||||||
NewStationResolver(&object, statspec, st, tile);
|
NewStationResolver(&object, statspec, st, tile);
|
||||||
object.callback_param1 = 2; // Indicate we are resolving the foundation sprites
|
object.callback_param1 = 2; // Indicate we are resolving the foundation sprites
|
||||||
|
object.callback_param2 = layout | (edge_info << 16);
|
||||||
|
|
||||||
ClearRegister(0x100);
|
ClearRegister(0x100);
|
||||||
group = ResolveStation(&object);
|
group = ResolveStation(&object);
|
||||||
|
|
|
@ -116,7 +116,7 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i
|
||||||
* for variational sprite groups. */
|
* for variational sprite groups. */
|
||||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
||||||
SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
||||||
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile, uint layout, uint edge_info);
|
||||||
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile);
|
||||||
|
|
||||||
/* Allocate a StationSpec to a Station. This is called once per build operation. */
|
/* Allocate a StationSpec to a Station. This is called once per build operation. */
|
||||||
|
|
|
@ -2503,6 +2503,7 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
uint32 relocation = 0;
|
uint32 relocation = 0;
|
||||||
const BaseStation *st = NULL;
|
const BaseStation *st = NULL;
|
||||||
const StationSpec *statspec = NULL;
|
const StationSpec *statspec = NULL;
|
||||||
|
uint tile_layout = 0;
|
||||||
|
|
||||||
if (HasStationRail(ti->tile)) {
|
if (HasStationRail(ti->tile)) {
|
||||||
rti = GetRailTypeInfo(GetRailType(ti->tile));
|
rti = GetRailTypeInfo(GetRailType(ti->tile));
|
||||||
|
@ -2516,18 +2517,18 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
|
statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
|
||||||
|
|
||||||
if (statspec != NULL) {
|
if (statspec != NULL) {
|
||||||
uint tile = GetStationGfx(ti->tile);
|
tile_layout = GetStationGfx(ti->tile);
|
||||||
|
|
||||||
relocation = GetCustomStationRelocation(statspec, st, ti->tile);
|
relocation = GetCustomStationRelocation(statspec, st, ti->tile);
|
||||||
|
|
||||||
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
|
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
|
||||||
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
|
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
|
||||||
if (callback != CALLBACK_FAILED) tile = (callback & ~1) + GetRailStationAxis(ti->tile);
|
if (callback != CALLBACK_FAILED) tile_layout = (callback & ~1) + GetRailStationAxis(ti->tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure the chosen tile layout is valid for this custom station */
|
/* Ensure the chosen tile layout is valid for this custom station */
|
||||||
if (statspec->renderdata != NULL) {
|
if (statspec->renderdata != NULL) {
|
||||||
t = &statspec->renderdata[tile < statspec->tiles ? tile : (uint)GetRailStationAxis(ti->tile)];
|
t = &statspec->renderdata[tile_layout < statspec->tiles ? tile_layout : (uint)GetRailStationAxis(ti->tile)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2583,8 +2584,14 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
/* don't show foundation for docks */
|
/* don't show foundation for docks */
|
||||||
if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
|
if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
|
||||||
if (statspec != NULL && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
|
if (statspec != NULL && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
|
||||||
/* Station has custom foundations. */
|
/* Station has custom foundations.
|
||||||
SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile);
|
* Check whether the foundation continues beyond the tile's upper sides. */
|
||||||
|
uint edge_info = 0;
|
||||||
|
uint z;
|
||||||
|
Slope slope = GetFoundationSlope(ti->tile, &z);
|
||||||
|
if (!HasFoundationNW(ti->tile, slope, z)) SetBit(edge_info, 0);
|
||||||
|
if (!HasFoundationNE(ti->tile, slope, z)) SetBit(edge_info, 1);
|
||||||
|
SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile, tile_layout, edge_info);
|
||||||
|
|
||||||
if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
|
if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) {
|
||||||
/* Station provides extended foundations. */
|
/* Station provides extended foundations. */
|
||||||
|
@ -2617,10 +2624,8 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
|
|
||||||
/* If foundations continue beyond the tile's upper sides then
|
/* If foundations continue beyond the tile's upper sides then
|
||||||
* mask out the last two pieces. */
|
* mask out the last two pieces. */
|
||||||
uint z;
|
if (HasBit(edge_info, 0)) ClrBit(parts, 6);
|
||||||
Slope slope = GetFoundationSlope(ti->tile, &z);
|
if (HasBit(edge_info, 1)) ClrBit(parts, 7);
|
||||||
if (!HasFoundationNW(ti->tile, slope, z)) ClrBit(parts, 6);
|
|
||||||
if (!HasFoundationNE(ti->tile, slope, z)) ClrBit(parts, 7);
|
|
||||||
|
|
||||||
if (parts == 0) {
|
if (parts == 0) {
|
||||||
/* We always have to draw at least one sprite to make sure there is a boundingbox and a sprite with the
|
/* We always have to draw at least one sprite to make sure there is a boundingbox and a sprite with the
|
||||||
|
|
Loading…
Reference in New Issue