about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/server.h2
-rw-r--r--src/engine/server/server.cpp8
-rw-r--r--src/engine/server/server.h3
-rw-r--r--src/engine/shared/network.h1
-rw-r--r--src/engine/shared/network_server.cpp1
-rw-r--r--src/game/server/entities/character.cpp124
-rw-r--r--src/game/server/entities/character.h3
-rw-r--r--src/game/server/entities/laser.cpp4
-rw-r--r--src/game/server/gamecontext.cpp328
-rw-r--r--src/game/server/gamecontext.h25
-rw-r--r--src/game/server/gamecontroller.cpp58
-rw-r--r--src/game/server/gamecontroller.h6
-rw-r--r--src/game/server/gamemodes/zcatch.cpp228
-rw-r--r--src/game/server/gamemodes/zcatch.h32
-rw-r--r--src/game/server/player.cpp88
-rw-r--r--src/game/server/player.h20
-rw-r--r--src/game/variables.h23
17 files changed, 890 insertions, 64 deletions
diff --git a/src/engine/server.h b/src/engine/server.h
index 5036b654..deb36ef5 100644
--- a/src/engine/server.h
+++ b/src/engine/server.h
@@ -66,6 +66,8 @@ public:
 
 	virtual void DemoRecorder_HandleAutoStart() = 0;
 	virtual bool DemoRecorder_IsRecording() = 0;
+	//zCatch
+	virtual void MapReload() = 0;
 };
 
 class IGameServer : public IInterface
diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp
index 3a652d68..4a03be16 100644
--- a/src/engine/server/server.cpp
+++ b/src/engine/server/server.cpp
@@ -1368,7 +1368,7 @@ int CServer::Run()
 	m_Econ.Init(Console(), &m_ServerBan);
 
 	Console()->ExecuteFile(SERVER_BANMASTERFILE);
-		
+
 	char aBuf[256];
 	str_format(aBuf, sizeof(aBuf), "server name is '%s'", g_Config.m_SvName);
 	Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
@@ -1575,6 +1575,11 @@ void CServer::DemoRecorder_HandleAutoStart()
 	}
 }
 
+void CServer::MapReload()
+{
+	m_MapReload = 1;
+}
+
 bool CServer::DemoRecorder_IsRecording()
 {
 	return m_DemoRecorder.IsRecording();
@@ -1606,7 +1611,6 @@ void CServer::ConMapReload(IConsole::IResult *pResult, void *pUser)
 	((CServer *)pUser)->m_MapReload = 1;
 }
 
-
 void CServer::ConAddBanmaster(IConsole::IResult *pResult, void *pUser)
 {
 	CServer *pServer = (CServer *)pUser;
diff --git a/src/engine/server/server.h b/src/engine/server/server.h
index 731ab1b9..9f62ab37 100644
--- a/src/engine/server/server.h
+++ b/src/engine/server/server.h
@@ -241,6 +241,9 @@ public:
 	virtual void SnapFreeID(int ID);
 	virtual void *SnapNewItem(int Type, int ID, int Size);
 	void SnapSetStaticsize(int ItemType, int Size);
+	
+	//zCatch
+	virtual void MapReload();
 };
 
 #endif
diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h
index d4418097..b607b4d4 100644
--- a/src/engine/shared/network.h
+++ b/src/engine/shared/network.h
@@ -242,7 +242,6 @@ public:
 // server side
 class CNetServer
 {
-public:
 	struct CSlot
 	{
 	public:
diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp
index 6818c0f0..f1190223 100644
--- a/src/engine/shared/network_server.cpp
+++ b/src/engine/shared/network_server.cpp
@@ -292,7 +292,6 @@ int CNetServer::CBanmaster::Add(const char *pAddrStr)
 			return 3;
 
 	m_aBanmasters[m_NumBanmasters] = Addr;
-
 	m_NumBanmasters++;
 	return 0;
 }
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 1c76f655..ac5f2f7c 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -45,6 +45,7 @@ CCharacter::CCharacter(CGameWorld *pWorld)
 	m_ProximityRadius = ms_PhysSize;
 	m_Health = 0;
 	m_Armor = 0;
+	m_FreezeTicks = 0;
 }
 
 void CCharacter::Reset()
@@ -56,8 +57,30 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
 {
 	m_EmoteStop = -1;
 	m_LastAction = -1;
-	m_ActiveWeapon = WEAPON_GUN;
-	m_LastWeapon = WEAPON_HAMMER;
+	
+	/*zCatch */
+	if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 1)
+	{
+		m_ActiveWeapon = WEAPON_RIFLE;
+		m_LastWeapon = WEAPON_RIFLE;
+	}
+	else if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 3)
+	{
+		m_ActiveWeapon = WEAPON_HAMMER;
+		m_LastWeapon = WEAPON_HAMMER;
+	}
+	else if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 4)
+	{
+		m_ActiveWeapon = WEAPON_GRENADE;
+		m_LastWeapon = WEAPON_GRENADE;
+	}
+	else
+	{
+		m_ActiveWeapon = WEAPON_GUN;
+		m_LastWeapon = WEAPON_HAMMER;
+	}
+    /* end zCatch */
+	
 	m_QueuedWeapon = -1;
 
 	m_pPlayer = pPlayer;
@@ -115,16 +138,21 @@ void CCharacter::HandleNinja()
 	if(m_ActiveWeapon != WEAPON_NINJA)
 		return;
 
-	if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
+	/* zCatch */
+	if(GameServer()->m_pController->IsZCatch() == false)
 	{
-		// time's up, return
-		m_aWeapons[WEAPON_NINJA].m_Got = false;
-		m_ActiveWeapon = m_LastWeapon;
+		if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
+		{
+			// time's up, return
+			m_aWeapons[WEAPON_NINJA].m_Got = false;
+			m_ActiveWeapon = m_LastWeapon;
 
-		SetWeapon(m_ActiveWeapon);
-		return;
+			SetWeapon(m_ActiveWeapon);
+			return;
+		}
 	}
-
+	/* zCatch end*/
+	
 	// force ninja Weapon
 	SetWeapon(WEAPON_NINJA);
 
@@ -444,6 +472,17 @@ void CCharacter::HandleWeapons()
 
 	// ammo regen
 	int AmmoRegenTime = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Ammoregentime;
+	if(GameServer()->m_pController->IsZCatch() && m_aWeapons[m_ActiveWeapon].m_Ammo > -1)
+	{
+		switch(m_ActiveWeapon)
+		{
+			case WEAPON_GUN: AmmoRegenTime = 125*5; break;
+			case WEAPON_GRENADE: AmmoRegenTime = 1000; break;
+			case WEAPON_RIFLE: AmmoRegenTime = 1200; break;
+			case WEAPON_SHOTGUN: AmmoRegenTime = 1000; break;
+		}
+	}
+
 	if(AmmoRegenTime)
 	{
 		// If equipped and not active, regen ammo?
@@ -455,7 +494,7 @@ void CCharacter::HandleWeapons()
 			if ((Server()->Tick() - m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart) >= AmmoRegenTime * Server()->TickSpeed() / 1000)
 			{
 				// Add some ammo
-				m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, 10);
+				m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, (GameServer()->m_pController->IsZCatch()) ? g_Config.m_SvGrenadeBullets : 10);
 				m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1;
 			}
 		}
