Change magic numbers of BSP version checks to macro defines.

This commit is contained in:
Marco Cawthorne 2020-12-13 00:56:11 +01:00
parent 46fb7c2e26
commit 6583a42a87
14 changed files with 19 additions and 19 deletions

View file

@ -33,7 +33,7 @@ Player_PreDraw(base_player pl, int thirdperson)
makevectors(ang);
traceline(src, src + (v_forward * 8096), MOVE_NORMAL, pl);
if (serverkeyfloat("*bspversion") == 30) {
if (serverkeyfloat("*bspversion") == BSPVER_HL) {
dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]);
} else {
float p = dynamiclight_add(src, 512, [1,1,1], 0, "textures/flashlight");

View file

@ -904,7 +904,7 @@ void
CSQC_WorldLoaded(void)
{
/* Primarily for the flashlight */
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
localcmd("r_shadow_realtime_dlight 1\n");
} else {
localcmd("r_shadow_realtime_dlight 0\n");

View file

@ -17,7 +17,7 @@
void
Sky_Update(void)
{
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
return;
}
localcmd(sprintf("sky %s\n", g_strSkyName));

View file

@ -33,7 +33,7 @@ Player_PreDraw(base_player pl, int thirdperson)
makevectors(ang);
traceline(src, src + (v_forward * 8096), MOVE_NORMAL, pl);
if (serverkeyfloat("*bspversion") == 30) {
if (serverkeyfloat("*bspversion") == BSPVER_HL) {
dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]);
} else {
float p = dynamiclight_add(src, 512, [1,1,1], 0, "textures/flashlight");

View file

@ -170,7 +170,7 @@ env_sound::env_sound(void)
setorigin(this, origin);
/* Valve BSP, convert their env_sound */
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
return;
}

View file

@ -33,7 +33,7 @@ This entity was introduced in Half-Life 2 (2004).
int
Util_IsSky(vector pos)
{
if (serverkeyfloat("*bspversion") == 30)
if (serverkeyfloat("*bspversion") == BSPVER_HL)
if (getsurfacetexture(world, getsurfacenearpoint(world, pos)) == "sky") {
return TRUE;
}

View file

@ -131,7 +131,7 @@ func_breakable::Pain(void)
if (spawnflags & SF_TRIGGER) {
return;
}
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
return;
}

View file

@ -95,7 +95,7 @@ infodecal::SpawnKey(string strKey, string strValue)
void
infodecal::infodecal(void)
{
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
remove(self);
return;
}

View file

@ -62,7 +62,7 @@ decal::ReceiveEntity(void)
size = drawgetimagesize(m_strTexture);
if (serverkeyfloat("*bspversion") == 30) {
if (serverkeyfloat("*bspversion") == BSPVER_HL) {
BuildShader();
}
@ -158,7 +158,7 @@ decal::Place(vector org, string dname)
#else
size = drawgetimagesize(m_strTexture);
if (serverkeyfloat("*bspversion") == 30) {
if (serverkeyfloat("*bspversion") == BSPVER_HL) {
BuildShader();
}
@ -222,7 +222,7 @@ decal Decals_Next(vector pos)
/* Generalized Decal Placing Function */
void Decals_Place(vector pos, string dname)
{
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") != BSPVER_HL) {
return;
}

View file

@ -153,7 +153,7 @@ void initents(void)
/* sound shader init */
Sound_Init();
if (serverkeyfloat("*bspversion") != 30) {
if (serverkeyfloat("*bspversion") == BSPVER_HL) {
/* load materials.txt because someone thought this was the best idea */
filestream fileMaterial = fopen("sound/materials.txt", FILE_READ);
hashMaterials = __NULL__;

View file

@ -267,12 +267,12 @@ Footsteps_Update(void)
pl.step_time = time + 0.35;
switch (serverkeyfloat("*bspversion")) {
case 30: /* HL */
case BSPVER_HL:
Footsteps_HLBSP(pl);
break;
case 46: /* Q3 */
case 47: /* RtCW */
case 1: /* RFVBSP */
case BSPVER_Q3: /* Q3 */
case BSPVER_RTCW: /* RtCW */
case BSPVER_RBSP: /* RFVBSP */
Footsteps_VVBSP(pl);
break;
default:

View file

@ -45,7 +45,7 @@ FX_Blood(vector pos, vector color)
#else
static void Blood_Touch(void)
{
if (serverkeyfloat("*bspversion") == 30)
if (serverkeyfloat("*bspversion") == BSPVER_HL)
Decals_Place(self.origin, sprintf("{blood%d", floor(random(1,9))));
else {
decal_pickwall(self, self.origin);

View file

@ -52,7 +52,7 @@ FX_GibHuman(vector pos)
}
static void Gib_Touch(void)
{
if (serverkeyfloat("*bspversion") == 30)
if (serverkeyfloat("*bspversion") == BSPVER_HL)
Decals_Place(self.origin, sprintf("{blood%d", floor(random(1,9))));
else {
decal_pickwall(self, self.origin);

View file

@ -88,7 +88,7 @@ FX_Impact(int iType, vector vecPos, vector vNormal)
multicast(vecPos, MULTICAST_PVS);
#else
/* decals */
if (serverkeyfloat("*bspversion") == 30)
if (serverkeyfloat("*bspversion") == BSPVER_HL)
switch (iType) {
case IMPACT_GLASS:
Decals_Place(vecPos, sprintf("{break%d", floor(random(1,4))));