diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 0e792e09c..5637a3a88 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -9,6 +9,7 @@ cvar_t *g_psv_friction = nullptr; cvar_t *g_psv_stopspeed = nullptr; cvar_t *g_psv_stepsize = nullptr; cvar_t *g_psv_clienttrace = nullptr; +cvar_t *g_psv_zmax = nullptr; cvar_t displaysoundlist = { "displaysoundlist", "0", 0, 0.0f, nullptr }; cvar_t timelimit = { "mp_timelimit", "0", FCVAR_SERVER, 0.0f, nullptr }; @@ -236,6 +237,7 @@ void EXT_FUNC GameDLLInit() g_psv_stopspeed = CVAR_GET_POINTER("sv_stopspeed"); g_psv_stepsize = CVAR_GET_POINTER("sv_stepsize"); g_psv_clienttrace = CVAR_GET_POINTER("sv_clienttrace"); + g_psv_zmax = CVAR_GET_POINTER("sv_zmax"); CVAR_REGISTER(&displaysoundlist); CVAR_REGISTER(&timelimit); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index b9b9253b9..c3eb768be 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -48,6 +48,7 @@ extern cvar_t *g_psv_friction; extern cvar_t *g_psv_stopspeed; extern cvar_t *g_psv_stepsize; extern cvar_t *g_psv_clienttrace; +extern cvar_t *g_psv_zmax; extern cvar_t *g_footsteps; extern cvar_t displaysoundlist; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 5e7eed2fc..0ba90b504 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -7950,9 +7950,12 @@ void CBasePlayer::UpdateStatusBar() UTIL_MakeVectors(pev->v_angle + pev->punchangle); Vector vecSrc = EyePosition(); - Vector vecEnd = vecSrc + (gpGlobals->v_forward * ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPEC_ID_RANGE : MAX_ID_RANGE)); + Vector vecEnd = vecSrc + (gpGlobals->v_forward * (g_psv_zmax ? g_psv_zmax->value : ((pev->flags & FL_SPECTATOR) != 0 ? MAX_SPEC_ID_RANGE : MAX_ID_RANGE))); + int iSolidityTypeArray[MAX_CLIENTS + 1]; + UTIL_ManageClientsSolidity(true, 1, SOLID_SLIDEBOX, iSolidityTypeArray); // Store in array & set solidity from variable. UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, edict(), &tr); + UTIL_ManageClientsSolidity(false, 2, 0, iSolidityTypeArray); // Restore solidity from array. if (tr.flFraction != 1.0f) { diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 6b2fda0c7..86e468319 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -1857,3 +1857,43 @@ int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, i return playersInCount + playersOutCount; } + +// Set modes (iSetMode): +// 0 - Do not set solidity. +// 1 - Set solidity from the value of the variable "iSolidityType". +// 2 - Set solidity from the value of the array "iSolidityTypeArray". +int UTIL_ManageClientsSolidity(bool bStore, int iSetMode, int iSolidityType, int iSolidityTypeArray[MAX_CLIENTS + 1]) { + iSetMode = clamp(iSetMode, 0, 2); + + // Note: Can not store to array & set from it at the same time! Not made for such goal! + if(bStore && iSetMode == 2) { + iSetMode = 0; + } + else if(iSetMode == 0) + return 0; + + if(bStore) { + Q_memset(iSolidityTypeArray, SOLID_NOT, sizeof(iSolidityTypeArray)); + } + + int iClientsBitsFound = 0; + for(int iClientID = 1; iClientID <= gpGlobals->maxClients; iClientID++) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex(iClientID); + + if (!pPlayer || pPlayer->has_disconnected || !pPlayer->IsAlive()) + continue; + + if(bStore) { + iSolidityTypeArray[iClientID] = pPlayer->pev->solid; + } + + if(iSetMode) { + pPlayer->pev->solid = (iSetMode == 1) ? iSolidityType : iSolidityTypeArray[iClientID]; + } + + iClientsBitsFound |= (1<<(iClientID - 1)); + } + + return iClientsBitsFound; +} diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 9ed3f40ee..edcf393cc 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -354,6 +354,7 @@ class CPlayerInVolumeAdapter }; int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter = nullptr); +int UTIL_ManageClientsSolidity(bool bStore, int iSetMode, int iSolidityType, int iSolidityTypeArray[MAX_CLIENTS + 1] = nullptr); inline real_t UTIL_FixupAngle(real_t v) {