forked from rosebudai/OpenRCT2-Web
Fix game not allowing to catch up if rendering is slow.
Refactored game_update to use the given parameters from context.
This commit is contained in:
1 parent
c11e925f40
commit
ad4eaff323
4 files changed
+26
-26
No files matched your search
+10
-18
@@ -25,6 +25,7 @@
|
||||
#include "core/FileScanner.h"
|
||||
#include "core/FileStream.hpp"
|
||||
#include "core/Guard.hpp"
|
||||
#include "core/Math.hpp"
|
||||
#include "core/MemoryStream.h"
|
||||
#include "core/Path.hpp"
|
||||
#include "core/String.hpp"
|
||||
@@ -361,7 +362,7 @@ namespace OpenRCT2
|
||||
}
|
||||
network_begin_server(gNetworkStartPort, gNetworkStartAddress);
|
||||
}
|
||||
#endif // DISABLE_NETWORK
|
||||
#endif // DISABLE_NETWORK
|
||||
break;
|
||||
}
|
||||
case STARTUP_ACTION_EDIT:
|
||||
@@ -442,23 +443,18 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
uint32 elapsed = currentTick - _lastTick;
|
||||
if (elapsed > UPDATE_TIME_MS)
|
||||
{
|
||||
elapsed = UPDATE_TIME_MS;
|
||||
}
|
||||
|
||||
_lastTick = currentTick;
|
||||
_accumulator += elapsed;
|
||||
_accumulator = Math::Min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
|
||||
|
||||
_uiContext->ProcessMessages();
|
||||
|
||||
if (_accumulator < UPDATE_TIME_MS)
|
||||
if (_accumulator < GAME_UPDATE_TIME_MS)
|
||||
{
|
||||
platform_sleep(UPDATE_TIME_MS - _accumulator - 1);
|
||||
platform_sleep(GAME_UPDATE_TIME_MS - _accumulator - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
_accumulator -= UPDATE_TIME_MS;
|
||||
_accumulator -= GAME_UPDATE_TIME_MS;
|
||||
|
||||
Update();
|
||||
if (!_isWindowMinimised && !gOpenRCT2Headless)
|
||||
@@ -480,17 +476,13 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
uint32 elapsed = currentTick - _lastTick;
|
||||
if (elapsed > UPDATE_TIME_MS)
|
||||
{
|
||||
elapsed = UPDATE_TIME_MS;
|
||||
}
|
||||
|
||||
_lastTick = currentTick;
|
||||
_accumulator += elapsed;
|
||||
_accumulator = Math::Min(_accumulator + elapsed, (uint32)GAME_UPDATE_MAX_THRESHOLD);
|
||||
|
||||
_uiContext->ProcessMessages();
|
||||
|
||||
while (_accumulator >= UPDATE_TIME_MS)
|
||||
while (_accumulator >= GAME_UPDATE_TIME_MS)
|
||||
{
|
||||
// Get the original position of each sprite
|
||||
if(draw)
|
||||
@@ -498,7 +490,7 @@ namespace OpenRCT2
|
||||
|
||||
Update();
|
||||
|
||||
_accumulator -= UPDATE_TIME_MS;
|
||||
_accumulator -= GAME_UPDATE_TIME_MS;
|
||||
|
||||
// Get the next position of each sprite
|
||||
if(draw)
|
||||
@@ -507,7 +499,7 @@ namespace OpenRCT2
|
||||
|
||||
if (draw)
|
||||
{
|
||||
const float alpha = (float)_accumulator / UPDATE_TIME_MS;
|
||||
const float alpha = (float)_accumulator / GAME_UPDATE_TIME_MS;
|
||||
sprite_position_tween_all(alpha);
|
||||
|
||||
drawing_engine_draw();
|
||||
|
||||
Reference in new issue
Block a user