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

Don't speed up fastloop() under accelerated time #939

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Daxtorim
Copy link

@Daxtorim Daxtorim commented Jul 19, 2023

Instead of running a fairly resource intensive loop even more often than normal, this will multiply all resource calculations by game speed. There already was a time_multiplier variable everywhere, it just wasn't really used in a way it could have been. Instead of maxing a core on my old laptop under accelerated time, now it only sits at ~60% of a core 😅.

It also has the nice side effect that the displayed resource production values are now accurate under accelerated time. As a result of that the time estimates in the build queue are showing real time as well instead of ticking down at double speed.

The midloop() and longloop() timers weren't changed, as most code is tightly build and balanced around those timings and introducing time_mulitplier variables in those functions would be a massive undertaking.

The `global.settings.at` variable was turned into units of milliseconds
and the hardcoded factor of 2.5 all over the place was removed.
`global.settings.gameSpeed` and `global.settings.atMultiplier` were
introduced and the timers for the game loops were added to `webWorker`
to calculate the correct factor where needed.

`atrack` variable was removed since it was equivalent to
`global.settings.at` and therefore redundant.

Gamespeed was added to topbar and removed from tooltips.

The `atMultiplier-1` is necessary in the topbar display as well as in
`longLoop()` in `src/main.js` because while the game runs at n-times
speed, only (n-1)-times are actually the bonus speed and the remaining
1-times is the normal game which should not count against the bonus
time.
Instead of simply running the game in tighter loops, multiply resource
calculations by game speed. This is only done for `fastloop()` for now
as most other code is tightly build and balanced around the timings of
`midloop()` and `longloop()`.

In a few places a `++` was replaced by `4*time_multiplier` to account
for the loop running 4 times per second and `time_multiplier` being
0.25 under normal game speed.
The previous versions all assumed `midloop()` would run exactly once a
second.  This is not the case under accelerated time.  This will
correctly subtract the time between `midloop()` calls from timers such
that the displayed timer accurately represents real time left.

Currently this is done for the spy's training and mission timers as well
as the gene mutation timer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant