Skip to content

Bug: alternative_sprites in conditional blocks away from the parent behave inconsistently #371

@zephyris

Description

@zephyris

As alternative_sprite blocks can be placed away from their 'parent' sprites, the NML syntax implies you can do things like define alternative_sprites in a conditional block which are used only when that condition is met. For example:

replace grid_temperate_spr3981(3981, "temperate_groundtiles_gridline_8bpp.png") { template_groundtiles(0, 0, 1) }
if (climate==CLIMATE_ARCTIC) {
    alternative_sprites (grid_temperate_spr3981, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, "arctic_groundtiles_gridline_bt32bpp.png") { template_groundtiles(0, 0, 1) }
}

This doesn't work as you'd expect from the code. The alternative sprites are always used irrespective of climate.

The syntax also allows some quite nonsensical definitions:

if (climate==CLIMATE_TEMPERATE) {
    replace grid_temperate_spr3981(3981, "temperate_groundtiles_gridline_8bpp.png") { template_groundtiles(0, 0, 1) }
}
if (climate==CLIMATE_ARCTIC) {
    alternative_sprites (grid_temperate_spr3981, ZOOM_LEVEL_NORMAL, BIT_DEPTH_32BPP, "arctic_groundtiles_gridline_bt32bpp.png") { template_groundtiles(0, 0, 1) }
}

Such behaviour is not possible for NewGRFs (cf. NFO specs) as alternative sprites are just one part of the definition of a single real sprite.

Some example NML and images:
redef-alternate.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions