From 5e235a98510a2aefa5b3e13f326c5c8b0a6aa78b Mon Sep 17 00:00:00 2001 From: s1lent Date: Wed, 4 Sep 2019 20:04:57 +0700 Subject: [PATCH] pm_shared.cpp: minor refactoring --- regamedll/pm_shared/pm_shared.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index 0d403934..09b04b6c 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -259,12 +259,12 @@ void PM_PlayStepSound(int step, float fvol) case STEP_SLOSH: switch (irand) { - // right foot - case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; - case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; - // left foot - case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; - case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // right foot + case 0: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh1.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 1: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh3.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + // left foot + case 2: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh2.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; + case 3: pmove->PM_PlaySound(CHAN_BODY, "player/pl_slosh4.wav", fvol, ATTN_NORM, 0, PITCH_NORM); break; } break; case STEP_WADE: @@ -1480,12 +1480,9 @@ void PM_CategorizePosition() int PM_GetRandomStuckOffsets(int nIndex, int server, vec_t *offset) { // Last time we did a full - int idx; - idx = rgStuckLast[nIndex][server]++; - - VectorCopy(rgv3tStuckTable[idx % 54], offset); - - return (idx % 54); + int idx = rgStuckLast[nIndex][server]++; + VectorCopy(rgv3tStuckTable[idx % ARRAYSIZE(rgv3tStuckTable)], offset); + return (idx % ARRAYSIZE(rgv3tStuckTable)); } void PM_ResetStuckOffsets(int nIndex, int server) @@ -1542,7 +1539,7 @@ qboolean PM_CheckStuck() nReps++; } - while (nReps < 54); + while (nReps < ARRAYSIZE(rgv3tStuckTable)); } } @@ -1571,7 +1568,7 @@ qboolean PM_CheckStuck() { PM_ResetStuckOffsets(pmove->player_index, pmove->server); - if (i >= 27) + if (i >= (ARRAYSIZE(rgv3tStuckTable) / 2)) { VectorCopy(test, pmove->origin); } @@ -1772,7 +1769,7 @@ void PM_FixPlayerCrouchStuck(int direction) int i; vec3_t test; - hitent = pmove->PM_TestPlayerPosition (pmove->origin, nullptr); + hitent = pmove->PM_TestPlayerPosition(pmove->origin, nullptr); if (hitent == -1) {