@@ -499,6 +538,9 @@ void CCharacter::SetEmote(int Emote, int Tick)
 
 void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
 {
+	if(m_FreezeTicks)
+		return;
+
 	// check for changes
 	if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0)
 		m_LastAction = Server()->Tick();
@@ -514,6 +556,9 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
 
 void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
 {
+	if(m_FreezeTicks)
+		return;
+
 	mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
 	mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
 
@@ -556,6 +601,23 @@ void CCharacter::Tick()
 	m_Core.m_Input = m_Input;
 	m_Core.Tick(true);
 
+	if(m_FreezeTicks)
+	{
+		if(Server()->Tick() % Server()->TickSpeed() == 0)
+		{
+			GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTicks/Server()->TickSpeed()+1);
+			GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO);
+		}
+		//Set weapon back to the last one
+		if(m_FreezeTicks == 1)
+			{
+				m_ActiveWeapon = m_LastWeapon;
+				GameServer()->SendBroadcast("", m_pPlayer->GetCID());
+			}
+		m_FreezeTicks--;
+	}
+
+
 	// handle death-tiles and leaving gamelayer
 	if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
 		GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
@@ -712,6 +774,8 @@ void CCharacter::Die(int Killer, int Weapon)
 
 	// this is for auto respawn after 3 secs
 	m_pPlayer->m_DieTick = Server()->Tick();
+	// unfreeze the player
+	m_FreezeTicks = 0;
 
 	m_Alive = false;
 	GameServer()->m_World.RemoveEntity(this);
@@ -725,24 +789,27 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
 
 	if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage)
 		return false;
+	
+	/* zCatch */
+	if(GameServer()->m_pController->IsZCatch())
+	{
+		if(From == m_pPlayer->GetCID() || Weapon == WEAPON_GAME)
+			return false;
 
-	// m_pPlayer only inflicts half damage on self
-	if(From == m_pPlayer->GetCID())
-		Dmg = max(1, Dmg/2);
-
-	m_DamageTaken++;
+		if(g_Config.m_SvMode == 4 && Weapon == WEAPON_GRENADE && Dmg < g_Config.m_SvGrenadeMinDamage)
+			return false;
 
-	// create healthmod indicator
-	if(Server()->Tick() < m_DamageTakenTick+25)
-	{
-		// make sure that the damage indicators doesn't group together
-		GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg);
+		m_Health = 0;
+		m_Armor = 0;
 	}
 	else
 	{
-		m_DamageTaken = 0;
-		GameServer()->CreateDamageInd(m_Pos, 0, Dmg);
+		if(From == m_pPlayer->GetCID())
+			Dmg = max(1, Dmg/2);
 	}
+	/* end zCatch */
+	
+	m_DamageTaken++;
 
 	if(Dmg)
 	{
@@ -857,8 +924,8 @@ void CCharacter::Snap(int SnappingClient)
 	if(m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 ||
 		(!g_Config.m_SvStrictSpectateMode && m_pPlayer->GetCID() == GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID))
 	{
-		pCharacter->m_Health = m_Health;
-		pCharacter->m_Armor = m_Armor;
+		pCharacter->m_Health = (m_FreezeTicks) ? (m_FreezeTicks/Server()->TickSpeed())/10 : m_Health;
+		pCharacter->m_Armor = (m_FreezeTicks) ? (m_FreezeTicks/Server()->TickSpeed()) % 10 +1 : m_Armor;
 		if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0)
 			pCharacter->m_AmmoCount = m_aWeapons[m_ActiveWeapon].m_Ammo;
 	}
@@ -871,3 +938,12 @@ void CCharacter::Snap(int SnappingClient)
 
 	pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags;
 }
+
+void CCharacter::Freeze(int Ticks)
+{
+	m_FreezeTicks = Ticks;
+	m_LastWeapon = m_ActiveWeapon;
+	m_ActiveWeapon = WEAPON_NINJA;
+	ResetInput();
+	GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
+}
diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h
index aa127979..dae01bd4 100644
--- a/src/game/server/entities/character.h
+++ b/src/game/server/entities/character.h
@@ -64,6 +64,9 @@ public:
 	bool IsAlive() const { return m_Alive; }
 	class CPlayer *GetPlayer() { return m_pPlayer; }
 
+	void Freeze(int Tick);
+	int m_FreezeTicks;
+
 private:
 	// player controlling this character
 	class CPlayer *m_pPlayer;
diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp
index eb40c4e1..f45a1d1d 100644
--- a/src/game/server/entities/laser.cpp
+++ b/src/game/server/entities/laser.cpp
@@ -2,6 +2,7 @@
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
 #include <game/generated/protocol.h>
 #include <game/server/gamecontext.h>
+#include <engine/shared/config.h>
 #include "laser.h"
 
 CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner)
@@ -67,6 +68,9 @@ void CLaser::DoBounce()
 				m_Energy = -1;
 
 			GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE);
+
+			if(m_Bounces == 1 && g_Config.m_SvLaserjumps && GameServer()->m_pController->IsZCatch())
+				GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_GAME, false);
 		}
 	}
 	else
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 5d2f22b8..3967f49d 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -13,6 +13,7 @@
 #include "gamemodes/tdm.h"
 #include "gamemodes/ctf.h"
 #include "gamemodes/mod.h"
+#include "gamemodes/zcatch.h"
 
 enum
 {
@@ -37,6 +38,9 @@ void CGameContext::Construct(int Resetting)
 
 	if(Resetting==NO_RESET)
 		m_pVoteOptionHeap = new CHeap();
+	
+	for(int i = 0; i < MAX_MUTES; i++)
+		m_aMutes[i].m_IP[0] = 0;
 }
 
 CGameContext::CGameContext(int Resetting)
@@ -257,7 +261,8 @@ void CGameContext::SendChat(int ChatterClientID, int Team, const char *pText)
 		// send to the clients
 		for(int i = 0; i < MAX_CLIENTS; i++)
 		{
-			if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() == Team)
+			//if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() == Team)
+			if(m_apPlayers[i] && ChatterClientID >= 0 && ChatterClientID < MAX_CLIENTS && m_apPlayers[ChatterClientID] && m_apPlayers[ChatterClientID]->m_SpecExplicit == m_apPlayers[i]->m_SpecExplicit)
 				Server()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i);
 		}
 	}
