Changeset - r17668:e0ec608a58fa
[Not reviewed]
master
0 3 0
frosch - 14 years ago 2011-05-14 12:38:10
frosch@openttd.org
(svn r22453) -Feature(ette): Implement variable 18 for custom station foundations.
3 files changed with 26 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/newgrf_station.cpp
Show inline comments
 
@@ -604,14 +604,23 @@ SpriteID GetCustomStationGroundRelocatio
 
	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);
src/newgrf_station.h
Show inline comments
 
@@ -116,7 +116,7 @@ uint32 GetPlatformInfo(Axis axis, byte t
 
 * 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. */
src/station_cmd.cpp
Show inline comments
 
@@ -2503,6 +2503,7 @@ static void DrawTile_Station(TileInfo *t
 
	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 *t
 
			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 *t
 
	/* 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 *t
 

	
 
				/* 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
0 comments (0 inline, 0 general)