mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
r_efrag.c is almost client.h free
This commit is contained in:
parent
aa09f5ce7a
commit
e0512e4af3
8 changed files with 62 additions and 46 deletions
|
@ -162,4 +162,6 @@ void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
|
||||||
|
|
||||||
void R_LoadSkys (const char *);
|
void R_LoadSkys (const char *);
|
||||||
|
|
||||||
|
void R_ClearEfrags (void);
|
||||||
|
|
||||||
#endif // __render_h
|
#endif // __render_h
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
#include "d_iface.h"
|
#include "d_iface.h"
|
||||||
|
|
||||||
|
#define MAX_EFRAGS 640
|
||||||
|
|
||||||
#define MAXVERTS 16 // max points in a surface polygon
|
#define MAXVERTS 16 // max points in a surface polygon
|
||||||
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
|
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
|
||||||
// polygon (while processing)
|
// polygon (while processing)
|
||||||
|
|
|
@ -84,7 +84,6 @@ typedef struct
|
||||||
|
|
||||||
#define MAX_DEMOS 8
|
#define MAX_DEMOS 8
|
||||||
#define MAX_DEMONAME 16
|
#define MAX_DEMONAME 16
|
||||||
#define MAX_EFRAGS 640
|
|
||||||
#define MAX_MAPSTRING 2048
|
#define MAX_MAPSTRING 2048
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -221,7 +220,6 @@ typedef struct
|
||||||
|
|
||||||
// refresh related state
|
// refresh related state
|
||||||
struct model_s *worldmodel; // cl_entitites[0].model
|
struct model_s *worldmodel; // cl_entitites[0].model
|
||||||
struct efrag_s *free_efrags;
|
|
||||||
int num_entities; // held in cl_entities array
|
int num_entities; // held in cl_entities array
|
||||||
int num_statics; // held in cl_staticentities array
|
int num_statics; // held in cl_staticentities array
|
||||||
entity_t viewent; // the gun model
|
entity_t viewent; // the gun model
|
||||||
|
@ -281,7 +279,6 @@ extern struct cvar_s *cl_name;
|
||||||
extern client_state_t cl;
|
extern client_state_t cl;
|
||||||
|
|
||||||
// FIXME, allocate dynamically
|
// FIXME, allocate dynamically
|
||||||
extern efrag_t cl_efrags[MAX_EFRAGS];
|
|
||||||
extern entity_t cl_entities[MAX_EDICTS];
|
extern entity_t cl_entities[MAX_EDICTS];
|
||||||
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||||
|
|
|
@ -84,7 +84,6 @@ client_static_t cls;
|
||||||
client_state_t cl;
|
client_state_t cl;
|
||||||
|
|
||||||
// FIXME: put these on hunk?
|
// FIXME: put these on hunk?
|
||||||
efrag_t cl_efrags[MAX_EFRAGS];
|
|
||||||
entity_t cl_entities[MAX_EDICTS];
|
entity_t cl_entities[MAX_EDICTS];
|
||||||
entity_state_t cl_baselines[MAX_EDICTS];
|
entity_state_t cl_baselines[MAX_EDICTS];
|
||||||
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||||
|
@ -172,7 +171,6 @@ CL_ClearState (void)
|
||||||
SZ_Clear (&cls.message);
|
SZ_Clear (&cls.message);
|
||||||
|
|
||||||
// clear other arrays
|
// clear other arrays
|
||||||
memset (cl_efrags, 0, sizeof (cl_efrags));
|
|
||||||
memset (cl_entities, 0, sizeof (cl_entities));
|
memset (cl_entities, 0, sizeof (cl_entities));
|
||||||
memset (cl_baselines, 0, sizeof (cl_baselines));
|
memset (cl_baselines, 0, sizeof (cl_baselines));
|
||||||
memset (cl_dlights, 0, sizeof (cl_dlights));
|
memset (cl_dlights, 0, sizeof (cl_dlights));
|
||||||
|
@ -180,11 +178,8 @@ CL_ClearState (void)
|
||||||
|
|
||||||
CL_ClearTEnts ();
|
CL_ClearTEnts ();
|
||||||
|
|
||||||
// allocate the efrags and chain together into a free list
|
R_ClearEfrags ();
|
||||||
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;
|
|
||||||
for (i = 0; i < MAX_EDICTS; i++) {
|
for (i = 0; i < MAX_EDICTS; i++) {
|
||||||
cl_entities[i].baseline = &cl_baselines[i];
|
cl_entities[i].baseline = &cl_baselines[i];
|
||||||
cl_entities[i].baseline->alpha = 255;
|
cl_entities[i].baseline->alpha = 255;
|
||||||
|
|
|
@ -31,12 +31,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "QF/console.h"
|
#include "QF/console.h"
|
||||||
|
#include "QF/render.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
|
||||||
mnode_t *r_pefragtopnode;
|
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;
|
ef = ef->entnext;
|
||||||
|
|
||||||
// put it on the free list
|
// put it on the free list
|
||||||
old->entnext = cl.free_efrags;
|
old->entnext = r_free_efrags;
|
||||||
cl.free_efrags = old;
|
r_free_efrags = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->efrag = NULL;
|
ent->efrag = NULL;
|
||||||
|
@ -111,12 +115,12 @@ R_SplitEntityOnNode (mnode_t *node)
|
||||||
leaf = (mleaf_t *) node;
|
leaf = (mleaf_t *) node;
|
||||||
|
|
||||||
// grab an efrag off the free list
|
// grab an efrag off the free list
|
||||||
ef = cl.free_efrags;
|
ef = r_free_efrags;
|
||||||
if (!ef) {
|
if (!ef) {
|
||||||
Con_Printf ("Too many efrags!\n");
|
Con_Printf ("Too many efrags!\n");
|
||||||
return; // no free fragments...
|
return; // no free fragments...
|
||||||
}
|
}
|
||||||
cl.free_efrags = cl.free_efrags->entnext;
|
r_free_efrags = r_free_efrags->entnext;
|
||||||
|
|
||||||
ef->entity = r_addent;
|
ef->entity = r_addent;
|
||||||
|
|
||||||
|
@ -199,7 +203,7 @@ R_AddEfrags (entity_t *ent)
|
||||||
if (!ent->model)
|
if (!ent->model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ent == cl_entities)
|
if (ent == &r_worldentity)
|
||||||
return; // never add the world
|
return; // never add the world
|
||||||
|
|
||||||
r_addent = ent;
|
r_addent = ent;
|
||||||
|
@ -214,7 +218,7 @@ R_AddEfrags (entity_t *ent)
|
||||||
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
|
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SplitEntityOnNode (cl.worldmodel->nodes);
|
R_SplitEntityOnNode (r_worldentity.model->nodes);
|
||||||
|
|
||||||
ent->topnode = r_pefragtopnode;
|
ent->topnode = r_pefragtopnode;
|
||||||
}
|
}
|
||||||
|
@ -229,15 +233,15 @@ void
|
||||||
R_StoreEfrags (efrag_t **ppefrag)
|
R_StoreEfrags (efrag_t **ppefrag)
|
||||||
{
|
{
|
||||||
entity_t *pent;
|
entity_t *pent;
|
||||||
model_t *clmodel;
|
model_t *model;
|
||||||
efrag_t *pefrag;
|
efrag_t *pefrag;
|
||||||
|
|
||||||
|
|
||||||
while ((pefrag = *ppefrag) != NULL) {
|
while ((pefrag = *ppefrag) != NULL) {
|
||||||
pent = pefrag->entity;
|
pent = pefrag->entity;
|
||||||
clmodel = pent->model;
|
model = pent->model;
|
||||||
|
|
||||||
switch (clmodel->type) {
|
switch (model->type) {
|
||||||
case mod_alias:
|
case mod_alias:
|
||||||
case mod_brush:
|
case mod_brush:
|
||||||
case mod_sprite:
|
case mod_sprite:
|
||||||
|
@ -258,7 +262,19 @@ R_StoreEfrags (efrag_t **ppefrag)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Sys_Error ("R_StoreEfrags: Bad entity type %d\n",
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -124,7 +124,6 @@ typedef struct
|
||||||
|
|
||||||
#define MAX_DEMOS 8
|
#define MAX_DEMOS 8
|
||||||
#define MAX_DEMONAME 16
|
#define MAX_DEMONAME 16
|
||||||
#define MAX_EFRAGS 512
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -267,7 +266,6 @@ typedef struct
|
||||||
|
|
||||||
// refresh related state
|
// refresh related state
|
||||||
struct model_s *worldmodel; // cl_entitites[0].model
|
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_entities; // stored bottom up in cl_entities array
|
||||||
int num_statics; // stored top down in cl_entitiers
|
int num_statics; // stored top down in cl_entitiers
|
||||||
|
|
||||||
|
@ -318,7 +316,6 @@ extern client_state_t cl;
|
||||||
|
|
||||||
// FIXME, allocate dynamically
|
// FIXME, allocate dynamically
|
||||||
extern entity_state_t cl_baselines[MAX_EDICTS];
|
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 entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||||
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||||
extern dlight_t cl_dlights[MAX_DLIGHTS];
|
extern dlight_t cl_dlights[MAX_DLIGHTS];
|
||||||
|
|
|
@ -405,8 +405,6 @@ CL_Rcon_f (void)
|
||||||
void
|
void
|
||||||
CL_ClearState (void)
|
CL_ClearState (void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
S_StopAllSounds (true);
|
S_StopAllSounds (true);
|
||||||
|
|
||||||
Con_DPrintf ("Clearing memory\n");
|
Con_DPrintf ("Clearing memory\n");
|
||||||
|
@ -418,6 +416,8 @@ CL_ClearState (void)
|
||||||
CL_ClearEnts ();
|
CL_ClearEnts ();
|
||||||
CL_ClearTEnts ();
|
CL_ClearTEnts ();
|
||||||
|
|
||||||
|
R_ClearEfrags ();
|
||||||
|
|
||||||
// wipe the entire cl structure
|
// wipe the entire cl structure
|
||||||
memset (&cl, 0, sizeof (cl));
|
memset (&cl, 0, sizeof (cl));
|
||||||
|
|
||||||
|
@ -427,14 +427,6 @@ CL_ClearState (void)
|
||||||
memset (cl_efrags, 0, sizeof (cl_efrags));
|
memset (cl_efrags, 0, sizeof (cl_efrags));
|
||||||
memset (cl_dlights, 0, sizeof (cl_dlights));
|
memset (cl_dlights, 0, sizeof (cl_dlights));
|
||||||
memset (cl_lightstyle, 0, sizeof (cl_lightstyle));
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,17 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "bothdefs.h"
|
|
||||||
#include "cl_main.h"
|
|
||||||
#include "cl_tent.h"
|
|
||||||
#include "QF/console.h"
|
#include "QF/console.h"
|
||||||
#include "r_local.h"
|
#include "QF/render.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
|
#include "cl_tent.h"
|
||||||
|
#include "r_local.h"
|
||||||
|
|
||||||
mnode_t *r_pefragtopnode;
|
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;
|
ef = ef->entnext;
|
||||||
|
|
||||||
// put it on the free list
|
// put it on the free list
|
||||||
old->entnext = cl.free_efrags;
|
old->entnext = r_free_efrags;
|
||||||
cl.free_efrags = old;
|
r_free_efrags = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->efrag = NULL;
|
ent->efrag = NULL;
|
||||||
|
@ -112,12 +115,12 @@ R_SplitEntityOnNode (mnode_t *node)
|
||||||
leaf = (mleaf_t *) node;
|
leaf = (mleaf_t *) node;
|
||||||
|
|
||||||
// grab an efrag off the free list
|
// grab an efrag off the free list
|
||||||
ef = cl.free_efrags;
|
ef = r_free_efrags;
|
||||||
if (!ef) {
|
if (!ef) {
|
||||||
Con_Printf ("Too many efrags!\n");
|
Con_Printf ("Too many efrags!\n");
|
||||||
return; // no free fragments...
|
return; // no free fragments...
|
||||||
}
|
}
|
||||||
cl.free_efrags = cl.free_efrags->entnext;
|
r_free_efrags = r_free_efrags->entnext;
|
||||||
|
|
||||||
ef->entity = r_addent;
|
ef->entity = r_addent;
|
||||||
|
|
||||||
|
@ -215,7 +218,7 @@ R_AddEfrags (entity_t *ent)
|
||||||
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
|
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SplitEntityOnNode (cl.worldmodel->nodes);
|
R_SplitEntityOnNode (r_worldentity.model->nodes);
|
||||||
|
|
||||||
ent->topnode = r_pefragtopnode;
|
ent->topnode = r_pefragtopnode;
|
||||||
}
|
}
|
||||||
|
@ -230,15 +233,15 @@ void
|
||||||
R_StoreEfrags (efrag_t **ppefrag)
|
R_StoreEfrags (efrag_t **ppefrag)
|
||||||
{
|
{
|
||||||
entity_t *pent;
|
entity_t *pent;
|
||||||
model_t *clmodel;
|
model_t *model;
|
||||||
efrag_t *pefrag;
|
efrag_t *pefrag;
|
||||||
|
|
||||||
|
|
||||||
while ((pefrag = *ppefrag) != NULL) {
|
while ((pefrag = *ppefrag) != NULL) {
|
||||||
pent = pefrag->entity;
|
pent = pefrag->entity;
|
||||||
clmodel = pent->model;
|
model = pent->model;
|
||||||
|
|
||||||
switch (clmodel->type) {
|
switch (model->type) {
|
||||||
case mod_alias:
|
case mod_alias:
|
||||||
case mod_brush:
|
case mod_brush:
|
||||||
case mod_sprite:
|
case mod_sprite:
|
||||||
|
@ -259,7 +262,19 @@ R_StoreEfrags (efrag_t **ppefrag)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Sys_Error ("R_StoreEfrags: Bad entity type %d\n",
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue