refactor: name some magic numbers in bg_pmove

This commit is contained in:
WofWca 2025-11-06 12:15:05 +04:00 committed by Tim Angus
parent 4f9e3b96e0
commit 3041ec3695
2 changed files with 12 additions and 9 deletions

View File

@ -1256,8 +1256,8 @@ static void PM_CheckDuck (void)
VectorSet( pm->maxs, 42, 42, 42 ); VectorSet( pm->maxs, 42, 42, 42 );
} }
else { else {
VectorSet( pm->mins, -15, -15, MINS_Z ); VectorSet( pm->mins, -PLAYER_WIDTH, -PLAYER_WIDTH, MINS_Z );
VectorSet( pm->maxs, 15, 15, 16 ); VectorSet( pm->maxs, PLAYER_WIDTH, PLAYER_WIDTH, 16 );
} }
pm->ps->pm_flags |= PMF_DUCKED; pm->ps->pm_flags |= PMF_DUCKED;
pm->ps->viewheight = CROUCH_VIEWHEIGHT; pm->ps->viewheight = CROUCH_VIEWHEIGHT;
@ -1265,11 +1265,11 @@ static void PM_CheckDuck (void)
} }
pm->ps->pm_flags &= ~PMF_INVULEXPAND; pm->ps->pm_flags &= ~PMF_INVULEXPAND;
pm->mins[0] = -15; pm->mins[0] = -PLAYER_WIDTH;
pm->mins[1] = -15; pm->mins[1] = -PLAYER_WIDTH;
pm->maxs[0] = 15; pm->maxs[0] = PLAYER_WIDTH;
pm->maxs[1] = 15; pm->maxs[1] = PLAYER_WIDTH;
pm->mins[2] = MINS_Z; pm->mins[2] = MINS_Z;
@ -1289,7 +1289,7 @@ static void PM_CheckDuck (void)
if (pm->ps->pm_flags & PMF_DUCKED) if (pm->ps->pm_flags & PMF_DUCKED)
{ {
// try to stand up // try to stand up
pm->maxs[2] = 32; pm->maxs[2] = DEFAULT_HEIGHT;
pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask ); pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask );
if (!trace.allsolid) if (!trace.allsolid)
pm->ps->pm_flags &= ~PMF_DUCKED; pm->ps->pm_flags &= ~PMF_DUCKED;
@ -1298,12 +1298,12 @@ static void PM_CheckDuck (void)
if (pm->ps->pm_flags & PMF_DUCKED) if (pm->ps->pm_flags & PMF_DUCKED)
{ {
pm->maxs[2] = 16; pm->maxs[2] = CROUCH_HEIGHT;
pm->ps->viewheight = CROUCH_VIEWHEIGHT; pm->ps->viewheight = CROUCH_VIEWHEIGHT;
} }
else else
{ {
pm->maxs[2] = 32; pm->maxs[2] = DEFAULT_HEIGHT;
pm->ps->viewheight = DEFAULT_VIEWHEIGHT; pm->ps->viewheight = DEFAULT_VIEWHEIGHT;
} }
} }

View File

@ -46,8 +46,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define VOTE_TIME 30000 // 30 seconds before vote times out #define VOTE_TIME 30000 // 30 seconds before vote times out
#define PLAYER_WIDTH 15
#define MINS_Z -24 #define MINS_Z -24
#define DEFAULT_HEIGHT 32
#define DEFAULT_VIEWHEIGHT 26 #define DEFAULT_VIEWHEIGHT 26
#define CROUCH_HEIGHT 16
#define CROUCH_VIEWHEIGHT 12 #define CROUCH_VIEWHEIGHT 12
#define DEAD_VIEWHEIGHT -16 #define DEAD_VIEWHEIGHT -16