mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Use server global variables for determining the num clients to loop over. This is cheaper and better than always looping over MAX_PLAYERS.
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
|
|
//
|
|
// Purpose: Physics simulation for non-havok/ipion objects
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================//
|
|
#include "core/stdafx.h"
|
|
#include "tier1/cvar.h"
|
|
#include "player.h"
|
|
#include "physics_main.h"
|
|
#include "engine/client/client.h"
|
|
#include "game/shared/util_shared.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Runs the command simulation for fake players
|
|
//-----------------------------------------------------------------------------
|
|
void Physics_RunBotSimulation(bool bSimulating)
|
|
{
|
|
if (!sv_simulateBots->GetBool())
|
|
return;
|
|
|
|
for (int i = 0; i < g_ServerGlobalVariables->m_nMaxClients; i++)
|
|
{
|
|
CClient* pClient = g_pClient->GetClient(i);
|
|
if (!pClient)
|
|
continue;
|
|
|
|
if (pClient->IsActive() && pClient->IsFakeClient())
|
|
{
|
|
CPlayer* pPlayer = UTIL_PlayerByIndex(pClient->GetHandle());
|
|
if (pPlayer)
|
|
pPlayer->RunNullCommand();
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Runs the main physics simulation loop against all entities ( except players )
|
|
//-----------------------------------------------------------------------------
|
|
void Physics_RunThinkFunctions(bool bSimulating)
|
|
{
|
|
Physics_RunBotSimulation(bSimulating);
|
|
v_Physics_RunThinkFunctions(bSimulating);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void VPhysics_Main::Attach() const
|
|
{
|
|
DetourAttach(&v_Physics_RunThinkFunctions, &Physics_RunThinkFunctions);
|
|
}
|
|
|
|
void VPhysics_Main::Detach() const
|
|
{
|
|
DetourDetach(&v_Physics_RunThinkFunctions, &Physics_RunThinkFunctions);
|
|
} |