mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-12 23:54:37 +00:00
- gameclock abstraction
This may need more work to have a reliable timer
This commit is contained in:
parent
7684f9e3e6
commit
007c6e122d
5 changed files with 20 additions and 8 deletions
|
@ -96,7 +96,8 @@ GameInterface* gi;
|
||||||
int myconnectindex, numplayers;
|
int myconnectindex, numplayers;
|
||||||
int connecthead, connectpoint2[MAXMULTIPLAYERS];
|
int connecthead, connectpoint2[MAXMULTIPLAYERS];
|
||||||
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
|
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
|
||||||
int gameclock, gameclockstart;
|
int gameclock;
|
||||||
|
uint64_t gameclockstart;
|
||||||
int lastTic;
|
int lastTic;
|
||||||
|
|
||||||
int automapMode;
|
int automapMode;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "name.h"
|
#include "name.h"
|
||||||
#include "memarena.h"
|
#include "memarena.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
#include "i_time.h"
|
||||||
|
|
||||||
extern FString currentGame;
|
extern FString currentGame;
|
||||||
extern FString LumpFilter;
|
extern FString LumpFilter;
|
||||||
|
@ -223,5 +224,16 @@ extern int automapMode;
|
||||||
extern bool automapFollow;
|
extern bool automapFollow;
|
||||||
extern bool sendPause;
|
extern bool sendPause;
|
||||||
extern int gameclock;
|
extern int gameclock;
|
||||||
extern int gameclockstart;
|
extern uint64_t gameclockstart;
|
||||||
extern int lastTic;
|
extern int lastTic;
|
||||||
|
|
||||||
|
inline void setGameClockStart()
|
||||||
|
{
|
||||||
|
gameclockstart = I_GetTimeNS();
|
||||||
|
gameclock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void updateGameClock()
|
||||||
|
{
|
||||||
|
gameclock = static_cast<int>((I_GetTimeNS() - gameclockstart) * 120 / 1'000'000'000);
|
||||||
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ static void GameTicker()
|
||||||
case GS_LEVEL:
|
case GS_LEVEL:
|
||||||
gameupdatetime.Reset();
|
gameupdatetime.Reset();
|
||||||
gameupdatetime.Clock();
|
gameupdatetime.Clock();
|
||||||
gameclock = I_GetBuildTime() - gameclockstart;
|
updateGameClock();
|
||||||
gi->Ticker();
|
gi->Ticker();
|
||||||
gameupdatetime.Unclock();
|
gameupdatetime.Unclock();
|
||||||
break;
|
break;
|
||||||
|
@ -248,7 +248,7 @@ void Display()
|
||||||
twod->Clear();
|
twod->Clear();
|
||||||
twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
twod->SetSize(screen->GetWidth(), screen->GetHeight());
|
||||||
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
|
||||||
gameclock = I_GetBuildTime() - gameclockstart;
|
updateGameClock();
|
||||||
gi->Render();
|
gi->Render();
|
||||||
DrawFullscreenBlends();
|
DrawFullscreenBlends();
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,8 +119,7 @@ void GameInterface::Ticker()
|
||||||
void resetGameClock()
|
void resetGameClock()
|
||||||
{
|
{
|
||||||
I_SetFrameTime();
|
I_SetFrameTime();
|
||||||
gameclockstart = I_GetBuildTime();
|
setGameClockStart();
|
||||||
gameclock = 0;
|
|
||||||
cloudclock = 0;
|
cloudclock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -728,7 +728,7 @@ void GameTicker(void)
|
||||||
ready2send = 1;
|
ready2send = 1;
|
||||||
|
|
||||||
int const currentTic = I_GetTime();
|
int const currentTic = I_GetTime();
|
||||||
gameclock = I_GetBuildTime() - gameclockstart;
|
updateGameClock();
|
||||||
|
|
||||||
if (paused)
|
if (paused)
|
||||||
{
|
{
|
||||||
|
@ -775,7 +775,7 @@ void GameTicker(void)
|
||||||
void resetGameClock()
|
void resetGameClock()
|
||||||
{
|
{
|
||||||
I_SetFrameTime();
|
I_SetFrameTime();
|
||||||
gameclockstart = I_GetBuildTime();
|
setGameClockStart();
|
||||||
ogameclock = gameclock = 0;
|
ogameclock = gameclock = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue