From ffdbed72ce04680f278cca81bbc202bf798cf5d9 Mon Sep 17 00:00:00 2001 From: Mordred Date: Tue, 28 Feb 2023 22:30:54 +0100 Subject: [PATCH] More cleanup around actions --- src/common/Common.h | 24 +++++++++++++++---- .../Network/PacketDef/Zone/ServerZoneDef.h | 5 ++-- src/world/Action/Action.cpp | 9 +------ src/world/Action/Action.h | 4 ++-- src/world/Action/EventItemAction.cpp | 6 ++--- src/world/Action/EventItemAction.h | 3 +-- src/world/Action/ItemManipulationAction.h | 2 +- src/world/Action/MountAction.cpp | 5 ++-- src/world/Network/GameConnection.cpp | 2 +- src/world/Network/Handlers/ActionHandler.cpp | 19 +++++++-------- 10 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/common/Common.h b/src/common/Common.h index 7309ef11..72adb008 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -1529,14 +1529,28 @@ namespace Sapphire::Common Visor = 0x40, }; - enum SkillType : uint8_t + enum ActionKind : uint8_t { - Normal = 0x1, - ItemAction = 0x2, - EventItem = 0x3, - MountSkill = 0xD, + ACTION_KIND_NOTHING = 0x0, + ACTION_KIND_NORMAL = 0x1, + ACTION_KIND_ITEM = 0x2, + 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 { HousePermit, diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 2fea66f4..694f9b1c 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -469,8 +469,8 @@ namespace Sapphire::Network::Packets::WorldPackets::Server uint8_t Type; }; - struct IntegrityStatus { - + struct IntegrityStatus + { uint8_t Slot; uint8_t __padding1; uint16_t Id; @@ -599,6 +599,7 @@ namespace Sapphire::Network::Packets::WorldPackets::Server uint8_t TargetCount; uint32_t BallistaEntityId; Common::CalcResult CalcResult[16]; + uint32_t Padding; uint64_t Target[16]; uint16_t TargetPos[3]; }; diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 6a87160e..ff092f79 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -41,9 +41,6 @@ using namespace Sapphire::World; 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( 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_interruptType( Common::ActionInterruptType::None ), 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: { auto filter = std::make_shared< World::Util::ActorFilterSingleTarget >( static_cast< uint32_t >( m_targetId ) ); - addActorFilter( filter ); - break; } case Common::CastType::CircularAOE: { auto filter = std::make_shared< World::Util::ActorFilterInRange >( m_pos, m_effectRange ); - addActorFilter( filter ); - break; } diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index e254253c..04468115 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -15,11 +15,11 @@ namespace Sapphire::World::Action public: - Action(); + Action() = default; 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 ); - virtual ~Action(); + virtual ~Action() = default; uint32_t getId() const; diff --git a/src/world/Action/EventItemAction.cpp b/src/world/Action/EventItemAction.cpp index af24f887..1da6ffa5 100644 --- a/src/world/Action/EventItemAction.cpp +++ b/src/world/Action/EventItemAction.cpp @@ -27,15 +27,15 @@ using namespace Sapphire::Network::ActorControl; EventItemAction::EventItemAction( Sapphire::Entity::CharaPtr source, uint32_t eventItemId, 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_eventItem = eventItemId; m_pSource = std::move( source ); - m_sequence = sequence; + m_requestId = requestId; m_targetId = targetId; m_interruptType = Common::ActionInterruptType::None; - m_actionKind = Common::SkillType::EventItem; + m_actionKind = Common::ActionKind::ACTION_KIND_EVENT_ITEM; } bool EventItemAction::init() diff --git a/src/world/Action/EventItemAction.h b/src/world/Action/EventItemAction.h index e4966f67..b171a7ab 100644 --- a/src/world/Action/EventItemAction.h +++ b/src/world/Action/EventItemAction.h @@ -15,7 +15,7 @@ namespace Sapphire::World::Action { public: 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; @@ -29,6 +29,5 @@ namespace Sapphire::World::Action private: std::shared_ptr< Excel::ExcelStruct< Excel::EventItem > > m_eventItemAction; uint32_t m_eventItem; - uint32_t m_sequence; }; } \ No newline at end of file diff --git a/src/world/Action/ItemManipulationAction.h b/src/world/Action/ItemManipulationAction.h index 003d6f40..cbccd70c 100644 --- a/src/world/Action/ItemManipulationAction.h +++ b/src/world/Action/ItemManipulationAction.h @@ -9,7 +9,7 @@ namespace Sapphire::World::Action { public: ItemManipulationAction( Entity::CharaPtr source, uint32_t actionId, uint16_t requestId, - std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData, uint32_t delayTime ); + std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData, uint32_t delayTime ); virtual ~ItemManipulationAction() = default; void start() override; diff --git a/src/world/Action/MountAction.cpp b/src/world/Action/MountAction.cpp index ef8de7da..2ef1d7a9 100644 --- a/src/world/Action/MountAction.cpp +++ b/src/world/Action/MountAction.cpp @@ -26,7 +26,7 @@ MountAction::MountAction( Sapphire::Entity::CharaPtr source, uint16_t mountId, u Action::Action( source, 4, sequence, actionData ), m_mountId( mountId ) { - m_actionKind = Common::SkillType::MountSkill; + m_actionKind = Common::ActionKind::ACTION_KIND_MOUNT; } bool MountAction::preCheck() @@ -58,8 +58,7 @@ void MountAction::start() data.TargetPos[ 2 ] = Common::Util::floatToUInt16( pos.z ); data.Dir = m_pSource->getRot(); server().queueForPlayers( m_pSource->getInRangePlayerIds( true ), castPacket ); - - Common::Service< World::Manager::PlayerMgr >::ref().setCondition( *player, Common::PlayerCondition::Casting ); + playerMgr().setCondition( *player, Common::PlayerCondition::Casting ); auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 ); server().queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt ); diff --git a/src/world/Network/GameConnection.cpp b/src/world/Network/GameConnection.cpp index 5a64975b..72d8821a 100644 --- a/src/world/Network/GameConnection.cpp +++ b/src/world/Network/GameConnection.cpp @@ -185,7 +185,7 @@ void GameConnection::onAccept( const std::string& host, uint16_t port ) void GameConnection::onDisconnect() { if( m_pSession ) - Logger::debug( "[{0}] Disconnect {1}:{2}\"", m_pSession->getId() ); + Logger::debug( "[{0}] Disconnected", m_pSession->getId() ); else Logger::debug( "Disconnect of lost session." ); m_pSession.reset(); diff --git a/src/world/Network/Handlers/ActionHandler.cpp b/src/world/Network/Handlers/ActionHandler.cpp index 75999043..379c387d 100644 --- a/src/world/Network/Handlers/ActionHandler.cpp +++ b/src/world/Network/Handlers/ActionHandler.cpp @@ -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 ); } - case Common::SkillType::Normal: + case Common::ActionKind::ACTION_KIND_NORMAL: { auto action = exdData.getRow< Excel::Action >( actionId ); @@ -56,7 +56,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P break; } - case Common::SkillType::ItemAction: + case Common::ActionKind::ACTION_KIND_ITEM: { auto item = exdData.getRow< Excel::Item >( actionId ); if( !item ) @@ -74,7 +74,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P break; } - case Common::SkillType::EventItem: + case Common::ActionKind::ACTION_KIND_EVENT_ITEM: { auto action = exdData.getRow< Excel::EventItem >( actionId ); assert( action ); @@ -82,7 +82,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P break; } - case Common::SkillType::MountSkill: + case Common::ActionKind::ACTION_KIND_MOUNT: { auto action = exdData.getRow< Excel::Action >( 4 ); 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, - Entity::Player& player ) +void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets::FFXIVARR_PACKET_RAW& inPacket, 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 requestId = packet.data().RequestId; const auto pos = packet.data().Pos; // 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 ); return; } 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(); @@ -124,5 +123,5 @@ void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets return; auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref(); - actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, sequence ); + actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, requestId ); }