@@ -447,7 +452,10 @@ void CGameContext::OnTick()
 				bool aVoteChecked[MAX_CLIENTS] = {0};
 				for(int i = 0; i < MAX_CLIENTS; i++)
 				{
-					if(!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || aVoteChecked[i])	// don't count in votes by spectators
+					/* zCatch - Allow voting from players in spectators (needed or the last 2 players ingame can kick the whole server),
+					 * but deny votes from players who are explicit in spec
+					*/
+					if(!m_apPlayers[i] || m_apPlayers[i]->m_SpecExplicit == 1 || aVoteChecked[i])	// don't count in votes by spectators
 						continue;
 
 					int ActVote = m_apPlayers[i]->m_Vote;
@@ -535,6 +543,72 @@ void CGameContext::OnClientEnter(int ClientID)
 {
 	//world.insert_entity(&players[client_id]);
 	m_apPlayers[ClientID]->Respawn();
+	
+	/* begin zCatch */
+	int LeaderID = -1;
+	int StartTeam = m_pController->ClampTeam(1);
+	
+	if(m_pController->IsZCatch())
+	{
+		int Num = 0;
+		
+		for(int i = 0; i < MAX_CLIENTS; i++)
+		{
+			if(IsClientReady(i))
+				Num++;
+		}
+		if(Num < 3)
+			m_pController->EndRound();
+		
+		if(g_Config.m_SvAllowJoin == 1)
+		{
+			m_apPlayers[ClientID]->m_CaughtBy = ZCATCH_NOT_CAUGHT;
+			m_apPlayers[ClientID]->m_SpecExplicit = (Num < 3) ? 0 : 1;
+			StartTeam = (Num < 3) ? m_pController->ClampTeam(1) : TEAM_SPECTATORS;
+			SendBroadcast("You can join the game", ClientID);
+		}
+		else if(g_Config.m_SvAllowJoin == 2)
+		{
+			int Num2 = 0, PrevNum = 0;
+
+			for(int i = 0; i < MAX_CLIENTS; i++)
+			{
+				if(m_apPlayers[i])
+				{
+					Num2 = 0;
+					for(int j = 0; j < MAX_CLIENTS; j++)
+						if(m_apPlayers[j] && m_apPlayers[j]->m_CaughtBy == i)
+							Num2++;
+
+					if(Num2 > PrevNum)
+					{
+						LeaderID = i;
+						PrevNum = Num2;
+		    		}
+				}
+		    }
+
+		    if(LeaderID > -1)
+			{
+				m_apPlayers[ClientID]->m_CaughtBy = LeaderID;
+				m_apPlayers[ClientID]->m_SpecExplicit = 0;
+				m_apPlayers[ClientID]->m_SpectatorID = LeaderID;
+				StartTeam = TEAM_SPECTATORS;
+			}
+			else
+			{
+				m_apPlayers[ClientID]->m_CaughtBy = ZCATCH_NOT_CAUGHT;
+				m_apPlayers[ClientID]->m_SpecExplicit = 0;
+			}
+		}
+		else
+			StartTeam = m_pController->GetAutoTeam(ClientID);
+	}
+	
+	m_apPlayers[ClientID]->SetTeamDirect(StartTeam);
+	
+	/* end zCatch */
+	
 	char aBuf[512];
 	str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientID), m_pController->GetTeamName(m_apPlayers[ClientID]->GetTeam()));
 	SendChat(-1, CGameContext::CHAT_ALL, aBuf);
@@ -543,6 +617,21 @@ void CGameContext::OnClientEnter(int ClientID)
 	Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
 
 	m_VoteUpdate = true;
+	
+	/* zCatch begin */
+   	if(m_pController->IsZCatch())
+	{
+	    SendChatTarget(ClientID, "Welcome to zCatch!");
+	    SendChatTarget(ClientID, "type /cmdlist to get all commands");
+	    SendChatTarget(ClientID, "type /help for instructions");
+	    if(g_Config.m_SvAllowJoin == 2 && LeaderID > -1)
+	    {
+	    	char buf[128];
+	    	str_format(buf, sizeof(buf), "You will join the game when %s dies", Server()->ClientName(LeaderID));
+	    	SendChatTarget(ClientID, buf);	
+	    }
+	}
+	/* zCatch end */
 }
 
 void CGameContext::OnClientConnected(int ClientID)
@@ -618,6 +707,26 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 			return;
 
 		pPlayer->m_LastChat = Server()->Tick();
+		
+		//Check if the player is muted
+		char aAddrStr[NETADDR_MAXSTRSIZE] = {0};
+		Server()->GetClientAddr(ClientID, aAddrStr, sizeof(aAddrStr));
+		int Pos;
+        if((Pos = Muted(aAddrStr)) > -1)
+		{
+			char aBuf[128];
+			int Expires = (m_aMutes[Pos].m_Expires - Server()->Tick())/Server()->TickSpeed(); 
+			str_format(aBuf, sizeof(aBuf), "You are muted for %d minutes and %d seconds.", Expires/60, Expires%60);
+			SendChatTarget(ClientID, aBuf);
+			return;
+		}
+        //mute the player if he's spamming
+		else if(g_Config.m_SvMuteDuration && ((pPlayer->m_ChatTicks += g_Config.m_SvChatValue) > g_Config.m_SvChatThreshold))
+		{
+			AddMute(ClientID, g_Config.m_SvMuteDuration);
+			pPlayer->m_ChatTicks = 0;
+			return;
+		}
 
 		// check for invalid chars
 		unsigned char *pMessage = (unsigned char *)pMsg->m_pMessage;
@@ -628,7 +737,46 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 			pMessage++;
 		}
 
-		SendChat(ClientID, Team, pMsg->m_pMessage);
+		/* begin zCatch*/
+		if(!str_comp("/info", pMsg->m_pMessage) || !str_comp("/about", pMsg->m_pMessage))
+		{
+			char aBuf[128];
+			str_format(aBuf, sizeof(aBuf), "zCatch version %s by erd and Teetime. Type /cmdlist for all commands.", ZCATCH_VERSION);
+			SendChatTarget(ClientID, " ");
+			SendChatTarget(ClientID, aBuf);
+		}
+		else if(!str_comp("/cmdlist", pMsg->m_pMessage))
+		{
+			SendChatTarget(ClientID, " ");
+			SendChatTarget(ClientID, "/info or /about - see information about author.");
+			SendChatTarget(ClientID, "/help - learn how to play.");
+			SendChatTarget(ClientID, "/follow 1 or /follow 0 - Enables/Disables following of the catcher.");
+		}
+		else if(!str_comp("/help", pMsg->m_pMessage))
+		{
+			SendChatTarget(ClientID, " ");
+			SendChatTarget(ClientID, "The winner is the tee which is left over at the end.");
+			SendChatTarget(ClientID, "If you die, all players that you killed will respawn.");
+			SendChatTarget(ClientID, "So the only way to win is to kill every player without beeing killed.");
+			SendChatTarget(ClientID, "Have fun!");
+		}
+		else if(!str_comp("/follow 0", pMsg->m_pMessage))
+		{
+			pPlayer->m_PlayerWantToFollowCatcher = 0;
+			pPlayer->m_SpectatorID = SPEC_FREEVIEW;
+			SendChatTarget(ClientID, "Follow of catcher disabled.");
+		}
+		else if(!str_comp("/follow 1", pMsg->m_pMessage))
+		{
+			pPlayer->m_PlayerWantToFollowCatcher = 1;
+			SendChatTarget(ClientID, "Follow of catcher enabled.");
+		}	
+		else if(!str_comp_num("/", pMsg->m_pMessage, 1))
+			SendChatTarget(ClientID, "Unknown command.");
+		else
+			SendChat(ClientID, Team, pMsg->m_pMessage);
+
+		/* end zCatch */
 	}
 	else if(MsgID == NETMSGTYPE_CL_CALLVOTE)
 	{
@@ -637,7 +785,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 
 		int64 Now = Server()->Tick();
 		pPlayer->m_LastVoteTry = Now;
-		if(pPlayer->GetTeam() == TEAM_SPECTATORS)
+		// zCatch - Only People who are explicit in Spectators can't vote!
+		if(pPlayer->m_SpecExplicit == 1) //zCatch
 		{
 			SendChatTarget(ClientID, "Spectators aren't allowed to start a vote.");
 			return;
@@ -688,6 +837,11 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 				return;
 			}
 		}
