Skip to content
Permalink
Browse files

Remove /whowas command

It turned out to be unreliable and can be implemented entirely in Lua
  • Loading branch information...
Jusonex committed Jul 29, 2018
1 parent de149ef commit 0cffa9215f4601e42b2dfbc254040aeda3caa8f0
@@ -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

@@ -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

@@ -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"
@@ -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<CPlayer*>(pClient));

// Delete the old account if it was a guest account
if (!pCurrentAccount->IsRegistered())
delete pCurrentAccount;
@@ -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;
}
@@ -13,13 +13,12 @@

#include "CConsoleCommand.h"
#include <list>
#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<CConsoleCommand*> m_Commands;
@@ -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<SWhoWasEntry>::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 <nick>'");
}

return false;
}

bool CConsoleCommands::DebugScript(CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient)
{
// Valid parameter?
@@ -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);

@@ -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
@@ -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;
@@ -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);

@@ -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);
}

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -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 );

4 comments on commit 0cffa92

@theSarrum

This comment has been minimized.

Copy link

theSarrum replied Jul 29, 2018

Now I have to spend my time on the whowas cmd 😢

@Dezash

This comment has been minimized.

Copy link
Contributor

Dezash replied Jul 29, 2018

@theSarrum you can implement that in like 5 minutes.

@ArranTuna

This comment has been minimized.

Copy link
Collaborator

ArranTuna replied Jul 29, 2018

Yep, was a very buggy command and had to script my own whowas which was better anyway as you can add extra features. Someone could make a source path for a whowas to be added to admin resource.

@qaisjp

This comment has been minimized.

Copy link
Member

qaisjp replied Jul 29, 2018

@ArranTuna Yep, created an issue for this to be added here: multitheftauto/mtasa-resources#116

Please sign in to comment.
You can’t perform that action at this time.