Don't keep track of characters in the predicted gameworld that are not in the snapshot and require pred characters to be alive

This commit is contained in:
trml 2022-05-26 23:06:17 +02:00
parent aa5471f98d
commit 85e86772b2
8 changed files with 4 additions and 40 deletions

View file

@ -486,8 +486,6 @@ void CGameClient::OnConnected()
m_GameWorld.m_WorldConfig.m_InfiniteAmmo = true;
mem_zero(&m_GameInfo, sizeof(m_GameInfo));
m_PredictedDummyID = -1;
for(auto &LastWorldCharacter : m_aLastWorldCharacters)
LastWorldCharacter.m_Alive = false;
LoadMapSettings();
if(Client()->State() != IClient::STATE_DEMOPLAYBACK && g_Config.m_ClAutoDemoOnConnect)
@ -813,7 +811,6 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dumm
if(!(m_GameWorld.m_WorldConfig.m_IsFNG && pMsg->m_Weapon == WEAPON_LASER))
{
m_CharOrder.GiveWeak(pMsg->m_Victim);
m_aLastWorldCharacters[pMsg->m_Victim].m_Alive = false;
if(CCharacter *pChar = m_GameWorld.GetCharacterByID(pMsg->m_Victim))
pChar->ResetPrediction();
m_GameWorld.ReleaseHooked(pMsg->m_Victim);
@ -2329,21 +2326,6 @@ void CGameClient::UpdatePrediction()
m_GameWorld.m_Core.m_Tuning[g_Config.m_ClDummy].m_PlayerHooking = 1;
}
// restore characters from previously saved ones if they temporarily left the snapshot
for(int i = 0; i < MAX_CLIENTS; i++)
if(m_aLastWorldCharacters[i].IsAlive() && m_Snap.m_aCharacters[i].m_Active && !m_GameWorld.GetCharacterByID(i))
if(CCharacter *pCopy = new CCharacter(m_aLastWorldCharacters[i]))
{
m_GameWorld.InsertEntity(pCopy);
if(pCopy->m_FreezeTime > 0)
pCopy->m_FreezeTime = 0;
if(pCopy->Core()->m_HookedPlayer > 0)
{
pCopy->Core()->SetHookedPlayer(-1);
pCopy->Core()->m_HookState = HOOK_IDLE;
}
}
CCharacter *pLocalChar = m_GameWorld.GetCharacterByID(m_Snap.m_LocalClientID);
CCharacter *pDummyChar = 0;
if(PredictDummy())
@ -2445,14 +2427,6 @@ void CGameClient::UpdatePrediction()
m_GameWorld.NetObjAdd(EntData.m_Item.m_ID, EntData.m_Item.m_Type, EntData.m_pData, EntData.m_pDataEx);
m_GameWorld.NetObjEnd(m_Snap.m_LocalClientID);
// save the characters that are currently active
for(int i = 0; i < MAX_CLIENTS; i++)
if(CCharacter *pChar = m_GameWorld.GetCharacterByID(i))
{
m_aLastWorldCharacters[i] = *pChar;
m_aLastWorldCharacters[i].DetachFromGameWorld();
}
}
void CGameClient::UpdateRenderedCharacters()

View file

@ -708,7 +708,6 @@ private:
int m_PredictedDummyID;
int m_IsDummySwapping;
CCharOrder m_CharOrder;
class CCharacter m_aLastWorldCharacters[MAX_CLIENTS];
int m_SwitchStateTeam[NUM_DUMMIES];
enum

View file

@ -305,7 +305,7 @@ void CCharacter::FireWeapon()
{
CCharacter *pTarget = apEnts[i];
if((pTarget == this || (pTarget->IsAlive() && !CanCollide(pTarget->GetCID()))))
if((pTarget == this || !CanCollide(pTarget->GetCID())))
continue;
// set his velocity to fast upward (for now)
@ -1110,7 +1110,6 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
m_LastJetpackStrength = 400.0f;
m_Super = false;
m_CanMoveInFreeze = false;
m_Alive = true;
m_TeleCheckpoint = 0;
m_StrongWeakID = 0;
@ -1301,7 +1300,6 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende
m_Core.m_JumpedTotal = m_Core.m_Jumps;
m_AttackTick = pChar->m_AttackTick;
m_LastSnapWeapon = pChar->m_Weapon;
m_Alive = true;
SetTuneZone(GameWorld()->m_WorldConfig.m_UseTuneZones ? Collision()->IsTune(Collision()->GetMapIndex(m_Pos)) : 0);

View file

@ -63,9 +63,6 @@ public:
void GiveNinja();
void RemoveNinja();
bool IsAlive() { return m_Alive; }
bool m_Alive;
bool m_IsLocal;
CTeamsCore *TeamsCore();
@ -146,7 +143,6 @@ public:
bool Match(CCharacter *pChar);
void ResetPrediction();
CCharacter() { m_Alive = false; }
void SetTuneZone(int Zone);
private:

View file

@ -13,7 +13,7 @@ void CPickup::Tick()
for(int i = 0; i < Num; ++i)
{
CCharacter *pChr = apEnts[i];
if(pChr && pChr->IsAlive())
if(pChr)
{
if(GameWorld()->m_WorldConfig.m_IsVanilla && distance(m_Pos, pChr->m_Pos) >= 20.0f * 2) // pickup distance is shorter on vanilla due to using ClosestEntity
continue;

View file

@ -90,8 +90,6 @@ void CProjectile::Tick()
if(
pOwnerChar &&
pTargetChr &&
pOwnerChar->IsAlive() &&
pTargetChr->IsAlive() &&
!pTargetChr->CanCollide(m_Owner))
{
isWeaponCollide = true;

View file

@ -70,7 +70,6 @@ public:
m_SnapTicks = 0;
m_MarkedForDestroy = false;
}
void DetachFromGameWorld() { m_pGameWorld = 0; }
CEntity()
{

View file

@ -322,9 +322,9 @@ void CGameWorld::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage,
if((int)Dmg)
if((GetCharacterByID(Owner) ? !(GetCharacterByID(Owner)->m_Hit & CCharacter::DISABLE_HIT_GRENADE) : g_Config.m_SvHit || NoDamage) || Owner == pChar->GetCID())
{
if(Owner != -1 && pChar->IsAlive() && !pChar->CanCollide(Owner))
if(Owner != -1 && !pChar->CanCollide(Owner))
continue;
if(Owner == -1 && ActivatedTeam != -1 && pChar->IsAlive() && pChar->Team() != ActivatedTeam)
if(Owner == -1 && ActivatedTeam != -1 && pChar->Team() != ActivatedTeam)
continue;
pChar->TakeDamage(ForceDir * Dmg * 2, (int)Dmg, Owner, Weapon);
if(GetCharacterByID(Owner) ? GetCharacterByID(Owner)->m_Hit & CCharacter::DISABLE_HIT_GRENADE : !g_Config.m_SvHit || NoDamage)