+		else if(g_Config.m_SvVoteForceReason && !pMsg->m_Reason[0])
+		{
+			SendChatTarget(ClientID, "You must give a reason for your vote");
+			return;
+		}
 		else if(str_comp_nocase(pMsg->m_Type, "kick") == 0)
 		{
 			if(!g_Config.m_SvVoteKick)
@@ -700,7 +854,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 			{
 				int PlayerNum = 0;
 				for(int i = 0; i < MAX_CLIENTS; ++i)
-					if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
+					if(m_apPlayers[i] && m_apPlayers[i]->m_SpecExplicit != 1) // zCatch - Count all Players who are not explicit in spectator
 						++PlayerNum;
 
 				if(PlayerNum < g_Config.m_SvVoteKickMin)
@@ -820,7 +974,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 		// Switch team on given client and kill/respawn him
 		if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID))
 		{
-			if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team))
+			if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team) && !m_pController->IsZCatch()) //zCatch
 			{
 				pPlayer->m_LastSetTeam = Server()->Tick();
 				if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS)
@@ -829,6 +983,23 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 				(void)m_pController->CheckTeamBalance();
 				pPlayer->m_TeamChangeTick = Server()->Tick();
 			}
+			/* begin zCatch */
+			else if(m_pController->IsZCatch())
+			{	
+				if(pPlayer->m_CaughtBy >= 0)
+				{
+					char buf[256];
+					str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", Server()->ClientName(pPlayer->m_CaughtBy));
+					SendChatTarget(ClientID, buf);
+					return;
+				}
+				else if(pPlayer->m_CaughtBy == ZCATCH_NOT_CAUGHT)
+				{
+					pPlayer->m_LastSetTeam = Server()->Tick();
+					pPlayer->SetTeam(pMsg->m_Team);
+				}
+			}
+            /* end zCatch */
 			else
 				SendBroadcast("Teams must be balanced, please join other team", ClientID);
 		}
@@ -990,14 +1161,88 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 	}
 	else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused)
 	{
-		if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick())
+		/* begin zCatch*/
+		if(pPlayer->GetTeam() == TEAM_SPECTATORS || (pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) ||
+				(pPlayer->m_LastKillTry+Server()->TickSpeed()*3 > Server()->Tick()))
 			return;
 
-		pPlayer->m_LastKill = Server()->Tick();
-		pPlayer->KillCharacter(WEAPON_SELF);
+		if(g_Config.m_SvSuicideTime == 0)
+		{
+			SendChatTarget(ClientID, "Suicide is not allowed.");
+		}
+		else if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*g_Config.m_SvSuicideTime > Server()->Tick())
+		{
+			char aBuf[128];
+			str_format(aBuf, sizeof(aBuf), "Only one suicide every %d seconds is allowed.", g_Config.m_SvSuicideTime);
+			SendChatTarget(ClientID, aBuf);
+		}
+		else if(pPlayer->GetCharacter() && pPlayer->GetCharacter()->m_FreezeTicks)
+		{
+			SendChatTarget(ClientID, "You can't kill yourself while you're frozen.");
+		}
+		else
+		{
+			pPlayer->m_LastKill = Server()->Tick();
+			pPlayer->KillCharacter(WEAPON_SELF);
+			pPlayer->m_Deaths++;
+			return;
+		}
+		pPlayer->m_LastKillTry = Server()->Tick();
+		/* end zCatch*/
 	}
 }
 
+void CGameContext::AddMute(const char* IP, int Secs)
+{
+	int Pos = Muted(IP);
+	if(Pos > -1)	
+		m_aMutes[Pos].m_Expires = Server()->TickSpeed() * Secs + Server()->Tick();	// overwrite mute
+	else
+		for(int i = 0; i < MAX_MUTES; i++)	// find free slot
+			if(!m_aMutes[i].m_IP[0])
+			{
+				str_copy(m_aMutes[i].m_IP, IP, sizeof(m_aMutes[i].m_IP));
+				m_aMutes[i].m_Expires = Server()->TickSpeed() * Secs + Server()->Tick();
+				break;
+			}
+}
+
+void CGameContext::AddMute(int ClientID, int Secs)
+{
+	char aAddrStr[NETADDR_MAXSTRSIZE] = {0};
+	Server()->GetClientAddr(ClientID, aAddrStr, sizeof(aAddrStr));
+	AddMute(aAddrStr, Secs);
+	
+	char aBuf[128];
+	if(Secs > 0)
+		str_format(aBuf, sizeof(aBuf), "%s has been muted for %d seconds.", Server()->ClientName(ClientID), Secs);
+	else
+		str_format(aBuf, sizeof(aBuf), "%s has been unmuted.", Server()->ClientName(ClientID));
+	SendChatTarget(-1, aBuf);
+}
+
+int CGameContext::Muted(const char* IP)
+{	
+	CleanMutes();
+	int Pos = -1;
+	if(!IP[0])
+		return -1;
+	for(int i = 0; i < MAX_MUTES; i++)
+		if(!str_comp_num(IP, m_aMutes[i].m_IP, sizeof(m_aMutes[i].m_IP)))
+		{
+			Pos = i;
+			break;
+		}
+	return Pos;
+}
+
+void CGameContext::CleanMutes()
+{
+	for(int i = 0; i < MAX_MUTES; i++)
+		if(m_aMutes[i].m_Expires < Server()->Tick())
+			m_aMutes[i].m_IP[0] = 0;
+}
+
 void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData)
 {
 	CGameContext *pSelf = (CGameContext *)pUserData;
@@ -1416,6 +1661,64 @@ void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *p
 	}
 }
 
