Skip to content

Commit

Permalink
Preserve client order of weapon physics
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Jun 2, 2024
1 parent 81f4c73 commit a202751
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/game/server/gameworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "entity.h"
#include "gamecontext.h"
#include "gamecontroller.h"
#include "player.h"

#include <engine/shared/config.h>

Expand Down Expand Up @@ -214,13 +215,15 @@ void CGameWorld::Tick()
if(GameServer()->m_pController->IsForceBalanced())
GameServer()->SendChat(-1, TEAM_ALL, "Teams have been balanced");

// This is placed here so that certain weapon physics can happen before the regular Charecter Tick() to preserve physics accuracy
auto *pChar = m_apFirstEntityTypes[ENTTYPE_CHARACTER];
for(; pChar;)
// This is placed here so that certain weapon physics can happen before the regular Charecter Tick() to preserve physics accuracy.
// It is done in client order to preserve previous behavior.
for(auto &pPlayer : GameServer()->m_apPlayers)
{
m_pNextTraverseEntity = pChar->m_pNextTypeEntity;
((CCharacter *)pChar)->WeaponTick();
pChar = m_pNextTraverseEntity;
if(!pPlayer)
continue;
CCharacter *pChar = pPlayer->GetCharacter();
if(pChar)
pChar->WeaponTick();
}

// update all objects
Expand Down

0 comments on commit a202751

Please sign in to comment.