From 0cffa9215f4601e42b2dfbc254040aeda3caa8f0 Mon Sep 17 00:00:00 2001 From: Jusonex Date: Sun, 29 Jul 2018 08:53:37 +0200 Subject: [PATCH] Remove /whowas command It turned out to be unreliable and can be implemented entirely in Lua --- Client/mods/deathmatch/logic/Config.h | 3 - Server/mods/deathmatch/Config.h | 3 - Server/mods/deathmatch/StdInc.h | 1 - .../mods/deathmatch/logic/CAccountManager.cpp | 4 -- Server/mods/deathmatch/logic/CConsole.cpp | 3 +- Server/mods/deathmatch/logic/CConsole.h | 5 +- .../deathmatch/logic/CConsoleCommands.cpp | 63 ------------------- .../mods/deathmatch/logic/CConsoleCommands.h | 1 - Server/mods/deathmatch/logic/CGame.cpp | 5 +- Server/mods/deathmatch/logic/CGame.h | 2 - Server/mods/deathmatch/logic/CMainConfig.cpp | 1 - Server/mods/deathmatch/logic/CPlayer.cpp | 6 -- Server/mods/deathmatch/logic/CWhoWas.cpp | 55 ---------------- Server/mods/deathmatch/logic/CWhoWas.h | 39 ------------ .../mods/deathmatch/logic/lua/CLuaManager.cpp | 1 - 15 files changed, 3 insertions(+), 189 deletions(-) delete mode 100644 Server/mods/deathmatch/logic/CWhoWas.cpp delete mode 100644 Server/mods/deathmatch/logic/CWhoWas.h diff --git a/Client/mods/deathmatch/logic/Config.h b/Client/mods/deathmatch/logic/Config.h index b5030747fd..6fe062a7b0 100644 --- a/Client/mods/deathmatch/logic/Config.h +++ b/Client/mods/deathmatch/logic/Config.h @@ -98,9 +98,6 @@ class CVaPassNext #error MAX_CHAT_LENGTH "macro can't exceed 255" #endif -// Defines how long the whowas list can be -#define MAX_WHOWAS_LENGTH 1024 - // Max valid weather id #define MAX_VALID_WEATHER 255 diff --git a/Server/mods/deathmatch/Config.h b/Server/mods/deathmatch/Config.h index 12d7ef90dc..74ac3e9fb5 100644 --- a/Server/mods/deathmatch/Config.h +++ b/Server/mods/deathmatch/Config.h @@ -107,9 +107,6 @@ class CVaPassNext #error MAX_CHAT_LENGTH "macro can't exceed 255" #endif -// Defines how long the whowas list can be -#define MAX_WHOWAS_LENGTH 1024 - // Max valid weather id #define MAX_VALID_WEATHER 255 diff --git a/Server/mods/deathmatch/StdInc.h b/Server/mods/deathmatch/StdInc.h index 934981b5fa..2789a72ff4 100644 --- a/Server/mods/deathmatch/StdInc.h +++ b/Server/mods/deathmatch/StdInc.h @@ -280,7 +280,6 @@ struct SAclRequest; #include "CWater.h" #include "CWaterManager.h" #include "CWeaponNames.h" -#include "CWhoWas.h" #include "CXMLConfig.h" #include "CZoneNames.h" #include "TaskNames.h" diff --git a/Server/mods/deathmatch/logic/CAccountManager.cpp b/Server/mods/deathmatch/logic/CAccountManager.cpp index 134bab5f8a..6347b9fa2c 100644 --- a/Server/mods/deathmatch/logic/CAccountManager.cpp +++ b/Server/mods/deathmatch/logic/CAccountManager.cpp @@ -568,10 +568,6 @@ bool CAccountManager::LogIn(CClient* pClient, CClient* pEchoClient, const char* pEchoClient->SendEcho("login: You successfully logged in"); } - // Update who was info - if (pClient->GetClientType() == CClient::CLIENT_PLAYER) - g_pGame->GetConsole()->GetWhoWas()->OnPlayerLogin(static_cast(pClient)); - // Delete the old account if it was a guest account if (!pCurrentAccount->IsRegistered()) delete pCurrentAccount; diff --git a/Server/mods/deathmatch/logic/CConsole.cpp b/Server/mods/deathmatch/logic/CConsole.cpp index 5e5dc1cafa..3b8ed2b3c5 100644 --- a/Server/mods/deathmatch/logic/CConsole.cpp +++ b/Server/mods/deathmatch/logic/CConsole.cpp @@ -12,7 +12,7 @@ #include "StdInc.h" CConsole::CConsole(CBlipManager* pBlipManager, CMapManager* pMapManager, CPlayerManager* pPlayerManager, CRegisteredCommands* pRegisteredCommands, - CVehicleManager* pVehicleManager, CLuaManager* pLuaManager, CWhoWas* pWhoWas, CBanManager* pBanManager, + CVehicleManager* pVehicleManager, CLuaManager* pLuaManager, CBanManager* pBanManager, CAccessControlListManager* pACLManager) { // Init @@ -22,7 +22,6 @@ CConsole::CConsole(CBlipManager* pBlipManager, CMapManager* pMapManager, CPlayer m_pRegisteredCommands = pRegisteredCommands; m_pVehicleManager = pVehicleManager; m_pLuaManager = pLuaManager; - m_pWhoWas = pWhoWas; m_pBanManager = pBanManager; m_pACLManager = pACLManager; } diff --git a/Server/mods/deathmatch/logic/CConsole.h b/Server/mods/deathmatch/logic/CConsole.h index 3d4ddbd90d..7d49e3fd55 100644 --- a/Server/mods/deathmatch/logic/CConsole.h +++ b/Server/mods/deathmatch/logic/CConsole.h @@ -13,13 +13,12 @@ #include "CConsoleCommand.h" #include -#include "CWhoWas.h" class CConsole { public: CConsole(class CBlipManager* pBlipManager, class CMapManager* pMapManager, class CPlayerManager* pPlayerManager, - class CRegisteredCommands* pRegisteredCommands, class CVehicleManager* pVehicleManager, class CLuaManager* pLuaManager, CWhoWas* pWhoWas, + class CRegisteredCommands* pRegisteredCommands, class CVehicleManager* pVehicleManager, class CLuaManager* pLuaManager, class CBanManager* pBanManager, class CAccessControlListManager* pACLManager); ~CConsole(void); @@ -39,7 +38,6 @@ class CConsole class CPlayerManager* GetPlayerManager(void) { return m_pPlayerManager; }; class CVehicleManager* GetVehicleManager(void) { return m_pVehicleManager; }; class CBanManager* GetBanManager(void) { return m_pBanManager; }; - class CWhoWas* GetWhoWas(void) { return m_pWhoWas; }; private: class CBlipManager* m_pBlipManager; @@ -49,7 +47,6 @@ class CConsole class CVehicleManager* m_pVehicleManager; class CLuaManager* m_pLuaManager; class CBanManager* m_pBanManager; - class CWhoWas* m_pWhoWas; class CAccessControlListManager* m_pACLManager; list m_Commands; diff --git a/Server/mods/deathmatch/logic/CConsoleCommands.cpp b/Server/mods/deathmatch/logic/CConsoleCommands.cpp index 6e52ed3a46..87f7f39901 100644 --- a/Server/mods/deathmatch/logic/CConsoleCommands.cpp +++ b/Server/mods/deathmatch/logic/CConsoleCommands.cpp @@ -1221,69 +1221,6 @@ bool CConsoleCommands::WhoIs(CConsole* pConsole, const char* szArguments, CClien return false; } -bool CConsoleCommands::WhoWas(CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient) -{ - // Got any arguments? - if (szArguments && strlen(szArguments) > 0) - { - // Is the nick requested anyone? - bool bAnyone = (SStringX(szArguments) == "*"); - - // Start iterating the whowas list - CWhoWas* pWhoWas = pConsole->GetWhoWas(); - if (pWhoWas->Count() > 0) - { - // Start iterating the list - unsigned int uiCount = 0; - list::const_iterator iter = pWhoWas->IterBegin(); - for (; iter != pWhoWas->IterEnd(); iter++) - { - // Matches? - if (bAnyone || iter->strNick.ContainsI(szArguments)) - { - // Haven't got too many entries printed? - if (++uiCount <= 20) - { - // Convert the IP to a string - SString strIP = LongToDottedIP(iter->ulIP); - - // Populate a line about him - SString strName = iter->strNick; - if (iter->strAccountName != GUEST_ACCOUNT_NAME) - strName += SString(" (%s)", *iter->strAccountName); - pClient->SendEcho( - SString("%s - IP:%s serial:%s version:%s", *strName, *strIP, iter->strSerial.c_str(), iter->strPlayerVersion.c_str())); - } - else - { - pClient->SendEcho("..."); - return true; - } - } - } - - // No matching entries? - if (uiCount == 0) - { - pClient->SendEcho("whowas: No matching nicks"); - return false; - } - - return true; - } - else - { - pClient->SendEcho("whowas: The whowas list is empty"); - } - } - else - { - pClient->SendEcho("whowas: Syntax is 'whowas '"); - } - - return false; -} - bool CConsoleCommands::DebugScript(CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient) { // Valid parameter? diff --git a/Server/mods/deathmatch/logic/CConsoleCommands.h b/Server/mods/deathmatch/logic/CConsoleCommands.h index 038a69cc12..1b718b755c 100644 --- a/Server/mods/deathmatch/logic/CConsoleCommands.h +++ b/Server/mods/deathmatch/logic/CConsoleCommands.h @@ -46,7 +46,6 @@ class CConsoleCommands static bool AExec(class CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient); static bool WhoIs(class CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient); - static bool WhoWas(class CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient); static bool DebugScript(class CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient); diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index c4f6987a94..74a185ea53 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -514,7 +514,7 @@ bool CGame::Start(int iArgumentCount, char* szArguments[]) m_pRegisteredCommands = new CRegisteredCommands(m_pACLManager); m_pLuaManager = new CLuaManager(m_pObjectManager, m_pPlayerManager, m_pVehicleManager, m_pBlipManager, m_pRadarAreaManager, m_pRegisteredCommands, m_pMapManager, &m_Events); - m_pConsole = new CConsole(m_pBlipManager, m_pMapManager, m_pPlayerManager, m_pRegisteredCommands, m_pVehicleManager, m_pLuaManager, &m_WhoWas, + m_pConsole = new CConsole(m_pBlipManager, m_pMapManager, m_pPlayerManager, m_pRegisteredCommands, m_pVehicleManager, m_pLuaManager, m_pBanManager, m_pACLManager); m_pMainConfig = new CMainConfig(m_pConsole, m_pLuaManager); m_pRPCFunctions = new CRPCFunctions; @@ -1787,9 +1787,6 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet) } #endif - // Add him to the whowas list - m_WhoWas.Add(szNick, Packet.GetSourceIP(), pPlayer->GetSerial(), pPlayer->GetPlayerVersion(), pPlayer->GetAccount()->GetName()); - PlayerCompleteConnect(pPlayer); } else diff --git a/Server/mods/deathmatch/logic/CGame.h b/Server/mods/deathmatch/logic/CGame.h index 1599401b3e..9f7758aaca 100644 --- a/Server/mods/deathmatch/logic/CGame.h +++ b/Server/mods/deathmatch/logic/CGame.h @@ -20,7 +20,6 @@ class CGame; #include "CCommandLineParser.h" #include "CConnectHistory.h" #include "CElementDeleter.h" -#include "CWhoWas.h" #include "packets/CCommandPacket.h" #include "packets/CExplosionSyncPacket.h" @@ -530,7 +529,6 @@ class CGame CClock* m_pClock; CBanManager* m_pBanManager; CTeamManager* m_pTeamManager; - CWhoWas m_WhoWas; CCommandLineParser m_CommandLineParser; CRegisteredCommands* m_pRegisteredCommands; CDatabaseManager* m_pDatabaseManager; diff --git a/Server/mods/deathmatch/logic/CMainConfig.cpp b/Server/mods/deathmatch/logic/CMainConfig.cpp index ae2befcbf5..1b479e7fa5 100644 --- a/Server/mods/deathmatch/logic/CMainConfig.cpp +++ b/Server/mods/deathmatch/logic/CMainConfig.cpp @@ -768,7 +768,6 @@ bool CMainConfig::LoadExtended(void) RegisterCommand("aexec", CConsoleCommands::AExec, false); RegisterCommand("whois", CConsoleCommands::WhoIs, false); - RegisterCommand("whowas", CConsoleCommands::WhoWas, false); RegisterCommand("debugscript", CConsoleCommands::DebugScript, false); diff --git a/Server/mods/deathmatch/logic/CPlayer.cpp b/Server/mods/deathmatch/logic/CPlayer.cpp index 82b63b56e4..fbfa913179 100644 --- a/Server/mods/deathmatch/logic/CPlayer.cpp +++ b/Server/mods/deathmatch/logic/CPlayer.cpp @@ -202,12 +202,6 @@ void CPlayer::DoPulse(void) void CPlayer::SetNick(const char* szNick) { - if (!m_strNick.empty() && m_strNick != szNick) - { - // If changing, add the new name to the whowas list - g_pGame->GetConsole()->GetWhoWas()->Add(szNick, inet_addr(GetSourceIP()), GetSerial(), GetPlayerVersion(), GetAccount()->GetName()); - } - m_strNick.AssignLeft(szNick, MAX_PLAYER_NICK_LENGTH); } diff --git a/Server/mods/deathmatch/logic/CWhoWas.cpp b/Server/mods/deathmatch/logic/CWhoWas.cpp deleted file mode 100644 index f0b6d225e7..0000000000 --- a/Server/mods/deathmatch/logic/CWhoWas.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto v1.0 - * LICENSE: See LICENSE in the top level directory - * FILE: mods/deathmatch/logic/CWhoWas.cpp - * PURPOSE: "Who-was" nick/ip/port logging class - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ - -#include "StdInc.h" - -void CWhoWas::Add(const char* szNick, unsigned long ulIP, std::string strSerial, const SString& strPlayerVersion, const SString& strAccountName) -{ - // Create the struct and copy the data over - SWhoWasEntry Entry; - Entry.strNick.AssignLeft(szNick, MAX_PLAYER_NICK_LENGTH); - Entry.ulIP = ulIP; - Entry.strSerial = strSerial; - Entry.strPlayerVersion = strPlayerVersion; - Entry.strAccountName = strAccountName; - - // Add it to our list - m_List.push_front(Entry); - - // Bigger than max? Trim it - if (m_List.size() > MAX_WHOWAS_LENGTH) - { - m_List.pop_back(); - } -} - -void CWhoWas::OnPlayerLogin(CPlayer* pPlayer) -{ - // Find last added item from this player - unsigned long ulIP = inet_addr(pPlayer->GetSourceIP()); - for (std::list::iterator iter = m_List.begin(); iter != m_List.end(); ++iter) - { - SWhoWasEntry& entry = *iter; - if (entry.ulIP == ulIP && entry.strSerial == pPlayer->GetSerial()) - { - if (entry.strAccountName == GUEST_ACCOUNT_NAME) - { - // Update account name if previously was a guest - entry.strAccountName = pPlayer->GetAccount()->GetName(); - return; - } - break; - } - } - - // Otherwise add a new line - Add(pPlayer->GetNick(), inet_addr(pPlayer->GetSourceIP()), pPlayer->GetSerial(), pPlayer->GetPlayerVersion(), pPlayer->GetAccount()->GetName()); -} diff --git a/Server/mods/deathmatch/logic/CWhoWas.h b/Server/mods/deathmatch/logic/CWhoWas.h deleted file mode 100644 index ad464eb10c..0000000000 --- a/Server/mods/deathmatch/logic/CWhoWas.h +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * - * PROJECT: Multi Theft Auto v1.0 - * LICENSE: See LICENSE in the top level directory - * FILE: mods/deathmatch/logic/CWhoWas.h - * PURPOSE: "Who-was" nick/ip/port logging class - * - * Multi Theft Auto is available from http://www.multitheftauto.com/ - * - *****************************************************************************/ - -#pragma once - -#include "../Config.h" -#include - -struct SWhoWasEntry -{ - SString strNick; - unsigned long ulIP; - std::string strSerial; - SString strPlayerVersion; - SString strAccountName; -}; - -class CWhoWas -{ -public: - void Add(const char* szNick, unsigned long ulIP, std::string strSerial, const SString& strPlayerVersion, const SString& strAccountName); - void Clear(void) { m_List.clear(); }; - - void OnPlayerLogin(CPlayer* pPlayer); - unsigned int Count(void) { return m_List.size(); }; - std::list::const_iterator IterBegin(void) { return m_List.begin(); }; - std::list::const_iterator IterEnd(void) { return m_List.end(); }; - -private: - std::list m_List; -}; diff --git a/Server/mods/deathmatch/logic/lua/CLuaManager.cpp b/Server/mods/deathmatch/logic/lua/CLuaManager.cpp index 3f70d92c70..c2eb44473c 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaManager.cpp +++ b/Server/mods/deathmatch/logic/lua/CLuaManager.cpp @@ -289,7 +289,6 @@ void CLuaManager::LoadCFunctions(void) CLuaCFunctions::AddFunction ( "banPlayer", CLuaFunctionDefinitions::BanPlayer ); CLuaCFunctions::AddFunction ( "banPlayerIP", CLuaFunctionDefinitions::BanPlayerIP ); CLuaCFunctions::AddFunction ( "setPlayerMuted", CLuaFunctionDefinitions::SetPlayerMuted ); - CLuaCFunctions::AddFunction ( "whoWas", CLuaFunctionDefinitions::WhoWas ); CLuaCFunctions::AddFunction ( "addAccount", CLuaFunctionDefinitions::AddAccount ); CLuaCFunctions::AddFunction ( "delAccount", CLuaFunctionDefinitions::DelAccount );