Fix spec-char not being shown

This commit is contained in:
fokkonaut 2021-09-02 02:34:32 +02:00 committed by def
parent 646a4c9fcd
commit 1da212207e
3 changed files with 42 additions and 38 deletions

View file

@ -1215,6 +1215,27 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
}
}
bool CCharacter::CanSnapCharacter(int SnappingClient)
{
if(SnappingClient < 0)
return true;
CCharacter *pSnapChar = GameServer()->GetPlayerChar(SnappingClient);
CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient];
if(pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused())
{
if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(pSnapPlayer->m_SpectatorID))))
return false;
else if(pSnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && pSnapPlayer->m_SpecTeam)
return false;
}
else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(SnappingClient))))
return false;
return true;
}
void CCharacter::Snap(int SnappingClient)
{
int ID = m_pPlayer->GetCID();
@ -1222,26 +1243,7 @@ void CCharacter::Snap(int SnappingClient)
if(SnappingClient > -1 && !Server()->Translate(ID, SnappingClient))
return;
if(NetworkClipped(SnappingClient))
return;
if(SnappingClient > -1)
{
CCharacter *pSnapChar = GameServer()->GetPlayerChar(SnappingClient);
CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient];
if(pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused())
{
if(pSnapPlayer->m_SpectatorID != -1 && !CanCollide(pSnapPlayer->m_SpectatorID) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(pSnapPlayer->m_SpectatorID))))
return;
else if(pSnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && pSnapPlayer->m_SpecTeam)
return;
}
else if(pSnapChar && !pSnapChar->m_Super && !CanCollide(SnappingClient) && (pSnapPlayer->m_ShowOthers == 0 || (pSnapPlayer->m_ShowOthers == 2 && !SameTeam(SnappingClient))))
return;
}
if(m_Paused)
if(NetworkClipped(SnappingClient) || !CanSnapCharacter(SnappingClient))
return;
SnapCharacter(SnappingClient, ID);
@ -1289,24 +1291,6 @@ void CCharacter::Snap(int SnappingClient)
}
}
bool ShowSpec = IsPaused();
if(SnappingClient >= 0)
{
CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient];
ShowSpec = ShowSpec && (GameServer()->GetDDRaceTeam(m_pPlayer->GetCID()) == GameServer()->GetDDRaceTeam(SnappingClient) || pSnapPlayer->m_ShowOthers == 1 || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()));
}
if(ShowSpec)
{
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, ID, sizeof(CNetObj_SpecChar)));
if(!pSpecChar)
return;
pSpecChar->m_X = Core()->m_Pos.x;
pSpecChar->m_Y = Core()->m_Pos.y;
}
CNetObj_DDNetCharacter *pDDNetCharacter = static_cast<CNetObj_DDNetCharacter *>(Server()->SnapNewItem(NETOBJTYPE_DDNETCHARACTER, ID, sizeof(CNetObj_DDNetCharacter)));
if(!pDDNetCharacter)
return;

View file

@ -41,6 +41,8 @@ public:
virtual void TickPaused();
virtual void Snap(int SnappingClient);
bool CanSnapCharacter(int SnappingClient);
bool IsGrounded();
void SetWeapon(int W);

View file

@ -422,6 +422,24 @@ void CPlayer::Snap(int SnappingClient)
return;
pRaceInfo->m_RaceStartTick = m_pCharacter->m_StartTime;
}
bool ShowSpec = m_pCharacter && m_pCharacter->IsPaused() && m_pCharacter->CanSnapCharacter(SnappingClient);
if(SnappingClient >= 0)
{
CPlayer *pSnapPlayer = GameServer()->m_apPlayers[SnappingClient];
ShowSpec = ShowSpec && (GameServer()->GetDDRaceTeam(m_ClientID) == GameServer()->GetDDRaceTeam(SnappingClient) || pSnapPlayer->m_ShowOthers == 1 || (pSnapPlayer->GetTeam() == TEAM_SPECTATORS || pSnapPlayer->IsPaused()));
}
if(ShowSpec)
{
CNetObj_SpecChar *pSpecChar = static_cast<CNetObj_SpecChar *>(Server()->SnapNewItem(NETOBJTYPE_SPECCHAR, id, sizeof(CNetObj_SpecChar)));
if(!pSpecChar)
return;
pSpecChar->m_X = m_pCharacter->Core()->m_Pos.x;
pSpecChar->m_Y = m_pCharacter->Core()->m_Pos.y;
}
}
void CPlayer::FakeSnap()