1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-04 17:57:47 +00:00

More cleanup around actions

This commit is contained in:
Mordred 2023-02-28 22:30:54 +01:00
parent 0a9f5da1d3
commit ffdbed72ce
10 changed files with 42 additions and 37 deletions

View file

@ -1529,14 +1529,28 @@ namespace Sapphire::Common
Visor = 0x40, Visor = 0x40,
}; };
enum SkillType : uint8_t enum ActionKind : uint8_t
{ {
Normal = 0x1, ACTION_KIND_NOTHING = 0x0,
ItemAction = 0x2, ACTION_KIND_NORMAL = 0x1,
EventItem = 0x3, ACTION_KIND_ITEM = 0x2,
MountSkill = 0xD, ACTION_KIND_EVENT_ITEM = 0x3,
ACTION_KIND_EVENT_ACTION = 0x4,
ACTION_KIND_GENERAL = 0x5,
ACTION_KIND_BUDDY = 0x6,
ACTION_KIND_COMMAND = 0x7,
ACTION_KIND_COMPANION = 0x8,
ACTION_KIND_CRAFT = 0x9,
ACTION_KIND_FISHING = 0xA,
ACTION_KIND_PET = 0xB,
ACTION_KIND_COMPANY_ACTION = 0xC,
ACTION_KIND_MOUNT = 0xD,
ACTION_KIND_PVP_ACTION = 0xE,
ACTION_KIND_FIELD_MARKER = 0xF,
}; };
enum HouseExteriorSlot enum HouseExteriorSlot
{ {
HousePermit, HousePermit,

View file

@ -469,8 +469,8 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
uint8_t Type; uint8_t Type;
}; };
struct IntegrityStatus { struct IntegrityStatus
{
uint8_t Slot; uint8_t Slot;
uint8_t __padding1; uint8_t __padding1;
uint16_t Id; uint16_t Id;
@ -599,6 +599,7 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
uint8_t TargetCount; uint8_t TargetCount;
uint32_t BallistaEntityId; uint32_t BallistaEntityId;
Common::CalcResult CalcResult[16]; Common::CalcResult CalcResult[16];
uint32_t Padding;
uint64_t Target[16]; uint64_t Target[16];
uint16_t TargetPos[3]; uint16_t TargetPos[3];
}; };

View file

@ -41,9 +41,6 @@ using namespace Sapphire::World;
using namespace Sapphire::World::Manager; using namespace Sapphire::World::Manager;
Action::Action::Action() = default;
Action::Action::~Action() = default;
Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId ) : Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId ) :
Action( std::move( caster ), actionId, requestId, nullptr ) Action( std::move( caster ), actionId, requestId, nullptr )
{ {
@ -58,7 +55,7 @@ Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t req
m_startTime( 0 ), m_startTime( 0 ),
m_interruptType( Common::ActionInterruptType::None ), m_interruptType( Common::ActionInterruptType::None ),
m_requestId( requestId ), m_requestId( requestId ),
m_actionKind( Common::SkillType::Normal ) m_actionKind( Common::ActionKind::ACTION_KIND_NORMAL )
{ {
} }
@ -798,18 +795,14 @@ void Action::Action::addDefaultActorFilters()
case Common::CastType::Type3: case Common::CastType::Type3:
{ {
auto filter = std::make_shared< World::Util::ActorFilterSingleTarget >( static_cast< uint32_t >( m_targetId ) ); auto filter = std::make_shared< World::Util::ActorFilterSingleTarget >( static_cast< uint32_t >( m_targetId ) );
addActorFilter( filter ); addActorFilter( filter );
break; break;
} }
case Common::CastType::CircularAOE: case Common::CastType::CircularAOE:
{ {
auto filter = std::make_shared< World::Util::ActorFilterInRange >( m_pos, m_effectRange ); auto filter = std::make_shared< World::Util::ActorFilterInRange >( m_pos, m_effectRange );
addActorFilter( filter ); addActorFilter( filter );
break; break;
} }

View file

@ -15,11 +15,11 @@ namespace Sapphire::World::Action
public: public:
Action(); Action() = default;
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId ); Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId );
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId, std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData ); Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId, std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData );
virtual ~Action(); virtual ~Action() = default;
uint32_t getId() const; uint32_t getId() const;

View file

@ -27,15 +27,15 @@ using namespace Sapphire::Network::ActorControl;
EventItemAction::EventItemAction( Sapphire::Entity::CharaPtr source, uint32_t eventItemId, EventItemAction::EventItemAction( Sapphire::Entity::CharaPtr source, uint32_t eventItemId,
std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > eventItemActionData, std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > eventItemActionData,
uint32_t sequence, uint64_t targetId ) : m_eventItemAction( std::move( eventItemActionData ) ) uint32_t requestId, uint64_t targetId ) : m_eventItemAction( std::move( eventItemActionData ) )
{ {
m_id = eventItemId; m_id = eventItemId;
m_eventItem = eventItemId; m_eventItem = eventItemId;
m_pSource = std::move( source ); m_pSource = std::move( source );
m_sequence = sequence; m_requestId = requestId;
m_targetId = targetId; m_targetId = targetId;
m_interruptType = Common::ActionInterruptType::None; m_interruptType = Common::ActionInterruptType::None;
m_actionKind = Common::SkillType::EventItem; m_actionKind = Common::ActionKind::ACTION_KIND_EVENT_ITEM;
} }
bool EventItemAction::init() bool EventItemAction::init()

View file

@ -15,7 +15,7 @@ namespace Sapphire::World::Action
{ {
public: public:
EventItemAction( Entity::CharaPtr source, uint32_t eventItemId, std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > itemActionData, EventItemAction( Entity::CharaPtr source, uint32_t eventItemId, std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > itemActionData,
uint32_t sequence, uint64_t targetId ); uint32_t requestId, uint64_t targetId );
virtual ~EventItemAction() = default; virtual ~EventItemAction() = default;
@ -29,6 +29,5 @@ namespace Sapphire::World::Action
private: private:
std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > m_eventItemAction; std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > m_eventItemAction;
uint32_t m_eventItem; uint32_t m_eventItem;
uint32_t m_sequence;
}; };
} }

View file

@ -26,7 +26,7 @@ MountAction::MountAction( Sapphire::Entity::CharaPtr source, uint16_t mountId, u
Action::Action( source, 4, sequence, actionData ), Action::Action( source, 4, sequence, actionData ),
m_mountId( mountId ) m_mountId( mountId )
{ {
m_actionKind = Common::SkillType::MountSkill; m_actionKind = Common::ActionKind::ACTION_KIND_MOUNT;
} }
bool MountAction::preCheck() bool MountAction::preCheck()
@ -58,8 +58,7 @@ void MountAction::start()
data.TargetPos[ 2 ] = Common::Util::floatToUInt16( pos.z ); data.TargetPos[ 2 ] = Common::Util::floatToUInt16( pos.z );
data.Dir = m_pSource->getRot(); data.Dir = m_pSource->getRot();
server().queueForPlayers( m_pSource->getInRangePlayerIds( true ), castPacket ); server().queueForPlayers( m_pSource->getInRangePlayerIds( true ), castPacket );
playerMgr().setCondition( *player, Common::PlayerCondition::Casting );
Common::Service< World::Manager::PlayerMgr >::ref().setCondition( *player, Common::PlayerCondition::Casting );
auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 ); auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 );
server().queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt ); server().queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt );

View file

@ -185,7 +185,7 @@ void GameConnection::onAccept( const std::string& host, uint16_t port )
void GameConnection::onDisconnect() void GameConnection::onDisconnect()
{ {
if( m_pSession ) if( m_pSession )
Logger::debug( "[{0}] Disconnect {1}:{2}\"", m_pSession->getId() ); Logger::debug( "[{0}] Disconnected", m_pSession->getId() );
else else
Logger::debug( "Disconnect of lost session." ); Logger::debug( "Disconnect of lost session." );
m_pSession.reset(); m_pSession.reset();

View file

@ -39,7 +39,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
{ {
PlayerMgr::sendDebug( player, "Skill type {0} not supported. Defaulting to normal action", type ); PlayerMgr::sendDebug( player, "Skill type {0} not supported. Defaulting to normal action", type );
} }
case Common::SkillType::Normal: case Common::ActionKind::ACTION_KIND_NORMAL:
{ {
auto action = exdData.getRow< Excel::Action >( actionId ); auto action = exdData.getRow< Excel::Action >( actionId );
@ -56,7 +56,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
break; break;
} }
case Common::SkillType::ItemAction: case Common::ActionKind::ACTION_KIND_ITEM:
{ {
auto item = exdData.getRow< Excel::Item >( actionId ); auto item = exdData.getRow< Excel::Item >( actionId );
if( !item ) if( !item )
@ -74,7 +74,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
break; break;
} }
case Common::SkillType::EventItem: case Common::ActionKind::ACTION_KIND_EVENT_ITEM:
{ {
auto action = exdData.getRow< Excel::EventItem >( actionId ); auto action = exdData.getRow< Excel::EventItem >( actionId );
assert( action ); assert( action );
@ -82,7 +82,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
break; break;
} }
case Common::SkillType::MountSkill: case Common::ActionKind::ACTION_KIND_MOUNT:
{ {
auto action = exdData.getRow< Excel::Action >( 4 ); auto action = exdData.getRow< Excel::Action >( 4 );
assert( action ); assert( action );
@ -95,25 +95,24 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
} }
void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
Entity::Player& player )
{ {
const auto packet = ZoneChannelPacket< FFXIVIpcSelectGroundActionRequest >( inPacket ); const auto packet = ZoneChannelPacket< FFXIVIpcSelectGroundActionRequest >( inPacket );
const auto type = packet.data().ActionKind; const auto type = packet.data().ActionKind;
const auto actionId = packet.data().ActionKey; const auto actionId = packet.data().ActionKey;
const auto sequence = packet.data().RequestId; const auto requestId = packet.data().RequestId;
const auto pos = packet.data().Pos; const auto pos = packet.data().Pos;
// todo: find out if there are any other action types which actually use this handler // todo: find out if there are any other action types which actually use this handler
if( type != Common::SkillType::Normal ) if( type != Common::ActionKind::ACTION_KIND_NORMAL )
{ {
PlayerMgr::sendDebug( player, "Skill type {0} not supported by aoe action handler!", type ); PlayerMgr::sendDebug( player, "Skill type {0} not supported by aoe action handler!", type );
return; return;
} }
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}", PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
type, sequence, actionId, pos.x, pos.y, pos.z ); type, requestId, actionId, pos.x, pos.y, pos.z );
auto& exdData = Common::Service< Data::ExdData >::ref(); auto& exdData = Common::Service< Data::ExdData >::ref();
@ -124,5 +123,5 @@ void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets
return; return;
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref(); auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, sequence ); actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, requestId );
} }