From cedc315a70eb9335df3d262f31ef69335281e7f3 Mon Sep 17 00:00:00 2001 From: fokkonaut <35420825+fokkonaut@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:52:31 +0200 Subject: [PATCH] Fix physics change by weak hook fix (fixes #5769) --- src/game/server/entities/character.h | 2 +- src/game/server/entity.h | 7 ------- src/game/server/gameworld.cpp | 16 +++++++++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 3eee2451a..ba2c13efe 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -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; diff --git a/src/game/server/entity.h b/src/game/server/entity.h index b918f00c4..c897a9073 100644 --- a/src/game/server/entity.h +++ b/src/game/server/entity.h @@ -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 diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index f3dcc616e..229e6864f 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -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;)