Skip to content

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

Merged
glx22 merged 2 commits intoOpenTTD:masterfrom
glx22:strings
Jun 28, 2023
Merged

Change: Support extended DCxx string range, and station names for IDs > 255#293
glx22 merged 2 commits intoOpenTTD:masterfrom
glx22:strings

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
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.

3 participants