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

[Bug]: GS story page button event handling can be very unresponsive #10393

Open
andythenorth opened this issue Jan 22, 2023 · 0 comments
Open
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests!

Comments

@andythenorth
Copy link
Contributor

Version of OpenTTD

13-ish

Expected result

GS story page can have push buttons.

These emit GS events on click.

The expectation is that these events are handled ~instantly, as normal in UIs.

Actual result

Because GS event processing is on a sequential queue, there can be significant delay in handling the button click events when the queue contains other events.

If the button event handler then causes commands to be issued, this will introduce a further delay due to 1-command-per-tick execution model for GS.

Even without trying pathological cases (very large maps, very large number of commands etc), the delay in responding to story book buttons can be many real-world seconds.

This is a compounding problem, as the natural human response to button latency is to click again, many many times. Which of course adds more events to the queue.

Additionally in some cases the game state will have changed by the time the button event is handling, leading to invalid results, nonsense results, or surprise clowns.

I don't propose a specific implementation, but ideas include:

  • improve button perceived response time, by prioritising button events to the top of the queue, either automatically (preferred), or by author setting a priority (like renice)
  • reduce the causes of latency by unyoking GS from 'one command per tick' issue
  • flood protection by capping the number of button clicks that will be added to the queue from a single button (this might be undesirable as it prevents authors making silly auto-clicker type games)

Steps to reproduce

Write a GS that handles story book button events, and then issues commands in response to the events.
Click the buttons a lot.
Observe latency.

I can provide a test GS for this if helpful.

@2TallTyler 2TallTyler added component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests! labels Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests!
Projects
None yet
Development

No branches or pull requests

2 participants