1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 15:17:46 +00:00
sapphire/src/world/Network/Handlers/ActionHandler.cpp

126 lines
4 KiB
C++
Raw Normal View History

2018-03-06 22:22:19 +01:00
#include <Common.h>
#include <Exd/ExdData.h>
2019-03-08 15:34:38 +01:00
#include <Network/GamePacket.h>
#include <Network/PacketDef/Zone/ClientZoneDef.h>
#include <Actor/Player.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
#include "Network/GameConnection.h"
#include "Manager/ActionMgr.h"
#include "Manager/PlayerMgr.h"
#include "Manager/EventMgr.h"
using namespace Sapphire::Common;
using namespace Sapphire::World::Manager;
using namespace Sapphire::Network::Packets;
using namespace Sapphire::Network::Packets::WorldPackets::Client;
void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player )
{
const auto packet = ZoneChannelPacket< FFXIVIpcActionRequest >( inPacket );
2018-06-28 00:07:07 +02:00
const auto type = packet.data().ActionKind;
const auto actionId = packet.data().ActionKey;
const auto sequence = packet.data().RequestId;
const auto targetId = packet.data().Target;
const auto itemSourceSlot = packet.data().Arg & 0xFFFF0000;
const auto itemSourceContainer = packet.data().Arg & 0x0000FFFF;
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, targetId: {3}", type, sequence, actionId, targetId );
2019-02-09 19:26:31 +11:00
auto& exdData = Common::Service< Data::ExdData >::ref();
2020-03-01 01:00:57 +11:00
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref();
2019-02-09 21:48:42 +11:00
2019-02-09 19:26:31 +11:00
switch( type )
{
default:
{
PlayerMgr::sendDebug( player, "Skill type {0} not supported. Defaulting to normal action", type );
2019-02-09 19:26:31 +11:00
}
case Common::SkillType::Normal:
{
auto action = exdData.getRow< Component::Excel::Action >( actionId );
2019-02-09 19:26:31 +11:00
// ignore invalid actions
if( !action )
return;
2020-03-01 01:00:57 +11:00
actionMgr.handleTargetedPlayerAction( player, actionId, action, targetId, sequence );
2019-02-09 19:26:31 +11:00
break;
}
case Common::SkillType::ItemAction:
{
auto item = exdData.getRow< Component::Excel::Item >( actionId );
2019-02-09 19:26:31 +11:00
if( !item )
return;
if( item->data().Action == 0 )
2019-02-09 19:26:31 +11:00
return;
auto itemAction = exdData.getRow< Component::Excel::ItemAction >( item->data().Action );
2019-02-09 21:48:42 +11:00
if( !itemAction )
return;
2020-03-01 01:00:57 +11:00
actionMgr.handleItemAction( player, actionId, itemAction, itemSourceSlot, itemSourceContainer );
2019-02-09 19:26:31 +11:00
break;
}
case Common::SkillType::EventItem:
{
auto action = exdData.getRow< Component::Excel::EventItem >( actionId );
assert( action );
actionMgr.handleEventItemAction( player, actionId, action, sequence, targetId );
break;
}
2019-02-09 19:26:31 +11:00
case Common::SkillType::MountSkill:
{
auto action = exdData.getRow< Component::Excel::Action >( 4 );
2020-01-23 22:36:01 +09:00
assert( action );
2020-03-01 01:00:57 +11:00
actionMgr.handleMountAction( player, static_cast< uint16_t >( actionId ), action, targetId, sequence );
2019-02-09 19:26:31 +11:00
break;
}
}
}
void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket,
2019-04-28 23:34:43 +02:00
Entity::Player& player )
{
const auto packet = ZoneChannelPacket< FFXIVIpcSelectGroundActionRequest >( inPacket );
const auto type = packet.data().ActionKind;
const auto actionId = packet.data().ActionKey;
const auto sequence = packet.data().RequestId;
const auto pos = packet.data().Pos;
2019-02-09 19:26:31 +11:00
// todo: find out if there are any other action types which actually use this handler
if( type != Common::SkillType::Normal )
{
PlayerMgr::sendDebug( player, "Skill type {0} not supported by aoe action handler!", type );
2019-02-09 19:26:31 +11:00
return;
}
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
2019-04-28 23:34:43 +02:00
type, sequence, actionId, pos.x, pos.y, pos.z );
2019-02-09 19:26:31 +11:00
auto& exdData = Common::Service< Data::ExdData >::ref();
auto action = exdData.getRow< Component::Excel::Action >( actionId );
// ignore invalid actions
if( !action )
return;
2020-03-01 01:00:57 +11:00
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, sequence );
}