Skip to content

Commit

Permalink
Remove /whowas command
Browse files Browse the repository at this point in the history
It turned out to be unreliable and can be implemented entirely in Lua
  • Loading branch information
jushar committed Jul 29, 2018
1 parent de149ef commit 0cffa92
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 189 deletions.
3 changes: 0 additions & 3 deletions Client/mods/deathmatch/logic/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions Server/mods/deathmatch/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion Server/mods/deathmatch/StdInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions Server/mods/deathmatch/logic/CAccountManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Server/mods/deathmatch/logic/CConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions Server/mods/deathmatch/logic/CConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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;
Expand Down
63 changes: 0 additions & 63 deletions Server/mods/deathmatch/logic/CConsoleCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
1 change: 0 additions & 1 deletion Server/mods/deathmatch/logic/CConsoleCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 1 addition & 4 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 0 additions & 6 deletions Server/mods/deathmatch/logic/CPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
55 changes: 0 additions & 55 deletions Server/mods/deathmatch/logic/CWhoWas.cpp

This file was deleted.

39 changes: 0 additions & 39 deletions Server/mods/deathmatch/logic/CWhoWas.h

This file was deleted.

1 change: 0 additions & 1 deletion Server/mods/deathmatch/logic/lua/CLuaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

4 comments on commit 0cffa92

@theSarrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Dezash
Copy link
Contributor

@Dezash Dezash commented on 0cffa92 Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theSarrum you can implement that in like 5 minutes.

@ArranTuna
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@qaisjp qaisjp commented on 0cffa92 Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.