engine/EngineClientParse.c
/*	Parse information given to us by the server.
*/
Parse information given to us by the server.
Parse information given to us by the server .
void Client_ParseServerInfo(void)
{
	int		i,
			nummodels, numsounds;
	char	*str,
			cModelPrecache[MAX_MODELS][MAX_QPATH],
			cSoundPrecache[MAX_SOUNDS][MAX_QPATH];
	Con_DPrintf("Parsing server information...\n");
	CL_ClearState();
	i = MSG_ReadLong();
	if(i != SERVER_PROTOCOL)
	{
		Con_Printf("\n");
		Host_Error("Server returned protocol version %i, not %i!\n",i,SERVER_PROTOCOL);
	}
	cl.protocol = i;
	cl.maxclients = MSG_ReadByte ();
	if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
	{
		Con_Printf("Bad maxclients (%u) from server\n", cl.maxclients);
		return;
	}
	cl.scores = (scoreboard_t*)Hunk_AllocName(cl.maxclients*sizeof(*cl.scores), "scores");
	cl.gametype = MSG_ReadByte();
	str = MSG_ReadString ();
	strncpy(cl.levelname, str, sizeof(cl.levelname) - 1);
	Con_Printf ("\n%s\n", Con_Quakebar(40)); 
	Con_Printf ("%c%s\n", 2, str);
	memset(cl.model_precache,0,sizeof(cl.model_precache));
	for(nummodels = 1;; nummodels++)
	{
		str = MSG_ReadString ();
		if(!str[0])
			break;
		if(nummodels == MAX_MODELS)
		{
			Con_Warning("Server sent too many model precaches!\n");
			return;
		}
		strcpy(cModelPrecache[nummodels], str);
		Model_Touch(str);
	}
	memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
	for (numsounds=1 ; ; numsounds++)
	{
		str = MSG_ReadString ();
		if (!str[0])
			break;
		if (numsounds==MAX_SOUNDS)
		{
			Con_Printf ("Server sent too many sound precaches\n");
			return;
		}
		strcpy(cSoundPrecache[numsounds], str);
		S_TouchSound (str);
	}
	memset(&gEffectTexture, 0, sizeof(gEffectTexture));
	{
		int iTextures;
		for(iTextures = 1; ; iTextures++)
		{
			str = MSG_ReadString();
			if(!str[0])
				break;
			Client_PrecacheResource(RESOURCE_SPRITE,str);
		}
	}
	for(i = 0; ; i++)
	{
		if(!MSG_ReadByte())
			break;
		{
			DynamicLight_t *dStaticLight = Client_AllocDlight(0);
			if(dStaticLight)
			{
				int j;
				for(j = 0; j < 3; j++)
					dStaticLight->origin[j] = MSG_ReadCoord();
				for(j = 0; j < 3; j++)
					dStaticLight->color[j] = MSG_ReadCoord();
				dStaticLight->decay		= 0;
				dStaticLight->lightmap	= false;
				dStaticLight->die		= 0;
				dStaticLight->minlight	= 32.0f;
				dStaticLight->radius	= MSG_ReadCoord();
			}
		}
	}
	for(i = 1; i < nummodels; i++)
	{
		cl.model_precache[i] = Mod_ForName(cModelPrecache[i]);
		if (!cl.model_precache[i])
		{
#ifndef _DEBUG
			Console_ErrorMessage(false, cModelPrecache[i], "Either the file is corrupt or does not exist.\n");
#endif 
		}
		CL_KeepaliveMessage ();
	}
	for (i=1 ; i<numsounds ; i++)
	{
		cl.sound_precache[i] = S_PrecacheSound(cSoundPrecache[i]);
		CL_KeepaliveMessage ();
	}
	cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
	R_NewMap ();
	 -- clear out string; we don't consider identical
	con_lastcenterstring[0] = 0;
	Hunk_Check ();		
	noclip_anglehack = false;		
 -- reset developer stats
	memset(&dev_stats, 0, sizeof(dev_stats));
	memset(&dev_peakstats, 0, sizeof(dev_peakstats));
	memset(&dev_overflows, 0, sizeof(dev_overflows));
}
void Client_ParseServerInfo ( void ) { int i , nummodels , numsounds ; char * str , cModelPrecache [ MAX_MODELS ] [ MAX_QPATH ] , cSoundPrecache [ MAX_SOUNDS ] [ MAX_QPATH ] ; Con_DPrintf ( " \n " ) ; CL_ClearState ( ) ; i = MSG_ReadLong ( ) ; if ( i != SERVER_PROTOCOL ) { Con_Printf ( " \n " ) ; Host_Error ( " \n " , i , SERVER_PROTOCOL ) ; } cl . protocol = i ; cl . maxclients = MSG_ReadByte ( ) ; if ( cl . maxclients < 1 || cl . maxclients > MAX_SCOREBOARD ) { Con_Printf ( " \n " , cl . maxclients ) ; return ; } cl . scores = ( scoreboard_t * ) Hunk_AllocName ( cl . maxclients * sizeof ( * cl . scores ) , " " ) ; cl . gametype = MSG_ReadByte ( ) ; str = MSG_ReadString ( ) ; strncpy ( cl . levelname , str , sizeof ( cl . levelname ) - 1 ) ; Con_Printf ( " \n \n " , Con_Quakebar ( 40 ) ) ; Con_Printf ( " \n " , 2 , str ) ; memset ( cl . model_precache , 0 , sizeof ( cl . model_precache ) ) ; for ( nummodels = 1 ; ; nummodels ++ ) { str = MSG_ReadString ( ) ; if ( ! str [ 0 ] ) break ; if ( nummodels == MAX_MODELS ) { Con_Warning ( " \n " ) ; return ; } strcpy ( cModelPrecache [ nummodels ] , str ) ; Model_Touch ( str ) ; } memset ( cl . sound_precache , 0 , sizeof ( cl . sound_precache ) ) ; for ( numsounds = 1 ; ; numsounds ++ ) { str = MSG_ReadString ( ) ; if ( ! str [ 0 ] ) break ; if ( numsounds == MAX_SOUNDS ) { Con_Printf ( " \n " ) ; return ; } strcpy ( cSoundPrecache [ numsounds ] , str ) ; S_TouchSound ( str ) ; } memset ( & gEffectTexture , 0 , sizeof ( gEffectTexture ) ) ; { int iTextures ; for ( iTextures = 1 ; ; iTextures ++ ) { str = MSG_ReadString ( ) ; if ( ! str [ 0 ] ) break ; Client_PrecacheResource ( RESOURCE_SPRITE , str ) ; } } for ( i = 0 ; ; i ++ ) { if ( ! MSG_ReadByte ( ) ) break ; { DynamicLight_t * dStaticLight = Client_AllocDlight ( 0 ) ; if ( dStaticLight ) { int j ; for ( j = 0 ; j < 3 ; j ++ ) dStaticLight -> origin [ j ] = MSG_ReadCoord ( ) ; for ( j = 0 ; j < 3 ; j ++ ) dStaticLight -> color [ j ] = MSG_ReadCoord ( ) ; dStaticLight -> decay = 0 ; dStaticLight -> lightmap = false ; dStaticLight -> die = 0 ; dStaticLight -> minlight = 32.0f ; dStaticLight -> radius = MSG_ReadCoord ( ) ; } } } for ( i = 1 ; i < nummodels ; i ++ ) { cl . model_precache [ i ] = Mod_ForName ( cModelPrecache [ i ] ) ; if ( ! cl . model_precache [ i ] ) { #ifndef _DEBUG Console_ErrorMessage ( false , cModelPrecache [ i ] , " \n " ) ; #endif } CL_KeepaliveMessage ( ) ; } for ( i = 1 ; i < numsounds ; i ++ ) { cl . sound_precache [ i ] = S_PrecacheSound ( cSoundPrecache [ i ] ) ; CL_KeepaliveMessage ( ) ; } cl_entities [ 0 ] . model = cl . worldmodel = cl . model_precache [ 1 ] ; R_NewMap ( ) ; con_lastcenterstring [ 0 ] = 0 ; Hunk_Check ( ) ; noclip_anglehack = false ; memset ( & dev_stats , 0 , sizeof ( dev_stats ) ) ; memset ( & dev_peakstats , 0 , sizeof ( dev_peakstats ) ) ; memset ( & dev_overflows , 0 , sizeof ( dev_overflows ) ) ; }
Parse information given to us by the server.
Parse information given to us by the server .
// Wipe the client_state_t struct // Parse protocol version number // Parse maxclients // Parse gametype // parse signon message // seperate the printfs so the server message can have a color //johnfitz // first we go through and touch all of the precache data that still // happens to be in the cache, so precaching something else doesn't // needlessly purge it // precache models // precache sounds // [6/6/2013] Precache textures ~hogsy // TODO: just check the level out client-side and add the lights ourselves, rather than passing from server!!! ~hogsy // now we try to load everything else until a cache allocation fails // !_DEBUG // Local state //johnfitz -- clear out string; we don't consider identical //messages to be duplicates if the map has changed in between //johnfitz // make sure nothing is hurt // noclip is turned off at start //johnfitz -- reset developer stats