Fix physics change by weak hook fix (fixes #5769)

This commit is contained in:
fokkonaut 2022-08-24 17:52:31 +02:00 committed by Jupeyy
parent 098cb2b0f2
commit cedc315a70
3 changed files with 12 additions and 13 deletions

View file

@ -33,7 +33,7 @@ public:
void Reset() override;
void Destroy() override;
void PreTick() override;
void PreTick();
void Tick() override;
void TickDeferred() override;
void TickPaused() override;

View file

@ -86,13 +86,6 @@ public: // TODO: Maybe make protected
*/
virtual void Reset() {}
/*
Function: PreTick
Called to progress the entity before the next tick.
Can be used to prepare variables for all clients before the next tick is executed.
*/
virtual void PreTick() {}
/*
Function: Tick
Called to progress the entity to the next tick. Updates

View file

@ -267,25 +267,31 @@ void CGameWorld::Tick()
{
if(GameServer()->m_pController->IsForceBalanced())
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Teams have been balanced");
// update all objects
if(g_Config.m_SvNoWeakHookAndBounce)
for(int i = 0; i < NUM_ENTTYPES; i++)
{
for(auto *pEnt : m_apFirstEntityTypes)
// It's important to call PreTick() and Tick() after each other.
// If we call PreTick() before, and Tick() after other entities have been processed, it causes physics changes such as a stronger shotgun or grenade.
if(g_Config.m_SvNoWeakHookAndBounce && i == ENTTYPE_CHARACTER)
{
auto *pEnt = m_apFirstEntityTypes[i];
for(; pEnt;)
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->PreTick();
((CCharacter *)pEnt)->PreTick();
pEnt = m_pNextTraverseEntity;
}
}
for(auto *pEnt : m_apFirstEntityTypes)
auto *pEnt = m_apFirstEntityTypes[i];
for(; pEnt;)
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->Tick();
pEnt = m_pNextTraverseEntity;
}
}
for(auto *pEnt : m_apFirstEntityTypes)
for(; pEnt;)