+void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData)
+{
+	CGameContext *pSelf = (CGameContext *)pUserData;
+	int CID = pResult->GetInteger(0);
+	if(CID < 0 || CID >= MAX_CLIENTS || !pSelf->m_apPlayers[CID])
+		return;
+		
+	pSelf->AddMute(CID, pResult->GetInteger(1));
+}
+
+void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData)
+{
+	CGameContext *pSelf = (CGameContext *)pUserData;
+	char aBuf[128];
+	int Sec, Count = 0;
+	pSelf->CleanMutes();
+	for(int i = 0; i < MAX_MUTES; i++)
+	{
+		if(pSelf->m_aMutes[i].m_IP[0] == 0)
+			continue;
+		
+		Sec = (pSelf->m_aMutes[i].m_Expires - pSelf->Server()->Tick())/pSelf->Server()->TickSpeed();
+		str_format(aBuf, sizeof(aBuf), "#%d: %s for %d minutes and %d sec", i, pSelf->m_aMutes[i].m_IP, Sec/60, Sec%60);
+		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
+		Count++;
+	}
+	str_format(aBuf, sizeof(aBuf), "%d mute(s)", Count);
+	pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);	
+}
+
+void CGameContext::ConUnmuteID(IConsole::IResult *pResult, void *pUserData)
+{
+	CGameContext *pSelf = (CGameContext *)pUserData;
+	int CID = pResult->GetInteger(0);
+	if(CID < 0 || CID >= MAX_CLIENTS || !pSelf->m_apPlayers[CID])
+		return;
+	pSelf->AddMute(CID, 0);
+}
+
+void CGameContext::ConUnmuteIP(IConsole::IResult *pResult, void *pUserData)
+{
+	CGameContext *pSelf = (CGameContext *)pUserData;
+	int MuteID = pResult->GetInteger(0);
+	char aBuf[128];
+	
+	if(MuteID < 0 || MuteID >= MAX_MUTES)
+		return;
+	
+	if(pSelf->Muted(pSelf->m_aMutes[MuteID].m_IP) > -1)
+	{
+		str_format(aBuf, sizeof(aBuf), "unmuted %s", pSelf->m_aMutes[MuteID].m_IP);
+		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf);
+		pSelf->AddMute(pSelf->m_aMutes[MuteID].m_IP, 0);
+	}
+	else
+		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "mute not found");
+}
+
 void CGameContext::OnConsoleInit()
 {
 	m_pServer = Kernel()->RequestInterface<IServer>();
@@ -1442,6 +1745,11 @@ void CGameContext::OnConsoleInit()
 	Console()->Register("clear_votes", "", CFGFLAG_SERVER, ConClearVotes, this, "Clears the voting options");
 	Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, "Force a vote to yes/no");
 
+	Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "Mutes a player for x sec");
+	Console()->Register("unmuteid", "i", CFGFLAG_SERVER, ConUnmuteID, this, "Unmutes a player by its client id");
+	Console()->Register("unmuteip", "i", CFGFLAG_SERVER, ConUnmuteIP, this, "Removes a mute by its index");
+	Console()->Register("mutes", "", CFGFLAG_SERVER, ConMutes, this, "Show all mutes");
+		
 	Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this);
 }
 
@@ -1472,6 +1780,8 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
 		m_pController = new CGameControllerCTF(this);
 	else if(str_comp(g_Config.m_SvGametype, "tdm") == 0)
 		m_pController = new CGameControllerTDM(this);
+	else if(str_comp_nocase(g_Config.m_SvGametype, "zcatch") == 0)
+		m_pController = new CGameController_zCatch(this);
 	else
 		m_pController = new CGameControllerDM(this);
 
diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h
index 2ffb0ab4..8dca1fbe 100644
--- a/src/game/server/gamecontext.h
+++ b/src/game/server/gamecontext.h
@@ -15,6 +15,9 @@
 #include "gameworld.h"
 #include "player.h"
 
+#define MAX_MUTES 35
+#define ZCATCH_VERSION "0.4.7 BETA"
+
 /*
 	Tick
 		Game Context (CGameContext::tick)
@@ -64,6 +67,11 @@ class CGameContext : public IGameServer
 	static void ConClearVotes(IConsole::IResult *pResult, void *pUserData);
 	static void ConVote(IConsole::IResult *pResult, void *pUserData);
 	static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
+	
+	static void ConMute(IConsole::IResult *pResult, void *pUserData);
+	static void ConUnmuteID(IConsole::IResult *pResult, void *pUserData);
+	static void ConUnmuteIP(IConsole::IResult *pResult, void *pUserData);
+	static void ConMutes(IConsole::IResult *pResult, void *pUserData);
 
 	CGameContext(int Resetting);
 	void Construct(int Resetting);
@@ -134,6 +142,23 @@ public:
 		CHAT_RED=0,
 		CHAT_BLUE=1
 	};
+	
+	enum
+	{
+		ZCATCH_NOT_CAUGHT = -1,
+	}; 
+	
+	struct CMutes
+	{
+		char m_IP[NETADDR_MAXSTRSIZE];
+		int m_Expires;
+	}; 
+	CMutes m_aMutes[MAX_MUTES];
+	// helper functions
+	void AddMute(const char* IP, int Secs);
+	void AddMute(int ClientID, int Secs);
+	int Muted(const char* IP);
+	void CleanMutes();
 
 	// network
 	void SendChatTarget(int To, const char *pText);
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp
index 7001ca32..58c4d9f0 100644
--- a/src/game/server/gamecontroller.cpp
+++ b/src/game/server/gamecontroller.cpp
@@ -136,30 +136,35 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
 		m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos;
 	else if(Index == ENTITY_SPAWN_BLUE)
 		m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
-	else if(Index == ENTITY_ARMOR_1)
-		Type = POWERUP_ARMOR;
-	else if(Index == ENTITY_HEALTH_1)
-		Type = POWERUP_HEALTH;
-	else if(Index == ENTITY_WEAPON_SHOTGUN)
-	{
-		Type = POWERUP_WEAPON;
-		SubType = WEAPON_SHOTGUN;
-	}
-	else if(Index == ENTITY_WEAPON_GRENADE)
-	{
-		Type = POWERUP_WEAPON;
-		SubType = WEAPON_GRENADE;
-	}
-	else if(Index == ENTITY_WEAPON_RIFLE)
-	{
-		Type = POWERUP_WEAPON;
-		SubType = WEAPON_RIFLE;
-	}
-	else if(Index == ENTITY_POWERUP_NINJA && g_Config.m_SvPowerups)
-	{
-		Type = POWERUP_NINJA;
-		SubType = WEAPON_NINJA;
-	}
+	/* zCatch */
+   	else if(!GameServer()->m_pController->IsZCatch())
+    	{
+        if(Index == ENTITY_ARMOR_1)
+            Type = POWERUP_ARMOR;
+        else if(Index == ENTITY_HEALTH_1)
+            Type = POWERUP_HEALTH;
+        else if(Index == ENTITY_WEAPON_SHOTGUN)
+        {
+            Type = POWERUP_WEAPON;
+            SubType = WEAPON_SHOTGUN;
+        }
+        else if(Index == ENTITY_WEAPON_GRENADE)
+        {
+            Type = POWERUP_WEAPON;
+            SubType = WEAPON_GRENADE;
+        }
+        else if(Index == ENTITY_WEAPON_RIFLE)
+        {
+            Type = POWERUP_WEAPON;
+            SubType = WEAPON_RIFLE;
+        }
+        else if(Index == ENTITY_POWERUP_NINJA && g_Config.m_SvPowerups)
+        {
+            Type = POWERUP_NINJA;
+            SubType = WEAPON_NINJA;
+        }
+    }
+    /* end zCatch*/
 
 	if(Type != -1)
 	{
@@ -171,6 +176,11 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
 	return false;
 }
 
