summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_station.cpp13
-rw-r--r--src/newgrf_station.h2
-rw-r--r--src/station_cmd.cpp23
3 files changed, 26 insertions, 12 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 4cc68e2a4..7465d5283 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -604,14 +604,23 @@ SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Bas
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;
ResolverObject object;
NewStationResolver(&object, statspec, st, tile);
object.callback_param1 = 2; // Indicate we are resolving the foundation sprites
+ object.callback_param2 = layout | (edge_info << 16);
ClearRegister(0x100);
group = ResolveStation(&object);
diff --git a/src/newgrf_station.h b/src/newgrf_station.h
index df474774c..c7fb556e6 100644
--- a/src/newgrf_station.h
+++ b/src/newgrf_station.h
@@ -116,7 +116,7 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i
* for variational sprite groups. */
SpriteID GetCustomStationRelocation(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);
/* Allocate a StationSpec to a Station. This is called once per build operation. */
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index d8a4a553a..57abbb8ae 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2503,6 +2503,7 @@ static void DrawTile_Station(TileInfo *ti)
uint32 relocation = 0;
const BaseStation *st = NULL;
const StationSpec *statspec = NULL;
+ uint tile_layout = 0;
if (HasStationRail(ti->tile)) {
rti = GetRailTypeInfo(GetRailType(ti->tile));
@@ -2516,18 +2517,18 @@ static void DrawTile_Station(TileInfo *ti)
statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
if (statspec != NULL) {
- uint tile = GetStationGfx(ti->tile);
+ tile_layout = GetStationGfx(ti->tile);
relocation = GetCustomStationRelocation(statspec, st, ti->tile);
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
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 */
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 */
if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile)) {
if (statspec != NULL && HasBit(statspec->flags, SSF_CUSTOM_FOUNDATIONS)) {
- /* Station has custom foundations. */
- SpriteID image = GetCustomStationFoundationRelocation(statspec, st, ti->tile);
+ /* Station has custom foundations.
+ * 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)) {
/* Station provides extended foundations. */
@@ -2617,10 +2624,8 @@ static void DrawTile_Station(TileInfo *ti)
/* If foundations continue beyond the tile's upper sides then
* mask out the last two pieces. */
- uint z;
- Slope slope = GetFoundationSlope(ti->tile, &z);
- if (!HasFoundationNW(ti->tile, slope, z)) ClrBit(parts, 6);
- if (!HasFoundationNE(ti->tile, slope, z)) ClrBit(parts, 7);
+ if (HasBit(edge_info, 0)) ClrBit(parts, 6);
+ if (HasBit(edge_info, 1)) ClrBit(parts, 7);
if (parts == 0) {
/* We always have to draw at least one sprite to make sure there is a boundingbox and a sprite with the