当前位置: 首页>>代码示例>>C++>>正文


C++ Sys_DoubleTime函数代码示例

本文整理汇总了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;
}
开发者ID:MP2E,项目名称:tyrquake,代码行数:30,代码来源:net_main.c

示例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);
}
开发者ID:luaman,项目名称:qforge-newtree,代码行数:35,代码来源:gl_screen.c

示例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;
}
开发者ID:Classic-Fortress,项目名称:client,代码行数:28,代码来源:EX_browser_net.c

示例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);
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:33,代码来源:HLAsyncSocket.cpp

示例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 );
}
开发者ID:DeadZoneLuna,项目名称:xash3d,代码行数:65,代码来源:cl_scrn.c

示例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));
	}
}
开发者ID:deurk,项目名称:qwfwd,代码行数:29,代码来源:query.c

示例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);
}
开发者ID:strelkovsky,项目名称:QuakeRefresh,代码行数:26,代码来源:gl_screen.c

示例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);
}
开发者ID:luaman,项目名称:qforge-newtree,代码行数:34,代码来源:screen.c

示例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;
}
开发者ID:EIREXE,项目名称:Quakeforge-gcw0,代码行数:31,代码来源:qtv.c

示例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;
}
开发者ID:jeefo,项目名称:xash3d,代码行数:28,代码来源:gl_rstrobe.c

示例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);
		}
	}
}
开发者ID:aonorin,项目名称:vkQuake,代码行数:40,代码来源:in_sdl.c

示例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;
}
开发者ID:ACIIL,项目名称:Quakespasm-Rift,代码行数:26,代码来源:net_main.c

示例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);
}
开发者ID:MaddTheSane,项目名称:Quake,代码行数:34,代码来源:screen.c

示例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;
	}
}
开发者ID:classicQ,项目名称:classicQ.github.io,代码行数:47,代码来源:sys_wii.c

示例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;
	}
}
开发者ID:luaman,项目名称:qforge-newtree,代码行数:49,代码来源:cl_sys_sdl.c


注:本文中的Sys_DoubleTime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。