mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-13 07:57:51 +00:00
- moved high level code out of i_time.cpp.
This commit is contained in:
parent
6049e806d1
commit
fabe772833
3 changed files with 28 additions and 26 deletions
|
@ -174,6 +174,26 @@ extern bool insave;
|
||||||
extern TDeletingArray<FLightDefaults *> LightDefaults;
|
extern TDeletingArray<FLightDefaults *> LightDefaults;
|
||||||
|
|
||||||
|
|
||||||
|
CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL)
|
||||||
|
{
|
||||||
|
if (netgame)
|
||||||
|
{
|
||||||
|
Printf("Time scale cannot be changed in net games.\n");
|
||||||
|
self = 1.0f;
|
||||||
|
}
|
||||||
|
else if (self >= 0.05f)
|
||||||
|
{
|
||||||
|
I_FreezeTime(true);
|
||||||
|
TimeScale = self;
|
||||||
|
I_FreezeTime(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Printf("Time scale must be at least 0.05!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
|
||||||
CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO)
|
CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO)
|
||||||
|
@ -2883,6 +2903,7 @@ static int D_DoomMain_Internal (void)
|
||||||
int D_DoomMain()
|
int D_DoomMain()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
GameTicRate = TICRATE;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = D_DoomMain_Internal();
|
ret = D_DoomMain_Internal();
|
||||||
|
|
|
@ -36,10 +36,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "doomdef.h"
|
|
||||||
#include "c_cvars.h"
|
|
||||||
#include "doomstat.h"
|
|
||||||
#include "doomtype.h"
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -50,27 +46,9 @@
|
||||||
static uint64_t FirstFrameStartTime;
|
static uint64_t FirstFrameStartTime;
|
||||||
static uint64_t CurrentFrameStartTime;
|
static uint64_t CurrentFrameStartTime;
|
||||||
static uint64_t FreezeTime;
|
static uint64_t FreezeTime;
|
||||||
|
int GameTicRate;
|
||||||
|
|
||||||
static double TimeScale = 1.0;
|
double TimeScale = 1.0;
|
||||||
|
|
||||||
CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL)
|
|
||||||
{
|
|
||||||
if (netgame)
|
|
||||||
{
|
|
||||||
Printf("Time scale cannot be changed in net games.\n");
|
|
||||||
self = 1.0f;
|
|
||||||
}
|
|
||||||
else if (self >= 0.05f)
|
|
||||||
{
|
|
||||||
I_FreezeTime(true);
|
|
||||||
TimeScale = self;
|
|
||||||
I_FreezeTime(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Printf("Time scale must be at least 0.05!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t GetClockTimeNS()
|
static uint64_t GetClockTimeNS()
|
||||||
{
|
{
|
||||||
|
@ -90,12 +68,12 @@ static uint64_t NSToMS(uint64_t ns)
|
||||||
|
|
||||||
static int NSToTic(uint64_t ns)
|
static int NSToTic(uint64_t ns)
|
||||||
{
|
{
|
||||||
return static_cast<int>(ns * TICRATE / 1'000'000'000);
|
return static_cast<int>(ns * GameTicRate / 1'000'000'000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t TicToNS(int tic)
|
static uint64_t TicToNS(int tic)
|
||||||
{
|
{
|
||||||
return static_cast<uint64_t>(tic) * 1'000'000'000 / TICRATE;
|
return static_cast<uint64_t>(tic) * 1'000'000'000 / GameTicRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_SetFrameTime()
|
void I_SetFrameTime()
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern int GameTicRate;
|
||||||
|
extern double TimeScale;
|
||||||
|
|
||||||
// Called by D_DoomLoop, sets the time for the current frame
|
// Called by D_DoomLoop, sets the time for the current frame
|
||||||
void I_SetFrameTime();
|
void I_SetFrameTime();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue