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

Improve KeyInputProc behaviour #469

Merged
merged 6 commits into from May 10, 2015
Merged

Improve KeyInputProc behaviour #469

merged 6 commits into from May 10, 2015

Conversation

@Zegeri
Copy link
Member

@Zegeri Zegeri commented May 10, 2015

You can now play everyone's favourite: the Nasu minigame of Yume Nikki!

The hardest issue is, without breaking anything, avoiding restarting an action-triggered event when one of its last commands is a KeyInputProc waiting for the action key. There're three relevant moments that run in the following order: the update of the main interpreter, the update of the event and the update of the game player. Suppose we have an event running a KeyInputProc waiting for the action key. This is what it should happen:

Frame Main Interpreter Event Game Player
1 Player presses Action Key. Event reaches command end. - Action key triggers event. The interpreter ran commands from this event in this frame, so its commands are not loaded
2 - - Player can trigger again the event

This is what happens without the workaround 08100c3:

Frame Main Interpreter Event Game Player
1 Player press Action Key. Event reaches command end. - Action key triggers event. The interpreter is free, so its commands are loaded
2 It runs the event's commands - -

This is how it looks with the workaround:

Frame Main Interpreter Event Game Player
1 Player presses Action Key. Event reaches command end. ready1 = false; ready1 = true; ready2 = false; Action key triggers event. ready2 == false, so its commands are not loaded
2 - ready2 = false; Player can trigger again the event

The workaround is ugly, but it works until we come up with a better solution.

@@ -1514,6 +1520,8 @@ bool Game_Interpreter_Map::CommandKeyInputProc(RPG::EventCommand const& com) { /
int result = 0;
size_t param_size = com.parameters.size();

bool (*check)(Input::InputButton) = wait ? Input::IsTriggered : Input::IsPressed;

This comment has been minimized.

@Ghabry

Ghabry May 10, 2015
Member

Is this some kind of inline-function declaration? Works with C++03?
Have never seen this before.

This comment has been minimized.

@Zegeri

Zegeri May 10, 2015
Author Member

It's a function pointer. We already use it in Game_Interpreter::SetContinuation.

@Ghabry
Copy link
Member

@Ghabry Ghabry commented May 10, 2015

needs rebase

@Zegeri Zegeri force-pushed the Zegeri:keyinput branch from 00ad7d5 to 324fc03 May 10, 2015
Ghabry added a commit that referenced this pull request May 10, 2015
Improve KeyInputProc behaviour
@Ghabry Ghabry merged commit 18aff0f into EasyRPG:master May 10, 2015
1 check passed
1 check passed
@fdelapena
default Merged build finished.
Details
@Zegeri Zegeri deleted the Zegeri:keyinput branch May 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants