diff options
| author | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-30 04:05:57 +0200 |
|---|---|---|
| committer | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-30 04:05:57 +0200 |
| commit | e799504cb2655bb3aa3a25c2a69ddc80558f9e99 (patch) | |
| tree | e9d3d8f63f4b50de198b5444f1d5111bc4391554 /src/game/server/player.cpp | |
| parent | 19a471a30c922ea3beffc7489fa05fe16d614f5b (diff) | |
| download | zcatch-e799504cb2655bb3aa3a25c2a69ddc80558f9e99.tar.gz zcatch-e799504cb2655bb3aa3a25c2a69ddc80558f9e99.zip | |
reworked the catching, counting and color system
Diffstat (limited to 'src/game/server/player.cpp')
| -rw-r--r-- | src/game/server/player.cpp | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 7e07c07f..d3e00f9c 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -23,18 +23,25 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team) m_TeamChangeTick = Server()->Tick(); //zCatch - m_CaughtBy = -1; - m_SpecExplicit = 0; + m_CaughtBy = ZCATCH_NOT_CAUGHT; + m_SpecExplicit = false; m_Kills = 0; m_Deaths = 0; m_LastKillTry = Server()->Tick(); m_TicksSpec = 0; m_TicksIngame = 0; m_ChatTicks = 0; + + // zCatch/TeeVi + m_ZCatchVictims = NULL; + m_zCatchNumVictims = 0; + m_zCatchNumKillsInARow = 0; } CPlayer::~CPlayer() { + ReleaseZCatchVictim(ZCATCH_RELEASE_ALL); + delete m_pCharacter; m_pCharacter = 0; } @@ -295,8 +302,6 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) 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]); - if(Team == TEAM_SPECTATORS) { // update spectator modes @@ -305,10 +310,10 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_SpectatorID == m_ClientID) GameServer()->m_apPlayers[i]->m_SpectatorID = SPEC_FREEVIEW; } - m_SpecExplicit = 1; + m_SpecExplicit = true; } else - m_SpecExplicit = 0; + m_SpecExplicit = false; } void CPlayer::SetTeamDirect(int Team) @@ -377,3 +382,54 @@ int CPlayer::Anticamper() } return 0; } + +// catch another player +void CPlayer::AddZCatchVictim(int ClientID) +{ + CPlayer *victim = GameServer()->m_apPlayers[ClientID]; + if(victim) + { + // add to list of victims + CZCatchVictim *v = new CZCatchVictim; + v->ClientID = ClientID; + v->prev = m_ZCatchVictims; + m_ZCatchVictims = v; + ++m_zCatchNumVictims; + // set victim's status + victim->m_CaughtBy = m_ClientID; + victim->m_SpecExplicit = false; + victim->SetTeamDirect(TEAM_SPECTATORS); + victim->m_SpectatorID = m_ClientID; + } +} + +// release one or more of the victims +void CPlayer::ReleaseZCatchVictim(int ClientID, int limit) +{ + CZCatchVictim **v = &m_ZCatchVictims; + CZCatchVictim *tmp; + CPlayer *victim; + int count = 0; + while(*v != NULL) + { + if(ClientID == ZCATCH_RELEASE_ALL || (*v)->ClientID == ClientID) + { + victim = GameServer()->m_apPlayers[(*v)->ClientID]; + if(victim) + { + victim->m_CaughtBy = ZCATCH_NOT_CAUGHT; + victim->SetTeamDirect(GameServer()->m_pController->ClampTeam(1)); + victim->m_SpectatorID = SPEC_FREEVIEW; + } + // delete from list + tmp = (*v)->prev; + delete *v; + *v = tmp; + --m_zCatchNumVictims; + if (limit && ++count >= limit) + return; + } + else + v = &(*v)->prev; + } +} |