r_efrag.c is almost client.h free

This commit is contained in:
Bill Currie 2001-05-20 01:58:59 +00:00
parent aa09f5ce7a
commit e0512e4af3
8 changed files with 62 additions and 46 deletions

View file

@ -162,4 +162,6 @@ void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
void R_LoadSkys (const char *);
void R_ClearEfrags (void);
#endif // __render_h

View file

@ -33,6 +33,8 @@
#include "d_iface.h"
#define MAX_EFRAGS 640
#define MAXVERTS 16 // max points in a surface polygon
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
// polygon (while processing)

View file

@ -84,7 +84,6 @@ typedef struct
#define MAX_DEMOS 8
#define MAX_DEMONAME 16
#define MAX_EFRAGS 640
#define MAX_MAPSTRING 2048
typedef enum {
@ -221,7 +220,6 @@ typedef struct
// refresh related state
struct model_s *worldmodel; // cl_entitites[0].model
struct efrag_s *free_efrags;
int num_entities; // held in cl_entities array
int num_statics; // held in cl_staticentities array
entity_t viewent; // the gun model
@ -281,7 +279,6 @@ extern struct cvar_s *cl_name;
extern client_state_t cl;
// FIXME, allocate dynamically
extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_entities[MAX_EDICTS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];

View file

@ -84,7 +84,6 @@ client_static_t cls;
client_state_t cl;
// FIXME: put these on hunk?
efrag_t cl_efrags[MAX_EFRAGS];
entity_t cl_entities[MAX_EDICTS];
entity_state_t cl_baselines[MAX_EDICTS];
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
@ -172,7 +171,6 @@ CL_ClearState (void)
SZ_Clear (&cls.message);
// clear other arrays
memset (cl_efrags, 0, sizeof (cl_efrags));
memset (cl_entities, 0, sizeof (cl_entities));
memset (cl_baselines, 0, sizeof (cl_baselines));
memset (cl_dlights, 0, sizeof (cl_dlights));
@ -180,11 +178,8 @@ CL_ClearState (void)
CL_ClearTEnts ();
// 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;
R_ClearEfrags ();
for (i = 0; i < MAX_EDICTS; i++) {
cl_entities[i].baseline = &cl_baselines[i];
cl_entities[i].baseline->alpha = 255;

View file

@ -31,12 +31,16 @@
#endif
#include "QF/console.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "client.h"
#include "r_local.h"
mnode_t *r_pefragtopnode;
efrag_t *r_free_efrags;
// FIXME: put this on hunk?
efrag_t r_efrags[MAX_EFRAGS];
//===========================================================================
@ -81,8 +85,8 @@ R_RemoveEfrags (entity_t *ent)
ef = ef->entnext;
// put it on the free list
old->entnext = cl.free_efrags;
cl.free_efrags = old;
old->entnext = r_free_efrags;
r_free_efrags = old;
}
ent->efrag = NULL;
@ -111,12 +115,12 @@ R_SplitEntityOnNode (mnode_t *node)
leaf = (mleaf_t *) node;
// grab an efrag off the free list
ef = cl.free_efrags;
ef = r_free_efrags;
if (!ef) {
Con_Printf ("Too many efrags!\n");
return; // no free fragments...
}
cl.free_efrags = cl.free_efrags->entnext;
r_free_efrags = r_free_efrags->entnext;
ef->entity = r_addent;
@ -199,7 +203,7 @@ R_AddEfrags (entity_t *ent)
if (!ent->model)
return;
if (ent == cl_entities)
if (ent == &r_worldentity)
return; // never add the world
r_addent = ent;
@ -214,7 +218,7 @@ R_AddEfrags (entity_t *ent)
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
}
R_SplitEntityOnNode (cl.worldmodel->nodes);
R_SplitEntityOnNode (r_worldentity.model->nodes);
ent->topnode = r_pefragtopnode;
}
@ -229,15 +233,15 @@ void
R_StoreEfrags (efrag_t **ppefrag)
{
entity_t *pent;
model_t *clmodel;
model_t *model;
efrag_t *pefrag;
while ((pefrag = *ppefrag) != NULL) {
pent = pefrag->entity;
clmodel = pent->model;
model = pent->model;
switch (clmodel->type) {
switch (model->type) {
case mod_alias:
case mod_brush:
case mod_sprite:
@ -258,7 +262,19 @@ R_StoreEfrags (efrag_t **ppefrag)
default:
Sys_Error ("R_StoreEfrags: Bad entity type %d\n",
clmodel->type);
model->type);
}
}
}
void
R_ClearEfrags (void)
{
// allocate the efrags and chain together into a free list
int i;
r_free_efrags = r_efrags;
for (i = 0; i < MAX_EFRAGS - 1; i++)
r_free_efrags[i].entnext = &r_free_efrags[i + 1];
r_free_efrags[i].entnext = NULL;
}

