Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix named constants usages #656

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions rehlds/HLTV/Core/src/BSPModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void BSPModel::Clear()
Free(m_model.surfaces);
Free(m_model.marksurfaces);
Free(m_model.clipnodes);
Free(m_model.hulls[0].clipnodes);
Free(m_model.hulls[point_hull].clipnodes);
Free(m_model.texinfo);

if (m_model.textures)
Expand Down Expand Up @@ -508,7 +508,7 @@ void BSPModel::MakeHull0()
int i, j, count;
hull_t *hull;

hull = &m_model.hulls[0];
hull = &m_model.hulls[point_hull];

in = m_model.nodes;
count = m_model.numnodes;
Expand Down Expand Up @@ -981,7 +981,7 @@ void BSPModel::LoadClipnodes(lump_t *l)
m_model.clipnodes = out;
m_model.numclipnodes = count;

hull = &m_model.hulls[1];
hull = &m_model.hulls[human_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -993,7 +993,7 @@ void BSPModel::LoadClipnodes(lump_t *l)
hull->clip_maxs[1] = 16;
hull->clip_maxs[2] = 36;

hull = &m_model.hulls[2];
hull = &m_model.hulls[large_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -1005,7 +1005,7 @@ void BSPModel::LoadClipnodes(lump_t *l)
hull->clip_maxs[1] = 32;
hull->clip_maxs[2] = 32;

hull = &m_model.hulls[3];
hull = &m_model.hulls[head_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -1027,7 +1027,7 @@ void BSPModel::LoadClipnodes(lump_t *l)

int BSPModel::TruePointContents(vec_t *point)
{
hull_t *hull = &m_model.hulls[0];
hull_t *hull = &m_model.hulls[point_hull];
if (hull->firstclipnode >= hull->lastclipnode) {
return CONTENTS_EMPTY;
}
Expand Down
10 changes: 5 additions & 5 deletions rehlds/engine/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ void Mod_LoadClipnodes(lump_t *l)
loadmodel->clipnodes = out;
loadmodel->numclipnodes = count;

hull = &loadmodel->hulls[1];
hull = &loadmodel->hulls[human_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -1102,7 +1102,7 @@ void Mod_LoadClipnodes(lump_t *l)
hull->clip_maxs[1] = 16;
hull->clip_maxs[2] = 36;

hull = &loadmodel->hulls[2];
hull = &loadmodel->hulls[large_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -1114,7 +1114,7 @@ void Mod_LoadClipnodes(lump_t *l)
hull->clip_maxs[1] = 32;
hull->clip_maxs[2] = 32;

hull = &loadmodel->hulls[3];
hull = &loadmodel->hulls[head_hull];
hull->clipnodes = out;
hull->firstclipnode = 0;
hull->lastclipnode = count - 1;
Expand All @@ -1141,7 +1141,7 @@ void Mod_MakeHull0(void)
int i, j, count;
hull_t *hull;

hull = &loadmodel->hulls[0];
hull = &loadmodel->hulls[point_hull];

in = loadmodel->nodes;
count = loadmodel->numnodes;
Expand Down Expand Up @@ -1317,7 +1317,7 @@ void EXT_FUNC Mod_LoadBrushModel_internal(model_t *mod, void *buffer)
{
bm = &mod->submodels[i];

mod->hulls[0].firstclipnode = bm->headnode[0];
mod->hulls[point_hull].firstclipnode = bm->headnode[point_hull];
for (int j = 1; j < MAX_MAP_HULLS; j++)
{
mod->hulls[j].firstclipnode = bm->headnode[j];
Expand Down
66 changes: 33 additions & 33 deletions rehlds/engine/pmovetst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void PM_InitBoxHull(void)
{
int side = i & 1;
box_clipnodes_0[i].planenum = i;
box_clipnodes_0[i].children[side] = -1;
box_clipnodes_0[i].children[side] = CONTENTS_EMPTY;
box_clipnodes_0[i].children[side ^ 1] = (i != 5) ? i + 1 : CONTENTS_SOLID;
box_planes_0[i].type = i >> 1;
box_planes_0[i].normal[i >> 1] = 1.0f;
Expand All @@ -108,7 +108,7 @@ int EXT_FUNC PM_HullPointContents(hull_t *hull, int num, vec_t *p)
mplane_t *plane;

if (hull->firstclipnode >= hull->lastclipnode)
return -1;
return CONTENTS_EMPTY;

while (num >= 0)
{
Expand Down Expand Up @@ -145,14 +145,14 @@ int PM_LinkContents(vec_t *p, int *pIndex)
test[0] = p[0] - pe->origin[0];
test[1] = p[1] - pe->origin[1];
test[2] = p[2] - pe->origin[2];
if (PM_HullPointContents(model->hulls, model->hulls[0].firstclipnode, test) != -1) {
if (PM_HullPointContents(model->hulls, model->hulls[point_hull].firstclipnode, test) != CONTENTS_EMPTY) {
if (pIndex)
*pIndex = pe->info;
return pe->skin;
}
}

return -1;
return CONTENTS_EMPTY;
}

int EXT_FUNC PM_PointContents(vec_t *p, int *truecontents)
Expand All @@ -165,27 +165,27 @@ int EXT_FUNC PM_PointContents(vec_t *p, int *truecontents)
{
int entityContents = PM_HullPointContents(
pmove->physents[0].model->hulls,
pmove->physents[0].model->hulls[0].firstclipnode,
pmove->physents[0].model->hulls[point_hull].firstclipnode,
p);
if (truecontents)
*truecontents = entityContents;
if (entityContents > -9 || entityContents < -14)
if (entityContents > CONTENTS_CURRENT_0 || entityContents < CONTENTS_CURRENT_DOWN)
{
if (entityContents == -2)
if (entityContents == CONTENTS_SOLID)
return entityContents;
}
else
{
entityContents = -3;
entityContents = CONTENTS_WATER;
}
int cont = PM_LinkContents(p, 0);
if (cont != -1)
if (cont != CONTENTS_EMPTY)
return cont;
return entityContents;
}
if (truecontents)
*truecontents = -1;
return -2;
*truecontents = CONTENTS_EMPTY;
return CONTENTS_SOLID;
}

int PM_WaterEntity(vec_t *p)
Expand All @@ -198,9 +198,9 @@ int PM_WaterEntity(vec_t *p)
#endif

model_t* model = pmove->physents[0].model;
cont = PM_HullPointContents(model->hulls, model->hulls[0].firstclipnode, p);
if (cont == -2) {
return -1;
cont = PM_HullPointContents(model->hulls, model->hulls[point_hull].firstclipnode, p);
if (cont == CONTENTS_SOLID) {
return CONTENTS_EMPTY;
}

entityIndex = 0;
Expand All @@ -210,9 +210,9 @@ int PM_WaterEntity(vec_t *p)
int EXT_FUNC PM_TruePointContents(vec_t *p)
{
if ((int)pmove->physents[0].model == -208)
return -1;
return CONTENTS_EMPTY;
else
return PM_HullPointContents(pmove->physents[0].model->hulls, pmove->physents[0].model->hulls[0].firstclipnode, p);
return PM_HullPointContents(pmove->physents[0].model->hulls, pmove->physents[0].model->hulls[point_hull].firstclipnode, p);
}

hull_t *PM_HullForStudioModel(model_t *pModel, vec_t *offset, float frame, int sequence, const vec_t *angles, const vec_t *origin, const unsigned char *pcontroller, const unsigned char *pblending, int *pNumHulls)
Expand All @@ -235,19 +235,19 @@ hull_t* EXT_FUNC PM_HullForBsp(physent_t *pe, vec_t *offset)

switch (pmove->usehull) {
case 1:
hull = &pe->model->hulls[3];
hull = &pe->model->hulls[head_hull];
break;

case 2:
hull = &pe->model->hulls[0];
hull = &pe->model->hulls[point_hull];
break;

case 3:
hull = &pe->model->hulls[2];
hull = &pe->model->hulls[large_hull];
break;

default:
hull = &pe->model->hulls[1];
hull = &pe->model->hulls[human_hull];
break;
}

Expand Down Expand Up @@ -405,16 +405,16 @@ pmtrace_t _PM_PlayerTrace(vec_t *start, vec_t *end, int traceFlags, int numphyse
switch (pmove->usehull)
{
case 1:
hull = &pe->model->hulls[3];
hull = &pe->model->hulls[head_hull];
break;
case 2:
hull = &pe->model->hulls[0];
hull = &pe->model->hulls[point_hull];
break;
case 3:
hull = &pe->model->hulls[2];
hull = &pe->model->hulls[large_hull];
break;
default:
hull = &pe->model->hulls[1];
hull = &pe->model->hulls[human_hull];
break;
}
offset[0] = hull->clip_mins[0] - player_mins[pmove->usehull][0];
Expand Down Expand Up @@ -578,9 +578,9 @@ struct pmtrace_s* EXT_FUNC PM_TraceLine(float *start, float *end, int flags, int

oldhull = pmove->usehull;
pmove->usehull = usehull;
if (flags)
if (flags != PM_TRACELINE_PHYSENTSONLY)
{
if (flags == 1)
if (flags == PM_TRACELINE_ANYVISIBLE)
tr = _PM_PlayerTrace(start, end, PM_NORMAL, pmove->numvisent, pmove->visents, ignore_pe, NULL);
}
else
Expand All @@ -598,7 +598,7 @@ struct pmtrace_s* EXT_FUNC PM_TraceLineEx(float *start, float *end, int flags, i

oldhull = pmove->usehull;
pmove->usehull = usehull;
if (flags)
if (flags != PM_TRACELINE_PHYSENTSONLY)
{
tr = _PM_PlayerTrace(start, end, PM_NORMAL, pmove->numvisent, pmove->visents, -1, pfnIgnore);
}
Expand Down Expand Up @@ -700,7 +700,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
if (!PM_RecursiveHullCheck(hull, node->children[side], p1f, frac, p1, mid, trace))
return 0;

if (PM_HullPointContents(hull, node->children[side ^ 1], mid) != -2)
if (PM_HullPointContents(hull, node->children[side ^ 1], mid) != CONTENTS_SOLID)
return PM_RecursiveHullCheck(hull, node->children[side ^ 1], frac, p2f, mid, p2, trace);

if (trace->allsolid)
Expand All @@ -721,7 +721,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
trace->plane.dist = plane->dist;
}

if (PM_HullPointContents(hull, hull->firstclipnode, mid) != -2)
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != CONTENTS_SOLID)
{
trace->fraction = frac;
trace->endpos[0] = mid[0];
Expand All @@ -740,7 +740,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
mid[0] = (p2[0] - p1[0]) * midf + p1[0];
mid[1] = (p2[1] - p1[1]) * midf + p1[1];
mid[2] = (p2[2] - p1[2]) * midf + p1[2];
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != -2)
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != CONTENTS_SOLID)
{
trace->fraction = frac;
trace->endpos[0] = mid[0];
Expand Down Expand Up @@ -858,7 +858,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
if (!PM_RecursiveHullCheck(hull, node->children[side], p1f, frac, p1, mid, trace))
return 0;

if (PM_HullPointContents(hull, node->children[side ^ 1], mid) != -2)
if (PM_HullPointContents(hull, node->children[side ^ 1], mid) != CONTENTS_SOLID)
{
num = node->children[side ^ 1];
p1f = frac;
Expand Down Expand Up @@ -887,7 +887,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
trace->plane.dist = plane->dist;
}

if (PM_HullPointContents(hull, hull->firstclipnode, mid) != -2)
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != CONTENTS_SOLID)
{
trace->fraction = frac;
trace->endpos[0] = mid[0];
Expand All @@ -906,7 +906,7 @@ qboolean PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, cons
mid[0] = (p2[0] - p1[0]) * midf + p1[0];
mid[1] = (p2[1] - p1[1]) * midf + p1[1];
mid[2] = (p2[2] - p1[2]) * midf + p1[2];
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != -2)
if (PM_HullPointContents(hull, hull->firstclipnode, mid) != CONTENTS_SOLID)
{
trace->fraction = frac;
trace->endpos[0] = mid[0];
Expand Down
2 changes: 1 addition & 1 deletion rehlds/engine/r_studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ hull_t *SV_HullForStudioModel(const edict_t *pEdict, const vec_t *mins, const ve
if (pEdict->v.gamestate == 1 && (g_eGameType == GT_TerrorStrike || g_eGameType == GT_CStrike || g_eGameType == GT_CZero))
bSkipShield = 1;

if ((g_psv.models[pEdict->v.modelindex]->flags & FL_ONGROUND) || useComplexHull == TRUE)
if ((g_psv.models[pEdict->v.modelindex]->flags & STUDIO_TRACE_HITBOX) || useComplexHull == TRUE)
{
VectorScale(size, factor, size);
offset[0] = 0;
Expand Down
10 changes: 5 additions & 5 deletions rehlds/engine/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ hull_t *SV_HullForBsp(edict_t *ent, const vec_t *mins, const vec_t *maxs, vec_t

if (size[0] <= 8.0f)
{
hull = &model->hulls[0];
hull = &model->hulls[point_hull];
VectorCopy(hull->clip_mins, offset);
}
else
Expand All @@ -202,13 +202,13 @@ hull_t *SV_HullForBsp(edict_t *ent, const vec_t *mins, const vec_t *maxs, vec_t
#else
if (size[2] <= 36.0f)
#endif
hull = &model->hulls[3];
hull = &model->hulls[head_hull];
else
hull = &model->hulls[1];
hull = &model->hulls[human_hull];
}
else
{
hull = &model->hulls[2];
hull = &model->hulls[large_hull];
}

// calculate an offset value to center the origin
Expand Down Expand Up @@ -1459,7 +1459,7 @@ void SV_SingleClipMoveToPoint(const vec_t *start, const vec_t *end, trace_t *tra
trace->allsolid = TRUE;
VectorCopy(end, trace->endpos);

hull_t *hull = &g_psv.models[1]->hulls[0]; // world point hull
hull_t *hull = &g_psv.models[1]->hulls[point_hull]; // world point hull
SV_RecursiveHullCheck(hull, hull->firstclipnode, 0.0f, 1.0f, start, end, trace);

if (trace->fraction != 1.0f)
Expand Down
1 change: 1 addition & 0 deletions rehlds/public/rehlds/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ typedef struct hull_s
int lastclipnode;
vec3_t clip_mins, clip_maxs;
} hull_t;
typedef enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 };
LevShisterov marked this conversation as resolved.
Show resolved Hide resolved

typedef struct mspriteframe_t
{
Expand Down