Add isGod checks to console command parsing

This commit is contained in:
AconiteGodOfSWG
2021-02-26 21:55:42 -05:00
parent 2915ebe567
commit d9ff25d06f
22 changed files with 277 additions and 7 deletions
@@ -107,6 +107,17 @@ bool ConsoleCommandParserAi::performParsing(const NetworkId & userId, const Stri
UNREF (userId);
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
FormattedString<1024> fs;
if (isAbbrev(argv[0], "log"))
@@ -14,6 +14,9 @@
#include "serverGame/CityInterface.h"
#include "serverGame/CityStructureInfo.h"
#include "serverGame/GameServer.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include "sharedFoundation/CalendarTime.h"
#include "sharedFoundation/FormattedString.h"
#include "sharedFoundation/NetworkId.h"
@@ -67,6 +70,17 @@ bool ConsoleCommandParserCity::performParsing (const NetworkId & userId, const S
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isCommand(argv [0], "listById"))
@@ -57,6 +57,17 @@ bool ConsoleCommandParserCollection::performParsing (const NetworkId & userId, c
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
// ----------------------------------------------------------------------
if (isCommand (argv [0], "adjustSlotValue"))
@@ -55,6 +55,16 @@ bool ConsoleCommandParserCraft::performParsing (const NetworkId & userId, const
CreatureObject * creatureObject = safe_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
PlayerObject * playerObject = const_cast<PlayerObject *>(PlayerCreatureController::getPlayerObject(creatureObject));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev( argv [0], "draft"))
@@ -45,6 +45,17 @@ bool ConsoleCommandParserCraftStation::performParsing (const NetworkId & userId,
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
// CreatureObject * playerObject = safe_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
//-----------------------------------------------------------------
@@ -8,6 +8,10 @@
#include "serverGame/FirstServerGame.h"
#include "serverGame/ConsoleCommandParserDefault.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include "serverGame/Chat.h"
#include "sharedFoundation/NetworkId.h"
@@ -120,6 +124,17 @@ bool ConsoleCommandParserDefault::performParsing (const NetworkId & userId, cons
UNREF (originalCommand);
UNREF (userId);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev( argv [0], "serverhelp"))
@@ -76,6 +76,17 @@ bool ConsoleCommandParserGuild::performParsing (const NetworkId & userId, const
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isCommand(argv [0], "listById"))
@@ -52,7 +52,16 @@ bool ConsoleCommandParserManufacture::performParsing (const NetworkId & userId,
NOT_NULL (node);
UNREF(originalCommand);
CreatureObject * playerObject = safe_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
@@ -8,6 +8,9 @@
#include "serverGame/FirstServerGame.h"
#include "serverGame/ConsoleCommandParserMessageTo.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include "UnicodeUtils.h"
#include "serverGame/MessageToQueue.h"
#include "serverGame/ServerObject.h"
@@ -34,8 +37,21 @@ ConsoleCommandParserMessageTo::ConsoleCommandParserMessageTo() :
//-----------------------------------------------------------------------
bool ConsoleCommandParserMessageTo::performParsing (const NetworkId & /*userId*/, const StringVector_t & argv, const String_t & /* originalMessage */, String_t & result, const CommandParser *)
bool ConsoleCommandParserMessageTo::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & /* originalMessage */, String_t & result, const CommandParser *)
{
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
if (isCommand( argv [0], "viewLastKnownLocations"))
{
result += Unicode::narrowToWide(MessageToQueue::getInstance().debugGetLastKnownLocations());
@@ -13,6 +13,7 @@
#include "serverGame/PlayerCreatureController.h"
#include "serverGame/PlayerObject.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include "sharedFoundation/FormattedString.h"
#include "sharedObject/NetworkIdManager.h"
#include "UnicodeUtils.h"
@@ -52,6 +53,17 @@ bool ConsoleCommandParserMoney::performParsing (const NetworkId & userId, const
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev( argv [0], "cashTransfer"))
@@ -44,6 +44,17 @@ bool ConsoleCommandParserNpc::performParsing (const NetworkId & userId, const St
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev( argv [0], "hail"))
@@ -501,6 +501,10 @@ bool ConsoleCommandParserObject::performParsing (const NetworkId & userId, const
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
UNREF(originalCommand);
@@ -2230,6 +2234,10 @@ bool ConsoleCommandParserObject::performParsing2(const NetworkId & userId, const
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
UNREF(originalCommand);
if(isCommand(argv[0], "getObservers"))
@@ -94,6 +94,17 @@ bool ConsoleCommandParserObjvar::performParsing (const NetworkId & userId, const
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev( argv [0], "set"))
@@ -73,6 +73,17 @@ bool ConsoleCommandParserPvp::performParsing (const NetworkId & userId, const St
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
// ----------------------------------------------------------------------
if (isCommand (argv [0], "showGcwRankTable"))
@@ -17,6 +17,7 @@
#include "serverGame/ServerUniverse.h"
#include "serverGame/ServerWorld.h"
#include "serverGame/SurveySystem.h"
#include "serverGame/CreatureObject.h"
#include "sharedFoundation/GameControllerMessage.h"
#include "sharedFoundation/NetworkId.h"
#include "sharedObject/Controller.h"
@@ -66,6 +67,17 @@ bool ConsoleCommandParserResource::performParsing (const NetworkId & userId, con
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isCommand( argv [0], "activate"))
@@ -220,6 +220,17 @@ bool ConsoleCommandParserServer::performParsing(const NetworkId & userId, const
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(userId));
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//-----------------------------------------------------------------
if (isAbbrev(argv[0], ms_testStructurePlacement))
@@ -1002,6 +1013,17 @@ bool ConsoleCommandParserServer::performParsing2(const NetworkId & userId, const
ServerObject * user = safe_cast<ServerObject *>(NetworkIdManager::getObjectById(userId));
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
if (isAbbrev(argv[0], "destroyPersistedBuildoutAreaDuplicates"))
{
ServerBuildoutManager::destroyPersistedDuplicates();
@@ -102,6 +102,18 @@ bool ConsoleCommandParserShip::performParsing (const NetworkId & userId, const S
if (!user)
return false;
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
// ----------------------------------------------------------------
if (isCommand (argv[0], CommandNames::getSlotList))
@@ -92,8 +92,20 @@ CommandParser ("skill", 0, "...", "Skill related commands.", 0)
bool ConsoleCommandParserSkill::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & , String_t & result, const CommandParser *)
{
// ----------------------------------------------------------------
{
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
// ----------------------------------------------------------------
if (isCommand (argv[0], CommandNames::grantSkill))
{
@@ -18,6 +18,7 @@
#include "serverGame/CreatureObject.h"
#include "serverGame/SpacePath.h"
#include "serverGame/SpaceAttackSquad.h"
#include "serverGame/ServerWorld.h"
#include "sharedFoundation/FormattedString.h"
#include "sharedFoundation/NetworkId.h"
#include "sharedGame/AiDebugString.h"
@@ -61,6 +62,17 @@ bool ConsoleCommandParserSpaceAi::performParsing(const NetworkId & userId, const
UNREF (userId);
UNREF(originalCommand);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
if (isAbbrev(argv[0], "war"))
{
AiShipController::setAttackingEnabled(true);
@@ -10,6 +10,8 @@
#include "UnicodeUtils.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include <cstdio>
#include <unordered_set>
@@ -46,9 +48,20 @@ CommandParser ("Spawner", 0, "...", "Spawner related commands.", 0)
//----------------------------------------------------------------------
bool ConsoleCommandParserSpawner::performParsing (const NetworkId &, const StringVector_t & argv, const String_t & , String_t & result, const CommandParser *)
bool ConsoleCommandParserSpawner::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & , String_t & result, const CommandParser *)
{
// ----------------------------------------------------------------
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
if (isCommand (argv[0], CommandNames::showQueue))
{
@@ -10,9 +10,11 @@
#include "UnicodeUtils.h"
#include "serverGame/ConfigServerGame.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/GameServer.h"
#include "serverGame/ServerMessageForwarding.h"
#include "serverGame/ServerObject.h"
#include "serverGame/ServerWorld.h"
#include "serverGame/VeteranRewardManager.h"
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
#include "sharedObject/NetworkIdManager.h"
@@ -38,6 +40,18 @@ ConsoleCommandParserVeteran::ConsoleCommandParserVeteran() :
bool ConsoleCommandParserVeteran::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & /* originalMessage */, String_t & result, const CommandParser *)
{
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
if (isCommand( argv [0], "getRewardInfo"))
{
NetworkId targetPlayer(Unicode::wideToNarrow (argv[1]));
@@ -11,8 +11,9 @@
#include "serverGame/Chat.h"
#include "sharedLog/Log.h"
//#include "serverGame/PlayerCreatureController.h"
//#include "serverGame/PlayerObject.h"
//#include "serverGame/ServerWorld.h"
#include "serverGame/PlayerObject.h"
#include "serverGame/CreatureObject.h"
#include "serverGame/ServerWorld.h"
#include "sharedNetworkMessages/VoiceChatMiscMessages.h"
@@ -51,6 +52,17 @@ bool ConsoleCommandParserVoice::performParsing (const NetworkId & userId, const
UNREF(originalCommand);
UNREF(userId);
CreatureObject * const playerObject = dynamic_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
if (!playerObject)
{
WARNING_STRICT_FATAL(true, ("Console command executed on invalid player object %s", userId.getValueString().c_str()));
return false;
}
if (!playerObject->getClient()->isGod()) {
return false;
}
//CreatureObject * creatureObject = safe_cast<CreatureObject *>(ServerWorld::findObjectByNetworkId(userId));
//PlayerObject * playerObject = const_cast<PlayerObject *>(PlayerCreatureController::getPlayerObject(creatureObject));