Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Typedefs | Functions | Variables
legacy_time.cpp File Reference
#include <ctype.h>
#include <time.h>
#include <chrono>
#include <thread>
#include <type_traits>
#include "inexor/util/legacy_time.hpp"

Typedefs

typedef std::chrono::steady_clock Clock
 

Functions

int scaletime (int time, int gamespeed)
 scale time with gametime: gamespeed default is 100. More...
 
int time_since_program_start ()
 real time in milliseconds since program start. More...
 
const char * gettimestr (const char *format, bool forcelowercase)
 Returns a string of the current time in the specified format. More...
 
void limitfps (int &millis, int curmillis, int fps_limit)
 Block for a specific time to limit frames per seconds to use resources intelligently. More...
 
void updatetime (bool is_paused, int gamespeed, int fps_limit)
 Updates the above global timing variables. More...
 

Variables

int curtime = 0
 
int lastmillis = 1
 
int elapsedtime = 0
 
int totalmillis = 1
 microtiming header More...
 
int gamemillis = 0
 
uint totalsecs = 0
 
static time_t systime = 0
 
static char timebuf [260]
 

Typedef Documentation

typedef std::chrono::steady_clock Clock

Function Documentation

const char* gettimestr ( const char *  format,
bool  forcelowercase 
)

Returns a string of the current time in the specified format.

References systime, timebuf, and totalmillis.

Referenced by gl_drawhud(), and screenshot().

void limitfps ( int &  millis,
int  curmillis,
int  fps_limit 
)

Block for a specific time to limit frames per seconds to use resources intelligently.

Parameters
max_fpsin case of limited fps we let this thread sleep for some milliseconds, if 0 everythings unlimited.
elapsed_timetime in real milliseconds since last updatetime();
Returns
We block inaccurately sometimes! So we give back the delay in milliseconds.

Referenced by updatetime().

int scaletime ( int  time,
int  gamespeed 
)

scale time with gametime: gamespeed default is 100.

Hence default return value would be t * 100.

Parameters
timein milliseconds.
gamespeedthere exist wall time and frame time: one is the virtual 'clock' for the game, the other one is scaled (and does not update when paused).

References game::gamespeed.

Referenced by physicsframe(), and updatetime().

int time_since_program_start ( )

real time in milliseconds since program start.

Referenced by recorder::gettime(), and updatetime().

void updatetime ( bool  is_paused,
int  gamespeed,
int  fps_limit = 0 
)

Updates the above global timing variables.

Parameters
is_pausedif true we won't update any frame times.
gamespeedthere exist wall time and frame time: one is the virtual 'clock' for the game, the other one is scaled (and does not update when paused).
fps_limitin case of limited fps we let this thread sleep for some milliseconds, if 0 everythings unlimited. TODO: encapsulate this into a class to make concurrency easier.

References curtime, elapsedtime, lastmillis, limitfps(), scaletime(), time_since_program_start(), totalmillis, and totalsecs.

Referenced by main(), and server::serverslice().

Variable Documentation

int curtime = 0
int elapsedtime = 0

Referenced by computezoom(), main(), and updatetime().

int gamemillis = 0
int lastmillis = 1

Referenced by aiman::addai(), decalrenderer::adddecal(), adddynlight(), addmotionblur(), listrenderer::addpart(), varenderer< T >::addpart(), addsleep(), ai::aiinfo::addstate(), game::captureclientmode::aidefend(), game::ctfclientmode::aidefend(), game::allowmove(), animategrass(), partrenderer::calc(), animmodel::part::calcanim(), dynlight::calccolor(), calcmodelpreviewpos(), dynlight::calcradius(), ai::canshoot(), server::changemap(), changetexgen(), game::checkattacksound(), server::checkmaps(), ai::checkroute(), skelmodel::skeleton::checkskelcache(), entities::checktriggers(), server::chooseworstteam(), cleardynlights(), decalrenderer::clearfadeddecals(), ai::aiinfo::clearsetup(), damageblend(), game::movable::damaged(), game::damaged(), game::deathstate(), game::collectclientmode::deposittokens(), server::collectservermode::deposittokens(), server::disconnect_client(), game::ctfclientmode::drawblip(), drawdamagescreen(), game::ctfclientmode::drawhud(), game::collectclientmode::drawhud(), game::captureclientmode::drawhud(), game::drawhudgun(), game::drawhudmodel(), drawskybox(), server::ctfservermode::dropflag(), game::ctfclientmode::dropflag(), game::collectclientmode::droptoken(), server::collectservermode::droptokens(), decalrenderer::fadeindecals(), decalrenderer::fadeoutdecals(), fireballrenderer::finddepthfxranges(), server::findscore(), server::forcespectator(), gengrassquads(), ai::getaimpos(), gl_drawframe(), ai::hastarget(), game::hit(), game::ctfclientmode::interpflagpos(), interppos(), game::ctfclientmode::invisflag(), ai::jumpto(), game::lighteffects(), ai::logic(), main(), flarerenderer::makelightflares(), ragdolldata::move(), moveragdoll(), game::moveragdolls(), game::newbouncer(), game::newprojectile(), game::otherplayers(), server::ctfservermode::parseflags(), game::parsemessages(), game::parsepositions(), game::collectclientmode::parsetokens(), physicsframe(), server::player_connected(), game::predictplayer(), ai::process(), game::receivefile(), vertmodel::vertmeshgroup::render(), animmodel::part::render(), animmodel::render(), ai::render(), skelmodel::skelmeshgroup::render(), renderbackground(), renderclient(), entities::renderentities(), game::captureclientmode::rendergame(), game::collectclientmode::rendergame(), game::ctfclientmode::rendergame(), game::rendergame(), renderlava(), renderlightning(), rendermaterials(), rendermodel(), fireballrenderer::renderpart(), game::renderplayer(), game::bombclientmode::renderplayersposindicator(), renderpostfx(), game::renderscoreboard(), rendervertwater(), renderwater(), game::respawn(), game::respawnself(), game::captureclientmode::respawnwait(), game::collectclientmode::respawnwait(), game::ctfclientmode::respawnwait(), game::saveragdoll(), server::ctfservermode::scoreflag(), game::selectcrosshair(), game::sendmap(), animmodel::animpos::setframes(), animmodel::skin::setshaderparams(), server::ctfservermode::setup(), ai::setup(), setupcaustics(), setupgeom(), setuplightning(), entities::setuptriggerflags(), game::shoot(), game::shoteffects(), game::collectclientmode::stealtoken(), game::suicide(), ai::aiinfo::switchstate(), game::ctfclientmode::takeflag(), server::ctfservermode::takeflag(), game::taunt(), ai::think(), ai::timeouts(), game::timeupdate(), entities::trypickup(), entities::unlocktriggers(), server::unspectate(), server::collectservermode::update(), server::ctfservermode::update(), varenderer< T >::update(), game::updatebouncers(), game::updatemovables(), updateparticles(), game::updateprojectiles(), updatetime(), game::updateworld(), and ai::violence().

time_t systime = 0
static

Referenced by gettimestr().

char timebuf[260]
static

Referenced by gettimestr().

int totalmillis = 1
uint totalsecs = 0