Skip to content

Commit

Permalink
Refactor: Moved the timer module to libdeng, renamed API functions
Browse files Browse the repository at this point in the history
The timer module's public functions are now named according to modern
practices.
  • Loading branch information
skyjake committed Nov 13, 2012
1 parent cdf6620 commit 8ac5480
Show file tree
Hide file tree
Showing 59 changed files with 253 additions and 235 deletions.
4 changes: 0 additions & 4 deletions doomsday/engine/api/dd_share.h
Expand Up @@ -1144,10 +1144,6 @@ typedef struct povertex_s {
//
//------------------------------------------------------------------------

#define TICRATE 35 // Number of tics / second.
#define TICSPERSEC 35
#define SECONDSPERTIC (1.0f/TICSPERSEC)

#define SCREENWIDTH 320
#define SCREENHEIGHT 200

Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/api/doomsday.def
Expand Up @@ -422,9 +422,9 @@ EXPORTS
B_SetContextFallback @440 NONAME
; System.
; Sys_TicksPerSecond @46 NONAME
Sys_GetTime @47 NONAME
Sys_GetSeconds @48 NONAME
Sys_GetRealTime @49 NONAME
; Sys_GetTime @47 NONAME
; Sys_GetSeconds @48 NONAME
; Timer_RealMilliseconds @49 NONAME
Sys_Sleep @50 NONAME
Sys_CriticalMessage @51 NONAME
Sys_Quit @52 NONAME
Expand Down
4 changes: 0 additions & 4 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -303,10 +303,6 @@ int DD_Executef(int silent, char const* command, ...);
* Functionality provided by or related to the operating system.
*/
///@{
void Sys_TicksPerSecond(float num);
int Sys_GetTime(void);
double Sys_GetSeconds(void);
uint Sys_GetRealTime(void);
void Sys_Sleep(int millisecs);
int Sys_CriticalMessage(char* msg);
void Sys_Quit(void);
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/engine.pro
Expand Up @@ -323,7 +323,6 @@ DENG_HEADERS += \
include/sys_system.h \
include/tab_anorms.h \
include/texturecontent.h \
include/timer.h \
include/ui/b_command.h \
include/ui/b_context.h \
include/ui/b_device.h \
Expand Down Expand Up @@ -609,7 +608,6 @@ SOURCES += \
src/sys_reslocator.cpp \
src/sys_system.c \
src/tab_tables.c \
src/timer.cpp \
src/ui/b_command.c \
src/ui/b_context.c \
src/ui/b_device.c \
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/include/de_system.h
Expand Up @@ -26,13 +26,13 @@
#define LIBDENG_SYSTEM_H

#include <de/concurrency.h>
#include <de/timer.h>

#include "sys_system.h"
#include "sys_console.h"
#include "ui/sys_input.h"
#include "network/sys_network.h"
#include "network/masterserver.h"
#include "timer.h"
#include "sys_opengl.h"

// Use SDL for window management under *nix
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/include/m_profiler.h
Expand Up @@ -30,7 +30,7 @@
#define __DOOMSDAY_MISC_PROFILER_H__

#include "dd_types.h"
#include "timer.h"
#include "de/timer.h"

/*
* This header defines some handy macros for profiling.
Expand All @@ -47,8 +47,8 @@ typedef struct profiler_s {

#ifdef DD_PROFILE // Profiling is enabled.
# define END_PROF_TIMERS() ,NUM_PROFS }; static profiler_t profiler_[NUM_PROFS];
# define BEGIN_PROF(x) (profiler_[x].startCount++, profiler_[x].startTime = Sys_GetRealTime())
# define END_PROF(x) (profiler_[x].totalTime += Sys_GetRealTime() - profiler_[x].startTime)
# define BEGIN_PROF(x) (profiler_[x].startCount++, profiler_[x].startTime = Timer_RealMilliseconds())
# define END_PROF(x) (profiler_[x].totalTime += Timer_RealMilliseconds() - profiler_[x].startTime)
# define PRINT_PROF(x) Con_Message("[%f ms] " #x ": %i ms (%i starts)\n", \
profiler_[x].startCount? profiler_[x].totalTime / \
(float) profiler_[x].startCount : 0, \
Expand Down
44 changes: 0 additions & 44 deletions doomsday/engine/include/timer.h

This file was deleted.

4 changes: 2 additions & 2 deletions doomsday/engine/src/audio/s_cache.c
Expand Up @@ -441,7 +441,7 @@ void Sfx_PurgeCache(void)

int totalSize = 0, maxSize = sfxMaxCacheKB * 1024;
sfxcache_t* it, *next, *lowest;
int i, lowHits = 0, nowTime = Sys_GetTime();
int i, lowHits = 0, nowTime = Timer_Ticks();

if(!sfxAvail)
return;
Expand Down Expand Up @@ -531,7 +531,7 @@ void Sfx_CacheHit(int id)
if(node)
{
node->hits++;
node->lastUsed = Sys_GetTime();
node->lastUsed = Timer_Ticks();
}
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/audio/s_environ.cpp
Expand Up @@ -201,7 +201,7 @@ static void findBspLeafsAffectingSector(GameMap* map, uint secIDX)

void S_DetermineBspLeafsAffectingSectorReverb(GameMap* map)
{
uint startTime = Sys_GetRealTime();
uint startTime = Timer_RealMilliseconds();

/// @todo optimize: Make use of the BSP leaf blockmap.
uint numSectors = GameMap_SectorCount(map);
Expand All @@ -214,7 +214,7 @@ void S_DetermineBspLeafsAffectingSectorReverb(GameMap* map)

// How much time did we spend?
LOG_VERBOSE("S_DetermineBspLeafsAffectingSectorReverb: Done in %.2f seconds.")
<< (Sys_GetRealTime() - startTime) / 1000.0f;
<< (Timer_RealMilliseconds() - startTime) / 1000.0f;
}

static boolean calcBspLeafReverb(BspLeaf* bspLeaf)
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/src/audio/s_logic.c
Expand Up @@ -38,7 +38,7 @@
#include "de_console.h"
#include "de_audio.h"

#include "timer.h"
#include "de/timer.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -163,7 +163,7 @@ void Sfx_StartLogical(int id, mobj_t *origin, boolean isRepeating)
node = Sfx_CreateLogical(id);
node->origin = origin;
node->isRepeating = isRepeating;
node->endTime = Sys_GetRealTime() + length;
node->endTime = Timer_RealMilliseconds() + length;
}

/*
Expand Down Expand Up @@ -217,7 +217,7 @@ int Sfx_StopLogical(int id, mobj_t *origin)
void Sfx_PurgeLogical(void)
{
static uint lastTime = 0;
uint i, nowTime = Sys_GetRealTime();
uint i, nowTime = Timer_RealMilliseconds();
logicsound_t *it, *next;

if(nowTime - lastTime < PURGE_INTERVAL)
Expand Down Expand Up @@ -255,7 +255,7 @@ void Sfx_PurgeLogical(void)
*/
boolean Sfx_IsPlaying(int id, mobj_t *origin)
{
uint nowTime = Sys_GetRealTime();
uint nowTime = Timer_RealMilliseconds();
logicsound_t *it;
int i;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/audio/s_sfx.c
Expand Up @@ -339,7 +339,7 @@ int Sfx_CountPlaying(int id)
float Sfx_Priority(mobj_t* emitter, coord_t* point, float volume, int startTic)
{
// In five seconds all priority of a sound is gone.
float timeoff = 1000 * (Sys_GetTime() - startTic) / (5.0f * TICSPERSEC);
float timeoff = 1000 * (Timer_Ticks() - startTic) / (5.0f * TICSPERSEC);
coord_t* origin;

if(!listener || (!emitter && !point))
Expand Down Expand Up @@ -678,7 +678,7 @@ int Sfx_StartSound(sfxsample_t* sample, float volume, float freq,
}

// Calculate the new sound's priority.
nowTime = Sys_GetTime();
nowTime = Timer_Ticks();
myPrio = Sfx_Priority(emitter, fixedOrigin, volume, nowTime);

// Ensure there aren't already too many channels playing this sample.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/audio/sys_audiod_dummy.c
Expand Up @@ -220,7 +220,7 @@ void DS_Dummy_SFX_Play(sfxbuffer_t* buf)
if(!(buf->flags & SFXBF_PLAYING))
{
// Calculate the end time (milliseconds).
buf->endTime = Sys_GetRealTime() + DS_DummyBufferLength(buf);
buf->endTime = Timer_RealMilliseconds() + DS_DummyBufferLength(buf);
}

// The buffer is now playing.
Expand Down Expand Up @@ -250,7 +250,7 @@ void DS_Dummy_SFX_Refresh(sfxbuffer_t* buf)
return;

// Have we passed the predicted end of sample?
if(!(buf->flags & SFXBF_REPEAT) && Sys_GetRealTime() >= buf->endTime)
if(!(buf->flags & SFXBF_REPEAT) && Timer_RealMilliseconds() >= buf->endTime)
{
// Time for the sound to stop.
DS_Dummy_SFX_Stop(buf);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/audio/sys_audiod_sdlmixer.c
Expand Up @@ -392,7 +392,7 @@ void DS_SDLMixer_SFX_Play(sfxbuffer_t* buf)
Mix_PlayChannel(buf->cursor, buf->ptr, (buf->flags & SFXBF_REPEAT ? -1 : 0));

// Calculate the end time (milliseconds).
buf->endTime = Sys_GetRealTime() + getBufLength(buf);
buf->endTime = Timer_RealMilliseconds() + getBufLength(buf);

// The buffer is now playing.
buf->flags |= SFXBF_PLAYING;
Expand All @@ -416,7 +416,7 @@ void DS_SDLMixer_SFX_Refresh(sfxbuffer_t* buf)
if(!buf || !buf->sample || !(buf->flags & SFXBF_PLAYING))
return;

nowTime = Sys_GetRealTime();
nowTime = Timer_RealMilliseconds();

/**
* Have we passed the predicted end of sample?
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/busymode.cpp
Expand Up @@ -146,7 +146,7 @@ static void beginTask(BusyTask* task)

Window_SetDrawFunc(Window_Main(), BusyVisual_Render);

busyTask->_startTime = Sys_GetRealSeconds();
busyTask->_startTime = Timer_RealSeconds();
}

/**
Expand Down Expand Up @@ -440,7 +440,7 @@ static void BusyMode_Loop(void)
// We accumulate time in the busy loop so that the animation of a task
// sequence doesn't jump around but remains continuous.
oldTime = busyTime;
busyTime = Sys_GetRealSeconds() - busyTask->_startTime;
busyTime = Timer_RealSeconds() - busyTask->_startTime;
if(busyTime > oldTime)
{
accumulatedBusyTime += busyTime - oldTime;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/src/client/cl_main.c
Expand Up @@ -93,7 +93,7 @@ void Cl_InitID(void)
}
// Ah-ha, we need to generate a new ID.
clientID = (ident_t)
ULONG(Sys_GetRealTime() * rand() + (rand() & 0xfff) +
ULONG(Timer_RealMilliseconds() * rand() + (rand() & 0xfff) +
((rand() & 0xfff) << 12) + ((rand() & 0xff) << 24));
// Write it to the file.
if((file = fopen("client.id", "wb")) != NULL)
Expand Down
10 changes: 5 additions & 5 deletions doomsday/engine/src/client/cl_mobj.c
Expand Up @@ -397,7 +397,7 @@ void GameMap_ClMobjReset(GameMap* map)

void GameMap_ExpireClMobjs(GameMap* map)
{
uint nowTime = Sys_GetRealTime();
uint nowTime = Timer_RealMilliseconds();
clmoinfo_t* info;
clmoinfo_t* next = 0;
mobj_t* mo;
Expand Down Expand Up @@ -451,7 +451,7 @@ void Cl_PredictMovement(void)
clmobj_t *cmo, *next = NULL;
int i;
int moCount = 0;
uint nowTime = Sys_GetRealTime();
uint nowTime = Timer_RealMilliseconds();

predicted_tics++;

Expand Down Expand Up @@ -550,7 +550,7 @@ mobj_t* ClMobj_Create(thid_t id)
mo = (mobj_t*) ((char*)data + sizeof(clmoinfo_t));

// Initialize the data.
info->time = Sys_GetRealTime();
info->time = Timer_RealMilliseconds();
info->startMagic = CLM_MAGIC1;
info->endMagic = CLM_MAGIC2;
mo->ddFlags = DDMF_REMOTE;
Expand Down Expand Up @@ -793,7 +793,7 @@ void ClMobj_ReadDelta2(boolean skip)
info->flags &= ~CLMF_UNPREDICTABLE;

// This clmobj is evidently alive.
info->time = Sys_GetRealTime();
info->time = Timer_RealMilliseconds();
}

d = mo;
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void ClMobj_ReadNullDelta2(boolean skip)

// This'll allow playing sounds from the mobj for a little while.
// The mobj will soon time out and be permanently removed.
info->time = Sys_GetRealTime();
info->time = Timer_RealMilliseconds();
info->flags |= CLMF_UNPREDICTABLE | CLMF_NULLED;

#ifdef _DEBUG
Expand Down
6 changes: 3 additions & 3 deletions doomsday/engine/src/con_bar.c
Expand Up @@ -79,7 +79,7 @@ void Con_ShutdownProgress(void)

static int currentProgress(void)
{
timespan_t nowTime = Sys_GetRealSeconds();
timespan_t nowTime = Timer_RealSeconds();
timespan_t span = target.time - last.time;

if(nowTime >= target.time || span <= 0)
Expand All @@ -99,7 +99,7 @@ boolean Con_IsProgressAnimationCompleted(void)
boolean done;

lockProgress(true);
done = (Sys_GetRealSeconds() >= target.time);
done = (Timer_RealSeconds() >= target.time);
lockProgress(false);

return done;
Expand All @@ -112,7 +112,7 @@ void Con_SetProgress(int progress)
lockProgress(true);

// Continue animation from the current value.
nowTime = Sys_GetRealSeconds();
nowTime = Timer_RealSeconds();
last.value = currentProgress();
last.time = nowTime;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/dd_help.c
Expand Up @@ -294,7 +294,7 @@ void DD_InitHelp(void)
if(helpInited) return; // Already inited.

VERBOSE( Con_Message("Initializing Help subsystem...\n") )
starttime = (verbose >= 2? Sys_GetSeconds() : 0);
starttime = (verbose >= 2? Timer_Seconds() : 0);

// Init the links.
helpRoot.next = helpRoot.prev = &helpRoot;
Expand All @@ -312,7 +312,7 @@ void DD_InitHelp(void)
// Help is now available.
helpInited = true;

VERBOSE2( Con_Message("DD_InitHelp: Done in %.2f seconds.\n", Sys_GetSeconds() - starttime) );
VERBOSE2( Con_Message("DD_InitHelp: Done in %.2f seconds.\n", Timer_Seconds() - starttime) );
}

/**
Expand Down

0 comments on commit 8ac5480

Please sign in to comment.