spelunky-fyi / overlunky

An overlay for Spelunky 2 to help you with modding, exploring the depths of the game and practicing with tools like spawning arbitrary items, warping to levels and teleporting.
MIT License
83 stars 31 forks source link

Dropped inputs during frame advance after tabbing in with PL + OL #373

Open Cosine256 opened 6 months ago

Cosine256 commented 6 months ago

Inputs are being dropped during the first frame advance after tabbing into the game when running PL + OL. This might look familiar because I originally reported it in the PauseAPI PR. It was fixed there, but only for plain OL. I've just now noticed it happening with PL + OL.

  1. Launch PL with speedrun mode disabled.
  2. Attach OL.
  3. Set pause flags to freeze updates, game loop, and inputs.
  4. Go to camp.
  5. Activate a freeze pause.
  6. Tab out of the game window (I'm using the borderless window setting).
  7. Tab back into the game window.
  8. Hold any combination of inputs and use frame advance once (I'm using keyboard).

Those first inputs are ignored by the game during that frame advance, and will keep being ignored until released. Any newly held inputs during subsequent frame advances are processed correctly, but the first set of inputs keeps getting dropped. Releasing the first set of inputs fixes them, even if you don't frame advance while they're released.

Dregu commented 6 months ago

IIRC the "Run in last API instance" option was added partly for and fixes this special case, but it's been too long since I made this for my old brain again.

Cosine256 commented 6 months ago

I see now, enabling that option does fix the issue. It looks like it defaulted to being disabled whenever it was added and I decided not to mess with it at the time. What reasons would there be to have that option disabled?

Dregu commented 6 months ago

The reason is pretty theoretical, but OL can't really promise the attached PL version even has a PauseAPI, but since PauseAPI and the ability to detect the existence of PL were added at the same time, it hardly matters. It should probably be default on.

Dregu commented 6 months ago

And to be clear, PauseAPI will just run in OL with the option enabled, but no PL or PL in speedrun mode, since it is now "the last api instance" and also the only one.

Cosine256 commented 6 months ago

Ok, I thought it might just matter only if you had two versions of the script API attached, which doesn't seem like a very good idea now that they can share a bucket. Maybe just defaulting it to true would be a good enough fix for this issue, and maybe warn users that there isn't much reason to disable it unless they really know what they're doing.