本文整理汇总了C++中Sys_DoubleTime函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_DoubleTime函数的具体用法?C++ Sys_DoubleTime怎么用?C++ Sys_DoubleTime使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sys_DoubleTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Slist_Poll
static void
Slist_Poll(void)
{
int i;
for (i = 0; i < net_numdrivers; i++) {
net_driver = &net_drivers[i];
/* Only list the loop driver if slistLocal is true */
if (!slistLocal && IS_LOOP_DRIVER(net_driver))
continue;
if (net_driver->initialized == false)
continue;
net_driver->SearchForHosts(false);
}
if (!slistSilent)
PrintSlist();
if ((Sys_DoubleTime() - slistStartTime) < 1.5) {
SchedulePollProcedure(&slistPollProcedure, 0.1);
return;
}
if (!slistSilent)
PrintSlistTrailer();
slistInProgress = false;
slistSilent = false;
slistLocal = true;
}
示例2: SCR_DrawFPS
void
SCR_DrawFPS (void)
{
static double lastframetime;
double t;
extern int fps_count;
static int lastfps;
int i, x, y;
char st[80];
if (!show_fps->int_val)
return;
t = Sys_DoubleTime ();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
snprintf (st, sizeof (st), "%3d FPS", lastfps);
// FIXME! This is evil. -- Deek
// calculate the location of the clock
if (show_time->int_val <= 0) {
i = 8;
} else if (show_time->int_val == 1) {
i = 56;
} else {
i = 80;
}
x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + i) : i;
y = vid.height - sb_lines - 8;
Draw_String8 (x, y, st);
}
示例3: AutoupdateProc
DWORD WINAPI AutoupdateProc(void * lpParameter)
{
double lastupdatetime = -1;
while (autoupdate_serverinfo)
{
double time = Sys_DoubleTime();
if ((sb_liveupdate.integer > 0) &&
time >= lastupdatetime + sb_liveupdate.integer &&
key_dest == key_menu /* todo: add "on server list tab" condition here */)
{
server_data *serv;
Sys_SemWait(&serverinfo_semaphore);
serv = autoupdate_server;
if (serv != NULL)
{
GetServerInfo(serv);
lastupdatetime = time;
}
Sys_SemPost(&serverinfo_semaphore);
}
Sys_MSleep(1000); // we don't need nor allow updates faster than 1 second anyway
}
return 0;
}
示例4: Receive
//===================================================================
// HL_ReceivePing()
//
// HL_ReceivePing computes server ping response time.
//===================================================================
void CHLAsyncSocket::HL_ReceivePing()
{
// Attempt to receive data
int iBytesRead;
iBytesRead = Receive(pMessageBuffer->GetData(), pMessageBuffer->GetMaxSize());
// Didn't receive anything, nothing to process
if (!iBytesRead)
return;
// Set buffer size appropriately
pMessageBuffer->SetCurSize(iBytesRead);
// Parse message buffer
int control;
pMessageBuffer->MSG_BeginReading();
control = pMessageBuffer->MSG_ReadLong();
if (control != -1)
return;
// Check message type and ignore if not appropriate
if (pMessageBuffer->MSG_ReadByte() != A2A_ACK)
return;
fRecTime = Sys_DoubleTime();
*m_pPingIndex = 1000.0 * (fRecTime - fSendTime);
}
示例5: SCR_DrawFPS
/*
==============
SCR_DrawFPS
==============
*/
void SCR_DrawFPS( void )
{
float calc;
rgba_t color;
static double nexttime = 0, lasttime = 0;
static double framerate = 0;
static int framecount = 0;
static int minfps = 9999;
static int maxfps = 0;
double newtime;
char fpsstring[64];
int offset;
if( cls.state != ca_active ) return;
if( !cl_showfps->integer || cl.background ) return;
switch( cls.scrshot_action )
{
case scrshot_normal:
case scrshot_snapshot:
case scrshot_inactive:
break;
default: return;
}
newtime = Sys_DoubleTime();
if( newtime >= nexttime )
{
framerate = framecount / (newtime - lasttime);
lasttime = newtime;
nexttime = max( nexttime + 1, lasttime - 1 );
framecount = 0;
}
framecount++;
calc = framerate;
if( calc == 0 ) return;
if( calc < 1.0f )
{
Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5f));
MakeRGBA( color, 255, 0, 0, 255 );
}
else
{
int curfps = (int)(calc + 0.5f);
if( curfps < minfps ) minfps = curfps;
if( curfps > maxfps ) maxfps = curfps;
if( cl_showfps->integer == 2 )
Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps );
else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps );
MakeRGBA( color, 255, 255, 255, 255 );
}
Con_DrawStringLen( fpsstring, &offset, NULL );
Con_DrawString( scr_width->integer - offset - 2, 4, fpsstring, color );
}
示例6: QRY_SV_PingReply
void QRY_SV_PingReply(void)
{
server_t *sv = NULL;
// ignore server ping reply since we do not query masters and can't keep server list up2date
if (!masters_query->integer)
{
Sys_DPrintf("server reply ignored\n");
return;
}
sv = QRY_SV_ByAddr(&net_from);
if (sv)
{
double current = Sys_DoubleTime();
double ping = current - sv->ping_sent_at;
sv->ping = (int)max(0, 1000.0 * ping);
sv->ping_reply_at = current;
sv->reply = true;
// Sys_Printf("ping <- %s:%d, %d\n", inet_ntoa(net_from.sin_addr), (int)ntohs(net_from.sin_port), sv->ping);
}
else
{
// Sys_Printf("ping <- %s:%d, not registered server\n", inet_ntoa(net_from.sin_addr), (int)ntohs(net_from.sin_port));
}
}
示例7: SCR_DrawFPS
void SCR_DrawFPS (void)
{
extern cvar_t show_fps;
static double lastframetime;
double t;
extern int fps_count;
static lastfps;
int x, y;
char st[80];
if (!show_fps.value)
return;
t = Sys_DoubleTime();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
sprintf(st, "%3d FPS", lastfps);
x = vid.width - strlen(st) * 8 - 8;
y = vid.height - sb_lines - 8;
// Draw_TileClear(x, y, strlen(st) * 8, 8);
Draw_String(x, y, st);
}
示例8: SCR_DrawFPS
void
SCR_DrawFPS (void)
{
static double lastframetime;
double t;
extern int fps_count;
static int lastfps;
int i, x, y;
char st[80];
if (!show_fps->int_val)
return;
t = Sys_DoubleTime ();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
snprintf (st, sizeof (st), "%3d FPS", lastfps);
/* Misty: New trick! (for me) the ? makes this work like a if then else -
IE: if cl_hudswap->int_val is not null, do first case, else (else is a
: here) do second case. Deek taught me this trick */
if (show_time->int_val <= 0) {
i = 8;
} else if (show_time->int_val == 1) {
i = 56;
} else {
i = 80;
}
x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + i) : i;
y = vid.height - (sb_lines + 8);
Draw_String8 (x, y, st);
}
示例9: main
int
main (int argc, const char *argv[])
{
int frame = 0;
COM_InitArgv (argc, argv);
qtv_init ();
Sys_Printf ("Ohayou gozaimasu\n");
while (1) {
Cbuf_Execute_Stack (qtv_cbuf);
Sys_CheckInput (1, net_socket);
realtime = Sys_DoubleTime () + 1;
qtv_read_packets ();
Con_ProcessInput ();
Server_Frame ();
Client_Frame ();
if (++frame == 100) {
frame = 0;
Con_DrawConsole ();
}
}
return 0;
}
示例10: _currentFPS
static double _currentFPS( void )
{
static double oldTime = 0;
static int mark = 0;
static double oldVal = 0;
double val;
double curTime = Sys_DoubleTime( );
double diff = curTime - oldTime;
if ( diff > 0.5 )
{
val = ( strobe.fCounter - mark ) / ( diff );
oldTime = curTime;
mark = strobe.fCounter;
}
else
{
val = oldVal;
}
oldVal = val;
if ( val < 0.0 )
val = 0.0;
return val;
}
示例11: IN_JoyKeyEvent
/*
================
IN_JoyKeyEvent
Sends a Key_Event if a unpressed -> pressed or pressed -> unpressed transition occurred,
and generates key repeats if the button is held down.
Adapted from DarkPlaces by lordhavoc
================
*/
static void IN_JoyKeyEvent(qboolean wasdown, qboolean isdown, int key, double *timer)
{
// we can't use `realtime` for key repeats because it is not monotomic
const double currenttime = Sys_DoubleTime();
if (wasdown)
{
if (isdown)
{
if (currenttime >= *timer)
{
*timer = currenttime + 0.1;
Key_Event(key, true);
}
}
else
{
*timer = 0;
Key_Event(key, false);
}
}
else
{
if (isdown)
{
*timer = currenttime + 0.5;
Key_Event(key, true);
}
}
}
示例12: Slist_Poll
static void Slist_Poll (void *unused)
{
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
continue;
if (net_drivers[net_driverlevel].initialized == false)
continue;
dfunc.SearchForHosts (false);
}
if (! slistSilent)
PrintSlist();
if ((Sys_DoubleTime() - slistStartTime) < 1.5)
{
SchedulePollProcedure(&slistPollProcedure, 0.1);
return;
}
if (! slistSilent)
PrintSlistTrailer();
slistInProgress = false;
slistSilent = false;
slistLocal = true;
}
示例13: SCR_DrawFPS
void SCR_DrawFPS (void)
{
extern cvar_t show_fps;
static double lastframetime;
double t;
extern int fps_count;
#if defined(__APPLE__) || defined(MACOSX)
static int lastfps;
#else
static lastfps;
#endif /* APPLE || MACOSX */
int x, y;
char st[80];
if (!show_fps.value)
return;
t = Sys_DoubleTime();
if ((t - lastframetime) >= 1.0) {
lastfps = fps_count;
fps_count = 0;
lastframetime = t;
}
#if defined (__APPLE__) || defined (MACOSX)
snprintf(st, 80, "%3d FPS", lastfps);
#else
sprintf(st, "%3d FPS", lastfps);
#endif /* __APPLE__ || MACOSX */
x = vid.width - ((int) strlen(st)) * 8 - 8;
y = vid.height - sb_lines - 8;
// Draw_TileClear(x, y, strlen(st) * 8, 8);
Draw_String(x, y, st);
}
示例14: main_real
static int main_real()
{
printf("Mounting drive\n");
{
FATFS fso;
FIL myfile;
int r;
memset(&fso, 0, sizeof(fso));
memset(&myfile, 0, sizeof(myfile));
r = f_mount(0, &fso);
if (r == 0)
printf("Succeeded\n");
else
printf("Failed\n");
}
{
double mytime, oldtime, newtime;
char *myargv[] = { "fodquake", 0 };
printf("Calling Host_Init()\n");
#if 0
cl.frames = malloc(sizeof(*cl.frames)*UPDATE_BACKUP);
memset(cl.frames, 0, sizeof(*cl.frames)*UPDATE_BACKUP);
#endif
Host_Init(1, myargv, 10*1024*1024);
oldtime = Sys_DoubleTime();
while(1)
{
newtime = Sys_DoubleTime();
mytime = newtime - oldtime;
oldtime = newtime;
Host_Frame(mytime);
}
Sys_Error("End of app");
return 0;
}
}
示例15: SDL_main
/*
main
*/
int
SDL_main (int c, char **v)
{
double time, oldtime, newtime;
int j;
#ifndef WIN32
signal (SIGFPE, SIG_IGN);
#endif
memset (&host_parms, 0, sizeof (host_parms));
COM_InitArgv (c, v);
host_parms.argc = com_argc;
host_parms.argv = com_argv;
host_parms.memsize = 16 * 1024 * 1024; // 16MB default heap
j = COM_CheckParm ("-mem");
if (j)
host_parms.memsize = (int) (atof (com_argv[j + 1]) * 1024 * 1024);
host_parms.membase = malloc (host_parms.memsize);
if (!host_parms.membase) {
printf ("Can't allocate memory for zone.\n");
return 1;
}
#ifndef WIN32
noconinput = COM_CheckParm ("-noconinput");
if (!noconinput)
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK);
#endif
Host_Init ();
oldtime = Sys_DoubleTime ();
while (1) {
// find time spent rendering last frame
newtime = Sys_DoubleTime ();
time = newtime - oldtime;
Host_Frame (time);
oldtime = newtime;
}
}