Skip to content

Fix: Nicer error message when a station switch returns a SpriteLayout#360

Merged
glx22 merged 1 commit intoOpenTTD:masterfrom
glx22:invalid_sprite_layout
Mar 14, 2025
Merged

Fix: Nicer error message when a station switch returns a SpriteLayout#360
glx22 merged 1 commit intoOpenTTD:masterfrom
glx22:invalid_sprite_layout

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Jan 23, 2025

Stations usage of SpriteLayouts is very different to other features, but it may happen an author write a switch returning a SpriteLayout (like it's done for other features).
This triggers this assert, which is not helpful for the author.

A check exist to prevent invalid use of SpriteLayout when following 1/2/3, but stations are allowed to have SpriteLayout with a special handling.

Detect the problem before asserting and output a more useful error message.

Doing the same kind of check for SpriteGroup is not necessary here because it's already handled here and here and all features follow 1/2/3 for SpriteGroups.

from nml import expression, generic, global_constants, nmlop
from nml.actions import action2, action2real, action2var_variables, action4, action6, actionD
from nml.ast import switch
from nml.ast import general, switch, spriteblock

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
nml.ast.spriteblock
begins an import cycle.
Import of module
nml.ast.switch
begins an import cycle.
@glx22 glx22 merged commit 750d06d into OpenTTD:master Mar 14, 2025
21 checks passed
@glx22 glx22 deleted the invalid_sprite_layout branch March 14, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants