Example #1
0
int main (int argc, char **argv)
{
    static quakeparms_t    parms;
    float time, oldtime, newtime;

    parms.memsize = 16*1024*1024;
    parms.membase = malloc (parms.memsize);
    parms.basedir = ".";
    parms.cachedir = NULL;

    COM_InitArgv (argc, argv);

    parms.argc = com_argc;
    parms.argv = com_argv;

    printf ("Host_Init\n");
    Host_Init (&parms);

	Sys_Init();

    // unroll the simulation loop to give the video side a chance to see _vid_default_mode
    Host_Frame( 0.1 );
    VID_SetDefaultMode();

    oldtime = Sys_FloatTime();
    while (1)
    {
		newtime = Sys_FloatTime();
		Host_Frame (newtime - oldtime);
		oldtime = newtime;
    }
	return 0;
}
Example #2
0
/*
====================
R_TimeRefresh_f

For program optimization
====================
*/
void R_TimeRefresh_f (void)
{
	int			i;
	float		start, stop, time;
	int			startangle;
	vrect_t		vr;

	startangle = r_refdef.viewangles[1];
	
	start = Sys_FloatTime ();
	for (i=0 ; i<128 ; i++)
	{
		r_refdef.viewangles[1] = i/128.0*360.0;

		VID_LockBuffer ();

		R_RenderView ();

		VID_UnlockBuffer ();

		vr.x = r_refdef.vrect.x;
		vr.y = r_refdef.vrect.y;
		vr.width = r_refdef.vrect.width;
		vr.height = r_refdef.vrect.height;
		vr.pnext = NULL;
		VID_Update (&vr);
	}
	stop = Sys_FloatTime ();
	time = stop-start;
	Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
	
	r_refdef.viewangles[1] = startangle;
}
Example #3
0
void Host_Frame (float time)
{
	double	time1, time2;
	static double	timetotal;
	static int		timecount;
	int		i, c, m;

	if (!serverprofile.value)
	{
		_Host_Frame (time);
		return;
	}
	
	time1 = Sys_FloatTime ();
	_Host_Frame (time);
	time2 = Sys_FloatTime ();	
	
	timetotal += time2 - time1;
	timecount++;
	
	if (timecount < 1000)
		return;

	m = timetotal*1000/timecount;
	timecount = 0;
	timetotal = 0;
	c = 0;
	for (i=0 ; i<svs.maxclients ; i++)
	{
		if (svs.clients[i].active)
			c++;
	}

	Con_Printf ("serverprofile: %2i clients %2i msec\n",  c,  m);
}
Example #4
0
/*
==================
Host_ShutdownServer

This only happens at the end of a game, not between levels
==================
*/
void Host_ShutdownServer(qboolean crash)
{
	int		i;
	int		count;
	sizebuf_t	buf;
	char		message[4];
	double	start;

	if (!sv.active)
		return;

	sv.active = false;

// flush any pending messages - like the score!!!
	start = Sys_FloatTime();
	do
	{
		count = 0;
		for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
		{
			if (host_client->active && host_client->message.cursize)
			{
				if (NET_CanSendMessage (host_client->netconnection))
				{
					NET_SendMessage(host_client->netconnection, &host_client->message);
					SZ_Clear (&host_client->message);
				}
				else
				{
					NET_GetMessage(host_client->netconnection);
					count++;
				}
			}
		}
		if ((Sys_FloatTime() - start) > 3.0)
			break;
	}
	while (count);

// make sure all the clients know we're disconnecting
	buf.data = message;
	buf.maxsize = 4;
	buf.cursize = 0;
	MSG_WriteByte(&buf, svc_disconnect);
	count = NET_SendToAll(&buf, 5);
	if (count)
		Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count);

	for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
		if (host_client->active)
			SV_DropClient(crash);

