mirror of
https://github.com/SWG-Source/client-tools.git
synced 2026-01-15 22:04:32 -05:00
Add Command String Variables for self/target OID
This commit is contained in:
@@ -9,15 +9,20 @@
|
||||
#include "clientUserInterface/CuiChatParserStrategy.h"
|
||||
|
||||
#include "clientGame/Game.h"
|
||||
#include "clientGame/CreatureObject.h"
|
||||
#include "clientGame/PlayerObject.h"
|
||||
#include "clientUserInterface/CuiChatParser.h"
|
||||
#include "clientUserInterface/CuiChatRoomManager.h"
|
||||
#include "clientUserInterface/CuiCommandTableParser.h"
|
||||
#include "clientUserInterface/CuiInstantMessageManager.h"
|
||||
#include "clientUserInterface/CuiMessageQueueManager.h"
|
||||
#include "clientUserInterface/CuiSocialsParser.h"
|
||||
#include "clientUserInterface/CuiStringVariablesData.h"
|
||||
#include "clientUserInterface/CuiStringVariablesManager.h"
|
||||
#include "sharedCommandParser/CommandParser.h"
|
||||
#include "sharedCommandParser/CommandParserHistory.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "sharedObject/NetworkIdManager.h"
|
||||
#include "sharedMessageDispatch/Transceiver.h"
|
||||
|
||||
#include "utf8.h"
|
||||
@@ -101,10 +106,21 @@ bool CuiChatParserStrategy::parse (const Unicode::String & str, Unicode::String
|
||||
if (CuiSocialsParser::preparseEmoticons (str, result))
|
||||
return true;
|
||||
|
||||
//-- handle parsing string variables in commands only if god mode is on
|
||||
Unicode::String stvResult;
|
||||
bool isAdmin = Game::getPlayerObject()->isAdmin();
|
||||
if (isAdmin) {
|
||||
CuiStringVariablesData svd;
|
||||
const ClientObject* self = dynamic_cast<ClientObject *>(NetworkIdManager::getObjectById(Game::getPlayerNetworkId()));
|
||||
svd.source = self;
|
||||
svd.target = self;
|
||||
CuiStringVariablesManager::process(str, svd, stvResult);
|
||||
}
|
||||
|
||||
//-- no handler means we pass it on to the chat parser
|
||||
if (str [0] == CuiChatParser::getCmdChar ())
|
||||
{
|
||||
const Unicode::String strippedString (str.substr (1));
|
||||
const Unicode::String strippedString = isAdmin ? stvResult.substr(1) : str.substr (1);
|
||||
|
||||
// The various command parsers will try to "auto-complete" a command. So it is
|
||||
// possible for one parser to finish successfully on a partial match while
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace CuiStringVariables
|
||||
* %KU/KT/KO title (if any) (master weaponsmith, journeyman chef, medical assistant)
|
||||
* %DI digit integer
|
||||
* %DF digit float
|
||||
*
|
||||
* Admin String Variables (must originate from a player object that is in god mode):
|
||||
* These ONLY work when used in a command parser (/command) NOT in chat or macros.
|
||||
* %ZU - The OID of your player object
|
||||
* %ZT - The OID of the object you are targeting
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -54,6 +59,7 @@ namespace CuiStringVariables
|
||||
V_militaryRank,
|
||||
V_title,
|
||||
V_digit,
|
||||
V_networkId,
|
||||
V_count,
|
||||
V_none,
|
||||
};
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
#include "clientGame/PlayerObject.h"
|
||||
#include "clientUserInterface/CuiStringVariables.h"
|
||||
#include "clientUserInterface/CuiStringVariablesData.h"
|
||||
#include "clientUserInterface/CuiSystemMessageManager.h"
|
||||
#include "sharedGame/GameObjectTypes.h"
|
||||
#include "sharedGame/SharedCreatureObjectTemplate.h"
|
||||
#include "sharedObject/NetworkIdManager.h"
|
||||
|
||||
//======================================================================
|
||||
|
||||
@@ -55,7 +57,8 @@ namespace
|
||||
{ V_honorific, 'H' },
|
||||
{ V_militaryRank, 'M' },
|
||||
{ V_title, 'K' },
|
||||
{ V_digit, 'D' }
|
||||
{ V_digit, 'D' },
|
||||
{ V_networkId, 'Z' },
|
||||
};
|
||||
|
||||
Variable findVariable (Unicode::unicode_char_t c)
|
||||
@@ -295,6 +298,18 @@ void CuiStringVariablesManager::process (const Unicode::String & encoded, const
|
||||
resultStr.append (field);
|
||||
break;
|
||||
}
|
||||
case V_networkId:
|
||||
{
|
||||
const PlayerObject * const playerObject = creature->getPlayerObject();
|
||||
if (PlayerObject::isAdmin()) {
|
||||
if (participantCode == 'U') {
|
||||
resultStr.append(Unicode::narrowToWide(participant->getNetworkId().getValueString()));
|
||||
}
|
||||
else if (participantCode == 'T' && creature) {
|
||||
resultStr.append(Unicode::narrowToWide(creature->getIntendedTarget().getValueString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user