mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Fixed /pause crash in spectator with out using /pause 1st.
Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
6fbb61e985
commit
4f22df654e
|
@ -600,6 +600,7 @@ void CGameContext::OnClientConnected(int ClientId)
|
|||
|
||||
void CGameContext::OnClientDrop(int ClientId)
|
||||
{
|
||||
ClientLeave(ClientId);
|
||||
AbortVoteKickOnDisconnect(ClientId);
|
||||
m_apPlayers[ClientId]->OnDisconnect();
|
||||
delete m_apPlayers[ClientId];
|
||||
|
@ -809,19 +810,23 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
if(g_Config.m_SvPauseable)
|
||||
{
|
||||
CCharacter* chr = p->GetCharacter();
|
||||
if(!p->GetTeam() && (!chr->m_aWeapons[WEAPON_NINJA].m_Got || chr->m_FreezeTime) && chr->IsGrounded() && chr->m_Pos==chr->m_PrevPos)
|
||||
{
|
||||
p->SaveCharacter();
|
||||
p->SetTeam(-1);
|
||||
}
|
||||
else if (p->GetTeam()==-1)
|
||||
{
|
||||
p->m_PauseInfo.m_Respawn = true;
|
||||
p->SetTeam(0);
|
||||
//p->LoadCharacter();//TODO:Check if this system Works
|
||||
}
|
||||
else
|
||||
SendChatTarget(ClientId, (chr->m_aWeapons[WEAPON_NINJA].m_Got)?"You can't use /pause while you are a ninja":(!chr->IsGrounded())?"You can't use /pause while you are a in air":"You can't use /pause while you are moving");
|
||||
if(!p->GetTeam() && chr && (!chr->m_aWeapons[WEAPON_NINJA].m_Got || chr->m_FreezeTime) && chr->IsGrounded() && chr->m_Pos==chr->m_PrevPos && !p->m_InfoSaved)
|
||||
{
|
||||
p->SaveCharacter();
|
||||
p->SetTeam(-1);
|
||||
p->m_InfoSaved = true;
|
||||
}
|
||||
else if (p->GetTeam()==-1 && p->m_InfoSaved)
|
||||
{
|
||||
p->m_InfoSaved = false;
|
||||
p->m_PauseInfo.m_Respawn = true;
|
||||
p->SetTeam(0);
|
||||
//p->LoadCharacter();//TODO:Check if this system Works
|
||||
}
|
||||
else if(chr)
|
||||
SendChatTarget(ClientId, (chr->m_aWeapons[WEAPON_NINJA].m_Got)?"You can't use /pause while you are a ninja":(!chr->IsGrounded())?"You can't use /pause while you are a in air":"You can't use /pause while you are moving");
|
||||
else
|
||||
SendChatTarget(ClientId, "No pause data saved.");
|
||||
}
|
||||
else
|
||||
SendChatTarget(ClientId, "The admin didn't activate /pause");
|
||||
|
@ -1033,6 +1038,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
else if(MsgId == NETMSGTYPE_CL_ISRACE)
|
||||
{
|
||||
p->m_IsUsingRaceClient = true;
|
||||
p->m_ShowOthers = true;
|
||||
// send time of all players
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
|
|
|
@ -226,12 +226,15 @@ void CPlayer::SetTeam(int Team)
|
|||
|
||||
void CPlayer::TryRespawn()
|
||||
{
|
||||
if(m_PauseInfo.m_Respawn) {
|
||||
if(m_PauseInfo.m_Respawn)
|
||||
{
|
||||
Character = new(m_ClientID) CCharacter(&GameServer()->m_World);
|
||||
Character->Spawn(this, m_PauseInfo.m_Core.m_Pos);
|
||||
GameServer()->CreatePlayerSpawn(m_PauseInfo.m_Core.m_Pos);
|
||||
LoadCharacter();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
vec2 SpawnPos = vec2(100.0f, -60.0f);
|
||||
if(!GameServer()->m_pController->CanSpawn(this, &SpawnPos))
|
||||
return;
|
||||
|
@ -278,6 +281,7 @@ void CPlayer::LoadCharacter() {
|
|||
Character->m_HammerType = m_PauseInfo.m_HammerType;
|
||||
Character->m_Super = m_PauseInfo.m_Super;
|
||||
m_PauseInfo.m_Respawn = false;
|
||||
m_InfoSaved = false;
|
||||
}
|
||||
|
||||
void CPlayer::SaveCharacter()
|
||||
|
|
|
@ -14,7 +14,7 @@ public:
|
|||
CPlayer(CGameContext *pGameServer, int CID, int Team);
|
||||
~CPlayer();
|
||||
|
||||
void Init(int CID);
|
||||
//void Init(int CID); idk what this does or where it is so i commented it. GreYFoXWas Here
|
||||
|
||||
void TryRespawn();
|
||||
void Respawn();
|
||||
|
@ -57,6 +57,7 @@ public:
|
|||
bool m_Super;
|
||||
int m_PauseTime;
|
||||
} m_PauseInfo;
|
||||
bool m_InfoSaved;
|
||||
void LoadCharacter();
|
||||
void SaveCharacter();
|
||||
|
||||
|
|
Loading…
Reference in a new issue