Skip to content

Commit

Permalink
CInfClassCharacter::Tick: Ignore the tick if Class is not set
Browse files Browse the repository at this point in the history
Fix a crash.
  • Loading branch information
Kaffeine committed Dec 16, 2023
1 parent 441c96d commit fa26b50
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/game/server/infclass/entities/infccharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,17 @@ void CInfClassCharacter::Destroy()

void CInfClassCharacter::Tick()
{
const vec2 PrevPos = m_Core.m_Pos;
const int CurrentTick = Server()->Tick();

if(m_pClass)
if(!m_pClass)
{
// On the very first tick of a new round when the Reset is not complete yet,
// The character can (still) be in a special zone while still have no class assigned.
GameController()->HandleCharacterTiles(this);
// Sometimes m_pClass is still nullptr on the very first tick
// of a new round when the Reset is not complete yet.
return;
}

const vec2 PrevPos = m_Core.m_Pos;
const int CurrentTick = Server()->Tick();
GameController()->HandleCharacterTiles(this);

CCharacter::Tick();

if(m_BlindnessTicks > 0)
Expand Down Expand Up @@ -225,10 +226,7 @@ void CInfClassCharacter::Tick()
--m_LastHelper.m_Tick;
}

if(m_pClass)
{
m_pClass->OnCharacterTick();
}
m_pClass->OnCharacterTick();
}

void CInfClassCharacter::TickDeferred()
Expand Down

0 comments on commit fa26b50

Please sign in to comment.