mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
D:/Portable Apps/PortableGit-1.7.1-preview20100612/pause works. Need to delete RACE_PAUSE. And check that character resurect correctly
This commit is contained in:
parent
7b05afa76d
commit
844f3116fe
|
@ -1226,16 +1226,4 @@ void CCharacter::Snap(int SnappingClient)
|
|||
}
|
||||
|
||||
Character->m_PlayerState = m_PlayerState;
|
||||
}
|
||||
|
||||
void CCharacter::LoadPauseData()
|
||||
{
|
||||
//TODO:Load The Data For a Paused Char
|
||||
m_Paused = false;
|
||||
}
|
||||
|
||||
void CCharacter::SavePauseData()
|
||||
{
|
||||
//TODO:Save The Data For a Paused Char
|
||||
m_Paused = true;
|
||||
}
|
||||
}
|
|
@ -39,9 +39,8 @@ public:
|
|||
virtual void Snap(int SnappingClient);
|
||||
|
||||
bool IsGrounded();
|
||||
bool m_Paused;
|
||||
void LoadPauseData();
|
||||
void SavePauseData();
|
||||
//bool m_Paused;
|
||||
|
||||
void SetWeapon(int W);
|
||||
void HandleWeaponSwitch();
|
||||
void DoWeaponSwitch();
|
||||
|
@ -177,10 +176,6 @@ public:
|
|||
int m_ReckoningTick; // tick that we are performing dead reckoning From
|
||||
CCharacterCore m_SendCore; // core that we should send
|
||||
CCharacterCore m_ReckoningCore; // the dead reckoning core
|
||||
struct Pause
|
||||
{
|
||||
int example;//TODO:Fill This struct with useful chardata for pause FreezeTime Pos...etc
|
||||
} m_Pause;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -651,24 +651,23 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
if(g_Config.m_SvPauseable)
|
||||
{
|
||||
CCharacter* chr = p->GetCharacter();
|
||||
if(chr)
|
||||
{
|
||||
if(!p->GetTeam() && !chr->m_Paused)
|
||||
|
||||
if(!p->GetTeam())
|
||||
{
|
||||
chr->SavePauseData();
|
||||
p->SaveCharacter();
|
||||
p->SetTeam(-1);
|
||||
}
|
||||
else if (p->GetTeam()==-1 && chr->m_Paused)
|
||||
else if (p->GetTeam()==-1)
|
||||
{
|
||||
p->m_PauseInfo.m_Respawn = true;
|
||||
p->SetTeam(0);
|
||||
chr->LoadPauseData();//TODO:Check if this system Works
|
||||
//p->LoadCharacter();//TODO:Check if this system Works
|
||||
}
|
||||
|
||||
if(chr->m_RaceState==RACE_STARTED)
|
||||
chr->m_RaceState = RACE_PAUSE;
|
||||
else if(chr->m_RaceState==RACE_PAUSE)
|
||||
chr->m_RaceState = RACE_STARTED;
|
||||
}
|
||||
//if(chr->m_RaceState==RACE_STARTED)
|
||||
// chr->m_RaceState = RACE_PAUSE;
|
||||
//else if(chr->m_RaceState==RACE_PAUSE)
|
||||
// chr->m_RaceState = RACE_STARTED;*/
|
||||
}
|
||||
} else if(!str_comp_nocase(pMsg->m_pMessage, "/info"))
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team)
|
|||
m_DieTick = Server()->Tick();
|
||||
m_ScoreStartTick = Server()->Tick();
|
||||
Character = 0;
|
||||
m_CharacterCopy = 0;
|
||||
m_Muted = 0;
|
||||
this->m_ClientID = CID;
|
||||
m_Team = GameServer()->m_pController->ClampTeam(Team);
|
||||
|
@ -29,6 +30,8 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team)
|
|||
m_LastTarget_y = 0;
|
||||
m_SentAfkWarning = 0; // afk timer's 1st warning after 50% of sv_max_afk_time
|
||||
m_SentAfkWarning2 = 0;
|
||||
|
||||
m_PauseInfo.m_Respawn = false;
|
||||
}
|
||||
|
||||
CPlayer::~CPlayer()
|
||||
|
@ -200,24 +203,51 @@ void CPlayer::SetTeam(int Team)
|
|||
|
||||
void CPlayer::TryRespawn()
|
||||
{
|
||||
vec2 SpawnPos = vec2(100.0f, -60.0f);
|
||||
|
||||
if(!GameServer()->m_pController->CanSpawn(this, &SpawnPos))
|
||||
return;
|
||||
|
||||
// check if the position is occupado
|
||||
CEntity *apEnts[2] = {0};
|
||||
int NumEnts = GameServer()->m_World.FindEntities(SpawnPos, 64, apEnts, 2, NETOBJTYPE_CHARACTER);
|
||||
|
||||
if(NumEnts == 0)
|
||||
{
|
||||
m_Spawning = false;
|
||||
if(m_PauseInfo.m_Respawn) {
|
||||
Character = new(m_ClientID) CCharacter(&GameServer()->m_World);
|
||||
Character->Spawn(this, SpawnPos);
|
||||
GameServer()->CreatePlayerSpawn(SpawnPos);
|
||||
Character->Spawn(this, m_PauseInfo.m_Core.m_Pos);
|
||||
GameServer()->CreatePlayerSpawn(m_PauseInfo.m_Core.m_Pos);
|
||||
LoadCharacter();
|
||||
} else {
|
||||
vec2 SpawnPos = vec2(100.0f, -60.0f);
|
||||
if(!GameServer()->m_pController->CanSpawn(this, &SpawnPos))
|
||||
return;
|
||||
|
||||
// check if the position is occupado
|
||||
CEntity *apEnts[2] = {0};
|
||||
int NumEnts = GameServer()->m_World.FindEntities(SpawnPos, 64, apEnts, 2, NETOBJTYPE_CHARACTER);
|
||||
if(NumEnts < 3)
|
||||
{
|
||||
m_Spawning = false;
|
||||
Character = new(m_ClientID) CCharacter(&GameServer()->m_World);
|
||||
Character->Spawn(this, SpawnPos);
|
||||
GameServer()->CreatePlayerSpawn(SpawnPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayer::LoadCharacter() {
|
||||
Character->m_Core = m_PauseInfo.m_Core;
|
||||
Character->m_StartTime = m_PauseInfo.m_StartTime;
|
||||
Character->m_RaceState = m_PauseInfo.m_RaceState;
|
||||
Character->m_RefreshTime = Server()->Tick();
|
||||
for(int i = 0; i < NUM_WEAPONS; ++i) {
|
||||
if(m_PauseInfo.m_aHasWeapon[i]) {
|
||||
Character->GiveWeapon(i, -1);
|
||||
}
|
||||
}
|
||||
m_PauseInfo.m_Respawn = false;
|
||||
}
|
||||
|
||||
void CPlayer::SaveCharacter() {
|
||||
m_PauseInfo.m_Core = Character->m_Core;
|
||||
m_PauseInfo.m_StartTime = Character->m_StartTime;
|
||||
m_PauseInfo.m_RaceState = Character->m_RaceState;
|
||||
for(int i = 0; i < NUM_WEAPONS; ++i) {
|
||||
m_PauseInfo.m_aHasWeapon[i] = Character->m_aWeapons[i].m_Got;
|
||||
}
|
||||
//m_PauseInfo.m_RefreshTime = Character->m_RefreshTime;
|
||||
}
|
||||
|
||||
void CPlayer::AfkTimer(int new_target_x, int new_target_y)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,18 @@ public:
|
|||
void KillCharacter(int Weapon = WEAPON_GAME);
|
||||
CCharacter *GetCharacter();
|
||||
|
||||
CCharacter* m_CharacterCopy;
|
||||
struct PauseInfo {
|
||||
CCharacterCore m_Core;
|
||||
int m_StartTime;
|
||||
int m_RaceState;
|
||||
//int m_RefreshTime;
|
||||
bool m_Respawn;
|
||||
bool m_aHasWeapon[NUM_WEAPONS];
|
||||
} m_PauseInfo;
|
||||
void LoadCharacter();
|
||||
void SaveCharacter();
|
||||
|
||||
//---------------------------------------------------------
|
||||
// this is used for snapping so we know how we can clip the view for the player
|
||||
vec2 m_ViewPos;
|
||||
|
|
Loading…
Reference in a new issue