+bool IGameController::IsZCatch()
+{
+	return false;
+}
+
 void IGameController::EndRound()
 {
 	if(m_Warmup) // game can't end when we are running warmup
diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h
index 1675fe35..1be24509 100644
--- a/src/game/server/gamecontroller.h
+++ b/src/game/server/gamecontroller.h
@@ -73,8 +73,8 @@ public:
 
 	void DoWarmup(int Seconds);
 
-	void StartRound();
-	void EndRound();
+	virtual void StartRound();
+	virtual void EndRound();
 	void ChangeMap(const char *pToMap);
 
 	bool IsFriendlyFire(int ClientID1, int ClientID2);
@@ -142,6 +142,8 @@ public:
 	int ClampTeam(int Team);
 
 	virtual void PostReset();
+	
+	virtual bool IsZCatch();
 };
 
 #endif
diff --git a/src/game/server/gamemodes/zcatch.cpp b/src/game/server/gamemodes/zcatch.cpp
new file mode 100644
index 00000000..2a94e7ac
--- /dev/null
+++ b/src/game/server/gamemodes/zcatch.cpp
@@ -0,0 +1,228 @@
+/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
+/* If you are missing that file, acquire a complete release at teeworlds.com.                */
+/* zCatch by erd and Teetime */
+
+#include <engine/shared/config.h>
+#include <game/server/gamecontext.h>
+#include "zcatch.h"
+
+CGameController_zCatch::CGameController_zCatch(class CGameContext *pGameServer) 
+: IGameController(pGameServer)
+{
+	m_pGameType = "zCatch";
+	m_OldMode = g_Config.m_SvMode;
+}
+
+void CGameController_zCatch::Tick()
+{
+	DoWincheck();
+	IGameController::Tick();
+
+	if(m_OldMode != g_Config.m_SvMode)
+	{
+		Server()->MapReload();
+		m_OldMode = g_Config.m_SvMode;
+	}
+}
+
+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();
+	char aBuf[256];
+	if(pKiller !=  pVictim->GetPlayer())
+	{
+		pKiller->m_Kills++;
+		pVictim->GetPlayer()->m_Deaths++; 
+
+		pKiller->m_Score++;
+
+		/* Check if the killer is already killed and in spectator (victim may died through wallshot) */
+		if(pKiller->GetTeam() != TEAM_SPECTATORS)
+		{
+			pVictim->GetPlayer()->m_CaughtBy = pKiller->GetCID();
+			pVictim->GetPlayer()->SetTeamDirect(TEAM_SPECTATORS);
+
+			if(pVictim->GetPlayer()->m_PlayerWantToFollowCatcher)
+				pVictim->GetPlayer()->m_SpectatorID = pKiller->GetCID(); // Let the victim follow his catcher
+
+			str_format(aBuf, sizeof(aBuf), "Caught by \"%s\". You will join the game automatically when \"%s\" dies.", Server()->ClientName(pKiller->GetCID()), Server()->ClientName(pKiller->GetCID()));
+			GameServer()->SendChatTarget(VictimID, aBuf);
+		}
+	}
+	else
+	{
+		//Punish selfkill/death
+		if(WeaponID == WEAPON_SELF || WeaponID == WEAPON_WORLD)
+			pVictim->GetPlayer()->m_Score -= g_Config.m_SvKillPenalty;
+	}
+
+	for(int i=0; i < MAX_CLIENTS; i++)
+	{
+		if(GameServer()->m_apPlayers[i])
+		{
+			if(GameServer()->m_apPlayers[i]->m_CaughtBy == VictimID)
+			{
+				GameServer()->m_apPlayers[i]->m_CaughtBy = ZCATCH_NOT_CAUGHT;
+				GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1));
+				
+				if(pKiller != pVictim->GetPlayer())
+					pKiller->m_Score++;
+			}
+		}
+	}
+
+	// Update colors
+	OnPlayerInfoChange(pKiller);
+	OnPlayerInfoChange(pVictim->GetPlayer());
+
+	return 0;
+}
+
+void CGameController_zCatch::OnPlayerInfoChange(class CPlayer *pP)
+{
+	if(g_Config.m_SvColorIndicator)
+	{
+		int Num = 161;
+		for(int i = 0; i < MAX_CLIENTS; i++)
+			if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_CaughtBy == pP->GetCID())
+				Num -= 10;
+		pP->m_TeeInfos.m_ColorBody = Num * 0x010000 + 0xff00;
+		pP->m_TeeInfos.m_ColorFeet = Num * 0x010000 + 0xff00;
+		pP->m_TeeInfos.m_UseCustomColor = 1;
+	}
+}
+
+void CGameController_zCatch::StartRound()
+{
+	ResetGame();
+
+	m_RoundStartTick = Server()->Tick();
+	m_SuddenDeath = 0;
+	m_GameOverTick = -1;
+	GameServer()->m_World.m_Paused = false;
+	m_aTeamscore[TEAM_RED] = 0;
+	m_aTeamscore[TEAM_BLUE] = 0;
+	m_ForceBalanced = false;
+	Server()->DemoRecorder_HandleAutoStart();
+	for(int i=0; i<MAX_CLIENTS; i++)
+	{
+		if(GameServer()->m_apPlayers[i])
+		{		
+			GameServer()->m_apPlayers[i]->m_CaughtBy = ZCATCH_NOT_CAUGHT;
+			GameServer()->m_apPlayers[i]->m_Kills = 0;
+			GameServer()->m_apPlayers[i]->m_Deaths = 0;
+			GameServer()->m_apPlayers[i]->m_TicksSpec = 0;
+			GameServer()->m_apPlayers[i]->m_TicksIngame = 0;
+		}
+	}
+	char aBuf[256];
+	str_format(aBuf, sizeof(aBuf), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
+	GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
+}
+
+void CGameController_zCatch::OnCharacterSpawn(class CCharacter *pChr)
+{
+	// default health and armor
+	pChr->IncreaseHealth(10);
+	if(g_Config.m_SvMode == 2)
+		pChr->IncreaseArmor(10);
+
+	// give default weapons
+	switch(g_Config.m_SvMode)
+		{
+			case 1: /* Instagib - Only Riffle */
+				pChr->GiveWeapon(WEAPON_RIFLE, -1);
+				break;
+			case 2: /* All Weapons */
+				pChr->GiveWeapon(WEAPON_HAMMER, -1);
+				pChr->GiveWeapon(WEAPON_GUN, 6);
+				pChr->GiveWeapon(WEAPON_GRENADE, 6);
+				pChr->GiveWeapon(WEAPON_SHOTGUN, 6);
+				pChr->GiveWeapon(WEAPON_RIFLE, 6);
+				break;
+			case 3: /* Hammer */
+				pChr->GiveWeapon(WEAPON_HAMMER, -1);
+				break;
+			case 4: /* Grenade */
+				pChr->GiveWeapon(WEAPON_GRENADE, g_Config.m_SvGrenadeBullets);
+				break;
+			case 5: /* Ninja */
+				pChr->GiveNinja();
+				break;
+		}
+
+	//Update color of spawning tees
+	OnPlayerInfoChange(pChr->GetPlayer());
+}
+
+void CGameController_zCatch::EndRound()
+{
+	for(int i = 0; i < MAX_CLIENTS; i++)
+	{
+		if(GameServer()->m_apPlayers[i])
+		{
+
+			if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 0)
+			{
+				GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1));
+				
+				char aBuf[128];
+				str_format(aBuf, sizeof(aBuf), "Kills: %d | Deaths: %d", GameServer()->m_apPlayers[i]->m_Kills, GameServer()->m_apPlayers[i]->m_Deaths);
+				GameServer()->SendChatTarget(i, aBuf);
+
+				if(GameServer()->m_apPlayers[i]->m_TicksSpec != 0 || GameServer()->m_apPlayers[i]->m_TicksIngame != 0)
+				{
+					double TimeInSpec = (GameServer()->m_apPlayers[i]->m_TicksSpec*100.0) / (GameServer()->m_apPlayers[i]->m_TicksIngame + GameServer()->m_apPlayers[i]->m_TicksSpec);
+					str_format(aBuf, sizeof(aBuf), "Spec: %.2f%% | Ingame: %.2f%%", (double)TimeInSpec, (double)(100.0 - TimeInSpec));
+					GameServer()->SendChatTarget(i, aBuf);
+				}
+				GameServer()->m_apPlayers[i]->m_CaughtBy = ZCATCH_NOT_CAUGHT; //Set all players in server as non-caught
+			}
+		}
+	}
+
+	if(m_Warmup) // game can't end when we are running warmup
+		return;
+
+	GameServer()->m_World.m_Paused = true;
+	m_GameOverTick = Server()->Tick();
+	m_SuddenDeath = 0;
+}
diff --git a/src/game/server/gamemodes/zcatch.h b/src/game/server/gamemodes/zcatch.h
new file mode 100644
index 00000000..cb01ff8b
--- /dev/null
+++ b/src/game/server/gamemodes/zcatch.h
@@ -0,0 +1,32 @@
+/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
+/* If you are missing that file, acquire a complete release at teeworlds.com.                */
+/* zCatch by erd and Teetime */
+
+#ifndef GAME_SERVER_GAMEMODES_ZCATCH_H
+#define GAME_SERVER_GAMEMODES_ZCATCH_H
+
+#include <game/server/gamecontroller.h>
+
+class CGameController_zCatch : public IGameController
+{
+	int m_OldMode;
+
+public:
+	CGameController_zCatch(class CGameContext *pGameServer);
+	virtual void Tick();
+	virtual void DoWincheck();
+	virtual bool IsZCatch();
+
+	enum
+	{
+		ZCATCH_NOT_CAUGHT = -1,
+	}; 
+
+	virtual void StartRound();
+	virtual void OnCharacterSpawn(class CCharacter *pChr);
+	virtual void OnPlayerInfoChange(class CPlayer *pP);
+	virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID);
+	virtual void EndRound();
+};
+
+#endif
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 75c2c1c6..7110d229 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -21,6 +21,17 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
 	m_SpectatorID = SPEC_FREEVIEW;
 	m_LastActionTick = Server()->Tick();
 	m_TeamChangeTick = Server()->Tick();
