about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTeetime <anton.tsoulos@yahoo.de>2011-10-14 02:40:05 +0200
committerTeetime <anton.tsoulos@yahoo.de>2011-10-14 02:40:05 +0200
commit5bd8c48b3c3f4e6c0d6fdc3c1b9a7e604ea1f3bb (patch)
treec56b72b20bbf051354a6d29fde41f428f7ecc0b5 /src
parent973894f33baae6411b920fb2dce7b92fe4f57343 (diff)
downloadzcatch-5bd8c48b3c3f4e6c0d6fdc3c1b9a7e604ea1f3bb.tar.gz
zcatch-5bd8c48b3c3f4e6c0d6fdc3c1b9a7e604ea1f3bb.zip
moved and overworked wincheck
Diffstat (limited to 'src')
-rw-r--r--src/game/server/gamemodes/zcatch.cpp43
-rw-r--r--src/game/server/gamemodes/zcatch.hpp3
-rw-r--r--src/game/server/player.cpp35
3 files changed, 42 insertions, 39 deletions
diff --git a/src/game/server/gamemodes/zcatch.cpp b/src/game/server/gamemodes/zcatch.cpp
index b61690cb..fb9af45e 100644
--- a/src/game/server/gamemodes/zcatch.cpp
+++ b/src/game/server/gamemodes/zcatch.cpp
@@ -20,11 +20,45 @@ void CGameController_zCatch::Tick()
 	DoWincheck();
 	IGameController::Tick();
 }
+
 bool CGameController_zCatch::IsZCatch()
 {
 	return true;
 }
 
+void CGameController_zCatch::DoWincheck()
+{
+	int Players = 0, Players_Spec = 0, Players_SpecExplicit = 0;	
+	
+	for(int i = 0; i < MAX_CLIENTS; i++)
+	{
+		if(GameServer()->m_apPlayers[i])
+		{
+			Players++;
+			if(GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS)
+				Players_Spec++;
+			if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1)
+				Players_SpecExplicit++;
+		}
+	}
+	
+	if(Players == 1)
+	{
+		//Do nothing
+	}
+	else if((Players - Players_Spec == 1) && (Players != Players_Spec) && (Players - Players_SpecExplicit != 1)) 
+	{
+		for(int i = 0; i < MAX_CLIENTS; i++)
+		{
+			if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
+				GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus;
+		}
+		EndRound();
+	}
+	
+	IGameController::DoWincheck(); //do also usual wincheck
+}
+
 int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID)
 {
 	int VictimID =  pVictim->GetPlayer()->GetCID();
@@ -71,12 +105,12 @@ void CGameController_zCatch::OnPlayerInfoChange(class CPlayer *pP)
 {
 	if(g_Config.m_SvColorIndicator)
 	{
-		int num = 161;
+		int Players = 161;
 		for(int i = 0; i < MAX_CLIENTS; i++)
 			if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_CatchedBy == pP->GetCID())
-				num -= 10;
-		pP->m_TeeInfos.m_ColorBody = num * 0x010000 + 0xff00;
-		pP->m_TeeInfos.m_ColorFeet = num * 0x010000 + 0xff00;
+				Players -= 10;
+		pP->m_TeeInfos.m_ColorBody = Players * 0x010000 + 0xff00;
+		pP->m_TeeInfos.m_ColorFeet = Players * 0x010000 + 0xff00;
 		pP->m_TeeInfos.m_UseCustomColor = 1;
 	}
 }
@@ -142,6 +176,7 @@ void CGameController_zCatch::OnCharacterSpawn(class CCharacter *pChr)
 		}
 	OnPlayerInfoChange(pChr->GetPlayer());
 }
+
 void CGameController_zCatch::EndRound()
 {
 	for(int i = 0; i < MAX_CLIENTS; i++)
diff --git a/src/game/server/gamemodes/zcatch.hpp b/src/game/server/gamemodes/zcatch.hpp
index 2103678c..64da71cc 100644
--- a/src/game/server/gamemodes/zcatch.hpp
+++ b/src/game/server/gamemodes/zcatch.hpp
@@ -12,13 +12,14 @@ class CGameController_zCatch : public IGameController
 	public:
 	CGameController_zCatch(class CGameContext *pGameServer);
 	virtual void Tick();
+	virtual void DoWincheck();
 	virtual bool IsZCatch();
 	
 	enum
 	{
 		ZCATCH_NOT_CATCHED = -1,
 	}; 
-
+	
 	virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID);
 	virtual void StartRound();
 	virtual void OnCharacterSpawn(class CCharacter *pChr);
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 77aa9b38..4ea2a4a6 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -50,44 +50,11 @@ void CPlayer::Tick()
 	Server()->SetClientScore(m_ClientID, m_Score);
 	
 	/* begin zCatch*/
-	int num = 0, num_spec = 0, num_SpecExplicit = 0;
 	
 	if(m_Team == TEAM_SPECTATORS)
 		m_TicksSpec++;
 	else
-		m_TicksIngame++;	
-	
-	for(int i = 0; i < MAX_CLIENTS; i++)
-	{
-		if(GameServer()->m_apPlayers[i])
-		{
-			num++;
-			if(GameServer()->m_apPlayers[i]->m_Team == TEAM_SPECTATORS)
-				num_spec++;
-			if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1)
-			num_SpecExplicit++;
-		}
-	}
-	
-	if(num == 1)
-	{
-	//Do nothing
-	}
-	//solution for sv_allow_join == 0 and mapchange:
-	else if((g_Config.m_SvAllowJoin == 0) && (num_spec == num) && (num_spec != num_SpecExplicit))
-	{
-		GameServer()->m_pController->EndRound();
-	}
-	else if((num - num_spec == 1) && (num != num_spec) && (num - num_SpecExplicit != 1)) 
-	{
-		for(int i = 0; i < MAX_CLIENTS; i++)
-		{
-			if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_Team != TEAM_SPECTATORS)
-				GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus;
-			GameServer()->m_pController->EndRound();
-			break;
-		}
-	}
+		m_TicksIngame++;
 		
 	/* end zCatch*/