View file

@ -124,7 +124,6 @@ typedef struct
#define MAX_DEMOS 8
#define MAX_DEMONAME 16
#define MAX_EFRAGS 512
typedef enum {
@ -267,7 +266,6 @@ typedef struct
// refresh related state
struct model_s *worldmodel; // cl_entitites[0].model
struct efrag_s *free_efrags;
int num_entities; // stored bottom up in cl_entities array
int num_statics; // stored top down in cl_entitiers
@ -318,7 +316,6 @@ extern client_state_t cl;
// FIXME, allocate dynamically
extern entity_state_t cl_baselines[MAX_EDICTS];
extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
extern dlight_t cl_dlights[MAX_DLIGHTS];

View file

@ -405,8 +405,6 @@ CL_Rcon_f (void)
void
CL_ClearState (void)
{
int i;
S_StopAllSounds (true);
Con_DPrintf ("Clearing memory\n");
@ -418,6 +416,8 @@ CL_ClearState (void)
CL_ClearEnts ();
CL_ClearTEnts ();
R_ClearEfrags ();
// wipe the entire cl structure
memset (&cl, 0, sizeof (cl));
@ -427,14 +427,6 @@ CL_ClearState (void)
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;
}

View file

@ -30,14 +30,17 @@
# include "config.h"
#endif
#include "bothdefs.h"
#include "cl_main.h"
#include "cl_tent.h"
#include "QF/console.h"
#include "r_local.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "cl_tent.h"
#include "r_local.h"
mnode_t *r_pefragtopnode;
efrag_t *r_free_efrags;
// FIXME: put this on hunk?
efrag_t r_efrags[MAX_EFRAGS];
//===========================================================================
@ -82,8 +85,8 @@ R_RemoveEfrags (entity_t *ent)
ef = ef->entnext;
// put it on the free list
old->entnext = cl.free_efrags;
cl.free_efrags = old;
old->entnext = r_free_efrags;
r_free_efrags = old;
}
ent->efrag = NULL;
@ -112,12 +115,12 @@ R_SplitEntityOnNode (mnode_t *node)
leaf = (mleaf_t *) node;
// grab an efrag off the free list
ef = cl.free_efrags;
ef = r_free_efrags;
if (!ef) {
Con_Printf ("Too many efrags!\n");
return; // no free fragments...
}
cl.free_efrags = cl.free_efrags->entnext;
r_free_efrags = r_free_efrags->entnext;
ef->entity = r_addent;
@ -215,7 +218,7 @@ R_AddEfrags (entity_t *ent)
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
}
R_SplitEntityOnNode (cl.worldmodel->nodes);
R_SplitEntityOnNode (r_worldentity.model->nodes);
ent->topnode = r_pefragtopnode;
}
@ -230,15 +233,15 @@ void
R_StoreEfrags (efrag_t **ppefrag)
{
entity_t *pent;
model_t *clmodel;
model_t *model;
efrag_t *pefrag;
while ((pefrag = *ppefrag) != NULL) {
pent = pefrag->entity;
clmodel = pent->model;
model = pent->model;
switch (clmodel->type) {
switch (model->type) {
case mod_alias:
case mod_brush:
case mod_sprite:
@ -259,7 +262,19 @@ R_StoreEfrags (efrag_t **ppefrag)
default:
Sys_Error ("R_StoreEfrags: Bad entity type %d\n",
clmodel->type);
model->type);
}
}
}
void
R_ClearEfrags (void)
{
// allocate the efrags and chain together into a free list
int i;
r_free_efrags = r_efrags;
for (i = 0; i < MAX_EFRAGS - 1; i++)
r_free_efrags[i].entnext = &r_free_efrags[i + 1];
r_free_efrags[i].entnext = NULL;
}