entities: push down constness of entities where possible

Pass over the source and make as many references to entities as possible
const. This makes it much more obvious where we are actually making
modifications to the entity_t structure.

Mostly trivial, the only place where I did something other than add the
keyword "const" was in R_DrawBrushModel where we were working around the
reversed pitch bug.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2012-11-25 15:49:46 +10:30
parent 1f07d50968
commit a475651b54
26 changed files with 63 additions and 60 deletions

View File

@ -75,7 +75,7 @@ entity_t cl_visedicts[MAX_VISEDICTS];
* Returns the player number if the entity is a player, 0 otherwise
*/
int
CL_PlayerEntity(entity_t *e)
CL_PlayerEntity(const entity_t *e)
{
ptrdiff_t offset;
int i;
@ -302,7 +302,7 @@ CL_PrintEntities_f
void
CL_PrintEntities_f(void)
{
entity_t *ent;
const entity_t *ent;
int i;
for (i = 0, ent = cl_entities; i < cl.num_entities; i++, ent++) {

View File

@ -265,7 +265,7 @@ extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
* CL_PlayerEntity()
* Returns the player number if the entity is a player, 0 otherwise
*/
int CL_PlayerEntity(entity_t *e);
int CL_PlayerEntity(const entity_t *e);
//=============================================================================

View File

@ -321,7 +321,7 @@ V_ParseDamage(void)
vec3_t from;
int i;
vec3_t forward, right, up;
entity_t *ent;
const entity_t *ent;
float side;
float count;
@ -694,7 +694,7 @@ V_BoundOffsets
void
V_BoundOffsets(void)
{
entity_t *ent;
const entity_t *ent;
ent = &cl_entities[cl.viewentity];

View File

@ -391,7 +391,7 @@ CL_Record_f(void)
byte buf_data[MAX_MSGLEN];
int n, i, j;
char *s;
entity_t *ent;
const entity_t *ent;
entity_state_t *es, blankes;
player_info_t *player;
int seq = 1;

View File

@ -170,7 +170,7 @@ D_DrawSurfaces
void
D_DrawSurfaces(void)
{
entity_t *e;
const entity_t *e;
surf_t *s;
msurface_t *pface;
surfcache_t *pcurrentcache;

View File

@ -264,7 +264,7 @@ D_CacheSurface
================
*/
surfcache_t *
D_CacheSurface(entity_t *e, msurface_t *surface, int miplevel)
D_CacheSurface(const entity_t *e, msurface_t *surface, int miplevel)
{
surfcache_t *cache;

View File

@ -156,7 +156,7 @@ R_CullBox(vec3_t mins, vec3_t maxs)
void
R_RotateForEntity(vec3_t origin, vec3_t angles)
R_RotateForEntity(const vec3_t origin, const vec3_t angles)
{
glTranslatef(origin[0], origin[1], origin[2]);
@ -197,7 +197,7 @@ R_DrawSpriteModel
=================
*/
static void
R_DrawSpriteModel(entity_t *e)
R_DrawSpriteModel(const entity_t *e)
{
vec3_t point;
mspriteframe_t *frame;
@ -417,7 +417,7 @@ GL_AliasDrawModel
=============
*/
static void
GL_AliasDrawModel(entity_t *e, float blend)
GL_AliasDrawModel(const entity_t *e, float blend)
{
float l;
aliashdr_t *pahdr;
@ -507,7 +507,7 @@ GL_DrawAliasShadow
=============
*/
static void
GL_DrawAliasShadow(entity_t *e, aliashdr_t *paliashdr, int posenum)
GL_DrawAliasShadow(const entity_t *e, aliashdr_t *paliashdr, int posenum)
{
trivertx_t *verts;
int *order;
@ -569,7 +569,7 @@ R_AliasSetupSkin
===============
*/
static void
R_AliasSetupSkin(entity_t *e, aliashdr_t *pahdr)
R_AliasSetupSkin(const entity_t *e, aliashdr_t *pahdr)
{
int skinnum;
int frame, numframes;

View File

@ -333,7 +333,7 @@ R_TranslatePlayerSkin(int playernum)
model_t *model;
aliashdr_t *paliashdr;
int size;
entity_t *e;
const entity_t *e;
#endif
#ifdef QW_HACK
player_info_t *player;

View File

@ -260,7 +260,7 @@ Returns the proper texture for a given time and base texture
===============
*/
texture_t *
R_TextureAnimation(entity_t *e, texture_t *base)
R_TextureAnimation(const entity_t *e, texture_t *base)
{
int reletive;
int count;
@ -628,7 +628,7 @@ R_RenderBrushPoly
================
*/
void
R_RenderBrushPoly(entity_t *e, msurface_t *fa)
R_RenderBrushPoly(const entity_t *e, msurface_t *fa)
{
int i;
texture_t *t;
@ -753,7 +753,7 @@ DrawTextureChains
================
*/
static void
DrawTextureChains(entity_t *e)
DrawTextureChains(const entity_t *e)
{
int i;
msurface_t *s;
@ -854,10 +854,10 @@ R_DrawBrushModel
=================
*/
void
R_DrawBrushModel(entity_t *e)
R_DrawBrushModel(const entity_t *e)
{
int i, k;
vec3_t mins, maxs;
vec3_t mins, maxs, angles_bug;
msurface_t *psurf;
float dot;
mplane_t *pplane;
@ -898,9 +898,10 @@ R_DrawBrushModel(entity_t *e)
psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
glPushMatrix();
e->angles[0] = -e->angles[0]; // stupid quake bug
R_RotateForEntity(e->origin, e->angles);
e->angles[0] = -e->angles[0]; // stupid quake bug
/* Stupid bug means pitch is reversed for entities */
VectorCopy(e->angles, angles_bug);
angles_bug[PITCH] = -angles_bug[PITCH];
R_RotateForEntity(e->origin, angles_bug);
if (!r_drawflat.value) {
/*

View File

@ -317,7 +317,7 @@ BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, mplane_t *p)
void
AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{
float angle;
float sr, sp, sy, cr, cp, cy;

View File

@ -80,9 +80,9 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
#include "anorms.h"
};
static void R_AliasSetUpTransform(entity_t *e, aliashdr_t *pahdr,
static void R_AliasSetUpTransform(const entity_t *e, aliashdr_t *pahdr,
int trivial_accept);
static void R_AliasTransformVector(vec3_t in, vec3_t out);
static void R_AliasTransformVector(const vec3_t in, vec3_t out);
static void R_AliasTransformFinalVert(finalvert_t *fv, auxvert_t *av,
trivertx_t *pverts, stvert_t *pstverts);
@ -336,7 +336,7 @@ R_AliasTransformVector
================
*/
static void
R_AliasTransformVector(vec3_t in, vec3_t out)
R_AliasTransformVector(const vec3_t in, vec3_t out)
{
out[0] = DotProduct(in, aliastransform[0]) + aliastransform[0][3];
out[1] = DotProduct(in, aliastransform[1]) + aliastransform[1][3];
@ -416,7 +416,7 @@ R_AliasSetUpTransform
================
*/
static void
R_AliasSetUpTransform(entity_t *e, aliashdr_t *pahdr, int trivial_accept)
R_AliasSetUpTransform(const entity_t *e, aliashdr_t *pahdr, int trivial_accept)
{
int i;
float rotationmatrix[3][4], t2matrix[3][4];
@ -659,7 +659,7 @@ R_AliasSetupSkin
===============
*/
static void
R_AliasSetupSkin(entity_t *e, aliashdr_t *pahdr)
R_AliasSetupSkin(const entity_t *e, aliashdr_t *pahdr)
{
int skinnum;
int frame, numframes, skinbytes;

View File

@ -78,7 +78,7 @@ R_RotateBmodel
================
*/
void
R_RotateBmodel(entity_t *e)
R_RotateBmodel(const entity_t *e)
{
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
@ -157,7 +157,7 @@ R_RecursiveClipBPoly
================
*/
static void
R_RecursiveClipBPoly(entity_t *e, bedge_t *pedges, mnode_t *pnode,
R_RecursiveClipBPoly(const entity_t *e, bedge_t *pedges, mnode_t *pnode,
msurface_t *psurf)
{
bedge_t *psideedges[2], *pnextedge, *ptedge;
@ -311,7 +311,7 @@ R_DrawSolidClippedSubmodelPolygons
================
*/
void
R_DrawSolidClippedSubmodelPolygons(entity_t *e, model_t *pmodel)
R_DrawSolidClippedSubmodelPolygons(const entity_t *e, model_t *pmodel)
{
int i, j, lindex;
vec_t dot;
@ -386,7 +386,7 @@ R_DrawSubmodelPolygons
================
*/
void
R_DrawSubmodelPolygons(entity_t *e, model_t *pmodel, int clipflags)
R_DrawSubmodelPolygons(const entity_t *e, model_t *pmodel, int clipflags)
{
int i;
vec_t dot;
@ -423,7 +423,7 @@ R_RecursiveWorldNode
================
*/
static void
R_RecursiveWorldNode(entity_t *e, mnode_t *node, int clipflags)
R_RecursiveWorldNode(const entity_t *e, mnode_t *node, int clipflags)
{
int i, c, side, *pindex;
vec3_t acceptpt, rejectpt;

View File

@ -345,7 +345,7 @@ R_RenderFace
================
*/
void
R_RenderFace(entity_t *e, msurface_t *fa, int clipflags)
R_RenderFace(const entity_t *e, msurface_t *fa, int clipflags)
{
int i, lindex;
unsigned mask;
@ -515,7 +515,7 @@ R_RenderBmodelFace
================
*/
void
R_RenderBmodelFace(entity_t *e, bedge_t *pedges, msurface_t *psurf)
R_RenderBmodelFace(const entity_t *e, bedge_t *pedges, msurface_t *psurf)
{
int i;
unsigned mask;
@ -619,7 +619,7 @@ R_RenderPoly
================
*/
void
R_RenderPoly(entity_t *e, msurface_t *fa, int clipflags)
R_RenderPoly(const entity_t *e, msurface_t *fa, int clipflags)
{
int i, lindex, lnumverts, s_axis, t_axis;
float dist, lastdist, lzi, scale, u, v, frac;
@ -791,7 +791,7 @@ R_ZDrawSubmodelPolys
================
*/
void
R_ZDrawSubmodelPolys(entity_t *e, model_t *pmodel)
R_ZDrawSubmodelPolys(const entity_t *e, model_t *pmodel)
{
int i, numsurfaces;
msurface_t *psurf;

View File

@ -83,7 +83,7 @@ R_DrawCulledPolys
void
R_DrawCulledPolys(void)
{
entity_t *e;
const entity_t *e;
surf_t *s;
msurface_t *pface;

View File

@ -746,7 +746,7 @@ R_BmodelCheckBBox
=============
*/
static int
R_BmodelCheckBBox(entity_t *e, model_t *clmodel, float *minmaxs)
R_BmodelCheckBBox(const entity_t *e, model_t *clmodel, float *minmaxs)
{
int i, *pindex, clipflags;
vec3_t acceptpt, rejectpt;

View File

@ -88,7 +88,7 @@ float partstep = 0.01;
float timescale = 0.01;
void
R_EntityParticles(entity_t *ent)
R_EntityParticles(const entity_t *ent)
{
int i;
particle_t *p;

View File

@ -255,7 +255,7 @@ R_DrawSprite
================
*/
void
R_DrawSprite(entity_t *e)
R_DrawSprite(const entity_t *e)
{
int i;
msprite_t *psprite;

View File

@ -190,7 +190,7 @@ Returns the proper texture for a given time and base texture
===============
*/
texture_t *
R_TextureAnimation(entity_t *e, texture_t *base)
R_TextureAnimation(const entity_t *e, texture_t *base)
{
int reletive;
int count;

View File

@ -200,7 +200,7 @@ Mod_GetSpriteFrame
==================
*/
mspriteframe_t *
Mod_GetSpriteFrame(entity_t *e, msprite_t *psprite, float time)
Mod_GetSpriteFrame(const entity_t *e, msprite_t *psprite, float time)
{
mspritegroup_t *pspritegroup;
mspriteframe_t *pspriteframe;

View File

@ -83,7 +83,8 @@ void D_DrawSkyScans16(espan_t *pspan);
void R_ShowSubDiv(void);
void (*prealspandrawer) (void);
surfcache_t *D_CacheSurface(entity_t *e, msurface_t *surface, int miplevel);
surfcache_t *D_CacheSurface(const entity_t *e, msurface_t *surface,
int miplevel);
#ifdef USE_X86_ASM
extern void D_PolysetAff8Start(void);

View File

@ -273,7 +273,7 @@ void GL_Set2D(void);
// gl_rmain.c
//
qboolean R_CullBox(vec3_t mins, vec3_t maxs);
void R_RotateForEntity(vec3_t origin, vec3_t angles);
void R_RotateForEntity(const vec3_t origin, const vec3_t angles);
/*
* The renderer supplies callbacks to the model loader
@ -307,11 +307,11 @@ void R_InitBubble(void);
//
// gl_rsurf.c
//
void R_DrawBrushModel(entity_t *e);
void R_DrawBrushModel(const entity_t *e);
void R_DrawWorld(void);
void R_DrawWorldHull(void); /* Quick hack for now... */
void R_DrawWaterSurfaces(void);
void R_RenderBrushPoly(entity_t *e, msurface_t *fa);
void R_RenderBrushPoly(const entity_t *e, msurface_t *fa);
void GL_BuildLightmaps(void);
//

View File

@ -94,7 +94,7 @@ void FloorDivMod(double numer, double denom, int *quotient, int *rem);
fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor(int i1, int i2);
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
float anglemod(float a);

View File

@ -473,14 +473,15 @@ mleaf_t *Mod_PointInLeaf(float *p, model_t *model);
byte *Mod_LeafPVS(mleaf_t *leaf, model_t *model);
// FIXME - surely this doesn't belong here?
texture_t *R_TextureAnimation(struct entity_s *e, texture_t *base);
texture_t *R_TextureAnimation(const struct entity_s *e, texture_t *base);
void Mod_LoadAliasModel(const model_loader_t *loader, model_t *mod,
void *buffer, const model_t *loadmodel,
const char *loadname);
void Mod_LoadSpriteModel(model_t *mod, void *buffer, const char *loadname);
mspriteframe_t *Mod_GetSpriteFrame(struct entity_s *e, msprite_t *psprite, float time);
mspriteframe_t *Mod_GetSpriteFrame(const struct entity_s *e,
msprite_t *psprite, float time);
int Mod_FindInterval(const float *intervals, int numintervals, float time);

View File

@ -117,10 +117,10 @@ void R_DrawPolyList(void);
//
extern qboolean insubmodel;
void R_DrawSprite(entity_t *e);
void R_RenderFace(entity_t *e, msurface_t *fa, int clipflags);
void R_RenderPoly(entity_t *e, msurface_t *fa, int clipflags);
void R_RenderBmodelFace(entity_t *e, bedge_t *pedges, msurface_t *psurf);
void R_DrawSprite(const entity_t *e);
void R_RenderFace(const entity_t *e, msurface_t *fa, int clipflags);
void R_RenderPoly(const entity_t *e, msurface_t *fa, int clipflags);
void R_RenderBmodelFace(const entity_t *e, bedge_t *pedges, msurface_t *psurf);
void R_TransformPlane(mplane_t *p, float *normal, float *dist);
void R_TransformFrustum(void);
void R_SetSkyFrame(void);
@ -140,8 +140,8 @@ void R_GenSkyTile(void *pdest);
void R_GenSkyTile16(void *pdest);
void R_Surf8Patch(void);
void R_Surf16Patch(void);
void R_DrawSubmodelPolygons(entity_t *e, model_t *pmodel, int clipflags);
void R_DrawSolidClippedSubmodelPolygons(entity_t *e, model_t *pmodel);
void R_DrawSubmodelPolygons(const entity_t *e, model_t *pmodel, int clipflags);
void R_DrawSolidClippedSubmodelPolygons(const entity_t *e, model_t *pmodel);
void R_AddPolygonEdges(emitpoint_t *pverts, int numverts, int miplevel);
surf_t *R_GetSurf(void);
@ -159,7 +159,7 @@ extern void R_Surf16End(void);
extern void R_EdgeCodeStart(void);
extern void R_EdgeCodeEnd(void);
extern void R_RotateBmodel(entity_t *e);
extern void R_RotateBmodel(const entity_t *e);
extern int c_faceclip;
extern int r_polycount;
@ -192,7 +192,7 @@ typedef struct btofpoly_s {
extern int numbtofpolys;
extern btofpoly_t *pbtofpolys;
void R_ZDrawSubmodelPolys(entity_t *e, model_t *clmodel);
void R_ZDrawSubmodelPolys(const entity_t *e, model_t *clmodel);
//=========================================================
// Alias models

View File

@ -92,7 +92,7 @@ typedef struct surf_s {
// start)
int flags; // currentface flags
void *data; // associated data like msurface_t
entity_t *entity;
const entity_t *entity;
float nearzi; // nearest 1/z on surface, for mipmapping
qboolean insubmodel;
float d_ziorigin, d_zistepu, d_zistepv;

View File

@ -180,7 +180,7 @@ void R_LavaSplash(vec3_t org);
void R_TeleportSplash(vec3_t org);
#ifdef NQ_HACK
void R_EntityParticles(entity_t *ent);
void R_EntityParticles(const entity_t *ent);
void R_ParticleExplosion2(vec3_t org, int colorStart, int colorLength);
#endif