1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02:00
VVVVVV/desktop_version/src
Misa 1e9fb6aac0 Generalize game loop order and fix it to what it was in 2.2
Okay, so the reason why all render functions were moved to the end of
the frame in #220 is because it's simpler to call two fixed functions
and then a delta function instead of one fixed function, then a delta
function, and then another fixed function.

This is because fixed functions need special handling inside
deltaloop(), and you can't simply duplicate this handling after calling
a delta function. Oh, and to make matters worse, it's not always
fixed-delta-fixed, sometimes (like in MAPMODE and TELEPORTERMODE) it's
delta-fixed-fixed, so we'd need to handle that somehow too.

The solution here is to generalize the game loop and factor out each
function, instead of hardcoding it. Instead of having hardcoded
case-switches directly in the loop, I made a function that returns an
array of functions for a given gamestate, along with the number of
functions, then the game loop processes it accordingly. In fixedloop(),
it iterates over the array and executes each function until it reaches a
delta function, at which point it stops. And when it reaches the end of
the array, it goes back to the start of the array.

But anyway, if it gets to a delta function, it'll stop the loop and
finish fixedloop(). Then deltaloop() will call the delta function. And
then on the next frame, the function index will be incremented again, so
fixedloop() will call the fixed functions again.

Actually, the previous game loop was actually made up of one big loop,
with a gamestate function loop nested inside it, flanked with code that
ran at the start and end of the "big loop". This would be easy to handle
with one loop (just include the beginning and end functions with the
gamestate functions in the array), except that the gamestate functions
could suddenly be swapped out with unfocused functions (the ones that
run when you unfocus the window) at any time (well, on frame boundaries,
since key.isActive only got checked once, guarding the entire "inner
loop" - and I made sure that changing key.isActive wouldn't immediately
apply, just like the previous game loop order) - so I had to add yet
another layer of indirection, where the gamestate functions could
immediately be swapped out with the unfocused functions (while still
running the beginning and end code, because that was how the previous
loop order worked, after all).

This also fixes a regression that the game loop that #220 introduced
had, where if the fixed functions switched the gamestate, the game would
prematurely start rendering the gamestate function of the new gamestate
in the deltaframes, which was a source of some deltaframe glitches. But
fixing this is likely to just as well cause deltaframe glitches, so it'd
be better to fix this along with fixing the loop order, and only have
one round of QA to do in the end, instead of doing one round after each
change separately.

Fixes #464... but this isn't the end of the patchset. There are bugs
that need to be fixed, and kludges that need to be reverted.
2021-03-21 02:55:42 -04:00
..
BinaryBlob.cpp Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
BinaryBlob.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
BlockV.cpp Remove unused x and y attributes of blockclass 2021-02-27 18:27:28 -05:00
BlockV.h Remove unused x and y attributes of blockclass 2021-02-27 18:27:28 -05:00
Credits.h Fix entities in the Warp Zone's gray tileset not being gray in the editor (#480) 2020-09-25 13:35:03 -04:00
editor.cpp Fix a few missing implicit void arg declarations 2021-03-19 10:27:54 -04:00
editor.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Ent.cpp Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Ent.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Entity.cpp Remove unused x and y attributes of blockclass 2021-02-27 18:27:28 -05:00
Entity.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Enums.h Hello WWWWWWorld! 2020-01-08 10:37:50 -05:00
Exit.h Add VVV_exit() 2021-02-15 23:07:35 -05:00
FileSystemUtils.cpp Make one-way recolors check for specific files 2021-03-06 16:00:57 -05:00
FileSystemUtils.h Make one-way recolors check for specific files 2021-03-06 16:00:57 -05:00
Finalclass.cpp Separate includes into sections and alphabetize them 2020-07-19 21:37:40 -04:00
Finalclass.h Remove unnecessary includes from header files 2020-07-19 21:37:40 -04:00
Game.cpp Switch all flippable text boxes to use createtextboxflipme 2021-03-21 02:53:25 -04:00
Game.h De-duplicate "Game Saved" telesave textbox 2021-03-21 02:53:25 -04:00
GOGNetwork.c Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Graphics.cpp Remove special text box checks for y-position 180 2021-03-21 02:53:25 -04:00
Graphics.h Add createtextboxreal() and createtextboxflipme() 2021-03-21 02:53:25 -04:00
GraphicsResources.cpp Free data upon failure in LoadImage() 2021-01-18 13:06:43 -05:00
GraphicsResources.h Consistently use angle brackets for SDL.h includes 2020-07-19 21:37:40 -04:00
GraphicsUtil.cpp Use SDL_floor() instead of libc floor() 2021-03-06 16:01:29 -05:00
GraphicsUtil.h Add ClearSurface() 2021-02-25 19:38:25 -05:00
Input.cpp Add graphic options and game options to editor settings 2021-03-18 23:01:00 -04:00
Input.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
KeyPoll.cpp Directly toggle fullscreen if keybind pressed in key.Poll() 2021-03-17 03:01:19 -04:00
KeyPoll.h Directly toggle fullscreen if keybind pressed in key.Poll() 2021-03-17 03:01:19 -04:00
Labclass.cpp Separate includes into sections and alphabetize them 2020-07-19 21:37:40 -04:00
Labclass.h Remove unnecessary includes from header files 2020-07-19 21:37:40 -04:00
Logic.cpp Ensure oldcutscenebars is updated when cutscenebarspos is 2021-03-21 01:06:29 -04:00
Logic.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
main.cpp Generalize game loop order and fix it to what it was in 2.2 2021-03-21 02:55:42 -04:00
MakeAndPlay.h Re-comment out #define MAKEANDPLAY 2020-02-09 10:42:03 -05:00
Map.cpp Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Map.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Maths.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Music.cpp Move resumesong assignment to songend() 2021-03-10 09:45:20 -05:00
Music.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Network.c Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Network.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Otherlevel.cpp Bounds check all entity getters that can return 0 2020-09-25 13:51:47 -04:00
Otherlevel.h Remove unnecessary includes from header files 2020-07-19 21:37:40 -04:00
preloader.cpp Change all surface-clearing FillRect()s to use ClearSurface() 2021-02-25 19:38:25 -05:00
preloader.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Render.cpp De-duplicate Gravitron initial message 2021-03-21 02:06:39 -04:00
Render.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
RenderFixed.cpp Inline cutscene bars timer for gamemodes that used it in 2.2 2021-03-17 11:03:14 -04:00
RenderFixed.h Inline cutscene bars timer for gamemodes that used it in 2.2 2021-03-17 11:03:14 -04:00
Screen.cpp Fix transitive includes in Screen.cpp 2021-02-27 14:26:08 -05:00
Screen.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
ScreenSettings.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Script.cpp Make foundtrinket() Flip Mode-aware 2021-03-21 02:53:25 -04:00
Script.h Switch flipme script command to use flipme textbox attribute 2021-03-21 02:53:25 -04:00
Scripts.cpp Make 'custom_' check more readable 2020-09-27 16:31:40 -04:00
SoundSystem.cpp Replace all SDL_RWFromMem() with SDL_RWFromConstMem() 2021-02-25 19:39:48 -05:00
SoundSystem.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Spacestation2.cpp Separate includes into sections and alphabetize them 2020-07-19 21:37:40 -04:00
Spacestation2.h Remove unnecessary includes from header files 2020-07-19 21:37:40 -04:00
SteamNetwork.c Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
TerminalScripts.cpp Separate includes into sections and alphabetize them 2020-07-19 21:37:40 -04:00
Textbox.cpp Add flipme attribute to textboxclass 2021-03-21 02:53:25 -04:00
Textbox.h Add flipme attribute to textboxclass 2021-03-21 02:53:25 -04:00
ThirdPartyDeps.c Reduce dependency on libc functions 2021-01-12 14:02:31 -05:00
Tower.cpp Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
Tower.h Explicitly declare void for all void parameter functions (#628) 2021-02-25 17:23:59 -05:00
TowerBG.h Move mapclass r/g/b variables off onto TowerBG 2021-01-07 21:15:34 -05:00
UtilityClass.cpp Refactor endsWith() to not use the STL 2021-02-27 01:40:05 -05:00
UtilityClass.h Refactor endsWith() to not use the STL 2021-02-27 01:40:05 -05:00
Version.h Don't recompile all files when the commit hash is changed 2020-12-25 20:17:01 -05:00
Version.h.in Don't recompile all files when the commit hash is changed 2020-12-25 20:17:01 -05:00
WarpClass.cpp Separate includes into sections and alphabetize them 2020-07-19 21:37:40 -04:00
WarpClass.h Remove unnecessary includes from header files 2020-07-19 21:37:40 -04:00
XMLUtils.cpp Move all settings to settings.vvv 2020-11-04 12:06:57 -05:00
XMLUtils.h Move all settings to settings.vvv 2020-11-04 12:06:57 -05:00