2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
|
|
|
#include <Network/CommonNetwork.h>
|
2019-03-08 15:34:38 +01:00
|
|
|
#include <Network/GamePacket.h>
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Logging/Logger.h>
|
|
|
|
#include <Network/PacketContainer.h>
|
2018-06-23 21:38:04 +02:00
|
|
|
#include <Network/CommonActorControl.h>
|
2018-07-06 19:47:35 +10:00
|
|
|
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
2018-09-21 02:02:51 +10:00
|
|
|
#include <Exd/ExdDataGenerated.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2018-02-28 10:26:03 +01:00
|
|
|
#include <unordered_map>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
|
|
|
|
#include "Session.h"
|
2018-03-06 00:10:36 +01:00
|
|
|
|
2018-12-01 00:27:16 +11:00
|
|
|
#include "Manager/TerritoryMgr.h"
|
|
|
|
#include "Territory/Zone.h"
|
|
|
|
#include "Territory/InstanceContent.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
|
|
|
|
#include "Network/PacketWrappers/InitUIPacket.h"
|
|
|
|
#include "Network/PacketWrappers/PingPacket.h"
|
|
|
|
#include "Network/PacketWrappers/MoveActorPacket.h"
|
|
|
|
#include "Network/PacketWrappers/ChatPacket.h"
|
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
|
|
|
#include "Network/PacketWrappers/EventStartPacket.h"
|
|
|
|
#include "Network/PacketWrappers/EventFinishPacket.h"
|
|
|
|
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
|
|
|
|
2018-11-20 21:32:13 +01:00
|
|
|
#include "ServerMgr.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "Framework.h"
|
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
using namespace Sapphire::Common;
|
|
|
|
using namespace Sapphire::Network::Packets;
|
|
|
|
using namespace Sapphire::Network::Packets::Server;
|
|
|
|
using namespace Sapphire::Network::ActorControl;
|
2018-12-01 00:27:16 +11:00
|
|
|
using namespace Sapphire::World::Manager;
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
enum GmCommand
|
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
Pos = 0x0000,
|
|
|
|
Lv = 0x0001,
|
|
|
|
Race = 0x0002,
|
|
|
|
Tribe = 0x0003,
|
|
|
|
Sex = 0x0004,
|
|
|
|
Time = 0x0005,
|
|
|
|
Weather = 0x0006,
|
|
|
|
Call = 0x0007,
|
|
|
|
Inspect = 0x0008,
|
|
|
|
Speed = 0x0009,
|
|
|
|
Invis = 0x000D,
|
|
|
|
|
|
|
|
Raise = 0x0010,
|
|
|
|
Kill = 0x000E,
|
|
|
|
Icon = 0x0012,
|
|
|
|
|
|
|
|
Hp = 0x0064,
|
|
|
|
Mp = 0x0065,
|
|
|
|
Tp = 0x0066,
|
|
|
|
Gp = 0x0067,
|
|
|
|
Exp = 0x0068,
|
|
|
|
Inv = 0x006A,
|
|
|
|
|
|
|
|
Orchestrion = 0x0074,
|
|
|
|
|
|
|
|
Item = 0x00C8,
|
|
|
|
Gil = 0x00C9,
|
|
|
|
Collect = 0x00CA,
|
|
|
|
|
|
|
|
QuestAccept = 0x012C,
|
|
|
|
QuestCancel = 0x012D,
|
|
|
|
QuestComplete = 0x012E,
|
|
|
|
QuestIncomplete = 0x012F,
|
|
|
|
QuestSequence = 0x0130,
|
|
|
|
QuestInspect = 0x0131,
|
|
|
|
GC = 0x0154,
|
|
|
|
GCRank = 0x0155,
|
|
|
|
Aetheryte = 0x015E,
|
|
|
|
Wireframe = 0x0226,
|
|
|
|
Teri = 0x0258,
|
|
|
|
Kick = 0x025C,
|
|
|
|
TeriInfo = 0x025D,
|
|
|
|
Jump = 0x025E,
|
|
|
|
JumpNpc = 0x025F,
|
2017-08-17 00:00:41 +02:00
|
|
|
};
|
2017-11-21 03:19:08 -02:00
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
void Sapphire::Network::GameConnection::gm1Handler( FrameworkPtr pFw,
|
|
|
|
const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
|
|
|
Entity::Player& player )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
if( player.getGmRank() <= 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand1 >( inPacket );
|
2018-10-14 23:31:52 +11:00
|
|
|
const auto commandId = packet.data().commandId;
|
|
|
|
const auto param1 = packet.data().param1;
|
|
|
|
const auto param2 = packet.data().param2;
|
|
|
|
const auto param3 = packet.data().param3;
|
2018-10-14 23:36:05 +11:00
|
|
|
const auto param4 = packet.data().param4;
|
|
|
|
const auto target = packet.data().target;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::info( "{0} used GM1 commandId: {1}, params: {2}, {3}, {4}, {5}, target: {6}",
|
|
|
|
player.getName(), commandId,
|
|
|
|
param1, param2, param3, param4, target );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Entity::ActorPtr targetActor;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
|
|
|
|
2018-10-14 12:52:06 +11:00
|
|
|
if( player.getId() == target )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
targetActor = player.getAsPlayer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto inRange = player.getInRangeActors();
|
|
|
|
for( auto& actor : inRange )
|
|
|
|
{
|
2018-10-14 12:52:06 +11:00
|
|
|
if( actor->getId() == target )
|
2018-08-29 21:40:59 +02:00
|
|
|
targetActor = actor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !targetActor )
|
|
|
|
return;
|
|
|
|
auto targetPlayer = targetActor->getAsPlayer();
|
|
|
|
|
|
|
|
switch( commandId )
|
|
|
|
{
|
|
|
|
case GmCommand::Lv:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->setLevel( param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Level for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Race:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->setLookAt( CharaLook::Race, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Race for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->spawn( targetPlayer );
|
2018-02-22 15:31:10 +01:00
|
|
|
auto inRange = targetPlayer->getInRangeActors();
|
2018-02-14 21:11:23 +01:00
|
|
|
for( auto actor : inRange )
|
2017-11-21 03:19:08 -02:00
|
|
|
{
|
2019-01-05 14:50:16 +01:00
|
|
|
if( actor->isPlayer() )
|
|
|
|
{
|
|
|
|
targetPlayer->despawn( actor->getAsPlayer() );
|
|
|
|
targetPlayer->spawn( actor->getAsPlayer() );
|
|
|
|
}
|
2019-01-05 18:50:27 +01:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Tribe:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->setLookAt( CharaLook::Tribe, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Tribe for {0} was set to ", targetPlayer->getName(), param1 );
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->spawn( targetPlayer );
|
2018-02-22 15:31:10 +01:00
|
|
|
auto inRange = targetPlayer->getInRangeActors();
|
2018-02-14 21:11:23 +01:00
|
|
|
for( auto actor : inRange )
|
2017-11-21 03:19:08 -02:00
|
|
|
{
|
2019-01-05 14:50:16 +01:00
|
|
|
if( actor->isPlayer() )
|
|
|
|
{
|
|
|
|
targetPlayer->despawn( actor->getAsPlayer() );
|
|
|
|
targetPlayer->spawn( actor->getAsPlayer() );
|
|
|
|
}
|
2017-11-21 03:19:08 -02:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Sex:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->setLookAt( CharaLook::Gender, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Sex for {0} was set to ", targetPlayer->getName(), param1 );
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->spawn( targetPlayer );
|
2018-02-22 15:31:10 +01:00
|
|
|
auto inRange = targetActor->getInRangeActors();
|
2018-02-14 21:11:23 +01:00
|
|
|
for( auto actor : inRange )
|
2017-11-21 03:19:08 -02:00
|
|
|
{
|
2019-01-05 14:50:16 +01:00
|
|
|
if( actor->isPlayer() )
|
|
|
|
{
|
|
|
|
targetPlayer->despawn( actor->getAsPlayer() );
|
|
|
|
targetPlayer->spawn( actor->getAsPlayer() );
|
|
|
|
}
|
2017-11-21 03:19:08 -02:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Time:
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setEorzeaTimeOffset( param2 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Eorzea time offset: {0}", param2 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Weather:
|
|
|
|
{
|
2018-02-14 21:11:23 +01:00
|
|
|
targetPlayer->getCurrentZone()->setWeatherOverride( static_cast< Common::Weather >( param1 ) );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Weather in Zone \"{0}\" of {1} set in range.",
|
|
|
|
targetPlayer->getCurrentZone()->getName(), targetPlayer->getName() );
|
2017-11-21 03:19:08 -02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Call:
|
|
|
|
{
|
2018-02-14 21:11:23 +01:00
|
|
|
if( targetPlayer->getZoneId() != player.getZoneId() )
|
2018-08-29 21:40:59 +02:00
|
|
|
targetPlayer->setZone( player.getZoneId() );
|
2018-01-20 02:04:38 +11:00
|
|
|
|
2018-02-22 18:12:36 +01:00
|
|
|
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Calling {0}", targetPlayer->getName() );
|
2018-01-20 02:04:38 +11:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Inspect:
|
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Name: {0}"
|
|
|
|
"\nGil: {1}"
|
|
|
|
"\nZone: {2}"
|
|
|
|
"({3})"
|
|
|
|
"\nClass: {4}"
|
|
|
|
"\nLevel: {5}"
|
|
|
|
"\nExp: {6}"
|
|
|
|
"\nSearchMessage: {7}"
|
|
|
|
"\nPlayTime: {8}",
|
|
|
|
targetPlayer->getName(),
|
|
|
|
targetPlayer->getCurrency( CurrencyType::Gil ),
|
|
|
|
targetPlayer->getCurrentZone()->getName(),
|
|
|
|
targetPlayer->getZoneId(),
|
|
|
|
static_cast< uint8_t >( targetPlayer->getClass() ),
|
|
|
|
targetPlayer->getLevel(),
|
|
|
|
targetPlayer->getExp(),
|
|
|
|
targetPlayer->getSearchMessage(),
|
|
|
|
targetPlayer->getPlayTime() );
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GmCommand::Speed:
|
|
|
|
{
|
2018-08-28 19:05:52 +02:00
|
|
|
targetPlayer->queuePacket( makeActorControl143( player.getId(), Flee, param1 ) );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Speed for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Invis:
|
|
|
|
{
|
2018-04-19 22:47:03 +10:00
|
|
|
player.setGmInvis( !player.getGmInvis() );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Invisibility flag for {0} was toggled to {1}", player.getName(), !player.getGmInvis() );
|
2018-04-19 22:47:03 +10:00
|
|
|
|
|
|
|
for( auto actor : player.getInRangeActors() )
|
2018-04-18 21:00:20 +10:00
|
|
|
{
|
2019-01-05 14:50:16 +01:00
|
|
|
if( actor->isPlayer() )
|
|
|
|
{
|
|
|
|
targetPlayer->despawn( actor->getAsPlayer() );
|
|
|
|
targetPlayer->spawn( actor->getAsPlayer() );
|
|
|
|
}
|
2018-04-18 21:00:20 +10:00
|
|
|
}
|
2018-04-19 22:47:03 +10:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Kill:
|
|
|
|
{
|
2018-02-22 15:31:10 +01:00
|
|
|
targetActor->getAsChara()->takeDamage( 9999999 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Killed {0}", targetActor->getId() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Icon:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->setOnlineStatusMask( param1 );
|
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto statusPacket = makeZonePacket< FFXIVIpcSetOnlineStatus >( player.getId() );
|
|
|
|
statusPacket->data().onlineStatusFlags = param1;
|
2017-11-21 03:19:08 -02:00
|
|
|
queueOutPacket( statusPacket );
|
|
|
|
|
2018-06-28 00:07:07 +02:00
|
|
|
auto searchInfoPacket = makeZonePacket< FFXIVIpcSetSearchInfo >( player.getId() );
|
|
|
|
searchInfoPacket->data().onlineStatusFlags = param1;
|
|
|
|
searchInfoPacket->data().selectRegion = targetPlayer->getSearchSelectRegion();
|
|
|
|
strcpy( searchInfoPacket->data().searchMessage, targetPlayer->getSearchMessage() );
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->queuePacket( searchInfoPacket );
|
|
|
|
|
2018-08-28 19:05:52 +02:00
|
|
|
targetPlayer->sendToInRangeSet( makeActorControl142( player.getId(), SetStatusIcon,
|
2018-08-29 21:40:59 +02:00
|
|
|
static_cast< uint8_t >( player.getOnlineStatus() ) ),
|
|
|
|
true );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Icon for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Hp:
|
|
|
|
{
|
2019-01-26 13:40:02 +11:00
|
|
|
auto chara = targetActor->getAsChara();
|
|
|
|
if( chara )
|
|
|
|
{
|
|
|
|
chara->setHp( param1 );
|
|
|
|
player.sendNotice( "Hp for {0} was set to {1}", chara->getName(), param1 );
|
|
|
|
}
|
|
|
|
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Mp:
|
|
|
|
{
|
2017-09-11 18:59:50 +02:00
|
|
|
targetPlayer->setMp( param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Mp for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Gp:
|
|
|
|
{
|
2017-09-11 18:59:50 +02:00
|
|
|
targetPlayer->setHp( param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Gp for {0} was set to {1}", targetPlayer->getName(), param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Exp:
|
|
|
|
{
|
2017-09-21 23:59:05 +02:00
|
|
|
targetPlayer->gainExp( param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "{0} Exp was added to {1}", param1, targetPlayer->getName() );
|
2017-09-22 01:12:37 +10:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Inv:
|
|
|
|
{
|
2018-02-22 15:31:10 +01:00
|
|
|
if( targetActor->getAsChara()->getInvincibilityType() == Common::InvincibilityType::InvincibilityRefill )
|
2018-08-29 21:40:59 +02:00
|
|
|
targetActor->getAsChara()->setInvincibilityType( Common::InvincibilityType::InvincibilityNone );
|
2017-11-21 03:19:08 -02:00
|
|
|
else
|
2018-08-29 21:40:59 +02:00
|
|
|
targetActor->getAsChara()->setInvincibilityType( Common::InvincibilityType::InvincibilityRefill );
|
2017-11-21 03:19:08 -02:00
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Invincibility for {0} was switched.", targetPlayer->getName() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Orchestrion:
|
|
|
|
{
|
2018-02-14 21:11:23 +01:00
|
|
|
if( param1 == 1 )
|
2017-09-11 18:59:50 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
if( param2 == 0 )
|
|
|
|
{
|
|
|
|
for( uint8_t i = 0; i < 255; i++ )
|
|
|
|
targetActor->getAsPlayer()->learnSong( i, 0 );
|
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "All Songs for {0} were turned on.", targetPlayer->getName() );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
targetActor->getAsPlayer()->learnSong( param2, 0 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Song {0} for {1} was turned on.", param2, targetPlayer->getName() );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
2017-11-21 03:19:08 -02:00
|
|
|
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Item:
|
|
|
|
{
|
2018-07-06 23:36:50 +10:00
|
|
|
auto quantity = param2;
|
|
|
|
|
|
|
|
if( quantity < 1 || quantity > 999 )
|
2017-09-11 18:59:50 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
quantity = 1;
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ( param1 == 0xcccccccc ) )
|
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
player.sendUrgent( "Syntaxerror." );
|
|
|
|
return;
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
|
|
|
|
2018-08-25 00:15:26 +10:00
|
|
|
if( !targetPlayer->addItem( param1, quantity ) )
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "Item #{0} could not be added to inventory.", param1 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Gil:
|
|
|
|
{
|
2018-07-24 23:58:08 +02:00
|
|
|
targetPlayer->addCurrency( CurrencyType::Gil, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Added {0} Gil for {1}", param1, targetPlayer->getName() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Collect:
|
|
|
|
{
|
2018-07-24 23:58:08 +02:00
|
|
|
uint32_t gil = targetPlayer->getCurrency( CurrencyType::Gil );
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-02-14 21:11:23 +01:00
|
|
|
if( gil < param1 )
|
2017-09-11 18:59:50 +02:00
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "Player does not have enough Gil({0})", gil );
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
targetPlayer->removeCurrency( CurrencyType::Gil, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Removed {0} Gil from {1} ({2} before)", param1, targetPlayer->getName(), gil );
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::QuestAccept:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->updateQuest( param1, 1 );
|
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::QuestCancel:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->removeQuest( param1 );
|
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::QuestComplete:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->finishQuest( param1 );
|
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::QuestIncomplete:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->unfinishQuest( param1 );
|
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::QuestSequence:
|
|
|
|
{
|
2017-11-21 03:19:08 -02:00
|
|
|
targetPlayer->updateQuest( param1, param2 );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::GC:
|
|
|
|
{
|
2019-01-28 18:58:02 +11:00
|
|
|
if( param1 > 3 )
|
|
|
|
{
|
|
|
|
player.sendUrgent( "Invalid Grand Company ID: {0}", param1 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-11 18:59:50 +02:00
|
|
|
targetPlayer->setGc( param1 );
|
2019-01-28 18:58:02 +11:00
|
|
|
|
|
|
|
// if we're changing them to a GC, check if they have a rank and if not, set it to the lowest rank
|
|
|
|
if( param1 > 0 )
|
|
|
|
{
|
|
|
|
auto gcRankIdx = static_cast< uint8_t >( param1 ) - 1;
|
|
|
|
if( targetPlayer->getGcRankArray()[ gcRankIdx ] == 0 )
|
|
|
|
{
|
|
|
|
player.setGcRankAt( gcRankIdx, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "GC for {0} was set to {1}", targetPlayer->getName(), targetPlayer->getGc() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::GCRank:
|
|
|
|
{
|
2019-01-28 18:58:02 +11:00
|
|
|
auto gcId = targetPlayer->getGc() - 1;
|
|
|
|
|
|
|
|
if( gcId > 2 )
|
|
|
|
{
|
|
|
|
player.sendUrgent( "{0} has an invalid Grand Company ID: {0}", targetPlayer->getName(), gcId );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
targetPlayer->setGcRankAt( gcId, param1 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "GC Rank for {0} for GC {1} was set to {2}", targetPlayer->getName(), targetPlayer->getGc(),
|
|
|
|
targetPlayer->getGcRankArray()[ targetPlayer->getGc() - 1 ] );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Aetheryte:
|
|
|
|
{
|
2018-02-14 21:11:23 +01:00
|
|
|
if( param1 == 0 )
|
2017-10-04 11:48:58 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
if( param2 == 0 )
|
|
|
|
{
|
|
|
|
for( uint8_t i = 0; i < 255; i++ )
|
|
|
|
targetActor->getAsPlayer()->registerAetheryte( i );
|
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "All Aetherytes for {0} were turned on.", targetPlayer->getName() );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
targetActor->getAsPlayer()->registerAetheryte( param2 );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Aetheryte {0} for {1} was turned on.", param2, targetPlayer->getName() );
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-10-04 11:48:58 +02:00
|
|
|
}
|
|
|
|
|
2017-10-09 20:09:49 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Wireframe:
|
|
|
|
{
|
|
|
|
player.queuePacket(
|
2018-10-25 12:44:51 +11:00
|
|
|
std::make_shared< ActorControlPacket143 >( player.getId(), ActorControlType::ToggleWireframeRendering ) );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Wireframe Rendering for {0} was toggled", player.getName() );
|
2018-08-28 15:02:59 +10:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Teri:
|
|
|
|
{
|
2018-12-23 03:53:08 +01:00
|
|
|
auto pTeriMgr = pFw->get< TerritoryMgr >();
|
2018-03-09 10:19:38 +01:00
|
|
|
if( auto instance = pTeriMgr->getInstanceZonePtr( param1 ) )
|
2017-10-09 20:09:49 +02:00
|
|
|
{
|
2019-01-05 12:32:10 +01:00
|
|
|
player.sendDebug( "Found instance: {0}, id#{1}", instance->getName(), param1 );
|
2018-01-29 13:05:33 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
// if the zone is an instanceContent instance, make sure the player is actually bound to it
|
|
|
|
auto pInstance = instance->getAsInstanceContent();
|
2018-03-16 20:33:28 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
// pInstance will be nullptr if you're accessing a normal zone via its allocated instance id rather than its zoneid
|
|
|
|
if( pInstance && !pInstance->isPlayerBound( player.getId() ) )
|
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "Not able to join instance#{0}", param1 );
|
|
|
|
player.sendUrgent( "Player not bound! ( run !instance bind <instanceId> first ) {0}", param1 );
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-03-15 23:37:21 +01:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
player.setInstance( instance );
|
2018-01-28 23:53:58 +11:00
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
else if( !pTeriMgr->isValidTerritory( param1 ) )
|
2017-10-09 20:09:49 +02:00
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "Invalid zone {0}", param1 );
|
2017-11-21 03:19:08 -02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-05 23:07:39 +01:00
|
|
|
auto pZone = pTeriMgr->getZoneByTerritoryTypeId( param1 );
|
2018-08-29 21:40:59 +02:00
|
|
|
if( !pZone )
|
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "No zone instance found for {0}", param1 );
|
2018-08-29 21:40:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-11-20 22:52:57 +11:00
|
|
|
|
2018-11-05 23:04:26 +11:00
|
|
|
if( !pTeriMgr->isDefaultTerritory( param1 ) )
|
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "{0} is an instanced area - instance ID required to zone in.", pZone->getName() );
|
2018-11-05 23:04:26 +11:00
|
|
|
break;
|
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-09-21 02:02:51 +10:00
|
|
|
bool doTeleport = false;
|
|
|
|
uint16_t teleport;
|
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
auto pExdData = pFw->get< Data::ExdDataGenerated >();
|
2018-09-21 02:02:51 +10:00
|
|
|
auto idList = pExdData->getAetheryteIdList();
|
|
|
|
|
|
|
|
for( auto i : idList )
|
|
|
|
{
|
2018-11-29 16:55:48 +01:00
|
|
|
auto data = pExdData->get< Sapphire::Data::Aetheryte >( i );
|
2018-09-21 02:02:51 +10:00
|
|
|
|
2018-09-21 03:50:38 +10:00
|
|
|
if( !data )
|
|
|
|
{
|
2018-09-21 02:02:51 +10:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-09-21 03:50:38 +10:00
|
|
|
if( data->territory == param1 )
|
|
|
|
{
|
|
|
|
if( data->isAetheryte )
|
|
|
|
{
|
2018-09-21 09:28:34 +10:00
|
|
|
doTeleport = true;
|
|
|
|
teleport = i;
|
|
|
|
break;
|
2018-09-21 02:02:51 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( doTeleport )
|
|
|
|
{
|
|
|
|
player.teleport( teleport );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
targetPlayer->setPos( targetPlayer->getPos() );
|
|
|
|
targetPlayer->performZoning( param1, targetPlayer->getPos(), 0 );
|
|
|
|
}
|
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "{0} was warped to zone {1}", targetPlayer->getName(), param1, pZone->getName() );
|
2017-10-09 20:09:49 +02:00
|
|
|
}
|
2017-10-04 11:48:58 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-11-20 22:52:57 +11:00
|
|
|
case GmCommand::Kick:
|
|
|
|
{
|
|
|
|
// todo: this doesn't kill their session straight away, should do this properly but its good for when you get stuck for now
|
|
|
|
targetPlayer->setMarkedForRemoval();
|
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Kicked {0}", targetPlayer->getName() );
|
2018-11-20 22:52:57 +11:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-08-29 21:40:59 +02:00
|
|
|
case GmCommand::TeriInfo:
|
|
|
|
{
|
2018-02-14 21:11:23 +01:00
|
|
|
auto pCurrentZone = player.getCurrentZone();
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "ZoneId: {0}"
|
|
|
|
"\nName: {1}"
|
|
|
|
"\nInternalName: {2}"
|
|
|
|
"\nGuId: {3}"
|
|
|
|
"\nPopCount: {4}"
|
|
|
|
"\nCurrentWeather: {5}"
|
|
|
|
"\nNextWeather: {6}",
|
|
|
|
player.getZoneId(),
|
|
|
|
pCurrentZone->getName(),
|
|
|
|
pCurrentZone->getInternalName(),
|
|
|
|
pCurrentZone->getGuId(),
|
|
|
|
pCurrentZone->getPopCount(),
|
|
|
|
static_cast< uint8_t >( pCurrentZone->getCurrentWeather() ),
|
|
|
|
static_cast< uint8_t >( pCurrentZone->getNextWeather() ) );
|
2017-11-21 03:19:08 -02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Jump:
|
|
|
|
{
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-02-22 15:31:10 +01:00
|
|
|
auto inRange = player.getInRangeActors();
|
2018-02-14 21:11:23 +01:00
|
|
|
|
|
|
|
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
2018-02-22 15:31:10 +01:00
|
|
|
targetActor->getRot() );
|
2018-02-14 21:11:23 +01:00
|
|
|
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Jumping to {0} in range.", targetPlayer->getName() );
|
2017-11-21 03:19:08 -02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-01-28 23:53:58 +11:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
default:
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "GM1 Command not implemented: {0}", commandId );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
void Sapphire::Network::GameConnection::gm2Handler( FrameworkPtr pFw,
|
|
|
|
const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
|
|
|
Entity::Player& player )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
if( player.getGmRank() <= 0 )
|
|
|
|
return;
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-12-23 03:53:08 +01:00
|
|
|
auto pServerZone = pFw->get< World::ServerMgr >();
|
2018-06-18 23:03:39 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket );
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-10-14 23:31:52 +11:00
|
|
|
const auto commandId = packet.data().commandId;
|
2018-10-14 23:36:05 +11:00
|
|
|
const auto param1 = packet.data().param1;
|
|
|
|
const auto param2 = packet.data().param2;
|
|
|
|
const auto param3 = packet.data().param3;
|
|
|
|
const auto param4 = packet.data().param4;
|
|
|
|
const auto target = std::string( packet.data().target );
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2019-01-04 22:37:01 +11:00
|
|
|
Logger::debug( "{0} used GM2 commandId: {1}, params: {2}, {3}, {4}, {5}, target: {6}",
|
|
|
|
player.getName(), commandId, param1, param2, param3, param4, target );
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-10-14 12:52:06 +11:00
|
|
|
auto targetSession = pServerZone->getSession( target );
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Entity::CharaPtr targetActor;
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
if( targetSession != nullptr )
|
|
|
|
{
|
|
|
|
targetActor = targetSession->getPlayer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-14 12:52:06 +11:00
|
|
|
if( target == "self" )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
targetActor = player.getAsPlayer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "Player {0} not found on this server.", target );
|
2017-09-11 18:59:50 +02:00
|
|
|
return;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !targetActor )
|
|
|
|
return;
|
2017-11-21 03:19:08 -02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
auto targetPlayer = targetActor->getAsPlayer();
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
switch( commandId )
|
|
|
|
{
|
|
|
|
case GmCommand::Raise:
|
|
|
|
{
|
2017-09-11 18:59:50 +02:00
|
|
|
targetPlayer->resetHp();
|
|
|
|
targetPlayer->resetMp();
|
2018-08-28 19:05:52 +02:00
|
|
|
targetPlayer->setStatus( Common::ActorStatus::Idle );
|
2018-04-22 18:21:22 +10:00
|
|
|
targetPlayer->sendZoneInPackets( 0x01, 0x01, 0, 113, true );
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2018-08-28 19:05:52 +02:00
|
|
|
|
|
|
|
targetPlayer->sendToInRangeSet( makeActorControl143( player.getId(), ZoneIn, 0x01, 0x01, 0, 113 ), true );
|
|
|
|
targetPlayer->sendToInRangeSet( makeActorControl142( player.getId(), SetStatus,
|
2018-08-29 21:40:59 +02:00
|
|
|
static_cast< uint8_t >( Common::ActorStatus::Idle ) ),
|
|
|
|
true );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Raised {0}", targetPlayer->getName() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Jump:
|
|
|
|
{
|
2019-01-06 01:47:07 +01:00
|
|
|
player.prepareZoning( targetPlayer->getZoneId(), true, 1, 0 );
|
|
|
|
if( player.getCurrentInstance() )
|
|
|
|
{
|
|
|
|
player.exitInstance();
|
|
|
|
}
|
2019-01-06 16:25:51 +01:00
|
|
|
if( targetPlayer->getCurrentZone()->getGuId() != player.getCurrentZone()->getGuId() )
|
2019-01-06 01:47:07 +01:00
|
|
|
{
|
2019-01-06 16:25:51 +01:00
|
|
|
// Checks if the target player is in an InstanceContent to avoid binding to a Zone or PublicContent
|
|
|
|
if( targetPlayer->getCurrentInstance() )
|
|
|
|
{
|
|
|
|
auto pInstanceContent = targetPlayer->getCurrentInstance()->getAsInstanceContent();
|
|
|
|
// Not sure if GMs actually get bound to an instance they jump to on retail. It's mostly here to avoid a crash for now
|
|
|
|
pInstanceContent->bindPlayer( player.getId() );
|
|
|
|
}
|
|
|
|
player.setInstance( targetPlayer->getCurrentZone()->getGuId() );
|
2017-09-11 18:59:50 +02:00
|
|
|
}
|
2017-12-08 11:46:47 +01:00
|
|
|
player.changePosition( targetActor->getPos().x, targetActor->getPos().y, targetActor->getPos().z,
|
2018-08-28 19:05:52 +02:00
|
|
|
targetActor->getRot() );
|
2019-01-06 01:47:07 +01:00
|
|
|
player.sendZoneInPackets( 0x00, 0x00, 0, 0, false );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Jumping to {0}", targetPlayer->getName() );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
case GmCommand::Call:
|
|
|
|
{
|
2018-07-10 20:22:46 +10:00
|
|
|
// We shouldn't be able to call a player into an instance, only call them out of one
|
|
|
|
if( player.getCurrentInstance() )
|
|
|
|
{
|
2018-08-29 21:40:59 +02:00
|
|
|
player.sendUrgent( "You are unable to call a player while bound to a battle instance." );
|
|
|
|
return;
|
2018-07-10 20:22:46 +10:00
|
|
|
}
|
2019-01-05 18:50:27 +01:00
|
|
|
targetPlayer->prepareZoning( player.getZoneId(), true, 1, 0 );
|
|
|
|
if( targetPlayer->getCurrentInstance() )
|
|
|
|
{
|
|
|
|
targetPlayer->exitInstance();
|
|
|
|
}
|
2019-01-06 16:25:51 +01:00
|
|
|
if( targetPlayer->getCurrentZone()->getGuId() != player.getCurrentZone()->getGuId() )
|
2019-01-05 18:50:27 +01:00
|
|
|
{
|
2019-01-06 16:25:51 +01:00
|
|
|
targetPlayer->setInstance( player.getCurrentZone()->getGuId() );
|
2019-01-05 18:50:27 +01:00
|
|
|
}
|
2018-02-22 18:12:36 +01:00
|
|
|
targetPlayer->changePosition( player.getPos().x, player.getPos().y, player.getPos().z, player.getRot() );
|
2019-01-06 01:47:07 +01:00
|
|
|
targetPlayer->sendZoneInPackets( 0x00, 0x00, 0, 0, false );
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendNotice( "Calling {0}", targetPlayer->getName() );
|
2018-01-20 01:56:00 +11:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
|
|
|
default:
|
2019-01-06 00:26:26 +01:00
|
|
|
player.sendUrgent( "GM2 Command not implemented: {0}", commandId );
|
2017-09-11 18:59:50 +02:00
|
|
|
break;
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2017-09-11 18:59:50 +02:00
|
|
|
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|