+	
+	//zCatch
+	m_CaughtBy = -1;
+	m_SpecExplicit = 0;
+	m_Kills = 0;
+	m_Deaths = 0;
+	m_PlayerWantToFollowCatcher = g_Config.m_SvFollowCatcher;
+	m_LastKillTry = Server()->Tick();
+	m_TicksSpec = 0;
+	m_TicksIngame = 0;
+	m_ChatTicks = 0;
 }
 
 CPlayer::~CPlayer()
@@ -38,6 +49,20 @@ void CPlayer::Tick()
 		return;
 
 	Server()->SetClientScore(m_ClientID, m_Score);
+	
+	/* begin zCatch*/
+	
+	if(m_Team == TEAM_SPECTATORS)
+		m_TicksSpec++;
+	else
+		m_TicksIngame++;
+	
+	if(m_ChatTicks > 0)
+		m_ChatTicks--;
+
+	if((g_Config.m_SvAnticamper == 2 && g_Config.m_SvMode == 1) || (g_Config.m_SvAnticamper == 1))
+		Anticamper();
+	/* end zCatch*/
 
 	// do latency stuff
 	{
@@ -179,6 +204,9 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
 	if((m_PlayerFlags&PLAYERFLAG_CHATTING) && (NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING))
 		return;
 
+	if(m_pCharacter && m_pCharacter->m_FreezeTicks)
+		return;
+
 	if(m_pCharacter)
 		m_pCharacter->OnPredictedInput(NewInput);
 }
@@ -204,6 +232,9 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
 	if(m_pCharacter)
 		m_pCharacter->OnDirectInput(NewInput);
 
+	if(m_pCharacter && m_pCharacter->m_FreezeTicks)
+		return;
+
 	if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
 		m_Spawning = true;
 
@@ -274,7 +305,15 @@ 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;
 	}
+	else
+		m_SpecExplicit = 0;
+}
+
+void CPlayer::SetTeamDirect(int Team)
+{
+	m_Team = Team;
 }
 
 void CPlayer::TryRespawn()
@@ -289,3 +328,52 @@ void CPlayer::TryRespawn()
 	m_pCharacter->Spawn(this, SpawnPos);
 	GameServer()->CreatePlayerSpawn(SpawnPos);
 }