//
// clear structures
//
	memset (&sv, 0, sizeof(sv));
	memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t));
}
/*
================
R_RenderView

r_refdef must be set before the first call
================
*/
void R_RenderView (void)
{
	double time1 = 0.0;
	double time2;
	GLfloat colors[4] = {(GLfloat) 0.0, (GLfloat) 0.0, (GLfloat) 1, (GLfloat) 0.20};

	if (r_norefresh.value)
		return;

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

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

	mirror = false;

	if (gl_finish.value)
		glFinish ();

	R_Clear ();

	// render normal view

/***** Experimental silly looking fog ******
****** Use r_fullbright if you enable ******
	glFogi(GL_FOG_MODE, GL_LINEAR);
	glFogfv(GL_FOG_COLOR, colors);
	glFogf(GL_FOG_END, 512.0);
	glEnable(GL_FOG);
********************************************/

	R_RenderScene ();
	R_DrawViewModel ();
	R_DrawWaterSurfaces ();

//  More fog right here :)
//	glDisable(GL_FOG);
//  End of all fog code...

	// render mirror view
	R_Mirror ();

	R_PolyBlend ();

	if (r_speeds.value)
	{
//		glFinish ();
		time2 = Sys_FloatTime ();
		Con_Printf ("%3i ms  %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys);
	}
}
Example #6
0
int main (int argc, char **argv)
{
    MSG        msg;
	quakeparms_t	parms;
	double			time, oldtime;
	static	char	cwd[1024];

	memset (&parms, 0, sizeof(parms));

	parms.memsize = 16384*1024;
	parms.membase = malloc (parms.memsize);

	_getcwd (cwd, sizeof(cwd));
	if (cwd[Q_strlen(cwd)-1] == '\\')
		cwd[Q_strlen(cwd)-1] = 0;
	parms.basedir = cwd; //"f:/quake";
//	parms.basedir = "f:\\quake";

	COM_InitArgv (argc, argv);

	// dedicated server ONLY!
	if (!COM_CheckParm ("-dedicated"))
	{
		memcpy (newargv, argv, argc*4);
		newargv[argc] = "-dedicated";
		argc++;
		argv = newargv;
		COM_InitArgv (argc, argv);
	}

	parms.argc = argc;
	parms.argv = argv;

	printf ("Host_Init\n");
	Host_Init (&parms);

	oldtime = Sys_FloatTime ();

    /* main window message loop */
	while (1)
	{
		time = Sys_FloatTime();
		if (time - oldtime < sys_ticrate.value )
		{
			Sleep(1);
			continue;
		}

		Host_Frame ( time - oldtime );
		oldtime = time;
	}

    /* return success of application */
    return TRUE;
}
Example #7
0
int main (int c, char **v)
{
	quakeparms_t parms;
	
	enableCrunLoop = c > 0;

//	signal(SIGFPE, floating_point_exception_handler);
	signal(SIGFPE, SIG_IGN);

	parms.memsize = 16*1024*1024;
	parms.membase = malloc (parms.memsize);
	parms.basedir = basedir;
	parms.cachedir = cachedir;

	COM_InitArgv(c, v);
	parms.argc = com_argc;
	parms.argv = com_argv;

	Sys_Init();

    Host_Init(&parms);

	Cvar_RegisterVariable (&sys_nostdout);

    oldtime = Sys_FloatTime () - 0.1;

    if(enableCrunLoop) {
    	while(true) {
    		engineTick();
    	}
    } else {
    	AS3_GoAsync();	
    }
}
Example #8
0
void SCR_DrawFPS(void) {
	extern CVar show_fps;
	static double lastframetime;
	double t;
	extern int fps_count;
	static int lastfps;
	static int totalfps;
	static int lastsecond;
	int x, y;
	char st[80];

	if (!show_fps.getBool())
		return;

	t = Sys_FloatTime();
	lastfps = 1 / (t - lastframetime);
	if (((int) (t) % 100) > ((int) (lastframetime) % 100)) {
		lastsecond = totalfps;
		totalfps = 0;
	}
	lastframetime = t;
	totalfps += 1;

	sprintf(st, "%3d FPS", lastfps);

	x = vid.conwidth - strlen(st) * 8 - 16;
	y = 0;
	Draw_String(x, y, st);

	sprintf(st, "%3d Last second", lastsecond);
	x = vid.conwidth - strlen(st) * 8 - 16;
	y = 8;
	Draw_String(x, y, st);
}
Example #9
0
BOOL PASCAL FAR BlockingHook(void)  
{ 
#ifdef ID_PC
    MSG		msg;
    BOOL	ret;
 
	if ((Sys_FloatTime() - blocktime) > 2.0)
	{
		WSACancelBlockingCall();
		return FALSE;
	}

    /* get the next message, if any */ 
    ret = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); 
 
    /* if we got one, process it */ 
    if (ret) { 
        TranslateMessage(&msg); 
        DispatchMessage(&msg); 
    } 
 
    /* TRUE if we got a message */ 
    return ret; 
#endif
	return false;
} 
Example #10
0
/*
=============
R_PrintDSpeeds
=============
*/
void R_PrintDSpeeds (void)
{
	float	ms, dp_time, r_time2, rw_time, db_time, se_time, de_time, dv_time;

	r_time2 = Sys_FloatTime ();

	dp_time = (dp_time2 - dp_time1) * 1000;
	rw_time = (rw_time2 - rw_time1) * 1000;
	db_time = (db_time2 - db_time1) * 1000;
	se_time = (se_time2 - se_time1) * 1000;
	de_time = (de_time2 - de_time1) * 1000;
#ifndef VMTOC
	dv_time = (dv_time2 - dv_time1) * 1000;
	ms = (r_time2 - r_time1) * 1000;

	Con_Printf ("%3i %4.1fp %3iw %4.1fb %3is %4.1fe %4.1fv\n",
				(int)ms, dp_time, (int)rw_time, db_time, (int)se_time, de_time,
				dv_time);
#else
	ms = (r_time2 - r_time1) * 1000;

	Con_Printf ("%3i %4.1fp %3iw %4.1fb %3is %4.1fe %4.1fv\n", (int)ms, dp_time, (int)rw_time, db_time, (int)se_time, de_time);

#endif
}
Example #11
0
void CRender::FrameBegin( void )
{
	if ( !host_state.worldmodel )
		return;

// don't allow cheats in multiplayer
#if !defined( _DEBUG )
	if (cl.maxclients > 1)
	{
//		mat_fullbright.SetValue( 0 );
//		mat_drawflat.SetValue( 0 );
		mat_reversedepth.SetValue( 0 );
		mat_luxels.SetValue( 0 );
		mat_normals.SetValue( 0 );
	}
#endif

	// This has to be before R_AnimateLight because it uses it to
	// set the frame number of changed lightstyles
	r_framecount++;
	R_AnimateLight ();
	R_PushDlights();

	if (!r_norefresh.GetInt())
	{
		m_frameStartTime = Sys_FloatTime ();
	}
	UpdateStudioRenderConfig();
	materialSystemInterface->BeginFrame();
	g_pStudioRender->BeginFrame();
}
Example #12
0
//muff - hacked out of SourceForge implementation + modified
void SCR_DrawFPS (void)
{
	static double lastframetime;
	double t;
	static int lastfps;
	int x, y;
	char st[80];

	if (!cl_showfps->value)
		return;

	t = Sys_FloatTime ();
	if ((t - lastframetime) >= 1.0) {
		lastfps = fps_count;
		fps_count = 0;
		lastframetime = t;
	}

	sprintf(st, "%3d FPS", lastfps);

	x = vid.width - strlen(st) * 16 - 16;
	y = 0 ; //vid.height - (sb_lines * (vid.height/240) )- 16;
//	Draw_TileClear(x, y, strlen(st)*16, 16);
	Draw_String(x, y, st);
}
Example #13
0
static void Slist_Poll(void)
{
	for (net_driverlevel=0; net_driverlevel < net_numdrivers; net_driverlevel++)
	{
		if (!slistLocal && net_driverlevel == 0)
			continue;
		if (net_drivers[net_driverlevel].initialized == false)
			continue;
		dfunc.SearchForHosts (false);
	}

	if (! slistSilent)
		PrintSlist();

	if ((Sys_FloatTime() - slistStartTime) < 1.5)
	{
		SchedulePollProcedure(&slistPollProcedure, 0.1);
		return;
	}

	if (! slistSilent)
		PrintSlistTrailer();
	slistInProgress = false;
	slistSilent = false;
	slistLocal = true;
}
Example #14
0
//-----------------------------------------------------------------------------
// Purpose: Resume playing cd
//-----------------------------------------------------------------------------
void CCDAudio::_Resume( int, int )
{
	double curTime;
	DWORD			dwReturn;
    MCI_PLAY_PARMS	mciPlayParms;

	if (!m_bEnabled)
		return;
	
	if (!m_bIsValid)
		return;

	if (!m_bWasPlaying)
		return;

    mciPlayParms.dwFrom = MCI_MAKE_TMSF(m_nPlayTrack, 0, 0, 0);
    mciPlayParms.dwTo = MCI_MAKE_TMSF(m_nPlayTrack + 1, 0, 0, 0);
    mciPlayParms.dwCallback = (DWORD)game->GetMainWindow();
    dwReturn = mciSendCommand(m_uiDeviceID, MCI_PLAY, MCI_TO | MCI_NOTIFY, (DWORD)(LPVOID) &mciPlayParms);
	if (dwReturn)
	{
		ResetCDTimes();
		return;
	}
	m_bIsPlaying = true;

	curTime = Sys_FloatTime();

	// Subtract the elapsed time from the current playback time. (i.e., add it to the start time).

	m_dStartTime += (curTime - m_dPauseTime);

	m_dPauseTime = 0.0;
}
Example #15
0
int main (int argc, char **argv)
{
	static quakeparms_t    parms;
	float  time, oldtime, newtime;

	signal(SIGFPE, SIG_IGN);
	SifInitRpc(0);
	LoadModules();
/*
	if(mcInit(MC_TYPE_MC) < 0) 
	{
		printf("Failed to initialise memcard\n");
		SleepThread();
	}
*/
	inithandle();
	
	parms.memsize = 24*1024*1024;
	parms.membase = malloc (parms.memsize);
	parms.basedir = ".";

	COM_InitArgv (argc, argv);

	parms.argc = com_argc;
	parms.argv = com_argv;

	printf ("Host_Init\n");
	Host_Init (&parms);
	
	start_ps2_timer();
	
	oldtime = Sys_FloatTime () - 0.1;
    while (1)
    {
// find time spent rendering last frame
        newtime = Sys_FloatTime ();
        time = newtime - oldtime;

		oldtime = newtime;

        Host_Frame (time);
    }
	stop_ps2_timer();
	
	return 0;
}
Example #16
0
/*
==================
CL_KeepaliveMessage

When the client is taking a long time to load stuff, send keepalive messages
so the server doesn't disconnect.
==================
*/
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
	old = net_message;
	olddata = Sys_BigStackAlloc(8192 * sizeof(byte), "CL_KeepaliveMessage");
	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_FloatTime ();
	if (time - lastmsg < 5)
	{
		Sys_BigStackFree(8192 * sizeof(byte), "CL_KeepaliveMessage");
		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);

	Sys_BigStackFree(8192 * sizeof(byte), "CL_KeepaliveMessage");
}
Example #17
0
/*
====================
//	if( r_drawtranslucentworld )
//	{
//		bSaveDrawTranslucentWorld = r_drawtranslucentworld->GetBool();
		// NOTE! : We use to set this to 0 for HDR.
		//		r_drawtranslucentworld->SetValue( 0 );
//	}
//	if( r_drawtranslucentrenderables )
R_TimeRefresh_f

For program optimization
====================
*/
void R_TimeRefresh_f (void)
{
	int			i;
	float		start, stop, time;
	CViewSetup		view;

	materials->Flush( true );

	Q_memset(&view, 0, sizeof(view));
	view.origin = MainViewOrigin();
	view.angles[0] = 0;
	view.angles[1] = 0;
	view.angles[2] = 0;
	view.x = 0;
	view.y = 0;
	view.width = videomode->GetModeWidth();
	view.height = videomode->GetModeHeight();
	view.fov = 75;
	view.fovViewmodel = 75;
	view.m_flAspectRatio = 1.0f;
	view.zNear = 4;
	view.zFar = MAX_COORD_FLOAT;
	view.zNearViewmodel = 4;
	view.zFarViewmodel = MAX_COORD_FLOAT;

	int savedeveloper = developer.GetInt();
	developer.SetValue( 0 );

	start = Sys_FloatTime ();
	for (i=0 ; i<128 ; i++)
	{
		view.angles[1] = i/128.0*360.0;
		g_ClientDLL->RenderView( view, VIEW_CLEAR_COLOR, RENDERVIEW_DRAWVIEWMODEL | RENDERVIEW_DRAWHUD );
		Shader_SwapBuffers();
	}

	materials->Flush( true );
	Shader_SwapBuffers();
	stop = Sys_FloatTime ();
	time = stop-start;

	developer.SetValue( savedeveloper );

	ConMsg ("%f seconds (%f fps)\n", time, 128/time);
}
Example #18
0
void TTY_Close(int handle)
{
	ComPort	*p;
	double		startTime;

	p = handleToPort [handle];

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

	if (p->useModem)
	{
		if (p->modemConnected)
			Modem_Hangup(p);
	}
}
void CEngineStats::EndFrame( void )
{
	double deltaTime;
	
	m_frameEndTime = Sys_FloatTime();
	deltaTime = GetCurrentSystemFrameTime();

	m_InFrame = false;
}
Example #20
0
int main (int argc, char **argv)
{
	float		time, oldtime;

	APT_CheckNew3DS(&isN3DS);
	if(isN3DS)
		osSetSpeedupEnable(true);

	gfxInit(GSP_RGB565_OES,GSP_RGB565_OES,false);
	gfxSetDoubleBuffering(GFX_TOP, false);
	gfxSetDoubleBuffering(GFX_BOTTOM, false);
	gfxSet3D(true);
	consoleInit(GFX_BOTTOM, NULL);

	#ifdef _3DS_CIA
		if(chdir("sdmc:/3ds/ctrQuake") != 0)
			Sys_Error("Could not find folder: sdmc:/3ds/ctrQuake");
	#endif

	static quakeparms_t    parms;

	parms.memsize = 24*1024*1024;
	parms.membase = malloc (parms.memsize);
	parms.basedir = ".";

	COM_InitArgv (argc, argv);

	parms.argc = com_argc;
	parms.argv = com_argv;
	Host_Init (&parms);
	
	Sys_Init();

	oldtime = Sys_FloatTime() -0.1;
	while (aptMainLoop())
	{
		time = Sys_FloatTime();
		separation_distance = osGet3DSliderState();
		Host_Frame (time - oldtime);
		oldtime = time;
	}
	gfxExit();
	return 0;
}
Example #21
0
/*
================
VID_ExtraVidLookForState
================
*/
qboolean VID_ExtraVidLookForState (unsigned state, unsigned mask)
{
	int		i;
	double	starttime, time;

	starttime = Sys_FloatTime ();

	do
	{
		for (i=0 ; i<100000 ; i++)
		{
			if ((inportb (0x3DA) & mask) == state)
				return true;
		}

		time = Sys_FloatTime ();
	} while ((time - starttime) < 0.1);

	return false;
}
Example #22
0
/*
=============
R_PrintTimes
=============
*/
void R_PrintTimes (void)
{
	float	r_time2;
	float		ms;

	r_time2 = Sys_FloatTime ();

	ms = 1000* (r_time2 - r_time1);
	
	Con_Printf ("%5.1f ms %3i/%3i/%3i poly %3i surf\n",
				ms, c_faceclip, r_polycount, r_drawnpolycount, c_surf);
	c_surf = 0;
}
Example #23
0
qboolean IsTimeout (float *PrevTime, float WaitTime)
{
    float CurrTime;

    CurrTime = Sys_FloatTime ();

    if (*PrevTime && CurrTime - *PrevTime < WaitTime)
        return false;

    *PrevTime = CurrTime;

    return true;
}
Example #24
0
File: host.cpp Project: TeamNyx/gdk
void Host_Frame (float time)
{
	double	time1, time2;
	static double	timetotal, timetotal_acc;
	static int		timecount, timecount_acc;
	int		i, c, m, m_acc;

	if (!serverprofile.value)
	{
		_Host_Frame (time);
		return;
	}

	time1 = Sys_FloatTime ();
	_Host_Frame (time);
	time2 = Sys_FloatTime ();

	timetotal += time2 - time1;
	timecount++;

	if (timecount < 1000)
		return;

        timetotal_acc += timetotal;
        timecount_acc += timecount;
        m = (int) (timetotal*10000/timecount);
	m_acc = (int) (timetotal_acc*10000/timecount_acc);
	timecount = 0;
	timetotal = 0;
	c = 0;
	for (i=0 ; i<svs.maxclients ; i++)
	{
		if (svs.clients[i].active)
			c++;
	}

	Con_Printf ("serverprofile: %2i clients %2i msec\n",  c,  m/10);
   LOGI("serverprofile: %2i clients %2i.%1i msec, acc = %2i.%1i msec\n",  c,  m/10, m%10, m_acc/10, m_acc%10);
}
Example #25
0
static void Slist_Send(void)
{
	for (net_driverlevel=0; net_driverlevel < net_numdrivers; net_driverlevel++)
	{
		if (!slistLocal && net_driverlevel == 0)
			continue;
		if (net_drivers[net_driverlevel].initialized == false)
			continue;
		dfunc.SearchForHosts (true);
	}

	if ((Sys_FloatTime() - slistStartTime) < 0.5)
		SchedulePollProcedure(&slistSendProcedure, 0.75);
}
Example #26
0
/*
====================
R_TimeRefresh_f

For program optimization
====================
*/
void R_TimeRefresh_f (void)
{
	int			i;
	double		start, stop, time;
	int			startangle;
	vrect_t		vr;

#ifdef PSP_SOFTWARE_VIDEO
	startangle = r_refdef.viewangles[1];
	
	start = Sys_FloatTime ();
	for (i=0 ; i<128 ; i++)
	{
		r_refdef.viewangles[1] = i/128.0*360.0;

		VID_LockBuffer ();

		R_RenderView ();

		VID_UnlockBuffer ();

		vr.x = r_refdef.vrect.x;
		vr.y = r_refdef.vrect.y;
		vr.width = r_refdef.vrect.width;
		vr.height = r_refdef.vrect.height;
		vr.pnext = NULL;
		VID_Update (&vr);
	}
	stop = Sys_FloatTime ();
	time = stop-start;
	Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
	
	r_refdef.viewangles[1] = startangle;
#else
	Con_Printf ("Sorry: 'timerefresh' command disabled\n");
#endif	
}
Example #27
0
//-----------------------------------------------------------------------------
// Draws a quad
//-----------------------------------------------------------------------------
void CAVITestApp::DrawStuff( AVIMaterial_t hMaterial )
{
	int iViewableWidth = GetWindowWidth();
	int iViewableHeight = GetWindowHeight();

	g_pAVI->SetTime( hMaterial, Sys_FloatTime() - m_flStartTime );

	float flMaxU, flMaxV;
	g_pAVI->GetTexCoordRange( hMaterial, &flMaxU, &flMaxV );
	IMaterial *pMaterial = g_pAVI->GetMaterial( hMaterial );

	CMatRenderContextPtr pRenderContext( g_pMaterialSystem );

	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->LoadIdentity();
	pRenderContext->Ortho( 0, 0, iViewableWidth, iViewableHeight, 0, 1 );

	pRenderContext->Bind( pMaterial );
	IMesh *pMesh = pRenderContext->GetDynamicMesh();
	CMeshBuilder meshBuilder;

	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	// Draw a polygon the size of the panel
	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.Position3f( -0.5, iViewableHeight + 0.5, 0 );
	meshBuilder.TexCoord2f( 0, 0, 0 );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.Position3f( -0.5, 0.5, 0 );
	meshBuilder.TexCoord2f( 0, 0, flMaxV );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.Position3f( iViewableWidth - 0.5, 0.5, 0 );
	meshBuilder.TexCoord2f( 0, flMaxU, flMaxV );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color4ub( 255, 255, 255, 255 );
	meshBuilder.Position3f( iViewableWidth - 0.5, iViewableHeight + 0.5, 0 );
	meshBuilder.TexCoord2f( 0, flMaxU, 0 );
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();
}
void CServerRemoteAccess::GetStatsString(char *buf, int bufSize)
{
	float avgIn=0,avgOut=0;

	sv.GetNetStats( avgIn, avgOut );

	// format: CPU percent, Bandwidth in, Bandwidth out, uptime, changelevels, framerate, total players
	_snprintf(buf, bufSize - 1, "%5.2f %5.2f %5.2f %7i %5i %7.2f %7i",
				sv.GetCPUUsage() * 100, 
				avgIn, 
				avgOut,
				(int)(Sys_FloatTime()) / 60,
				sv.GetSpawnCount() - 1,
				1.0/host_frametime, // frame rate
				sv.GetNumClients() - sv.GetNumProxies());
	buf[bufSize - 1] = 0;
};
Example #29
0
//-----------------------------------------------------------------------------
// Purpose: Pause playback
//-----------------------------------------------------------------------------
void CCDAudio::_Pause( int, int )
{
	MCI_GENERIC_PARMS	mciGenericParms;

	if (!m_bEnabled)
		return;

	if (!m_bIsPlaying)
		return;

	mciGenericParms.dwCallback = (DWORD)game->GetMainWindow();
    mciSendCommand(m_uiDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms);

	m_bWasPlaying = m_bIsPlaying;
	m_bIsPlaying = false;

	m_dPauseTime = Sys_FloatTime();
}
Example #30
-1
void WINS_GetLocalAddress()
{
    struct hostent	*local = NULL;
    char			buff[MAXHOSTNAMELEN];
    unsigned long	addr;

    if (myAddr != INADDR_ANY) {
        return;
    }

    if (pgethostname(buff, MAXHOSTNAMELEN) == SOCKET_ERROR) {
        return;
    }

    blocktime = Sys_FloatTime();
    WSASetBlockingHook(BlockingHook);
    local = pgethostbyname(buff);
    WSAUnhookBlockingHook();
    if (local == NULL) {
        return;
    }

    myAddr = *(int *)local->h_addr_list[0];

    addr = ntohl(myAddr);
    sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
}