Skip to content

Change EasyRPG's "SetInterpreterFlag" to make patch overrides temporary #3379

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

Merged
merged 6 commits into from
May 21, 2025

Conversation

florianessl
Copy link
Member

This PR refactors the EasyRPG feature "SetInterpreterFlag" (#3123), similar to the way @Ghabry suggested there, by making use of some new state flags that have been merged into liblcf.

See liblcf PRs:

Rather than setting the global config options directly as before, a new field "easyrpg_runtime_flags" in the SaveEventExecState" struct is used, to make these overrides persist across save/load boundaries.

This makes these config overrides apply only to the Interpreter instance where they have been set, and when the end of the base frame is reached, all of the flags are reset automatically. To make this possible, a new global field "active_interpreter_flags" has been introduced, so the Player functions responsible for restricting use to these custom features can access & consider the state of the active interpreter flags for its check.

Test Project

RuntimeFlags.zip

Set "EasyRPG.ini" accordingly, whether you want to test the explicit enabling or disabling of certain patches.

  • Talking to the ladies at the "ON" section should always trigger the test code.
  • Talking to the ladies at the "OFF" section should never trigger the test code.
  • Talking to the ladies at the "---" section: Here it depends on the patches enabled inside EasyRPG.ini.

Note:
Some extra test code has been introduced via a commit, to make it possible to easily test DynRPG & Destiny support using a simple log command. (@easyrpg_output would always be possible, even without DynRPG enabled)

Copy link
Member

@Ghabry Ghabry left a comment

Choose a reason for hiding this comment

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

Thanks for finishing the command implementation.

@Ghabry Ghabry added this to the 0.8.2 milestone Mar 24, 2025
@florianessl florianessl force-pushed the features/RuntimeFlags branch from d174607 to ab89abb Compare April 16, 2025 05:32
@Ghabry
Copy link
Member

Ghabry commented Apr 29, 2025

Guess this one should be before #3349 as is simpler. All of the conflict in the debug scene. (can you rebase it?) (and remove the testing code)

…, according to Ghabry's suggestions:

- Overrides of interpreter features are now stored inside a new lcf field "easyrpg_runtime_flags", so the settings can be retrieved from save files.
- These overrides are only valid for the current interpreter & the runtime flags will be cleared, once the last frame has been popped
- A new global field "active_interpreter_flags" has been introduced, so the Player functions responsible for restricting use to these custom features can access & consider the state of the active interpreter flags for its check.
- Implemented a very rudimentary display for active engine flag overrides in window_interpreter
…gExtensions() evaluates to true -> Separated script handling for Dyn/Easy & Destiny
@florianessl florianessl force-pushed the features/RuntimeFlags branch from ab89abb to 0745b49 Compare April 29, 2025 16:02
@Ghabry
Copy link
Member

Ghabry commented May 7, 2025

I'll make some adjustments to this myself during the weekend. So no need for you to fix the warnings etc. (also want to check how the code-gen of your code is as this is all checked alot during execution)

Also from now on we should, before adding further flags, think about whether it even makes sense to have them as the flag is only active while in the interpreter context. (also to save flags, we only have 32, so cannot add all of monsca etc. xD).

But is in general useful to have some kind of facility that alters the execution behaviour.

@florianessl
Copy link
Member Author

But is in general useful to have some kind of facility that alters the execution behaviour.

Apropos altering execution behavior:
I've been testing an alternative approach for variable operations & conditional branches for a while now, which uses some sort of dispatching approach using vtables. This could also be used to swap out individual patch implementations for individual interpreter instances, as every interpreter has its own vtable instance.

It seems pretty stable by now & performs well (played through several larger games to really validate that I didn't break anything..)
https://github.com/florianessl/Player/tree/refactor/VariableOps

All this code stems from me experimenting with my ScopedVars branch last year, to make it possible to use all the pre-existing var operations in other new command variants (eg. "ControlVariablesEx" or "ControlScopedVars") without additional overhead.

This would be the important part that is responsible for generating the dispatch tables:
https://github.com/florianessl/Player/blob/refactor/VariableOps/src/game_interpreter.cpp#L5735

@Ghabry
Copy link
Member

Ghabry commented May 9, 2025

Good idea with this dispatch functionality. We really have a problem by now with too much "if ManiacPatch" conditions all around the event code.

Better would be to have a "vanilla 2k" and a "maniac patch" version.

Causes some code duplication but event commands usually don't change except for rare bugfixes and reduces the risk of breaking stuff as has already happened far too often when adding maniac stuff :/.

Also allows more compiler flags like "Only Vanilla game support is enough for me" (could be useful for some of the constrained homebrew platforms).

@Ghabry
Copy link
Member

Ghabry commented May 15, 2025

In the end my changes were only minor.

Will do some game tests tomorrow, then is ready for merging.

(But the patch stuff needs a refactor someday, Player namespace becomes more and more bloated with this stuff xD.)

@Ghabry Ghabry merged commit bbdb3c8 into EasyRPG:master May 21, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Settings All about customizable features, storing and applying them Window/Scenes
Development

Successfully merging this pull request may close these issues.

2 participants