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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Support extended DCxx string range, and station names for IDs > 255 #293

Merged
merged 2 commits into from Jun 28, 2023

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented May 28, 2023

Implements support for OpenTTD/OpenTTD@f5394ed and OpenTTD/OpenTTD@bc7dfd7.

Draft because only half of it is done.

For stations I have 2 options, just switch to DCxx range, or use a mechanism to still use C5xx and C6xx ranges for IDs < 256 then fallback to DCxx.

@michicc
Copy link
Member

michicc commented May 28, 2023

For the extended string range there also needs to be a way to reference them from a switch block.

As far as I can tell, a string() in a switch will always be allocated in the D0 range, even if it is used in the text stack and not as a CB result. Some kind of additional feature or automatic logic would be needed to also make it useable for e.g. the engine name callback.

@glx22
Copy link
Contributor Author

glx22 commented May 28, 2023

Yeah it allocates in D0 range and does some magic to return the unprefixed ID. Then authors have to readd the prefix in some cases (can't remember exactly where and why, but I'm sure I saw this being done)

Edit: found where I saw it (see https://github.com/andythenorth/firs/blob/main/src/templates/extra_text_informative.pynml#L42-L47)

Station names use C5xx range for first 256 IDs, and DCxx range for the rest.
As classnames are most likely to be shared they use only DCxx range.
@glx22
Copy link
Contributor Author

glx22 commented May 28, 2023

I used a very simple mechanism to switch range for station names depending on IDs.
For classnames I just decided to use only DCxx range, as in most cases many stations will use the same class.

Regarding the D0xx range and switches, I think it's very difficult to determine if you are in the callback result case (which means allocate in D000 range and return allocated_id - 0xD000 + 0x8000) or in the procedure result case (allocated in DCxx range and possibly put on text stack)
Hmm, even a procedure call result could actually be used as a callback result.

@glx22 glx22 marked this pull request as ready for review May 28, 2023 15:20
@glx22 glx22 merged commit a9a1a3e into OpenTTD:master Jun 28, 2023
21 checks passed
@glx22 glx22 deleted the strings branch June 28, 2023 19:39
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