Feature Request #2790
Renum: Escape RPN expressions.
I'd like to suggest the allowing of RPN expressions escape sequences so that RPN expressions can be used inside of Actions as well as sprite definitions. There is already a hook point within Renum for this, but the hook was left commented out.
This would allow for the following format,
\<size>(<rpn>), an example could be
\w(0x8000 VEH_ID +).
- Altering both GrfCodec and Renum to support it.
- Alter only Renum, and have it rewrite the escape.
The former would require a fair amount of rewriting and duplication of code, due to GrfCodec not supporting the various commands linked to RPN expressions, and DoCalc being specifically designed for use only in Renum.
The latter is a less clean solution, but would require minimalist changes to achieve, it would require altering the original string, removing the RPN expression and replacing it with the RPN result instead.
I've attached two diffs, the first merely enables the existence (and value checking) of escape based RPN sequences, the second built upon the first, replaces the RPN with the result. (The third is the same as the second, but just writes the hexadecimal version for results over or equal to 0x8000).
-Change: enable the existence (and value checking) of escape based RPN sequences (Lakie #2790)
#1 Updated by Rubidium over 1 year ago
I'd personally go with nforenum rewriting the number, and keeping grfcodec simple. Especially since you should run nforenum anyhow for validations and what not.