Exemplo n.º 1
0
/*
=====================
CL_ClearState

=====================
*/
void CL_ClearState (void)
{
	int			i;

	// STRIP S_StopAllSounds (true);

	Con_DPrintf ("Clearing memory\n");
	//D_FlushCaches ();
	Mod_ClearAll ();
	if (host_hunklevel)	// FIXME: check this...
		Hunk_FreeToLowMark (host_hunklevel);

	CL_ClearTEnts ();

// wipe the entire cl structure
	memset (&cl, 0, sizeof(cl));

	SZ_Clear (&cls.netchan.message);

// clear other arrays	
	memset (cl_efrags, 0, sizeof(cl_efrags));
	memset (cl_dlights, 0, sizeof(cl_dlights));
	memset (cl_lightstyle, 0, sizeof(cl_lightstyle));

//
// allocate the efrags and chain together into a free list
//
	cl.free_efrags = cl_efrags;
	for (i=0 ; i<MAX_EFRAGS-1 ; i++)
		cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
	cl.free_efrags[i].entnext = NULL;
}
Exemplo n.º 2
0
/*
=====================
CL_ClearState

=====================
*/
void
CL_ClearState(void)
{
    int i;

    if (!sv.active)
	Host_ClearMemory();

    CL_ClearTEnts();

// wipe the entire cl structure
    memset(&cl, 0, sizeof(cl));

    SZ_Clear(&cls.message);

// clear other arrays
    memset(cl_efrags, 0, sizeof(cl_efrags));
    memset(cl_entities, 0, sizeof(cl_entities));
    memset(cl_dlights, 0, sizeof(cl_dlights));
    memset(cl_lightstyle, 0, sizeof(cl_lightstyle));

//
// allocate the efrags and chain together into a free list
//
    cl.free_efrags = cl_efrags;
    for (i = 0; i < MAX_EFRAGS - 1; i++)
	cl.free_efrags[i].entnext = &cl.free_efrags[i + 1];
    cl.free_efrags[i].entnext = NULL;
}
Exemplo n.º 3
0
void VID_Restart(void)
{
	int i;

	if (!display)
		return;

	VID_Close();
	VID_Open();
	
	for(i=1;i < MAX_MODELS;i++)
	{
		if (cl.model_name[i][0] == 0)
			break;

		cl.model_precache[i] = Mod_ForName(cl.model_name[i], false);
		if (!cl.model_precache[i])
		{
			Com_Printf("Unable to reload model '%s'.\n", cl.model_name[i]);
			Host_EndGame();
			return;
		}
	}

	if (cl.model_precache[1])
	{
		cl.worldmodel = cl.model_precache[1];
		R_NewMap();
		R_DrawFlat_NewMap();
	}

	CL_ClearTEnts(); /* Not the prettiest, but the safest for now... */

	vid_restarted = 1;
}
Exemplo n.º 4
0
/*
=====================
CL_ClearState

=====================
*/
void CL_ClearState (void)
{
	S_StopAllSounds ();
	CL_ClearEffects ();
	CL_ClearTEnts ();

// wipe the entire cl structure
	memset (&cl, 0, sizeof(cl));
	memset (&cl_entities, 0, sizeof(cl_entities));

	SZ_Clear (&cls.netchan.message);

}
Exemplo n.º 5
0
/*
=====================
CL_ClearState

=====================
*/
void CL_ClearState (void)
{
    S_StopAllSounds ();
    CL_ClearEffects ();
    CL_ClearTEnts ();
    R_SetFogVars (false, 0, 0, 0, 0, 0, 0, 0); // clear fog effets

// wipe the entire cl structure
    memset (&cl, 0, sizeof(cl));
    memset (&cl_entities, 0, sizeof(cl_entities));

    SZ_Clear (&cls.netchan.message);

}
Exemplo n.º 6
0
Arquivo: cl_main.c Projeto: luaman/zq
/*
=====================
CL_ClearState

=====================
*/
void CL_ClearState (void)
{
	int			i;
	extern float	scr_centertime_off;

	S_StopAllSounds (true);

	Com_DPrintf ("Clearing memory\n");

	if (!com_serveractive)
	{
		Host_ClearMemory ();
	}

	CL_ClearTEnts ();
	CL_ClearDlights ();
	CL_ClearParticles ();
	CL_ClearNails ();

	for (i = 0; i < UPDATE_BACKUP; i++)
		Q_free (cl.frames[i].packet_entities.entities);

// wipe the entire cl structure
	memset (&cl, 0, sizeof(cl));

	SZ_Clear (&cls.netchan.message);

// clear other arrays	
	memset (cl_efrags, 0, sizeof(cl_efrags));
	memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
	memset (cl_entities, 0, sizeof(cl_entities));

	cl_entframecount = 2;		// so that cl_entframecount - 1 != 0
	cl.viewheight = DEFAULT_VIEWHEIGHT;
	cl.minpitch = -70;
	cl.maxpitch = 80;

	V_NewMap ();

// make sure no centerprint messages are left from previous level
	scr_centertime_off = 0;

//
// allocate the efrags and chain together into a free list
//
	cl.free_efrags = cl_efrags;
	for (i=0 ; i<MAX_EFRAGS-1 ; i++)
		cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
	cl.free_efrags[i].entnext = NULL;
}
Exemplo n.º 7
0
/*
=====================
CL_ClearState

=====================
*/
void CL_ClearState (void)
{
	S_StopAllSounds ();
	CL_ClearEffects ();
	CL_ClearTEnts ();

//	R_SetFogVars (false, 0, 0, 0, 0, 0, 0, 0); // clear fog effets
	R_ClearState ();

// wipe the entire cl structure
	memset (&cl, 0, sizeof(cl));
	memset (&cl_entities, 0, sizeof(cl_entities));

	SZ_Clear (&cls.netchan.message);

//	if (vr_enabled->value)
//		VR_ResetOrientation();
}
Exemplo n.º 8
0
void
CL_ClearState (void)
{
	int         i;

	S_StopAllSounds ();

	// wipe the entire cl structure
	if (cl.serverinfo)
		Info_Destroy (cl.serverinfo);
	memset (&cl, 0, sizeof (cl));
	r_data->force_fullscreen = 0;

	cl.maxclients = MAX_CLIENTS;

	// Note: we should probably hack around this and give diff values for
	// diff gamedirs
	cl.fpd = FPD_DEFAULT;
	cl.fbskins = FBSKINS_DEFAULT;

	for (i = 0; i < UPDATE_BACKUP; i++)
		cl.frames[i].packet_entities.entities = qw_entstates.frame[i];
	cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0);

	CL_Init_Entity (&cl.viewent);

	Sys_MaskPrintf (SYS_DEV, "Clearing memory\n");
	if (viddef.flush_caches)
		viddef.flush_caches ();
	Mod_ClearAll ();
	if (host_hunklevel)					// FIXME: check this...
		Hunk_FreeToLowMark (host_hunklevel);

	CL_ClearEnts ();
	CL_ClearTEnts ();

	r_funcs->R_ClearState ();

	SZ_Clear (&cls.netchan.message);

	if (centerprint)
		dstring_clearstr (centerprint);
}
Exemplo n.º 9
0
void V_InitRenderer()
{
	guard(V_InitRenderer);

	int		i;

	if (!cl.configstrings[CS_MODELS+1][0]) return;			// no map loaded
	SCR_SetLevelshot();

	// wait a small time to let server complete initialization
	// allow map to be changed before initializing renderer, when loading savegames,
	// saved at point of changing map; this situation is possible because:
	//   - server frame#1:
	//      - loading savegame, will create configstrings + may be insert command string "gamemap <newmap>"
	//      - send configstrings#1
	//   - server frame#2:
	//      - exec "gamemap" command from previous frame, change map etc.
	//      - send configstrings#2
	// in some circumstances, client will receive configstrings#1 after server frame#2 - this will load
	// client map#1 after loading server map#2 (out-of-sync client/server maps -- fatal error)
	static int startTime = 0;
	static int serverCount = 0;
	if (serverCount != cl.servercount)
	{
		serverCount = cl.servercount;
		startTime = cls.realtime;
		return;
	}
	if (cls.realtime < startTime + 300)
		return;

	CL_ClearEffects();		// can use shaders ...
	CL_ClearTEnts();		// temp entities linked to models, which are invalid after vid_restart

	// let the render dll load the map
	char mapname[MAX_QPATH];
	strcpy(mapname, cl.configstrings[CS_MODELS+1] + 5);	// skip "maps/"
	mapname[strlen(mapname)-4] = 0;		// cut off ".bsp"

	// compute total loading weight
	float totalWeight = W_MAP + W_TEXTURES + W_SKY;
	for (i = 1; i < MAX_MODELS && cl.configstrings[CS_MODELS+i][0]; i++) // models
		if (cl.configstrings[CS_MODELS+i][0] != '*')
			totalWeight += W_MODEL;
	for (i = 0; i < MAX_CLIENTS; i++)	// clients
		if (cl.configstrings[CS_PLAYERSKINS+i][0])
			totalWeight += W_CLIENT;

	// register models, pics, and skins
	float loadingFrac = 0;
	SCR_LoadingNotify(va("map: %s", mapname), 0);
	loadingFrac += W_MAP / totalWeight;
	RE_LoadNewWorld();

	// precache status bar pics
	SCR_TouchPics();

	CL_RegisterTEntModels();
	RegisterShaders();

	strcpy(cl_weaponmodels[0], "weapon.md2");	// default weapon model
	num_cl_weaponmodels = 1;

	for (i = 1; i < MAX_MODELS && cl.configstrings[CS_MODELS+i][0]; i++)
	{
		const char *name = cl.configstrings[CS_MODELS+i];
		if (name[0] != '*')
		{
			SCR_LoadingNotify(name, loadingFrac);
			loadingFrac += W_MODEL / totalWeight;
		}
		if (name[0] == '#')
		{
			// special player weapon model
			if (num_cl_weaponmodels < MAX_CLIENTWEAPONMODELS)
				strncpy(cl_weaponmodels[num_cl_weaponmodels++], cl.configstrings[CS_MODELS+i]+1,
					sizeof(cl_weaponmodels[0])-1);
		}
		else
		{
			const char *mdl = cl.configstrings[CS_MODELS + i];
			const char *ext = strrchr(name, '.');
			// load model, but do not reload BSP file:
			cl.model_draw[i] = (!ext || stricmp(ext, ".bsp")) ? RE_RegisterModel(mdl) : NULL;
			cl.model_clip[i] = (name[0] == '*') ? CM_InlineModel(mdl) : NULL;
		}
	}

	SCR_LoadingNotify("textures", loadingFrac);
	loadingFrac += W_TEXTURES / totalWeight;
	for (i = 1; i < MAX_IMAGES && cl.configstrings[CS_IMAGES+i][0]; i++)
		cl.image_precache[i] = RE_RegisterPic(va("pics/%s", cl.configstrings[CS_IMAGES+i]));

	for (i = 0; i < MAX_CLIENTS; i++)
	{
		if (!cl.configstrings[CS_PLAYERSKINS+i][0])
			continue;
		SCR_LoadingNotify(va("client %d: %s", i, cl.configstrings[CS_PLAYERSKINS+i]), loadingFrac);
		loadingFrac += W_CLIENT / totalWeight;
		CL_ParseClientinfo(i);
	}
	if (!cl.configstrings[CS_PLAYERSKINS+cl.playernum][0])
	{
		// in a singleplayer mode, server will not send clientinfo - generate it by
		// ourself for correct third-person view
//		Com_DPrintf("Fixing CI[playernum]\n");
		CL_UpdatePlayerClientInfo();
	}

	// setup sky
	SCR_LoadingNotify("sky", loadingFrac);
	float rotate = atof(cl.configstrings[CS_SKYROTATE]);
	CVec3 axis;
	sscanf(cl.configstrings[CS_SKYAXIS], "%f %f %f", &axis[0], &axis[1], &axis[2]);
	RE_SetSky(cl.configstrings[CS_SKY], rotate, axis);

	// the renderer can now free unneeded stuff
	RE_FinishLoadingWorld();

	Con_ClearNotify();
	SCR_EndLoadingPlaque(true);
	cl.rendererReady  = true;
	cl.forceViewFrame = true;

	// start the cd track
	CDAudio_Play(atoi(cl.configstrings[CS_CDTRACK]), true);

	unguard;
}