+
+int CPlayer::Anticamper()
+{
+	if(GameServer()->m_World.m_Paused || !m_pCharacter || m_Team == TEAM_SPECTATORS || m_pCharacter->m_FreezeTicks)
+	{
+		m_CampTick = -1;
+		m_SentCampMsg = false;
+		return 0;
+	}
+
+	int AnticamperTime = g_Config.m_SvAnticamperTime;
+	int AnticamperRange = g_Config.m_SvAnticamperRange;
+
+	if(m_CampTick == -1)
+	{
+		m_CampPos = m_pCharacter->m_Pos;
+		m_CampTick = Server()->Tick() + Server()->TickSpeed()*AnticamperTime;
+	}
+
+	// Check if the player is moving
+	if((m_CampPos.x - m_pCharacter->m_Pos.x >= (float)AnticamperRange || m_CampPos.x - m_pCharacter->m_Pos.x <= -(float)AnticamperRange)
+	|| (m_CampPos.y - m_pCharacter->m_Pos.y >= (float)AnticamperRange || m_CampPos.y - m_pCharacter->m_Pos.y <= -(float)AnticamperRange))
+		{
+			m_CampTick = -1;
+		}
+
+	// Send warning to the player
+	if(m_CampTick <= Server()->Tick() + Server()->TickSpeed() * AnticamperTime/2 && m_CampTick != -1 && !m_SentCampMsg)
+	{
+		GameServer()->SendBroadcast("ANTICAMPER: Move or die", m_ClientID);
+		m_SentCampMsg = true;
+	}
+
+	// Kill him
+	if((m_CampTick <= Server()->Tick()) && (m_CampTick > 0))
+	{
+		if(g_Config.m_SvAnticamperFreeze)
+		{
+			m_pCharacter->Freeze(Server()->TickSpeed()*g_Config.m_SvAnticamperFreeze);
+			GameServer()->SendBroadcast("You have been freezed due camping", m_ClientID);
+		}
+		else
+			m_pCharacter->Die(m_ClientID, WEAPON_GAME);
+		m_CampTick = -1;
+		m_SentCampMsg = false;
+		return 1;
+	}
+	return 0;
+}
diff --git a/src/game/server/player.h b/src/game/server/player.h
index dd804a95..6bd39370 100644
--- a/src/game/server/player.h
+++ b/src/game/server/player.h
@@ -21,6 +21,7 @@ public:
 	void TryRespawn();
 	void Respawn();
 	void SetTeam(int Team, bool DoChatMsg=true);
+	void SetTeamDirect(int Team); //zCatch
 	int GetTeam() const { return m_Team; };
 	int GetCID() const { return m_ClientID; };
 
@@ -95,7 +96,24 @@ public:
 		int m_Min;
 		int m_Max;
 	} m_Latency;
-
+	
+		//zCatch:
+	int m_CaughtBy;
+	int m_SpecExplicit;
+	int m_Deaths;
+	int m_Kills;
+	int m_LastKillTry;
+	bool m_PlayerWantToFollowCatcher;
+	
+	int m_TicksSpec;
+	int m_TicksIngame;
+	int m_ChatTicks;
+	//Anticamper
+	int Anticamper();
+	bool m_SentCampMsg;
+	int m_CampTick;
+	vec2 m_CampPos;
+	
 private:
 	CCharacter *m_pCharacter;
 	CGameContext *m_pGameServer;
diff --git a/src/game/variables.h b/src/game/variables.h
index e57a0954..15a8e30f 100644
--- a/src/game/variables.h
+++ b/src/game/variables.h
@@ -90,4 +90,27 @@ MACRO_CONFIG_INT(SvVoteKickBantime, sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SE
 
 MACRO_CONFIG_INT(DbgFocus, dbg_focus, 0, 0, 1, CFGFLAG_CLIENT, "")
 MACRO_CONFIG_INT(DbgTuning, dbg_tuning, 0, 0, 1, CFGFLAG_CLIENT, "")
+
+//zCatch:
+MACRO_CONFIG_INT(SvMode, sv_mode, 1, 1, 5, CFGFLAG_SERVER, "1 - Instagib; 2 - Rocket area; 3 - Hammerparty; 4 - Grenade; 5 - Ninja")
+MACRO_CONFIG_INT(SvAllowJoin, sv_allow_join, 2, 1, 2, CFGFLAG_SERVER, "Allow new Players to join without waiting for the next round")
+//1 = Allowed to join; 2 = Will join when person with the most kills die
+MACRO_CONFIG_INT(SvColorIndicator, sv_color_indicator, 1, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently caught players")
+MACRO_CONFIG_INT(SvBonus, sv_bonus, 0, 0, 100, CFGFLAG_SERVER, "Give the last player extra points")
+MACRO_CONFIG_INT(SvFollowCatcher, sv_follow_catcher, 1, 0, 1, CFGFLAG_SERVER, "If a victim should follow his catcher")
+MACRO_CONFIG_INT(SvLaserjumps, sv_laserjumps, 0, 0, 1, CFGFLAG_SERVER, "Use laserjumps - on a laser bounce a explosion will occur which takes no damage")
+
+MACRO_CONFIG_INT(SvChatValue, sv_chat_value, 250, 100, 1000, CFGFLAG_SERVER, "A value which is added on each message and decreased on each tick")
+MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 250, 10000, CFGFLAG_SERVER, "If this threshold will exceed by too many messages the player will be muted")
+MACRO_CONFIG_INT(SvMuteDuration, sv_mute_duration, 60, 0, 3600, CFGFLAG_SERVER, "How long the player will be muted (in seconds)")
+MACRO_CONFIG_INT(SvAnticamper, sv_anticamper, 2, 0, 2, CFGFLAG_SERVER, "0 disables, 1 enables anticamper in all modes and 2 only in Instagib")
+MACRO_CONFIG_INT(SvAnticamperFreeze, sv_anticamper_freeze, 7, 0, 15, CFGFLAG_SERVER, "If a player should freeze on camping (and how long) or die")
+MACRO_CONFIG_INT(SvAnticamperTime, sv_anticamper_time, 10, 5, 120, CFGFLAG_SERVER, "How long to wait till the player dies/freezes")
+MACRO_CONFIG_INT(SvAnticamperRange, sv_anticamper_range, 200, 0, 1000, CFGFLAG_SERVER, "Distance how far away the player must move to escape anticamper")
+
+MACRO_CONFIG_INT(SvVoteForceReason, sv_vote_forcereason, 1, 0, 1, CFGFLAG_SERVER, "Allow only votes with a reason (except settings)")
+MACRO_CONFIG_INT(SvGrenadeMinDamage, sv_grenade_min_damage, 4, 1, 6, CFGFLAG_SERVER, "How much damage the grenade must do to kill the player (depends how far away it explodes)")
+MACRO_CONFIG_INT(SvGrenadeBullets, sv_grenade_bullets, -1, -1, 10, CFGFLAG_SERVER, "Default amount of bullets for the grenade (-1 = endless ammo), otherwise it reloads after some time")
+MACRO_CONFIG_INT(SvSuicideTime, sv_suicide_time, 15, 0, 60, CFGFLAG_SERVER, "Minimum time between suicides. 0 to forbid suicides completely")
+MACRO_CONFIG_INT(SvKillPenalty, sv_kill_penalty, 5, 0, 50, CFGFLAG_SERVER, "The amount of points which the score will be decreased on each suicide")
 #endif