mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
1e9fb6aac0
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. |
||
---|---|---|
.. | ||
BinaryBlob.cpp | ||
BinaryBlob.h | ||
BlockV.cpp | ||
BlockV.h | ||
Credits.h | ||
editor.cpp | ||
editor.h | ||
Ent.cpp | ||
Ent.h | ||
Entity.cpp | ||
Entity.h | ||
Enums.h | ||
Exit.h | ||
FileSystemUtils.cpp | ||
FileSystemUtils.h | ||
Finalclass.cpp | ||
Finalclass.h | ||
Game.cpp | ||
Game.h | ||
GOGNetwork.c | ||
Graphics.cpp | ||
Graphics.h | ||
GraphicsResources.cpp | ||
GraphicsResources.h | ||
GraphicsUtil.cpp | ||
GraphicsUtil.h | ||
Input.cpp | ||
Input.h | ||
KeyPoll.cpp | ||
KeyPoll.h | ||
Labclass.cpp | ||
Labclass.h | ||
Logic.cpp | ||
Logic.h | ||
main.cpp | ||
MakeAndPlay.h | ||
Map.cpp | ||
Map.h | ||
Maths.h | ||
Music.cpp | ||
Music.h | ||
Network.c | ||
Network.h | ||
Otherlevel.cpp | ||
Otherlevel.h | ||
preloader.cpp | ||
preloader.h | ||
Render.cpp | ||
Render.h | ||
RenderFixed.cpp | ||
RenderFixed.h | ||
Screen.cpp | ||
Screen.h | ||
ScreenSettings.h | ||
Script.cpp | ||
Script.h | ||
Scripts.cpp | ||
SoundSystem.cpp | ||
SoundSystem.h | ||
Spacestation2.cpp | ||
Spacestation2.h | ||
SteamNetwork.c | ||
TerminalScripts.cpp | ||
Textbox.cpp | ||
Textbox.h | ||
ThirdPartyDeps.c | ||
Tower.cpp | ||
Tower.h | ||
TowerBG.h | ||
UtilityClass.cpp | ||
UtilityClass.h | ||
Version.h | ||
Version.h.in | ||
WarpClass.cpp | ||
WarpClass.h | ||
XMLUtils.cpp | ||
XMLUtils.h |