mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-24 12:44:10 +01:00
ProcessRegisters must be called even if the sprite resolve result is not valid. A zero-length ResultSpriteGroup is valid because the output value is an offset, not a sprite ID within the ResultSpriteGroup.
This commit is contained in:
committed by
GitHub
parent
74cb4dcefc
commit
84eb3fb0e0
@@ -614,7 +614,9 @@ SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st
|
||||
{
|
||||
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, var10);
|
||||
const auto *group = object.Resolve<ResultSpriteGroup>();
|
||||
if (group == nullptr || group->num_sprites == 0) return 0;
|
||||
|
||||
/* A zero-length ResultSpriteGroup is valid because the output value is an offset, not a sprite ID within the ResultSpriteGroup. */
|
||||
if (group == nullptr) return 0;
|
||||
return group->sprite - SPR_RAIL_PLATFORM_Y_FRONT;
|
||||
}
|
||||
|
||||
@@ -624,8 +626,12 @@ void GetCustomStationRelocation(SpriteLayoutProcessor &processor, const StationS
|
||||
for (uint8_t var10 : processor.Var10Values()) {
|
||||
object.callback_param1 = var10;
|
||||
const auto *group = object.Resolve<ResultSpriteGroup>();
|
||||
if (group == nullptr || group->num_sprites == 0) continue;
|
||||
processor.ProcessRegisters(object, var10, group->sprite - SPR_RAIL_PLATFORM_Y_FRONT);
|
||||
|
||||
/* ProcessRegisters must be called no matter the type of the sprite resolve result or whether it is valid.
|
||||
* The sprite offset is only used for layouts with the SPRITE_MODIFIER_CUSTOM_SPRITE flag, however other aspects of layouts
|
||||
* such as register operations must still be processed even if this flag is not set and the sprite offset is never used.
|
||||
* A zero-length ResultSpriteGroup is valid because the output value is an offset, not a sprite ID within the ResultSpriteGroup. */
|
||||
processor.ProcessRegisters(object, var10, group != nullptr ? group->sprite - SPR_RAIL_PLATFORM_Y_FRONT : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user