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

Add: Allow stepping the game forward by a tick at a time #8696

Open
James103 opened this issue Feb 19, 2021 · 2 comments
Open

Add: Allow stepping the game forward by a tick at a time #8696

James103 opened this issue Feb 19, 2021 · 2 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented Feb 19, 2021

Version of OpenTTD

1.11.0-beta1

Expected result

You should be able to press a hotkey or button that advances the game by a single tick when the game is paused. This can be used to, for example, debug AI/GS scripts, see what's going on inside a contraption, or work out other stuff on a tick by tick basis.

Alternatively, a console command tick step can be added which takes in an optional integer argument (defaulting to 1) and runs the game for that many ticks.

Actual result

Whenever you unpause and pause the game, even if the game is limited to running at 0.25x speed by #8693, that's still 54 ms per tick, which is faster than the time it takes most humans (and some bots) to click the button to unpause the game then the same button to pause it.

Steps to reproduce

  1. Pause the game.
  2. Unpause then pause the game as fast as you can. For example, press the PAUSE hotkey twice in a row, or hover the cursor over the pause button and click twice in succession.
  3. Notice that multiple game ticks will have passed.
@JGRennison
Copy link
Contributor

@JGRennison JGRennison commented Feb 19, 2021

I've used this technique for debugging/testing things a few times, but never went as far as making an actual option for it.
Adding a _pause_mode = PM_PAUSED_NORMAL; towards the end of StateGameLoop() and rebuilding had the desired effect.

@ldpl
Copy link
Contributor

@ldpl ldpl commented Feb 19, 2021

I have cmstep [ticks] console command for that in cmclient. Implementation is a bit whacky but can be used as a reference I guess.
citymania-org/cmclient@5ce2d21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants