Exemple #1
0
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;
}
Exemple #2
0
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);
}
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;
}
//===================================================================
// 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);
}
Exemple #5
0
void SCR_DrawFPS (void)
{
	static double lastframetime;
	double t;
	extern int fps_count;
	static int lastfps;
	int x, y;
	char st[80];

	if (!show_fps.value)
		return;

	RB_SetCanvas (CANVAS_BOTTOMRIGHT);

	t = Sys_DoubleTime();
	if ((t - lastframetime) >= 1.0) {
		lastfps = fps_count / (t - lastframetime) + 0.5;
		fps_count = 0;
		lastframetime = t;
	}

	sprintf(st, "%3d FPS", lastfps);
	x = 320 - (strlen(st)<<3);
	y = 200 - 8;
	R_DrawString(x, y, st);
}
Exemple #6
0
/*
==============
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 );
}
Exemple #7
0
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));
	}
}
Exemple #8
0
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);
}
Exemple #9
0
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);
}
Exemple #10
0
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;
}
Exemple #11
0
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;
}
Exemple #12
0
/*
================
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);
		}
	}
}
Exemple #13
0
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;
}
Exemple #14
0
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);
}
Exemple #15
0
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;
	}
}
Exemple #16
0
/*
	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;
	}
}
Exemple #17
0
/*
==================
Host_ClientFrame

==================
*/
void Host_ClientFrame( void )
{
	// if client is not active, do nothing
	if( !cls.initialized ) return;

	// decide the simulation time
	cl.oldtime = cl.time;
	cl.time += host.frametime;

	if( menu.hInstance )
	{
		// menu time (not paused, not clamped)
		menu.globals->time = host.realtime;
		menu.globals->frametime = host.realframetime;
		menu.globals->demoplayback = cls.demoplayback;
		menu.globals->demorecording = cls.demorecording;
	}

	// if in the debugger last frame, don't timeout
	if( host.frametime > 5.0f ) cls.netchan.last_received = Sys_DoubleTime();

	VGui_RunFrame ();

	clgame.dllFuncs.pfnFrame( host.frametime );

	// fetch results from server
	CL_ReadPackets();

	VID_CheckChanges();

	// allow sound and video DLL change
	if( cls.state == ca_active )
	{
		if( !cl.video_prepped ) CL_PrepVideo();
		if( !cl.audio_prepped ) CL_PrepSound();
	}

	// update the screen
	SCR_UpdateScreen ();

	// update audio
	S_RenderFrame( &cl.refdef );

	// send a new command message to the server
	CL_SendCommand();

	// predict all unacknowledged movements
	CL_PredictMovement();

	// decay dynamic lights
	CL_DecayLights ();

	SCR_RunCinematic();
	Con_RunConsole();

	cls.framecount++;
}
Exemple #18
0
void TTY_Close(int handle)
{
	ComPort	*p;
	double		startTime;

	p = handleToPort [handle];

	startTime = Sys_DoubleTime();
	while ((Sys_DoubleTime() - startTime) < 1.0)
		if (EMPTY(p->outputQueue))
			break;

	if (p->useModem)
	{
		if (p->modemConnected)
			Modem_Hangup(p);
	}
}
Exemple #19
0
/*
==================
SCR_ModalMessage

Displays a text string in the center of the screen and waits for a Y or N
keypress.
==================
*/
int SCR_ModalMessage (const char *text, float timeout) //johnfitz -- timeout
{
	double time1, time2; //johnfitz -- timeout
	int lastkey, lastchar;

	if (cls.state == ca_dedicated)
		return true;

	scr_notifystring = text;

// draw a fresh screen
	scr_drawdialog = true;
	SCR_UpdateScreen ();
	scr_drawdialog = false;

	S_ClearBuffer ();		// so dma doesn't loop current sound

	time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout
	time2 = 0.0f; //johnfitz -- timeout

	Key_BeginInputGrab ();
	do
	{
		Sys_SendKeyEvents ();
		Key_GetGrabbedInput (&lastkey, &lastchar);
		Sys_Sleep (16);
		if (timeout) time2 = Sys_DoubleTime (); //johnfitz -- zero timeout means wait forever.
	} while (lastchar != 'y' && lastchar != 'Y' &&
		 lastchar != 'n' && lastchar != 'N' &&
		 lastkey != K_ESCAPE &&
		 lastkey != K_ABUTTON &&
		 lastkey != K_BBUTTON &&
		 time2 <= time1);
	Key_EndInputGrab ();

//	SCR_UpdateScreen (); //johnfitz -- commented out

	//johnfitz -- timeout
	if (time2 > time1)
		return false;
	//johnfitz

	return (lastchar == 'y' || lastchar == 'Y' || lastkey == K_ABUTTON);
}
Exemple #20
0
/*
=================
CL_CheckForResend

Resend a connect message if the last one has timed out
=================
*/
void CL_CheckForResend (void)
{
	char	data[2048];
	double t1, t2;

	if (cls.state == ca_disconnected && com_serveractive) {
		// if the local server is running and we are not, then connect
		cls.nqprotocol = false;
		strlcpy (cls.servername, "local", sizeof(cls.servername));
		NET_StringToAdr ("local", &cls.server_adr);
		CL_SendConnectPacket ();	// we don't need a challenge on the local server
		// FIXME: cls.state = ca_connecting so that we don't send the packet twice?
		return;
	}

	if (cls.state != ca_disconnected || !connect_time)
		return;
	if (cls.realtime - connect_time < 5.0)
		return;

	t1 = Sys_DoubleTime ();
	if (!NET_StringToAdr (cls.servername, &cls.server_adr))
	{
		Com_Printf ("Bad server address\n");
		connect_time = 0;
		return;
	}
	t2 = Sys_DoubleTime ();
	connect_time = cls.realtime + t2 - t1;	// for retransmit requests

	if (cls.server_adr.port == 0)
		cls.server_adr.port = BigShort (cls.nqprotocol ? 26000 : PORT_SERVER);

	Com_Printf ("Connecting to %s...\n", cls.servername);

	if (cls.nqprotocol) {
		memcpy (data, "\x80\x00\x00\x0C" "\x01" "QUAKE\x00" "\x03", 12);
		NET_SendPacket (NS_CLIENT, 12, data, cls.server_adr);
	}
	else {
		sprintf (data, "\xff\xff\xff\xff" "getchallenge\n");
		NET_SendPacket (NS_CLIENT, strlen(data), data, cls.server_adr);
	}
}
Exemple #21
0
/*
=======================
CL_SendConnectPacket

called by CL_Connect_f and CL_CheckResend
======================
*/
void CL_SendConnectPacket (void)
{
	netadr_t	adr;
	char	data[2048];
	double t1, t2;
// JACK: Fixed bug where DNS lookups would cause two connects real fast
//       Now, adds lookup time to the connect time.
//		 Should I add it to realtime instead?!?!

	if (cls.state != ca_disconnected)
		return;

	t1 = Sys_DoubleTime ();

	if (!NET_StringToAdr (cls.servername, &adr))
	{
		Con_Printf ("Bad server address\n");
		connect_time = -1;
		return;
	}

	if (!NET_IsClientLegal(&adr))
	{
		Con_Printf ("Illegal server address\n");
		connect_time = -1;
		return;
	}

	if (adr.port == 0)
		adr.port = BigShort (27500);
	t2 = Sys_DoubleTime ();

	connect_time = realtime+t2-t1;	// for retransmit requests

	cls.qport = Cvar_VariableValue("qport");

	Info_SetValueForStarKey (cls.userinfo, "*ip", NET_AdrToString(adr), MAX_INFO_STRING);

	//Con_Printf ("Connecting to %s...\n", cls.servername);
	sprintf (data, "%c%c%c%cconnect %i %i %i \"%s\"\n",
		255, 255, 255, 255,	PROTOCOL_VERSION, cls.qport, cls.challenge, cls.userinfo);
	NET_SendPacket (strlen(data), data, adr);
}
Exemple #22
0
/*
==================
SCR_ModalMessage

Displays a text string in the center of the screen and waits for a Y or N
keypress.
==================
*/
int SCR_ModalMessage (const char *text, float timeout) //johnfitz -- timeout
{
	double time1, time2; //johnfitz -- timeout

	if (cls.state == ca_dedicated)
		return true;

	scr_notifystring = text;

// draw a fresh screen
	scr_drawdialog = true;
	SCR_UpdateScreen ();
	scr_drawdialog = false;

	S_ClearBuffer ();		// so dma doesn't loop current sound

	time1 = Sys_DoubleTime () + timeout; //johnfitz -- timeout
	time2 = 0.0f; //johnfitz -- timeout

	do
	{
		key_count = -1;		// wait for a key down and up
		Sys_SendKeyEvents ();
		Sys_Sleep(16);
		if (timeout) time2 = Sys_DoubleTime (); //johnfitz -- zero timeout means wait forever.
	} while (key_lastpress != 'y' &&
			 key_lastpress != 'n' &&
			 key_lastpress != K_ESCAPE &&
			 time2 <= time1);

	// make sure we don't ignore the next keypress
	if (key_count < 0)
		key_count = 0;

//	SCR_UpdateScreen (); //johnfitz -- commented out

	//johnfitz -- timeout
	if (time2 > time1)
		return false;
	//johnfitz

	return key_lastpress == 'y';
}
void AndroidStep()
{
	double time, newtime;
	// find time spent rendering last frame
	newtime = Sys_DoubleTime ();
	time = newtime - g_oldtime;

	Host_Frame(time);
	g_oldtime = newtime;
}
Exemple #24
0
/* Pauses execution for a specified number
of seconds */
static void
Cmd_Sleep_f (void)
{
	double waittime;
	cbuf_t *p;
	cbuf_active->state = CBUF_STATE_WAIT;
	waittime = atof (Cmd_Argv (1));
	for (p = cbuf_active; p->up; p = p->up); // Get to top of stack
	p->resumetime = Sys_DoubleTime() + waittime;
}
Exemple #25
0
void IN_SMouseShutdown(void)
{
	double start = Sys_DoubleTime();

	if (!use_m_smooth)
		return;

	use_m_smooth = false; // signaling to thread, time to die

	//
	// wait thread termination
	//
	while( smooth_thread ) 
	{
    	DWORD exitCode;

    	if(!GetExitCodeThread(smooth_thread, &exitCode))
			Sys_Error("IN_SMouseShutdown: GetExitCodeThread: failed");

		if (exitCode != STILL_ACTIVE) 
		{
			// ok, thread terminated

			// Terminating a thread does not necessarily remove the thread object from the operating system.
			// A thread object is deleted when the last handle to the thread is closed. 
 			CloseHandle(smooth_thread);
			smooth_thread = NULL;
			break;
		}

		if (Sys_DoubleTime() - start > 5)
			Sys_Error("IN_SMouseShutdown: thread does't respond");

		Sys_MSleep(1); // sleep a bit, may be that help thread die fast
	}

	if (m_event) 
	{
		CloseHandle(m_event); // close event
		m_event = NULL;
	}
}
Exemple #26
0
/*
================
R_RenderView

r_refdef must be set before the first call
================
*/
void R_RenderView (void)
{
	double	time1 = 0, time2;

	if (r_norefresh.value)
		return;

	if (!r_worldentity.model || !cl.worldmodel)
		Sys_Error ("R_RenderView: NULL worldmodel");

	if (r_speeds.value)
	{
		glFinish ();
		time1 = Sys_DoubleTime ();
		c_brush_polys = 0;
		c_alias_polys = 0;
	}

	mirror = false;

	if (gl_finish.value)
		glFinish ();

	R_Clear ();

	// render normal view
	R_RenderScene ();
	R_DrawViewModel ();
	R_DrawWaterSurfaces ();

	// render mirror view
//	R_Mirror ();

	R_PolyBlend ();

	if (r_speeds.value)
	{
//		glFinish ();
		time2 = Sys_DoubleTime ();
		Con_Printf ("%3i ms  %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys); 
	}
}
Exemple #27
0
static void IN_DebugKeyEvent(SDL_Event *event)
{
	const char *eventtype = (event->key.state == SDL_PRESSED) ? "SDL_KEYDOWN" : "SDL_KEYUP";
	Con_Printf ("%s scancode: '%s' keycode: '%s' time: %g\n",
		eventtype,
		SDL_GetScancodeName(event->key.keysym.scancode),
		SDL_GetKeyName(event->key.keysym.sym),
		Sys_DoubleTime());


}
Exemple #28
0
// Returns true if it's not time yet to run a frame
qbool VID_VSyncLagFix(void)
{
        extern double vid_last_swap_time;
        double avg_rendertime, tmin, tmax;

	static int timings_idx;
        int i;

	if (!VID_VSyncIsOn() || !vid_vsync_lag_fix.integer) {
		return false;
	}

	if (!glConfig.displayFrequency) {
		Com_Printf("VID_VSyncLagFix: displayFrequency isn't set, can't enable vsync lag fix\n");
		return false;
	}

        // collect statistics so that
        timings[timings_idx] = render_frame_end - render_frame_start;
        timings_idx = (timings_idx + 1) % NUMTIMINGS;
        avg_rendertime = tmin = tmax = 0;
        for (i = 0; i < NUMTIMINGS; i++) {
                if (timings[i] == 0) {
                        return false;   // not enough statistics yet
		}

                avg_rendertime += timings[i];

                if (timings[i] < tmin || !tmin) {
                        tmax = timings[i];
		}

                if (timings[i] > tmax) {
                        tmax = timings[i];
		}
        }
        avg_rendertime /= NUMTIMINGS;
        // if (tmax and tmin differ too much) do_something(); ?
        avg_rendertime = tmax;  // better be on the safe side

	double time_left = vid_last_swap_time + 1.0/glConfig.displayFrequency - Sys_DoubleTime();
	time_left -= avg_rendertime;
	time_left -= vid_vsync_lag_tweak.value * 0.001;
	if (time_left > 0) {
		extern cvar_t sys_yieldcpu;

		if (time_left > 0.001 && sys_yieldcpu.integer) {
			Sys_MSleep(min(time_left * 1000, 500));
		}

		return true;    // don't run a frame yet
	}
        return false;
}
void CL_KeepaliveMessage (void)
{
	float	time;
	static float lastmsg;
	int		ret;
	sizebuf_t	old;
	byte	*olddata;

	if (sv.active)
		return;		// no need if server is local
	if (cls.demoplayback)
		return;

// read messages from server, should just be nops
	olddata = net_olddata;
	old = net_message;
	memcpy (olddata, net_message.data, net_message.cursize);

	do
	{
		ret = CL_GetMessage ();
		switch (ret)
		{
		default:
			Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");
		case 0:
			break;	// nothing waiting
		case 1:
			Host_Error ("CL_KeepaliveMessage: received a message");
			break;
		case 2:
			if (MSG_ReadByte() != svc_nop)
				Host_Error ("CL_KeepaliveMessage: datagram wasn't a nop");
			break;
		}
	} while (ret);

	net_message = old;
	memcpy (net_message.data, olddata, net_message.cursize);

// check time
	time = Sys_DoubleTime ();
	if (time - lastmsg < 5)
		return;
	lastmsg = time;

// write out a nop
	Con_Printf ("--> client to server keepalive\n");

	MSG_WriteByte (&cls.message, clc_nop);
	NET_SendMessage (cls.netcon, &cls.message);
	SZ_Clear (&cls.message);
}
//===================================================================
// OnSend()
//
//===================================================================
void CHLAsyncSocket::OnSend(int nErrorCode) 
{
	if (nErrorCode == WSAENETDOWN)
	{
		CAsyncSocket::OnSend(nErrorCode);	
		return;
	};

	fSendTime = Sys_DoubleTime();

	CAsyncSocket::OnSend(nErrorCode);
}