mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r22454) -Codechange: Deduplicate GetCustomStationGroundRelocation() into GetCustomStationRelocation() and only call it if actually needed.
This commit is contained in:
parent
fdd2f8447e
commit
20e86fd5ea
|
@ -576,28 +576,21 @@ static const SpriteGroup *ResolveStation(ResolverObject *object)
|
||||||
return SpriteGroup::Resolve(group, object);
|
return SpriteGroup::Resolve(group, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile)
|
/**
|
||||||
|
* Resolve sprites for drawing a station tile.
|
||||||
|
* @param statspec Station spec
|
||||||
|
* @param st Station (NULL in GUI)
|
||||||
|
* @param tile Station tile being drawn (INVALID_TILE in GUI)
|
||||||
|
* @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 ot use, minus an offset of 0x42D to accommodate for weird NewGRF specs.
|
||||||
|
*/
|
||||||
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile, uint32 var10)
|
||||||
{
|
{
|
||||||
const SpriteGroup *group;
|
const SpriteGroup *group;
|
||||||
ResolverObject object;
|
ResolverObject object;
|
||||||
|
|
||||||
NewStationResolver(&object, statspec, st, tile);
|
NewStationResolver(&object, statspec, st, tile);
|
||||||
|
object.callback_param1 = var10;
|
||||||
group = ResolveStation(&object);
|
|
||||||
if (group == NULL || group->type != SGT_RESULT) return 0;
|
|
||||||
return group->GetResult() - 0x42D;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile)
|
|
||||||
{
|
|
||||||
const SpriteGroup *group;
|
|
||||||
ResolverObject object;
|
|
||||||
|
|
||||||
NewStationResolver(&object, statspec, st, tile);
|
|
||||||
if (HasBit(statspec->flags, SSF_SEPARATE_GROUND)) {
|
|
||||||
object.callback_param1 = 1; // Indicate we are resolving the ground sprite
|
|
||||||
}
|
|
||||||
|
|
||||||
group = ResolveStation(&object);
|
group = ResolveStation(&object);
|
||||||
if (group == NULL || group->type != SGT_RESULT) return 0;
|
if (group == NULL || group->type != SGT_RESULT) return 0;
|
||||||
|
@ -777,7 +770,12 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
||||||
SpriteID image = sprites->ground.sprite;
|
SpriteID image = sprites->ground.sprite;
|
||||||
PaletteID pal = sprites->ground.pal;
|
PaletteID pal = sprites->ground.pal;
|
||||||
if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
|
if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
|
||||||
image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE);
|
if (HasBit(statspec->flags, SSF_SEPARATE_GROUND)) {
|
||||||
|
/* Use separate action 1-2-3 chain for ground sprite */
|
||||||
|
image += GetCustomStationRelocation(statspec, NULL, INVALID_TILE, 1);
|
||||||
|
} else {
|
||||||
|
image += relocation;
|
||||||
|
}
|
||||||
image += rti->fallback_railtype;
|
image += rti->fallback_railtype;
|
||||||
} else {
|
} else {
|
||||||
image += rti->GetRailtypeSpriteOffset();
|
image += rti->GetRailtypeSpriteOffset();
|
||||||
|
|
|
@ -111,11 +111,7 @@ const StationSpec *GetStationSpec(TileIndex t);
|
||||||
/* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
|
/* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
|
||||||
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
|
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
|
||||||
|
|
||||||
/* Get sprite offset for a given custom station and station structure (may be
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile, uint32 var10 = 0);
|
||||||
* NULL - that means we are in a build dialog). The station structure is used
|
|
||||||
* 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, uint layout, uint edge_info);
|
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);
|
||||||
|
|
||||||
|
|
|
@ -2678,7 +2678,12 @@ draw_default_foundation:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
|
if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
|
||||||
image += GetCustomStationGroundRelocation(statspec, st, ti->tile);
|
if (HasBit(statspec->flags, SSF_SEPARATE_GROUND)) {
|
||||||
|
/* Use separate action 1-2-3 chain for ground sprite */
|
||||||
|
image += GetCustomStationRelocation(statspec, st, ti->tile, 1);
|
||||||
|
} else {
|
||||||
|
image += relocation;
|
||||||
|
}
|
||||||
image += custom_ground_offset;
|
image += custom_ground_offset;
|
||||||
} else {
|
} else {
|
||||||
image += total_offset;
|
image += total_offset;
|
||||||
|
|
Loading…
Reference in New Issue