From 7fcd24561151b07d4f1aa4746cc8142168269180 Mon Sep 17 00:00:00 2001 From: btd Date: Sat, 13 Nov 2010 00:50:51 +0300 Subject: [PATCH] Fixes --- src/game/server/entities/character.cpp | 7 +++++-- src/game/server/entities/door.cpp | 4 ++-- src/game/server/entity.h | 4 ++++ src/game/server/player.cpp | 11 +++++------ src/game/server/teams.cpp | 9 +++++---- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c6cf36ee3..a78cd2d4a 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -93,7 +93,9 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) if(m_pPlayer->m_RconFreeze) Freeze(-1); GameServer()->m_pController->OnCharacterSpawn(this); - + if(GetPlayer()->m_IsUsingDDRaceClient) { + Controller->m_Teams.SendTeamsState(GetPlayer()->GetCID()); + } return true; } @@ -102,6 +104,7 @@ void CCharacter::Destroy() { GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0; m_Alive = false; + CEntity::Destroy(); } void CCharacter::SetWeapon(int W) @@ -1368,7 +1371,7 @@ void CCharacter::Die(int Killer, int Weapon) m_pPlayer->m_DieTick = Server()->Tick(); m_Alive = false; - GameServer()->m_World.RemoveEntity(this); + MarkDestroy(); GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0; GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID()); diff --git a/src/game/server/entities/door.cpp b/src/game/server/entities/door.cpp index f247db8a5..455c39f3d 100644 --- a/src/game/server/entities/door.cpp +++ b/src/game/server/entities/door.cpp @@ -25,7 +25,7 @@ void CDoor::Open(int Tick, bool ActivatedTeam[]) { for (int i = 0; i < MAX_CLIENTS; ++i) { if(ActivatedTeam[i]) m_EvalTick[i] = Tick; - m_Opened[i] = ActivatedTeam[i]; + //m_Opened[i] = ActivatedTeam[i]; if(ActivatedTeam[i]) Open(i); } } @@ -62,7 +62,7 @@ void CDoor::Close(int Team) void CDoor::Reset() { for (int i = 0; i < MAX_CLIENTS; ++i) { - m_Opened[i] = false; + //m_Opened[i] = false; Close(i); } } diff --git a/src/game/server/entity.h b/src/game/server/entity.h index b7fd3d94f..beaac62ac 100644 --- a/src/game/server/entity.h +++ b/src/game/server/entity.h @@ -76,6 +76,10 @@ public: class CGameContext *GameServer() { return GameWorld()->GameServer(); } class IServer *Server() { return GameWorld()->Server(); } + void MarkDestroy() { + m_MarkedForDestroy = true; + } + CEntity *TypeNext() { return m_pNextTypeEntity; } CEntity *TypePrev() { return m_pPrevTypeEntity; } diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 8259d3c48..976072073 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -35,8 +35,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team) CPlayer::~CPlayer() { - delete Character; - Character = 0; + if(!Character) Character->Destroy(); } void CPlayer::Tick() @@ -80,7 +79,7 @@ void CPlayer::Tick() } else { - delete Character; + Character->MarkDestroy(); Character = 0; } } @@ -179,7 +178,7 @@ void CPlayer::KillCharacter(int Weapon) if(Character) { Character->Die(m_ClientID, Weapon); - delete Character; + //delete Character; Character = 0; } } @@ -207,8 +206,8 @@ void CPlayer::SetTeam(int Team) m_LastActionTick = Server()->Tick(); // we got to wait 0.5 secs before respawning m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; - str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); - GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); + //str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); + //GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); //GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]); } diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index c1cfa06bc..486cf6a7d 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -89,11 +89,7 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) { } SetForceCharacterTeam(id, Team); - dbg_msg1("Teams", "Id = %d Team = %d", id, Team); - if(Character(id) && Character(id)->GetPlayer()->m_IsUsingDDRaceClient) { - SendTeamsState(id); - } //GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask()); return true; } @@ -120,6 +116,11 @@ void CGameTeams::SetForceCharacterTeam(int id, int Team) { if(Team != TEAM_SUPER && m_TeamState[Team] == EMPTY) { ChangeTeamState(Team, OPEN); } + dbg_msg1("Teams", "Id = %d Team = %d", id, Team); + + if(Character(id) && Character(id)->GetPlayer()->m_IsUsingDDRaceClient) { + SendTeamsState(id); + } } int CGameTeams::Count(int Team) const{