Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: support for stations #244

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Add: support for stations #244

wants to merge 12 commits into from

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Nov 1, 2021

It's finally possible to create stations newgrf with NML.
I implemented most props, but I'm not sure about their naming or simplicity of use. Maybe more global constants are needed.
I think I correctly implemented sprite layout for stations (was the hardest part).
I added a SPRITESET() function existing only for stations, used to refer to active spriteset (the one selected with basic action2).
Custom foundations are also implemented.
I tested many things locally and it works for me.

As an example, I converted CHIPS Cow pens station (and yes there are blinking cows 馃惍馃ぃ).
Regression test also produces a working grf.

@glx22 glx22 marked this pull request as draft Nov 1, 2021
@glx22
Copy link
Contributor Author

@glx22 glx22 commented Nov 1, 2021

copy_sprite_layout can't work in the current implementation. I need to rethink things.

nml/actions/action3_callbacks.py Outdated Show resolved Hide resolved
'default' : {'type': 'cargo', 'num': None},
'availability' : {'type': 'cb', 'num': 0x13, 'flag_bit': 0},
'select_sprite_layout' : {'type': 'cb', 'num': 0x14, 'flag_bit': 1},
'custom_station_layout' : {'type': 'cb', 'num': 0x24, 'purchase': 2},
Copy link
Member

@frosch123 frosch123 Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the name here.
The result indexes into the properties "draw_pylon_tiles", "hide_wire_tiles" and "non_traversable_tiles".
So maybe "select_tile_index", "select_tile_type" or just "select_tille"?

Copy link
Contributor Author

@glx22 glx22 Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah naming is hard.

nml/actions/action0properties.py Show resolved Hide resolved
"STAT_FLAG_CUSTOM_FOUNDATIONS" : 3,
"STAT_FLAG_EXTENDED_FOUNDATIONS" : 4,

# station tile types
Copy link
Member

@frosch123 frosch123 Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If property 0E is not supported/needed, I don't think these constants are useful either.

Copy link
Contributor Author

@glx22 glx22 Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only use I can see would be in bitmask() for hide_wire_tiles or non_traversable_tiles, so yeah probably useless.

@glx22 glx22 marked this pull request as ready for review Nov 6, 2021
@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Nov 14, 2021

CHIPS port in progress to test this: https://github.com/andythenorth/chips/tree/nml-port

@glx22
Copy link
Contributor Author

@glx22 glx22 commented Nov 17, 2021

I did some test trying to port CHIPS 'magic' stations.
Found some issues:

  • it's not possible to use LOAD_TEMP() in the layout, because the STORE_TEMP() will happen after registers are set (registers action2 is inserted in front of any action3 result)
  • some callbacks need a purchase specific version (at least select_sprite_layout)

@glx22
Copy link
Contributor Author

@glx22 glx22 commented Nov 19, 2021

Fixed the 2 issues I noticed (and reworked some part for the third time)

@glx22
Copy link
Contributor Author

@glx22 glx22 commented Nov 22, 2021

SPRITESET([offset]) renamed to DEFAULT([offset]).
Added CUSTOM(index, [offset]), with index pointing into custom_spritesets array.
Advanced test using most of the implemented stuff is available here.

Purchase/non-purchase splitting for callbacks may not be enough. Originally CHIPS defines 3 different chains for select_sprite_layout, 1 for default, 1 for purchase and 1 for cargos. prepare_layout may benefit from a similar spliting.

@glx22
Copy link
Contributor Author

@glx22 glx22 commented Dec 6, 2021

Applied #246.

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.

None yet

3 participants