2017-08-08 13:53:47 +02:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Common.h>
|
|
|
|
#include <common/Version.h>
|
|
|
|
#include <common/Network/GamePacketNew.h>
|
|
|
|
#include <common/Network/CommonNetwork.h>
|
|
|
|
#include <common/Util/UtilMath.h>
|
|
|
|
#include <common/Network/PacketContainer.h>
|
|
|
|
#include <common/Logging/Logger.h>
|
2018-01-31 11:43:22 +01:00
|
|
|
#include <common/Exd/ExdDataGenerated.h>
|
2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Database/DatabaseDef.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-18 17:16:15 +02:00
|
|
|
#include "DebugCommand.h"
|
|
|
|
#include "DebugCommandHandler.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/InitUIPacket.h"
|
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
#include "Script/ScriptManager.h"
|
2017-12-13 15:07:03 +11:00
|
|
|
#include "Script/NativeScriptManager.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
|
|
|
#include "Actor/BattleNpc.h"
|
2018-01-20 22:03:41 +01:00
|
|
|
#include "Actor/EventNpc.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Zone/Zone.h"
|
2018-02-07 00:00:48 +01:00
|
|
|
#include "Zone/InstanceContent.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "ServerZone.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "StatusEffect/StatusEffect.h"
|
|
|
|
#include "Session.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
#include <boost/make_shared.hpp>
|
2017-12-12 17:29:31 +11:00
|
|
|
#include <boost/format.hpp>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-10-26 15:22:58 +02:00
|
|
|
|
2017-11-01 22:24:50 -07:00
|
|
|
#include <cinttypes>
|
2018-01-20 22:03:41 +01:00
|
|
|
#include "Network/PacketWrappers/PlayerSpawnPacket.h"
|
2018-01-28 23:53:58 +11:00
|
|
|
#include "Zone/TerritoryMgr.h"
|
2017-11-01 22:24:50 -07:00
|
|
|
|
2017-08-17 18:12:29 +02:00
|
|
|
extern Core::Scripting::ScriptManager g_scriptMgr;
|
2018-01-31 11:43:22 +01:00
|
|
|
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
2017-08-17 18:12:29 +02:00
|
|
|
extern Core::Logger g_log;
|
|
|
|
extern Core::ServerZone g_serverZone;
|
2018-01-28 23:53:58 +11:00
|
|
|
extern Core::TerritoryMgr g_territoryMgr;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
// instanciate and initialize commands
|
2017-08-18 17:16:15 +02:00
|
|
|
Core::DebugCommandHandler::DebugCommandHandler()
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-09-18 18:44:38 +02:00
|
|
|
// Push all commands onto the register map ( command name - function - description - required GM level )
|
2018-01-08 21:42:44 +01:00
|
|
|
registerCommand( "set", &DebugCommandHandler::set, "Executes SET commands.", 1 );
|
|
|
|
registerCommand( "get", &DebugCommandHandler::get, "Executes GET commands.", 1 );
|
|
|
|
registerCommand( "add", &DebugCommandHandler::add, "Executes ADD commands.", 1 );
|
2017-10-21 23:41:09 +11:00
|
|
|
registerCommand( "inject", &DebugCommandHandler::injectPacket, "Loads and injects a premade packet.", 1 );
|
|
|
|
registerCommand( "injectc", &DebugCommandHandler::injectChatPacket, "Loads and injects a premade chat packet.", 1 );
|
2018-01-08 21:42:44 +01:00
|
|
|
registerCommand( "replay", &DebugCommandHandler::replay, "Replays a saved capture folder.", 1 );
|
|
|
|
registerCommand( "nudge", &DebugCommandHandler::nudge, "Nudges you forward/up/down.", 1 );
|
|
|
|
registerCommand( "info", &DebugCommandHandler::serverInfo, "Show server info.", 0 );
|
|
|
|
registerCommand( "unlock", &DebugCommandHandler::unlockCharacter, "Unlock character.", 1 );
|
|
|
|
registerCommand( "help", &DebugCommandHandler::help, "Shows registered commands.", 0 );
|
|
|
|
registerCommand( "script", &DebugCommandHandler::script, "Server script utilities.", 1 );
|
2018-01-28 23:53:58 +11:00
|
|
|
registerCommand( "instance", &DebugCommandHandler::instance, "Instance utilities", 1 );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// clear all loaded commands
|
2017-08-18 17:16:15 +02:00
|
|
|
Core::DebugCommandHandler::~DebugCommandHandler()
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
for( auto it = m_commandMap.begin(); it != m_commandMap.end(); ++it )
|
|
|
|
( *it ).second.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
// add a command set to the register map
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::registerCommand( const std::string& n, DebugCommand::pFunc functionPtr,
|
2017-12-08 11:46:47 +01:00
|
|
|
const std::string& hText, uint8_t uLevel )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
m_commandMap[std::string( n )] = boost::make_shared< DebugCommand >( n, functionPtr, hText, uLevel );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// try to retrieve the command in question, execute if found
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::execCommand( char * data, Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
// define callback pointer
|
2017-12-08 11:46:47 +01:00
|
|
|
void ( DebugCommandHandler::*pf )( char *, Entity::Player&, boost::shared_ptr< DebugCommand > );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
std::string commandString;
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data );
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
commandString = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no parameters, just get the command
|
|
|
|
commandString = tmpCommand;
|
|
|
|
|
2017-08-19 11:28:04 +09:00
|
|
|
// try to retrieve the command
|
2017-08-08 13:53:47 +02:00
|
|
|
auto it = m_commandMap.find( commandString );
|
|
|
|
|
|
|
|
if( it == m_commandMap.end() )
|
|
|
|
// no command found, do something... or not
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( "Command not found." );
|
2017-08-08 13:53:47 +02:00
|
|
|
else
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
if( player.getGmRank() < it->second->getRequiredGmLevel() )
|
2017-09-18 18:44:38 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( "You are not allowed to use this command." );
|
2017-09-18 18:44:38 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
// command found, call the callback function and pass parameters if present.
|
|
|
|
pf = ( *it ).second->m_pFunc;
|
2017-12-08 11:46:47 +01:00
|
|
|
( this->*pf )( data, player, ( *it ).second );
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Definition of the commands
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::help( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-10-21 23:41:09 +11:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "Registered debug commands:" );
|
2017-10-21 23:41:09 +11:00
|
|
|
for ( auto cmd : m_commandMap )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
if ( player.getGmRank( ) >= cmd.second->m_gmLevel )
|
2017-10-21 23:41:09 +11:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( " - " + cmd.first + " - " + cmd.second->getHelpText( ) );
|
2017-10-21 23:41:09 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::set( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
std::string subCommand = "";
|
|
|
|
std::string params = "";
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
subCommand = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no subcommand given
|
|
|
|
subCommand = tmpCommand;
|
|
|
|
|
|
|
|
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
|
|
|
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
2017-08-08 13:53:47 +02:00
|
|
|
"subCommand " + subCommand + " params: " + params );
|
|
|
|
|
|
|
|
|
|
|
|
if( ( ( subCommand == "pos" ) || ( subCommand == "posr" ) ) && ( params != "" ) )
|
|
|
|
{
|
|
|
|
int32_t posX;
|
|
|
|
int32_t posY;
|
|
|
|
int32_t posZ;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%d %d %d", &posX, &posY, &posZ );
|
|
|
|
|
|
|
|
if( ( posX == 0xcccccccc ) || ( posY == 0xcccccccc ) || ( posZ == 0xcccccccc ) )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( "Syntaxerror." );
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( subCommand == "pos" )
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setPosition( static_cast< float >( posX ),
|
|
|
|
static_cast< float >( posY ),
|
|
|
|
static_cast< float >( posZ ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
else
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setPosition( player.getPos().x + static_cast< float >( posX ),
|
|
|
|
player.getPos().y + static_cast< float >( posY ),
|
|
|
|
player.getPos().z + static_cast< float >( posZ ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-11-21 18:43:09 +01:00
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
|
2017-12-08 11:46:47 +01:00
|
|
|
setActorPosPacket( player.getId() );
|
|
|
|
setActorPosPacket.data().x = player.getPos().x;
|
|
|
|
setActorPosPacket.data().y = player.getPos().y;
|
|
|
|
setActorPosPacket.data().z = player.getPos().z;
|
|
|
|
player.queuePacket( setActorPosPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else if( ( subCommand == "tele" ) && ( params != "" ) )
|
|
|
|
{
|
|
|
|
int32_t aetheryteId;
|
|
|
|
sscanf( params.c_str(), "%i", &aetheryteId );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.teleport( aetheryteId );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
else if( ( subCommand == "discovery" ) && ( params != "" ) )
|
|
|
|
{
|
|
|
|
int32_t map_id;
|
|
|
|
int32_t discover_id;
|
|
|
|
sscanf( params.c_str(), "%i %i", &map_id, &discover_id );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcDiscovery > discoveryPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
discoveryPacket.data().map_id = map_id;
|
|
|
|
discoveryPacket.data().map_part_id = discover_id;
|
2017-12-08 11:46:47 +01:00
|
|
|
player.queuePacket( discoveryPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
else if( ( subCommand == "discovery_pos" ) && ( params != "" ) )
|
|
|
|
{
|
|
|
|
int32_t map_id;
|
|
|
|
int32_t discover_id;
|
|
|
|
int32_t pos_id;
|
|
|
|
sscanf( params.c_str(), "%i %i %i", &pos_id, &map_id, &discover_id );
|
|
|
|
|
2017-08-08 15:17:34 -04:00
|
|
|
std::string query2 = "UPDATE IGNORE `discoveryinfo` SET `discover_id` = '" + std::to_string( discover_id ) +
|
|
|
|
"' WHERE `discoveryinfo`.`id` = " + std::to_string( pos_id ) + ";";
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-08 15:17:34 -04:00
|
|
|
std::string query1 = "INSERT IGNORE INTO `discoveryinfo` (`id`, `map_id`, `discover_id`) VALUES ('" + std::to_string( pos_id ) +
|
2017-08-08 13:53:47 +02:00
|
|
|
"', '" + std::to_string( map_id ) +
|
|
|
|
"', '" + std::to_string( discover_id ) + "')";
|
|
|
|
|
2017-10-26 15:22:58 +02:00
|
|
|
g_charaDb.execute( query1 );
|
|
|
|
g_charaDb.execute( query2 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( subCommand == "discovery_reset" )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.resetDiscovery();
|
|
|
|
player.queuePacket( Network::Packets::Server::InitUIPacket( player ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
2017-08-09 14:38:46 +02:00
|
|
|
else if( subCommand == "classjob" )
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
if( player.getLevelForClass( static_cast< Common::ClassJob > ( id ) ) == 0 )
|
2017-08-09 14:38:46 +02:00
|
|
|
{
|
2017-12-08 15:38:25 +01:00
|
|
|
player.setLevelForClass( 1, static_cast< Common::ClassJob > ( id ) );
|
|
|
|
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
|
2017-08-09 14:38:46 +02:00
|
|
|
}
|
|
|
|
else
|
2017-12-08 15:38:25 +01:00
|
|
|
player.setClassJob( static_cast< Common::ClassJob > ( id ) );
|
2017-08-09 14:38:46 +02:00
|
|
|
}
|
2017-08-19 11:28:04 +09:00
|
|
|
else if ( subCommand == "cfpenalty" )
|
|
|
|
{
|
|
|
|
int32_t minutes;
|
|
|
|
sscanf( params.c_str(), "%d", &minutes );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setCFPenaltyMinutes( minutes );
|
2017-08-19 11:28:04 +09:00
|
|
|
}
|
2017-09-22 22:03:57 +09:00
|
|
|
else if ( subCommand == "eorzeatime" )
|
|
|
|
{
|
|
|
|
uint64_t timestamp;
|
2017-11-01 22:24:50 -07:00
|
|
|
sscanf( params.c_str(), "%" SCNu64, ×tamp );
|
2017-09-22 22:03:57 +09:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setEorzeaTimeOffset( timestamp );
|
|
|
|
player.sendNotice( "Eorzea time offset: " + std::to_string( timestamp ) );
|
2017-09-22 22:03:57 +09:00
|
|
|
}
|
2017-10-02 16:00:26 +02:00
|
|
|
else if ( subCommand == "model" )
|
|
|
|
{
|
|
|
|
uint32_t slot;
|
|
|
|
uint32_t val;
|
2017-10-02 16:02:28 +02:00
|
|
|
sscanf( params.c_str(), "%d %d", &slot, &val );
|
2017-10-02 16:00:26 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
player.setModelForSlot( static_cast< Inventory::EquipSlot >( slot ), val );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendModel();
|
|
|
|
player.sendDebug( "Model updated" );
|
2017-10-02 16:00:26 +02:00
|
|
|
}
|
2017-10-18 18:06:25 +02:00
|
|
|
else if ( subCommand == "mount" )
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.dismount();
|
|
|
|
player.mount( id );
|
2017-10-18 18:06:25 +02:00
|
|
|
}
|
2018-01-27 14:52:14 +09:00
|
|
|
else if ( subCommand == "msqguide" )
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcMSQTrackerProgress > msqPacket(
|
|
|
|
player.getId());
|
|
|
|
msqPacket.data().id = id;
|
|
|
|
player.queuePacket( msqPacket );
|
|
|
|
|
|
|
|
player.sendDebug( "MSQ Guide updated " );
|
|
|
|
}
|
|
|
|
else if ( subCommand == "msqdone")
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcMSQTrackerComplete > msqPacket ( player.getId() );
|
|
|
|
msqPacket.data().id = id;
|
|
|
|
player.queuePacket( msqPacket );
|
|
|
|
|
|
|
|
player.sendDebug( "MSQ Guide updated " );
|
|
|
|
}
|
2017-10-02 16:00:26 +02:00
|
|
|
else
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( subCommand + " is not a valid SET command." );
|
2017-10-02 16:00:26 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::add( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
std::string subCommand;
|
|
|
|
std::string params = "";
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
subCommand = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no subcommand given
|
|
|
|
subCommand = tmpCommand;
|
|
|
|
|
|
|
|
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
|
|
|
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
2017-08-08 13:53:47 +02:00
|
|
|
"subCommand " + subCommand + " params: " + params );
|
|
|
|
|
|
|
|
|
2017-09-22 17:08:12 +10:00
|
|
|
if( subCommand == "status" )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
int32_t duration;
|
2017-08-12 22:36:52 -03:00
|
|
|
uint16_t param;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-10-09 10:45:18 -03:00
|
|
|
sscanf( params.c_str(), "%d %d %hu", &id, &duration, ¶m );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-02-10 01:21:31 +01:00
|
|
|
auto effect = StatusEffect::make_StatusEffect( id, player.getAsPlayer(), player.getAsPlayer(), duration, 3000 );
|
2017-08-12 22:36:52 -03:00
|
|
|
effect->setParam( param );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.addStatusEffect( effect );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
2017-12-08 15:38:25 +01:00
|
|
|
else if( subCommand == "title" )
|
2017-10-09 00:31:31 -03:00
|
|
|
{
|
|
|
|
uint32_t titleId;
|
2017-10-09 10:45:18 -03:00
|
|
|
sscanf( params.c_str(), "%u", &titleId );
|
2017-10-09 00:31:31 -03:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.addTitle( titleId );
|
|
|
|
player.sendNotice( "Added title (ID: " + std::to_string( titleId ) + ")" );
|
2017-10-09 00:31:31 -03:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
else if( subCommand == "spawn" )
|
|
|
|
{
|
|
|
|
int32_t model, name;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%d %d", &model, &name );
|
|
|
|
|
2018-02-10 01:21:31 +01:00
|
|
|
auto pBNpc = Entity::make_BattleNpc( model, name, player.getPos() );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
auto pZone = player.getCurrentZone();
|
2017-08-08 13:53:47 +02:00
|
|
|
pBNpc->setCurrentZone( pZone );
|
|
|
|
pZone->pushActor( pBNpc );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( subCommand == "op" )
|
|
|
|
{
|
|
|
|
// temporary research packet
|
|
|
|
int32_t opcode;
|
|
|
|
sscanf( params.c_str(), "%x", &opcode );
|
2018-02-10 01:21:31 +01:00
|
|
|
auto pPe = Network::Packets::make_GamePacket( opcode, 0x30, player.getId(), player.getId() );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.queuePacket( pPe );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
2018-01-20 22:03:41 +01:00
|
|
|
else if( subCommand == "eventnpc-self" )
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcNpcSpawn > spawnPacket( player.getId() );
|
|
|
|
spawnPacket.data().type = 3;
|
|
|
|
spawnPacket.data().pos = player.getPos();
|
|
|
|
spawnPacket.data().rotation = player.getRotation();
|
|
|
|
spawnPacket.data().bNPCBase = id;
|
|
|
|
spawnPacket.data().bNPCName = id;
|
|
|
|
spawnPacket.data().targetId = player.getId();
|
|
|
|
player.queuePacket( spawnPacket );
|
|
|
|
}
|
|
|
|
else if( subCommand == "eventnpc" )
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%d", &id );
|
|
|
|
|
2018-02-10 01:21:31 +01:00
|
|
|
auto pENpc = Entity::make_EventNpc( id, player.getPos(), player.getRotation() );
|
2018-01-20 22:03:41 +01:00
|
|
|
|
|
|
|
auto pZone = player.getCurrentZone();
|
|
|
|
pENpc->setCurrentZone( pZone );
|
|
|
|
pZone->pushActor( pENpc );
|
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
else if( subCommand == "actrl" )
|
|
|
|
{
|
|
|
|
|
|
|
|
// temporary research packet
|
|
|
|
|
|
|
|
int32_t opcode;
|
|
|
|
int32_t param1;
|
|
|
|
int32_t param2;
|
|
|
|
int32_t param3;
|
|
|
|
int32_t param4;
|
|
|
|
int32_t param5;
|
|
|
|
int32_t param6;
|
|
|
|
int32_t playerId;
|
|
|
|
|
|
|
|
sscanf( params.c_str(), "%x %x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &playerId );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
|
2017-08-19 11:28:04 +09:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( playerId, player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
actorControl.data().category = opcode;
|
|
|
|
actorControl.data().param1 = param1;
|
|
|
|
actorControl.data().param2 = param2;
|
|
|
|
actorControl.data().param3 = param3;
|
|
|
|
actorControl.data().param4 = param4;
|
|
|
|
actorControl.data().param5 = param5;
|
|
|
|
actorControl.data().param6 = param6;
|
2017-12-08 11:46:47 +01:00
|
|
|
player.queuePacket( actorControl );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*sscanf(params.c_str(), "%x %x %x %x %x %x %x", &opcode, ¶m1, ¶m2, ¶m3, ¶m4, ¶m5, ¶m6, &playerId);
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
Network::Packets::Server::ServerNoticePacket noticePacket( player, "Injecting ACTOR_CONTROL " + std::to_string( opcode ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
player.queuePacket( noticePacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
Network::Packets::Server::ActorControlPacket143 controlPacket( player, opcode,
|
|
|
|
param1, param2, param3, param4, param5, param6, playerId );
|
|
|
|
player.queuePacket( controlPacket );*/
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
2017-10-02 16:00:26 +02:00
|
|
|
else
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( subCommand + " is not a valid ADD command." );
|
2017-10-02 16:00:26 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::get( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
std::string subCommand;
|
|
|
|
std::string params = "";
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
subCommand = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no subcommand given
|
|
|
|
subCommand = tmpCommand;
|
|
|
|
|
|
|
|
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
|
|
|
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
2017-08-08 13:53:47 +02:00
|
|
|
"subCommand " + subCommand + " params: " + params );
|
|
|
|
|
|
|
|
|
|
|
|
if( ( subCommand == "pos" ) )
|
|
|
|
{
|
|
|
|
|
2018-01-31 11:43:22 +01:00
|
|
|
int16_t map_id = g_exdDataGen.getTerritoryType( player.getCurrentZone()->getTerritoryId() )->map;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "Pos:\n" +
|
|
|
|
std::to_string( player.getPos().x ) + "\n" +
|
|
|
|
std::to_string( player.getPos().y ) + "\n" +
|
|
|
|
std::to_string( player.getPos().z ) + "\n" +
|
|
|
|
std::to_string( player.getRotation() ) + "\nMapId: " +
|
|
|
|
std::to_string( map_id ) + "\nZoneID: " +
|
2018-01-28 11:16:34 +01:00
|
|
|
std::to_string(player.getCurrentZone()->getTerritoryId() ) + "\n" );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
2017-10-02 16:00:26 +02:00
|
|
|
else
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( subCommand + " is not a valid GET command." );
|
2017-10-02 16:00:26 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::injectPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
auto pSession = g_serverZone.getSession( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
if( pSession )
|
2017-12-08 11:46:47 +01:00
|
|
|
pSession->getZoneConnection()->injectPacket( data + 7, player );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::injectChatPacket( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-22 23:53:20 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
auto pSession = g_serverZone.getSession( player.getId() );
|
2017-08-22 23:53:20 +02:00
|
|
|
if( pSession )
|
2017-12-08 11:46:47 +01:00
|
|
|
pSession->getChatConnection()->injectPacket( data + 8, player );
|
2017-08-22 23:53:20 +02:00
|
|
|
}
|
|
|
|
|
2018-01-08 21:42:44 +01:00
|
|
|
void Core::DebugCommandHandler::replay( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
|
|
|
{
|
|
|
|
std::string subCommand;
|
|
|
|
std::string params = "";
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
subCommand = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no subcommand given
|
|
|
|
subCommand = tmpCommand;
|
|
|
|
|
|
|
|
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
|
|
|
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
|
|
|
|
|
|
|
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
|
|
|
"subCommand " + subCommand + " params: " + params );
|
|
|
|
|
|
|
|
|
|
|
|
if( subCommand == "start" )
|
|
|
|
{
|
|
|
|
auto pSession = g_serverZone.getSession( player.getId() );
|
|
|
|
if( pSession )
|
|
|
|
pSession->startReplay( params );
|
|
|
|
}
|
|
|
|
else if( subCommand == "stop" )
|
|
|
|
{
|
|
|
|
auto pSession = g_serverZone.getSession( player.getId() );
|
|
|
|
if( pSession )
|
|
|
|
pSession->stopReplay();
|
|
|
|
}
|
2018-01-09 18:54:09 +01:00
|
|
|
else if( subCommand == "info" )
|
|
|
|
{
|
|
|
|
auto pSession = g_serverZone.getSession( player.getId() );
|
|
|
|
if( pSession )
|
|
|
|
pSession->sendReplayInfo();
|
|
|
|
}
|
2018-01-08 21:42:44 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
player.sendUrgent( subCommand + " is not a valid replay command." );
|
|
|
|
}
|
|
|
|
|
2018-01-28 23:53:58 +11:00
|
|
|
|
2018-01-08 21:42:44 +01:00
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
void Core::DebugCommandHandler::nudge( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
std::string subCommand;
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t spos = tmpCommand.find_first_of( " " );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
auto& pos = player.getPos();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
int32_t offset = 0;
|
|
|
|
char direction[20];
|
|
|
|
memset( direction, 0, 20 );
|
|
|
|
|
|
|
|
sscanf( tmpCommand.c_str(), "%d %s", &offset, direction );
|
|
|
|
|
|
|
|
if( direction[0] == 'u' || direction[0] == '+' )
|
|
|
|
{
|
|
|
|
pos.y += offset;
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "nudge: Placing up " + std::to_string( offset ) + " yalms" );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
else if( direction[0] == 'd' || direction[0] == '-' )
|
|
|
|
{
|
|
|
|
pos.y -= offset;
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "nudge: Placing down " + std::to_string( offset ) + " yalms" );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
float angle = player.getRotation() + ( PI / 2 );
|
2017-08-08 13:53:47 +02:00
|
|
|
pos.x -= offset * cos( angle );
|
|
|
|
pos.z += offset * sin( angle );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "nudge: Placing forward " + std::to_string( offset ) + " yalms" );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
if( offset != 0 )
|
|
|
|
{
|
2017-11-21 18:43:09 +01:00
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorSetPos >
|
2017-12-08 11:46:47 +01:00
|
|
|
setActorPosPacket( player.getId() );
|
|
|
|
setActorPosPacket.data().x = player.getPos().x;
|
|
|
|
setActorPosPacket.data().y = player.getPos().y;
|
|
|
|
setActorPosPacket.data().z = player.getPos().z;
|
|
|
|
setActorPosPacket.data().r16 = Math::Util::floatToUInt16Rot( player.getRotation() );
|
|
|
|
player.queuePacket( setActorPosPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-14 17:07:58 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::serverInfo( char * data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-09-14 17:07:58 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "SapphireServer " + Version::VERSION + "\nRev: " + Version::GIT_HASH );
|
|
|
|
player.sendDebug( "Compiled: " __DATE__ " " __TIME__ );
|
|
|
|
player.sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) );
|
2017-09-14 17:07:58 +02:00
|
|
|
}
|
2017-10-21 23:41:09 +11:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
void Core::DebugCommandHandler::unlockCharacter( char* data, Entity::Player& player, boost::shared_ptr< DebugCommand > command )
|
2017-10-21 23:41:09 +11:00
|
|
|
{
|
2017-12-12 01:45:24 +11:00
|
|
|
player.unlock();
|
|
|
|
}
|
|
|
|
|
2017-12-12 20:28:57 +11:00
|
|
|
void Core::DebugCommandHandler::script( char* data, Entity::Player &player, boost::shared_ptr< DebugCommand > command )
|
2017-12-12 01:45:24 +11:00
|
|
|
{
|
|
|
|
std::string subCommand;
|
|
|
|
std::string params = "";
|
|
|
|
|
|
|
|
// check if the command has parameters
|
|
|
|
std::string tmpCommand = std::string( data + command->getName().length() + 1 );
|
|
|
|
|
|
|
|
std::size_t pos = tmpCommand.find_first_of( " " );
|
|
|
|
|
|
|
|
if( pos != std::string::npos )
|
|
|
|
// command has parameters, grab the first part
|
|
|
|
subCommand = tmpCommand.substr( 0, pos );
|
|
|
|
else
|
|
|
|
// no subcommand given
|
|
|
|
subCommand = tmpCommand;
|
|
|
|
|
|
|
|
// todo: fix params so it's empty if there's no params
|
|
|
|
if( command->getName().length() + 1 + pos + 1 < strlen( data ) )
|
|
|
|
params = std::string( data + command->getName().length() + 1 + pos + 1 );
|
|
|
|
|
|
|
|
g_log.debug( "[" + std::to_string( player.getId() ) + "] " +
|
|
|
|
"subCommand " + subCommand + " params: " + params );
|
|
|
|
|
|
|
|
if( subCommand == "unload" )
|
|
|
|
{
|
|
|
|
if ( subCommand == params )
|
|
|
|
player.sendDebug( "Command failed: requires name of script" );
|
|
|
|
else
|
2017-12-12 13:17:43 +11:00
|
|
|
if( g_scriptMgr.getNativeScriptHandler().unloadScript( params ) )
|
|
|
|
player.sendDebug( "Unloaded script successfully." );
|
|
|
|
else
|
|
|
|
player.sendDebug( "Failed to unload script: " + params );
|
2017-12-12 01:45:24 +11:00
|
|
|
}
|
|
|
|
else if( subCommand == "find" || subCommand == "f" )
|
|
|
|
{
|
|
|
|
if( subCommand == params )
|
|
|
|
player.sendDebug( "Because reasons of filling chat with nonsense, please enter a search term" );
|
|
|
|
else
|
|
|
|
{
|
2017-12-12 17:29:31 +11:00
|
|
|
std::set< Core::Scripting::ScriptInfo* > scripts;
|
|
|
|
g_scriptMgr.getNativeScriptHandler().findScripts( scripts, params );
|
|
|
|
|
2017-12-14 13:23:59 +11:00
|
|
|
if( !scripts.empty() )
|
2017-12-12 17:29:31 +11:00
|
|
|
{
|
|
|
|
player.sendDebug( "Found " + std::to_string( scripts.size() ) + " scripts" );
|
|
|
|
|
|
|
|
for( auto it = scripts.begin(); it != scripts.end(); ++it )
|
|
|
|
{
|
|
|
|
auto script = *it;
|
2017-12-27 18:47:51 +11:00
|
|
|
player.sendDebug( " - '" + script->library_name + "' loaded at @ 0x" +
|
2017-12-12 17:29:31 +11:00
|
|
|
boost::str( boost::format( "%|X|" ) % script->handle ) +
|
2017-12-27 18:47:51 +11:00
|
|
|
", num scripts: " + std::to_string( script->scripts.size() ) );
|
2017-12-12 17:29:31 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
player.sendDebug( "No scripts found with search term: " + params );
|
2017-12-12 01:45:24 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( subCommand == "load" || subCommand == "l" )
|
|
|
|
{
|
|
|
|
if( subCommand == params )
|
|
|
|
player.sendDebug( "Command failed: requires relative path to script" );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( g_scriptMgr.getNativeScriptHandler().loadScript( params ) )
|
|
|
|
player.sendDebug( "Loaded '" + params + "' successfully" );
|
|
|
|
else
|
|
|
|
player.sendDebug( "Failed to load '" + params + "'" );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2017-12-14 23:05:53 +11:00
|
|
|
else if( subCommand == "queuereload" || subCommand == "qrl" )
|
2017-12-14 13:23:59 +11:00
|
|
|
{
|
|
|
|
if( subCommand == params )
|
|
|
|
player.sendDebug( "Command failed: requires name of script to reload" );
|
|
|
|
else
|
2017-12-14 22:30:06 +11:00
|
|
|
{
|
2017-12-14 23:11:29 +11:00
|
|
|
g_scriptMgr.getNativeScriptHandler().queueScriptReload( params );
|
2017-12-14 23:05:53 +11:00
|
|
|
player.sendDebug( "Queued script reload for script: " + params );
|
2017-12-14 22:30:06 +11:00
|
|
|
}
|
2017-12-14 13:23:59 +11:00
|
|
|
}
|
2017-12-12 01:45:24 +11:00
|
|
|
else
|
|
|
|
{
|
|
|
|
player.sendDebug( "Unknown script subcommand: " + subCommand );
|
|
|
|
}
|
2017-10-21 23:41:09 +11:00
|
|
|
}
|
2018-01-28 23:53:58 +11:00
|
|
|
|
|
|
|
void Core::DebugCommandHandler::instance( char* data, Entity::Player &player, boost::shared_ptr< DebugCommand > command )
|
|
|
|
{
|
|
|
|
std::string cmd( data ), params, subCommand;
|
|
|
|
auto cmdPos = cmd.find_first_of( ' ' );
|
|
|
|
|
|
|
|
if( cmdPos != std::string::npos )
|
|
|
|
{
|
|
|
|
params = cmd.substr( cmdPos + 1 );
|
|
|
|
|
|
|
|
auto p = params.find_first_of( ' ' );
|
|
|
|
|
|
|
|
if( p != std::string::npos )
|
|
|
|
{
|
|
|
|
subCommand = params.substr( 0, p );
|
|
|
|
params = params.substr( subCommand.length() + 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
subCommand = params;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( subCommand == "create" || subCommand == "cr" )
|
|
|
|
{
|
2018-01-29 19:40:27 +11:00
|
|
|
uint32_t instanceContentId;
|
|
|
|
sscanf( params.c_str(), "%d", &instanceContentId );
|
2018-01-28 23:53:58 +11:00
|
|
|
|
2018-01-29 19:40:27 +11:00
|
|
|
auto instance = g_territoryMgr.createInstanceContent( instanceContentId );
|
|
|
|
if( instance )
|
|
|
|
player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) + " -> " + instance->getName() );
|
|
|
|
else
|
|
|
|
player.sendDebug( "Failed to create instance with id: " + std::to_string( instanceContentId ) );
|
2018-01-28 23:53:58 +11:00
|
|
|
}
|
2018-01-29 00:52:11 +11:00
|
|
|
else if( subCommand == "remove" || subCommand == "rm" )
|
|
|
|
{
|
|
|
|
uint32_t terriId;
|
|
|
|
sscanf( params.c_str(), "%d", &terriId );
|
|
|
|
|
|
|
|
if( g_territoryMgr.removeTerritoryInstance( terriId ) )
|
|
|
|
player.sendDebug( "Removed instance with id: " + std::to_string( terriId ) );
|
|
|
|
else
|
|
|
|
player.sendDebug( "Failed to remove instance with id: " + std::to_string( terriId ) );
|
|
|
|
}
|
2018-01-29 13:05:33 +11:00
|
|
|
else if( subCommand == "return" || subCommand == "ret" )
|
|
|
|
{
|
|
|
|
player.exitInstance();
|
|
|
|
}
|
2018-02-07 00:00:48 +01:00
|
|
|
else if( subCommand == "set" )
|
|
|
|
{
|
|
|
|
uint32_t instanceId;
|
|
|
|
uint32_t index;
|
|
|
|
uint32_t value;
|
|
|
|
sscanf( params.c_str(), "%d %d %d", &instanceId, &index, &value );
|
|
|
|
|
|
|
|
auto pInstance = g_territoryMgr.getInstanceZonePtr( instanceId );
|
|
|
|
if( !pInstance )
|
|
|
|
return;
|
|
|
|
auto instance = boost::dynamic_pointer_cast< InstanceContent >( pInstance );
|
|
|
|
|
|
|
|
instance->setVar( static_cast< uint8_t >( index ), static_cast< uint8_t >( value ) );
|
|
|
|
}
|
2018-02-10 14:03:59 +11:00
|
|
|
else if( subCommand == "objupdate" )
|
|
|
|
{
|
|
|
|
uint32_t objId;
|
|
|
|
|
2018-02-10 22:35:02 +11:00
|
|
|
sscanf( params.c_str(), "%d", &objId );
|
2018-02-10 14:03:59 +11:00
|
|
|
|
2018-02-10 22:35:02 +11:00
|
|
|
auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() );
|
|
|
|
if( !instance )
|
2018-02-10 14:03:59 +11:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto obj = instance->getInstanceObject( objId );
|
|
|
|
if( !obj )
|
|
|
|
return;
|
|
|
|
|
|
|
|
instance->updateInstanceObj( obj );
|
|
|
|
}
|
|
|
|
else if( subCommand == "objstate" )
|
|
|
|
{
|
|
|
|
uint32_t objId;
|
2018-02-10 22:35:02 +11:00
|
|
|
uint8_t state;
|
2018-02-10 14:03:59 +11:00
|
|
|
|
2018-02-10 22:35:02 +11:00
|
|
|
sscanf( params.c_str(), "%d %hhu", &objId, &state );
|
2018-02-10 14:03:59 +11:00
|
|
|
|
2018-02-10 22:35:02 +11:00
|
|
|
auto instance = boost::dynamic_pointer_cast< InstanceContent >( player.getCurrentZone() );
|
|
|
|
if( !instance )
|
2018-02-10 14:03:59 +11:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto obj = instance->getInstanceObject( objId );
|
|
|
|
if( !obj )
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj->setState( state );
|
|
|
|
}
|
2018-02-03 02:11:29 +11:00
|
|
|
else if( subCommand == "festival" )
|
|
|
|
{
|
|
|
|
uint32_t festivalId;
|
|
|
|
sscanf( params.c_str(), "%d", &festivalId );
|
|
|
|
|
|
|
|
player.getCurrentZone()->setCurrentFestival( static_cast< uint16_t >( festivalId ) );
|
|
|
|
}
|
|
|
|
else if( subCommand == "disablefestival" )
|
|
|
|
{
|
|
|
|
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcActorControl143 > actorControl( player.getId() );
|
|
|
|
actorControl.data().category = Core::Common::ActorControlType::DisableCurrentFestival;
|
|
|
|
player.queuePacket( actorControl );
|
|
|
|
|
|
|
|
player.getCurrentZone()->setCurrentFestival( 0 );
|
|
|
|
}
|
2018-01-28 23:53:58 +11:00
|
|
|
}
|