diff options
| author | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-04-08 02:18:26 +0200 |
|---|---|---|
| committer | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-04-08 02:18:26 +0200 |
| commit | 2e3107802663087eadd711eb43b09605080730be (patch) | |
| tree | 093941a33542932f952bf60820f8a426e3c825c4 /src/game/server | |
| parent | 834e02e63445d1c4f7830109184420b6e9813b39 (diff) | |
| download | zcatch-2e3107802663087eadd711eb43b09605080730be.tar.gz zcatch-2e3107802663087eadd711eb43b09605080730be.zip | |
added chat commands /victims and /kills
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/gamecontext.cpp | 58 | ||||
| -rw-r--r-- | src/game/server/gamemodes/zcatch.cpp | 2 | ||||
| -rw-r--r-- | src/game/server/player.cpp | 3 | ||||
| -rw-r--r-- | src/game/server/player.h | 7 |
4 files changed, 56 insertions, 14 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 7c3534a6..2374d5ff 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -688,7 +688,7 @@ void CGameContext::OnClientEnter(int ClientID) if(m_apPlayers[i] && ((leader && m_apPlayers[i]->m_zCatchNumKillsInARow > leader->m_zCatchNumKillsInARow) || (!leader && m_apPlayers[i]->m_zCatchNumKillsInARow))) leader = m_apPlayers[i]; if(leader) - leader->AddZCatchVictim(ClientID); + leader->AddZCatchVictim(ClientID, CPlayer::ZCATCH_CAUGHT_REASON_JOINING); else p->m_SpecExplicit = false; } @@ -805,20 +805,58 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) } /* begin zCatch*/ - if(!str_comp("/info", pMsg->m_pMessage)) + if(!str_comp_num("/", pMsg->m_pMessage, 1)) { - char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "zCatch %s by erd and Teetime, modified by Teelevision.", ZCATCH_VERSION); - SendChatTarget(ClientID, aBuf); - SendChatTarget(ClientID, "You are caught when killed and released when your killer dies. Catch everyone to win the round."); - if(g_Config.m_SvLastStandingPlayers > 2) + if(!str_comp_nocase("info", pMsg->m_pMessage + 1)) { - str_format(aBuf, sizeof(aBuf), "If there are less than %d players, the round does not end and all players are released instead.", g_Config.m_SvLastStandingPlayers); + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "zCatch %s by erd and Teetime, modified by Teelevision.", ZCATCH_VERSION); SendChatTarget(ClientID, aBuf); + SendChatTarget(ClientID, "You are caught when killed and released when your killer dies. Catch everyone to win the round."); + if(g_Config.m_SvLastStandingPlayers > 2) + { + str_format(aBuf, sizeof(aBuf), "If there are less than %d players, the round does not end and all players are released instead.", g_Config.m_SvLastStandingPlayers); + SendChatTarget(ClientID, aBuf); + } + } + else if(!str_comp_nocase("victims", pMsg->m_pMessage + 1)) + { + if(pPlayer->m_zCatchNumVictims) + { + char aBuf[256], bBuf[256]; + CPlayer::CZCatchVictim *v = pPlayer->m_ZCatchVictims; + str_format(aBuf, sizeof(aBuf), "%d player(s) await your death: ", pPlayer->m_zCatchNumVictims); + while(v != NULL) + { + str_format(bBuf, sizeof(bBuf), (v == pPlayer->m_ZCatchVictims) ? "%s '%s'%s" : "%s, '%s'%s", aBuf, Server()->ClientName(v->ClientID), (v->Reason == CPlayer::ZCATCH_CAUGHT_REASON_JOINING) ? " (joined the game)" : ""); + str_copy(aBuf, bBuf, sizeof(aBuf)); + v = v->prev; + } + SendChatTarget(ClientID, aBuf); + } + else + { + SendChatTarget(ClientID, "Noone awaits your death."); + } + } + else if(!str_comp_nocase("kills", pMsg->m_pMessage + 1)) + { + if(pPlayer->m_zCatchNumKillsInARow) + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "You caught %d player(s) since your last death.", pPlayer->m_zCatchNumKillsInARow); + SendChatTarget(ClientID, aBuf); + } + else + { + SendChatTarget(ClientID, "You caught noone since your last death."); + } + } + else + { + SendChatTarget(ClientID, "Unknown command, try /info"); } } - else if(!str_comp_num("/", pMsg->m_pMessage, 1)) - SendChatTarget(ClientID, "Unknown command, try /info"); else { //Check if muted diff --git a/src/game/server/gamemodes/zcatch.cpp b/src/game/server/gamemodes/zcatch.cpp index 4df58d4f..3dbec457 100644 --- a/src/game/server/gamemodes/zcatch.cpp +++ b/src/game/server/gamemodes/zcatch.cpp @@ -87,7 +87,7 @@ int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CP if(pKiller->GetTeam() != TEAM_SPECTATORS) { ++pKiller->m_zCatchNumKillsInARow; - pKiller->AddZCatchVictim(victim->GetCID()); + pKiller->AddZCatchVictim(victim->GetCID(), CPlayer::ZCATCH_CAUGHT_REASON_KILLED); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "You are caught until '%s' dies.", Server()->ClientName(pKiller->GetCID())); GameServer()->SendChatTarget(victim->GetCID(), aBuf); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 62d29a4a..d2d621b7 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -406,7 +406,7 @@ int CPlayer::Anticamper() } // catch another player -void CPlayer::AddZCatchVictim(int ClientID) +void CPlayer::AddZCatchVictim(int ClientID, int reason) { CPlayer *victim = GameServer()->m_apPlayers[ClientID]; if(victim) @@ -414,6 +414,7 @@ void CPlayer::AddZCatchVictim(int ClientID) // add to list of victims CZCatchVictim *v = new CZCatchVictim; v->ClientID = ClientID; + v->Reason = reason; v->prev = m_ZCatchVictims; m_ZCatchVictims = v; ++m_zCatchNumVictims; diff --git a/src/game/server/player.h b/src/game/server/player.h index 32860106..e6595245 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -117,17 +117,20 @@ public: enum { ZCATCH_NOT_CAUGHT = -1, - ZCATCH_RELEASE_ALL = -1 + ZCATCH_RELEASE_ALL = -1, + ZCATCH_CAUGHT_REASON_JOINING = 0, + ZCATCH_CAUGHT_REASON_KILLED, }; struct CZCatchVictim { int ClientID; + int Reason; CZCatchVictim *prev; }; CZCatchVictim *m_ZCatchVictims; int m_zCatchNumVictims; int m_zCatchNumKillsInARow; - void AddZCatchVictim(int ClientID); + void AddZCatchVictim(int ClientID, int reason = ZCATCH_CAUGHT_REASON_JOINING); void ReleaseZCatchVictim(int ClientID, int limit = 0); bool HasZCatchVictims() { return (m_ZCatchVictims != NULL); } int LastZCatchVictim() { return HasZCatchVictims() ? m_ZCatchVictims->ClientID : -1; } |