diff options
| -rw-r--r-- | .gitignore | 6 | ||||
| -rw-r--r-- | bam.lua | 9 | ||||
| -rw-r--r-- | banmasters.cfg | 5 | ||||
| -rw-r--r-- | bans.cfg | 2 | ||||
| -rw-r--r-- | scripts/make_release.py | 1 | ||||
| -rw-r--r-- | src/banmaster/banmaster.cpp | 261 | ||||
| -rw-r--r-- | src/banmaster/banmaster.h | 12 | ||||
| -rw-r--r-- | src/engine/server.h | 2 | ||||
| -rw-r--r-- | src/engine/server/server.cpp | 88 | ||||
| -rw-r--r-- | src/engine/server/server.h | 7 | ||||
| -rw-r--r-- | src/engine/shared/config_variables.h | 2 | ||||
| -rw-r--r-- | src/engine/shared/network.h | 24 | ||||
| -rw-r--r-- | src/engine/shared/network_server.cpp | 61 | ||||
| -rw-r--r-- | src/game/server/entities/character.cpp | 123 | ||||
| -rw-r--r-- | src/game/server/entities/character.h | 3 | ||||
| -rw-r--r-- | src/game/server/gamecontext.cpp | 327 | ||||
| -rw-r--r-- | src/game/server/gamecontext.h | 25 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.cpp | 58 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.h | 6 | ||||
| -rw-r--r-- | src/game/server/gamemodes/zcatch.cpp | 225 | ||||
| -rw-r--r-- | src/game/server/gamemodes/zcatch.hpp | 33 | ||||
| -rw-r--r-- | src/game/server/player.cpp | 88 | ||||
| -rw-r--r-- | src/game/server/player.h | 20 | ||||
| -rw-r--r-- | src/game/variables.h | 21 |
24 files changed, 1346 insertions, 63 deletions
diff --git a/.gitignore b/.gitignore index edbb7eab..3f334d73 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,9 @@ teeworlds* teeworlds_srv* tileset_border* versionsrv* + +zcatch_srv* +config.cfg +.project +.cproject + diff --git a/bam.lua b/bam.lua index da893e10..e59e88eb 100644 --- a/bam.lua +++ b/bam.lua @@ -232,6 +232,7 @@ function build(settings) versionserver = Compile(settings, Collect("src/versionsrv/*.cpp")) masterserver = Compile(settings, Collect("src/mastersrv/*.cpp")) + banmaster = Compile(settings, Collect("src/banmaster/*.cpp")) game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, network_source) game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), client_content_source) game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), server_content_source) @@ -258,7 +259,7 @@ function build(settings) engine, client, game_editor, zlib, pnglite, wavpack, client_link_other, client_osxlaunch) - server_exe = Link(server_settings, "teeworlds_srv", engine, server, + server_exe = Link(server_settings, "zcatch_srv", engine, server, game_shared, game_server, zlib, server_link_other) serverlaunch = {} @@ -272,6 +273,9 @@ function build(settings) masterserver_exe = Link(server_settings, "mastersrv", masterserver, engine, zlib) + banmaster_exe = Link(server_settings, "banmaster", banmaster, + engine, zlib) + -- make targets c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends) s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch) @@ -279,9 +283,10 @@ function build(settings) v = PseudoTarget("versionserver".."_"..settings.config_name, versionserver_exe) m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe) + b = PseudoTarget("banmaster".."_"..settings.config_name, banmaster_exe) t = PseudoTarget("tools".."_"..settings.config_name, tools) - all = PseudoTarget(settings.config_name, c, s, v, m, t) + all = PseudoTarget(settings.config_name, c, s, v, m, b, t) return all end diff --git a/banmasters.cfg b/banmasters.cfg new file mode 100644 index 00000000..28279b5c --- /dev/null +++ b/banmasters.cfg @@ -0,0 +1,5 @@ +clear_banmasters +add_banmaster banmaster.kottnet.net +add_banmaster banmaster.heinrich5991.de +add_banmaster banmaster.teetw.de + diff --git a/bans.cfg b/bans.cfg new file mode 100644 index 00000000..bc3e1d65 --- /dev/null +++ b/bans.cfg @@ -0,0 +1,2 @@ +unban_all +bind 127.0.0.1:8302 diff --git a/scripts/make_release.py b/scripts/make_release.py index c0cbb152..80cbd35b 100644 --- a/scripts/make_release.py +++ b/scripts/make_release.py @@ -110,6 +110,7 @@ print("adding files") shutil.copy("readme.txt", package_dir) shutil.copy("license.txt", package_dir) shutil.copy("storage.cfg", package_dir) +shutil.copy("banmasters.cfg", package_dir) if include_data and not use_bundle: os.mkdir(os.path.join(package_dir, "data")) diff --git a/src/banmaster/banmaster.cpp b/src/banmaster/banmaster.cpp new file mode 100644 index 00000000..e9057579 --- /dev/null +++ b/src/banmaster/banmaster.cpp @@ -0,0 +1,261 @@ +/* (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. */ +#include <base/system.h> +#include <engine/shared/network.h> +#include <engine/console.h> +#include <engine/storage.h> + +#include "banmaster.h" + +enum +{ + MAX_BANS=1024, + BAN_REREAD_TIME=300, + CFGFLAG_BANMASTER=32 +}; + +static const char BANMASTER_BANFILE[] = "bans.cfg"; + +struct CBan +{ + NETADDR m_Address; + char m_aReason[256]; + int64 m_Expire; +}; + +static CBan m_aBans[MAX_BANS]; +static int m_NumBans = 0; +static CNetClient m_Net; +static IConsole *m_pConsole; +static char m_aBindAddr[64] = ""; + +CBan* CheckBan(NETADDR *pCheck) +{ + for(int i = 0; i < m_NumBans; i++) + if(net_addr_comp(&m_aBans[i].m_Address, pCheck) == 0) + return &m_aBans[i]; + + return 0; +} + +int SendResponse(NETADDR *pAddr, NETADDR *pCheck) +{ + static char aIpBan[sizeof(BANMASTER_IPBAN) + NETADDR_MAXSTRSIZE] = { 0 }; + static char *pIpBanContent = aIpBan + sizeof(BANMASTER_IPBAN); + if (!aIpBan[0]) + mem_copy(aIpBan, BANMASTER_IPBAN, sizeof(BANMASTER_IPBAN)); + + static CNetChunk p; + + p.m_ClientID = -1; + p.m_Address = *pAddr; + p.m_Flags = NETSENDFLAG_CONNLESS; + + CBan* pBan = CheckBan(pCheck); + if(pBan) + { + net_addr_str(pCheck, pIpBanContent, NETADDR_MAXSTRSIZE, 0); + char *pIpBanReason = pIpBanContent + (str_length(pIpBanContent) + 1); + str_copy(pIpBanReason, pBan->m_aReason, 256); + + p.m_pData = aIpBan; + p.m_DataSize = sizeof(BANMASTER_IPBAN) + str_length(pIpBanContent) + 1 + str_length(pIpBanReason) + 1; + m_Net.Send(&p); + return 1; + } + + return 0; + /*else + { + p.m_DataSize = sizeof(BANMASTER_IPOK); + p.m_pData = BANMASTER_IPOK; + m_Net.Send(&p); + return 0; + }*/ +} + +void AddBan(NETADDR *pAddr, const char *pReason) +{ + pAddr->port = 0; + + CBan *pBan = CheckBan(pAddr); + char aAddressStr[NETADDR_MAXSTRSIZE]; + net_addr_str(pAddr, aAddressStr, sizeof(aAddressStr), 0); + + if(pBan) + { + char aAddressStr[NETADDR_MAXSTRSIZE]; + net_addr_str(pAddr, aAddressStr, sizeof(aAddressStr), 0); + dbg_msg("banmaster", "updated ban, ip=%s oldreason='%s' reason='%s'", aAddressStr, pBan->m_aReason, pReason); + + str_copy(pBan->m_aReason, pReason, sizeof(m_aBans[m_NumBans].m_aReason)); + pBan->m_Expire = -1; + } + else + { + if(m_NumBans == MAX_BANS) + { + dbg_msg("banmaster", "error: banmaster is full"); + return; + } + + m_aBans[m_NumBans].m_Address = *pAddr; + str_copy(m_aBans[m_NumBans].m_aReason, pReason, sizeof(m_aBans[m_NumBans].m_aReason)); + m_aBans[m_NumBans].m_Expire = -1; + + dbg_msg("banmaster", "added ban, ip=%s reason='%s'", aAddressStr, m_aBans[m_NumBans].m_aReason); + + m_NumBans++; + } +} + +void ClearBans() +{ + m_NumBans = 0; +} + +void PurgeBans() +{ + int64 Now = time_get(); + int i = 0; + while(i < m_NumBans) + { + if(m_aBans[i].m_Expire != -1 && m_aBans[i].m_Expire < Now) + { + // remove ban + char aBuf[NETADDR_MAXSTRSIZE]; + net_addr_str(&m_aBans[i].m_Address, aBuf, sizeof(aBuf), 0); + dbg_msg("banmaster", "ban expired, ip=%s reason='%s'", aBuf, m_aBans[i].m_aReason); + m_aBans[i] = m_aBans[m_NumBans - 1]; + m_NumBans--; + } + else + i++; + } +} + +void ConBan(IConsole::IResult *pResult, void *pUser) +{ + NETADDR Addr; + const char *pStr = pResult->GetString(0); + const char *pReason = ""; + + if(pResult->NumArguments() > 1) + pReason = pResult->GetString(1); + + if(!net_addr_from_str(&Addr, pStr)) + AddBan(&Addr, pReason); + else + dbg_msg("banmaster", "invalid network address to ban, str='%s'", pStr); +} + +void ConUnbanAll(IConsole::IResult *pResult, void *pUser) +{ + ClearBans(); +} + +void ConSetBindAddr(IConsole::IResult *pResult, void *pUser) +{ + if(m_aBindAddr[0]) + return; + str_copy(m_aBindAddr, pResult->GetString(0), sizeof(m_aBindAddr)); + dbg_msg("banmaster/network", "bound to %s", m_aBindAddr); +} + +void StandardOutput(const char *pLine, void *pUser) +{ +} + +int main(int argc, const char **argv) // ignore_convention +{ + int64 LastUpdate = time_get(); + + dbg_logger_stdout(); + net_init(); + + IKernel *pKernel = IKernel::Create(); + IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv); // ignore_convention + + m_pConsole = CreateConsole(CFGFLAG_BANMASTER); + m_pConsole->RegisterPrintCallback(2, StandardOutput, 0); + m_pConsole->Register("ban", "s?r", CFGFLAG_BANMASTER, ConBan, 0, "Bans the specified ip"); + m_pConsole->Register("unban_all", "", CFGFLAG_BANMASTER, ConUnbanAll, 0, "Unbans all ips"); + m_pConsole->Register("bind", "s", CFGFLAG_BANMASTER, ConSetBindAddr, 0, "Binds to the specified address"); + + { + bool RegisterFail = false; + + RegisterFail = RegisterFail || !pKernel->RegisterInterface(m_pConsole); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pStorage); + + if(RegisterFail) + return -1; + } + + m_pConsole->ExecuteFile(BANMASTER_BANFILE); + + NETADDR BindAddr; + if(m_aBindAddr[0] && net_host_lookup(m_aBindAddr, &BindAddr, NETTYPE_IPV4) == 0) + { + if(BindAddr.port == 0) + BindAddr.port = BANMASTER_PORT; + } + else + { + mem_zero(&BindAddr, sizeof(BindAddr)); + BindAddr.port = BANMASTER_PORT; + } + + m_Net.Open(BindAddr, 0); + // TODO: check socket for errors + + dbg_msg("banmaster", "started"); + + while(1) + { + m_Net.Update(); + + // process m_aPackets + CNetChunk Packet; + while(m_Net.Recv(&Packet)) + { + char aAddressStr[NETADDR_MAXSTRSIZE]; + net_addr_str(&Packet.m_Address, aAddressStr, sizeof(aAddressStr), 0); + + if(Packet.m_DataSize >= (int)sizeof(BANMASTER_IPCHECK) && mem_comp(Packet.m_pData, BANMASTER_IPCHECK, sizeof(BANMASTER_IPCHECK)) == 0) + { + char *pAddr = (char *)Packet.m_pData + sizeof(BANMASTER_IPCHECK); + NETADDR CheckAddr; + if(net_addr_from_str(&CheckAddr, pAddr)) + { + dbg_msg("banmaster", "dropped weird message, ip=%s checkaddr='%s'", aAddressStr, pAddr); + } + else + { + CheckAddr.port = 0; + + int Banned = SendResponse(&Packet.m_Address, &CheckAddr); + + char aBuf[NETADDR_MAXSTRSIZE]; + net_addr_str(&CheckAddr, aBuf, sizeof(aBuf), 0); + dbg_msg("banmaster", "responded to checkmsg, ip=%s checkaddr=%s result=%s", aAddressStr, aBuf, (Banned) ? "ban" : "ok"); + } + } + else + dbg_msg("banmaster", "dropped weird packet, ip=%s", aAddressStr, (char *)Packet.m_pData); + } + + if(time_get() - LastUpdate > time_freq() * BAN_REREAD_TIME) + { + ClearBans(); + LastUpdate = time_get(); + m_pConsole->ExecuteFile(BANMASTER_BANFILE); + } + + // be nice to the CPU + thread_sleep(1); + } + + return 0; +} + diff --git a/src/banmaster/banmaster.h b/src/banmaster/banmaster.h new file mode 100644 index 00000000..f7c645f7 --- /dev/null +++ b/src/banmaster/banmaster.h @@ -0,0 +1,12 @@ +/* (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. */ +#ifndef BANMASTER_BANMASTER_H +#define BANMASTER_BANMASTER_H + +static const int BANMASTER_PORT = 8302; + +//static const char BANMASTER_IPOK[] = {255, 255, 255, 255, 'i', 'p', 'o', 'k'}; +static const char BANMASTER_IPBAN[] = {255, 255, 255, 255, 'i', 'p', 'b', 'a'}; +static const char BANMASTER_IPCHECK[] = {255, 255, 255, 255, 'i', 'p', 'c', 'h'}; + +#endif 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 a231d1e8..fca9e045 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -27,6 +27,8 @@ #include <mastersrv/mastersrv.h> +#include <banmaster/banmaster.h> + #include "register.h" #include "server.h" @@ -36,6 +38,8 @@ #include <windows.h> #endif +static const char SERVER_BANMASTERFILE[] = "banmasters.cfg"; + static const char *StrUTF8Ltrim(const char *pStr) { while(*pStr) @@ -1178,6 +1182,38 @@ void CServer::PumpNetwork() { SendServerInfo(&Packet.m_Address, ((unsigned char *)Packet.m_pData)[sizeof(SERVERBROWSE_GETINFO)]); } + + /*if(Packet.m_DataSize >= sizeof(BANMASTER_IPOK) && + mem_comp(Packet.m_pData, BANMASTER_IPOK, sizeof(BANMASTER_IPOK)) == 0 && + m_NetServer.BanmasterCheck(&Packet.m_Address) != -1) + { + }*/ + + if(Packet.m_DataSize >= (int)sizeof(BANMASTER_IPBAN) && + mem_comp(Packet.m_pData, BANMASTER_IPBAN, sizeof(BANMASTER_IPBAN)) == 0) + { + if(!g_Config.m_SvGlobalBantime) + return; + + if(m_NetServer.BanmasterCheck(&Packet.m_Address) == -1) + return; + + CUnpacker Up; + char aIp[NETADDR_MAXSTRSIZE]; + char aReason[256]; + NETADDR Addr; + Up.Reset((unsigned char*)Packet.m_pData + sizeof(BANMASTER_IPBAN), Packet.m_DataSize - sizeof(BANMASTER_IPBAN)); + str_copy(aIp, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(aIp)); + str_copy(aReason, Up.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(aReason)); + if(net_addr_from_str(&Addr, aIp)) + { + dbg_msg("globalbans", "dropped weird message from banmaster"); + return; + } + + m_ServerBan.BanAddr(&Addr, g_Config.m_SvGlobalBantime * 60, aReason); + dbg_msg("globalbans", "added ban, ip=%s, reason='%s'", aIp, aReason); + } } } else @@ -1294,6 +1330,8 @@ int CServer::Run() m_ServerBan.Init(Console(), Storage(), this); 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); @@ -1500,6 +1538,11 @@ void CServer::DemoRecorder_HandleAutoStart() } } +void CServer::MapReload() +{ + m_MapReload = 1; +} + bool CServer::DemoRecorder_IsRecording() { return m_DemoRecorder.IsRecording(); @@ -1531,6 +1574,45 @@ 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; + + int Result = pServer->m_NetServer.BanmasterAdd(pResult->GetString(0)); + + if(Result == 0) + pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "succesfully added banmaster"); + else if (Result == 1) + pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "invalid address for banmaster / net lookup failed"); + else + pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "too many banmasters"); +} + +void CServer::ConBanmasters(IConsole::IResult *pResult, void *pUser) +{ + CServer *pServer = (CServer *)pUser; + int NumBanmasters = pServer->m_NetServer.BanmasterNum(); + + char aBuf[128]; + char aIpString[64]; + + for(int i = 0; i < NumBanmasters; i++) + { + NETADDR *pBanmaster = pServer->m_NetServer.BanmasterGet(i); + net_addr_str(pBanmaster, aIpString, sizeof(aIpString), 0); + str_format(aBuf, sizeof(aBuf), "%d: %s", i, aIpString); + pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", aBuf); + } +} + +void CServer::ConClearBanmasters(IConsole::IResult *pResult, void *pUser) +{ + CServer *pServer = (CServer *)pUser; + + pServer->m_NetServer.BanmastersClear(); + pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server/banmaster", "cleared banmaster list"); +} + void CServer::ConLogout(IConsole::IResult *pResult, void *pUser) { CServer *pServer = (CServer *)pUser; @@ -1617,8 +1699,12 @@ void CServer::RegisterCommands() Console()->Register("record", "?s", CFGFLAG_SERVER|CFGFLAG_STORE, ConRecord, this, "Record to a file"); Console()->Register("stoprecord", "", CFGFLAG_SERVER, ConStopRecord, this, "Stop recording"); + Console()->Register("add_banmaster", "s", CFGFLAG_SERVER, ConAddBanmaster, this, ""); + Console()->Register("banmasters", "", CFGFLAG_SERVER, ConBanmasters, this, ""); + Console()->Register("clear_banmasters", "", CFGFLAG_SERVER, ConClearBanmasters, this, ""); + Console()->Register("reload", "", CFGFLAG_SERVER, ConMapReload, this, "Reload the map"); - + Console()->Chain("sv_name", ConchainSpecialInfoupdate, this); Console()->Chain("password", ConchainSpecialInfoupdate, this); diff --git a/src/engine/server/server.h b/src/engine/server/server.h index 696b472d..9f62ab37 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -230,6 +230,10 @@ public: static void ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); + static void ConAddBanmaster(IConsole::IResult *pResult, void *pUser); + static void ConBanmasters(IConsole::IResult *pResult, void *pUser); + static void ConClearBanmasters(IConsole::IResult *pResult, void *pUser); + void RegisterCommands(); @@ -237,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/config_variables.h b/src/engine/shared/config_variables.h index ac913162..76e4ccd3 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -100,6 +100,8 @@ MACRO_CONFIG_INT(EcBantime, ec_bantime, 0, 0, 1440, CFGFLAG_ECON, "The time a cl MACRO_CONFIG_INT(EcAuthTimeout, ec_auth_timeout, 30, 1, 120, CFGFLAG_ECON, "Time in seconds before the the econ authentification times out") MACRO_CONFIG_INT(EcOutputLevel, ec_output_level, 1, 0, 2, CFGFLAG_ECON, "Adjusts the amount of information in the external console") +MACRO_CONFIG_INT(SvGlobalBantime, sv_global_bantime, 60, 0, 1440, CFGFLAG_SERVER, "The time a client gets banned if the ban server reports it. 0 to disable") + MACRO_CONFIG_INT(Debug, debug, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Debug mode") MACRO_CONFIG_INT(DbgStress, dbg_stress, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Stress systems") MACRO_CONFIG_INT(DbgStressNetwork, dbg_stress_network, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Stress network") diff --git a/src/engine/shared/network.h b/src/engine/shared/network.h index dd43389e..cf2310bb 100644 --- a/src/engine/shared/network.h +++ b/src/engine/shared/network.h @@ -242,6 +242,20 @@ public: // server side class CNetServer { +public: + enum + { + MAX_BANMASTERS=16 + }; + + struct CBanInfo + { + NETADDR m_Addr; + int m_Expires; + char m_Reason[128]; + }; + +private: struct CSlot { public: @@ -254,6 +268,9 @@ class CNetServer int m_MaxClients; int m_MaxClientsPerIP; + NETADDR m_aBanmasters[MAX_BANMASTERS]; + int m_NumBanmasters; + NETFUNC_NEWCLIENT m_pfnNewClient; NETFUNC_DELCLIENT m_pfnDelClient; void *m_UserPtr; @@ -284,6 +301,13 @@ public: // void SetMaxClientsPerIP(int Max); + + // + int BanmasterAdd(const char *pAddrStr); + int BanmasterNum() const; + NETADDR* BanmasterGet(int Index); + int BanmasterCheck(NETADDR *pAddr); + void BanmastersClear(); }; class CNetConsole diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 1264a4a5..e2e0d16b 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -3,6 +3,7 @@ #include <base/system.h> #include <engine/console.h> +#include <banmaster/banmaster.h> #include "netban.h" #include "network.h" @@ -140,6 +141,22 @@ int CNetServer::Recv(CNetChunk *pChunk) // client that wants to connect if(!Found) { + CNetChunk Packet; + char aBuffer[sizeof(BANMASTER_IPCHECK) + NETADDR_MAXSTRSIZE]; + mem_copy(aBuffer, BANMASTER_IPCHECK, sizeof(BANMASTER_IPCHECK)); + net_addr_str(&Addr, aBuffer + sizeof(BANMASTER_IPCHECK), sizeof(aBuffer) - sizeof(BANMASTER_IPCHECK), 0); + + Packet.m_ClientID = -1; + Packet.m_Flags = NETSENDFLAG_CONNLESS; + Packet.m_DataSize = str_length(aBuffer) + 1; + Packet.m_pData = aBuffer; + + for(int i = 0; i < m_NumBanmasters; i++) + { + Packet.m_Address = m_aBanmasters[i]; + Send(&Packet); + } + // only allow a specific number of players with the same ip NETADDR ThisAddr = Addr, OtherAddr; int FoundAddr = 1; @@ -171,6 +188,7 @@ int CNetServer::Recv(CNetChunk *pChunk) m_aSlots[i].m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr); if(m_pfnNewClient) m_pfnNewClient(i, m_UserPtr); + break; } } @@ -248,3 +266,46 @@ void CNetServer::SetMaxClientsPerIP(int Max) m_MaxClientsPerIP = Max; } + +int CNetServer::BanmasterAdd(const char *pAddrStr) +{ + if(m_NumBanmasters >= MAX_BANMASTERS) + return 2; + + if(net_host_lookup(pAddrStr, &m_aBanmasters[m_NumBanmasters], NETTYPE_IPV4)) + return 1; + + if(m_aBanmasters[m_NumBanmasters].port == 0) + m_aBanmasters[m_NumBanmasters].port = BANMASTER_PORT; + + m_NumBanmasters++; + return 0; +} + +int CNetServer::BanmasterNum() const +{ + return m_NumBanmasters; +} + +NETADDR* CNetServer::BanmasterGet(int Index) +{ + if(Index < 0 || Index >= m_NumBanmasters) + return 0; + + return &m_aBanmasters[Index]; +} + +int CNetServer::BanmasterCheck(NETADDR *pAddr) +{ + for(int i = 0; i < m_NumBanmasters; i++) + if(net_addr_comp(&m_aBanmasters[i], pAddr) == 0) + return i; + + return -1; +} + +void CNetServer::BanmastersClear() +{ + m_NumBanmasters = 0; +} + diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 1c76f655..f64a16e3 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); @@ -499,6 +527,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 +545,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 +590,24 @@ 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); + m_Armor = m_FreezeTicks/Server()->TickSpeed(); + 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 +764,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,28 +779,38 @@ 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; - - // m_pPlayer only inflicts half damage on self + + /* zCatch */ + bool Is_zCatch = GameServer()->m_pController->IsZCatch(); + if(From == m_pPlayer->GetCID()) - Dmg = max(1, Dmg/2); - - m_DamageTaken++; - - // 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); - } - else - { - m_DamageTaken = 0; - GameServer()->CreateDamageInd(m_Pos, 0, Dmg); + //No selfdamage + if(Is_zCatch) + Dmg = 0; + // m_pPlayer only inflicts half damage on self + else + Dmg = max(1, Dmg/2); } + if(g_Config.m_SvMode == 4 && Weapon == WEAPON_GRENADE && Dmg < g_Config.m_SvGrenadeMinDamage) + Dmg = 0; + /* end zCatch */ + + m_DamageTaken++; + if(Dmg) { - if(m_Armor) + /* zCatch*/ + //One-Shot-One-Kill + if(Is_zCatch) + { + m_Health = 0; + m_Armor = 0; + } + /* end zCatch*/ + + else if(m_Armor) { if(Dmg > 1) { @@ -871,3 +935,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/gamecontext.cpp b/src/game/server/gamecontext.cpp index 5d2f22b8..9e8afea8 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.hpp" 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) @@ -447,7 +451,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 +542,74 @@ void CGameContext::OnClientEnter(int ClientID) { //world.insert_entity(&players[client_id]); m_apPlayers[ClientID]->Respawn(); + + /* begin zCatch */ + int leader_id = -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_CatchedBy = ZCATCH_NOT_CATCHED; + 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, num_prev = 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_CatchedBy == i) + num2++; + } + if(num2 > num_prev) + { + leader_id = i; + num_prev = num2; + } + } + } + + if(leader_id > -1) + { + m_apPlayers[ClientID]->m_CatchedBy = leader_id; + m_apPlayers[ClientID]->m_SpecExplicit = 0; + m_apPlayers[ClientID]->m_SpectatorID = leader_id; + StartTeam = TEAM_SPECTATORS; + } + else + { + m_apPlayers[ClientID]->m_CatchedBy = ZCATCH_NOT_CATCHED; + 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 +618,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 && leader_id > -1) + { + char buf[128]; + str_format(buf, sizeof(buf), "You will join the game when %s dies", Server()->ClientName(leader_id)); + SendChatTarget(ClientID, buf); + } + } + /* zCatch end */ } void CGameContext::OnClientConnected(int ClientID) @@ -618,6 +708,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 +738,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 +786,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 +838,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 +855,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 +975,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 +984,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_CatchedBy >= 0) + { + char buf[256]; + str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", Server()->ClientName(pPlayer->m_CatchedBy)); + SendChatTarget(ClientID, buf); + return; + } + else if(pPlayer->m_CatchedBy == ZCATCH_NOT_CATCHED) + { + 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 +1162,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 +1662,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 +1746,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 +1781,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..fa85151c 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.5" + /* 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_CATCHED = -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..2fe7569f --- /dev/null +++ b/src/game/server/gamemodes/zcatch.cpp @@ -0,0 +1,225 @@ +/* (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.hpp" + +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 buf[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_CatchedBy = 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(buf, sizeof(buf), "Caught by \"%s\". You will join the game automatically when \"%s\" dies.", Server()->ClientName(pKiller->GetCID()), Server()->ClientName(pKiller->GetCID())); + GameServer()->SendChatTarget(VictimID, buf); + } + } + 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_CatchedBy == VictimID) + { + GameServer()->m_apPlayers[i]->m_CatchedBy = ZCATCH_NOT_CATCHED; + GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1)); + + if(pKiller != pVictim->GetPlayer()) + pKiller->m_Score++; + } + } + } + + // Update color of the killer + OnPlayerInfoChange(pKiller); + + 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_CatchedBy == 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_UnbalancedTick = -1; + m_ForceBalanced = false; + for(int i=0; i<MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i]) + { + GameServer()->m_apPlayers[i]->m_CatchedBy = ZCATCH_NOT_CATCHED; + 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 aBufMsg[256]; + str_format(aBufMsg, sizeof(aBufMsg), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBufMsg); +} + +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: + pChr->GiveWeapon(WEAPON_RIFLE, -1); + break; + case 2: + pChr->GiveWeapon(WEAPON_HAMMER, -1); + pChr->GiveWeapon(WEAPON_GUN, -1); + pChr->GiveWeapon(WEAPON_GRENADE, -1); + pChr->GiveWeapon(WEAPON_SHOTGUN, -1); + pChr->GiveWeapon(WEAPON_RIFLE, -1); + break; + case 3: + pChr->GiveWeapon(WEAPON_HAMMER, -1); + break; + case 4: + pChr->GiveWeapon(WEAPON_GRENADE, -1); + break; + case 5: + 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_CatchedBy = ZCATCH_NOT_CATCHED; //Set all players in server as non-catched + } + } + } + + 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.hpp b/src/game/server/gamemodes/zcatch.hpp new file mode 100644 index 00000000..58e43f61 --- /dev/null +++ b/src/game/server/gamemodes/zcatch.hpp @@ -0,0 +1,33 @@ +/* (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 +{ + private: + int m_OldMode; + + 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); + virtual void OnPlayerInfoChange(class CPlayer *pP); + virtual void EndRound(); +}; + +#endif diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 75c2c1c6..09518a78 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_CatchedBy = -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..92e2ccc8 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_CatchedBy; + 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..99377a64 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -90,4 +90,25 @@ 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 catched players") +MACRO_CONFIG_INT(SvBonus, sv_bonus, 0, 0, 10000, 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(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(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 |