From e3881a4d7030183dad9f6907456d66e2dca4f64c Mon Sep 17 00:00:00 2001 From: WofWca Date: Tue, 18 Nov 2025 12:05:34 +0400 Subject: [PATCH] refactor: un-magic `#define INVUL_RADIUS 42` --- code/game/bg_pmove.c | 4 ++-- code/game/bg_public.h | 1 + code/game/g_active.c | 4 ++-- code/game/g_combat.c | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 592a977f..c7541743 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -1252,8 +1252,8 @@ static void PM_CheckDuck (void) if ( pm->ps->powerups[PW_INVULNERABILITY] ) { if ( pm->ps->pm_flags & PMF_INVULEXPAND ) { // invulnerability sphere has a 42 units radius - VectorSet( pm->mins, -42, -42, -42 ); - VectorSet( pm->maxs, 42, 42, 42 ); + VectorSet( pm->mins, -INVUL_RADIUS, -INVUL_RADIUS, -INVUL_RADIUS ); + VectorSet( pm->maxs, INVUL_RADIUS, INVUL_RADIUS, INVUL_RADIUS ); } else { VectorSet( pm->mins, -PLAYER_WIDTH, -PLAYER_WIDTH, MINS_Z ); diff --git a/code/game/bg_public.h b/code/game/bg_public.h index a9b8aea6..7d203fb0 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -54,6 +54,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define CROUCH_VIEWHEIGHT 12 #define DEAD_HEIGHT -8 #define DEAD_VIEWHEIGHT -16 +#define INVUL_RADIUS 42 // // config strings are a general means of communicating variable length strings diff --git a/code/game/g_active.c b/code/game/g_active.c index a506a1e0..8c9a7848 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -879,8 +879,8 @@ void ClientThink_real( gentity_t *ent ) { // check for invulnerability expansion before doing the Pmove if (client->ps.powerups[PW_INVULNERABILITY] ) { if ( !(client->ps.pm_flags & PMF_INVULEXPAND) ) { - vec3_t mins = { -42, -42, -42 }; - vec3_t maxs = { 42, 42, 42 }; + vec3_t mins = { -INVUL_RADIUS, -INVUL_RADIUS, -INVUL_RADIUS }; + vec3_t maxs = { INVUL_RADIUS, INVUL_RADIUS, INVUL_RADIUS }; vec3_t oldmins, oldmaxs; VectorCopy (ent->r.mins, oldmins); diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 70818f3b..b8f7448a 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -753,8 +753,7 @@ int G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t i } VectorCopy(dir, vec); VectorInverse(vec); - // sphere model radius = 42 units - n = RaySphereIntersections( targ->client->ps.origin, 42, point, vec, intersections); + n = RaySphereIntersections( targ->client->ps.origin, INVUL_RADIUS, point, vec, intersections); if (n > 0) { impact = G_TempEntity( targ->client->ps.origin, EV_INVUL_IMPACT ); VectorSubtract(intersections[0], targ->client->ps.origin, vec);