From f9abeee2f7fdbfdaa33c2b5e53e2b88c5e80da70 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Mon, 11 Feb 2019 11:47:04 +1100 Subject: [PATCH] fix effect packets not showing the action name after the initial cast --- .../Network/PacketDef/Zone/ServerZoneDef.h | 2 +- src/world/Action/Action.cpp | 17 +++++++++++++++-- src/world/Network/PacketWrappers/EffectPacket.h | 5 +++++ src/world/Territory/Zone.cpp | 5 +++++ src/world/Territory/Zone.h | 4 ++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index f6d33205..d24d8452 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -415,7 +415,7 @@ struct FFXIVIpcEffect : FFXIVIpcBasePacket< Effect > uint64_t animationTargetId; // who the animation targets uint32_t actionId; // what the casting player casts, shown in battle log/ui - uint32_t globalEffectCounter; // seems to only increment on retail? + uint32_t sequence; // seems to only increment on retail? float animationLockTime; // maybe? doesn't seem to do anything uint32_t someTargetId; // always 00 00 00 E0, 0x0E000000 is the internal def for INVALID TARGET ID diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 1a56ca55..3a07709e 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -8,6 +8,8 @@ #include "Actor/Player.h" #include "Actor/BNpc.h" +#include "Territory/Zone.h" + #include #include "Network/PacketWrappers/ActorControlPacket142.h" #include "Network/PacketWrappers/ActorControlPacket143.h" @@ -293,11 +295,22 @@ void Sapphire::Action::Action::buildEffectPackets() { auto& packetData = m_effects[ static_cast< EffectPacketIdentity >( i ) ]; - if( packetData.m_hitActors.size() == 1 ) + auto actorsHit = packetData.m_hitActors.size(); + if( actorsHit == 0 ) + continue; + + // get effect sequence + auto zone = m_pSource->getCurrentZone(); + assert( zone ); + + auto sequence = zone->getNextEffectSequence(); + + if( actorsHit == 1 ) { // send normal effect auto effectPacket = std::make_shared< Network::Packets::Server::EffectPacket >( m_pSource->getId(), m_pTarget->getId(), getId() ); effectPacket->setTargetActor( packetData.m_hitActors[ 0 ] ); + effectPacket->setSequence( sequence ); effectPacket->setDisplayType( Common::ActionEffectDisplayType::ShowActionName ); for( auto& effect : packetData.m_entries ) @@ -307,7 +320,7 @@ void Sapphire::Action::Action::buildEffectPackets() m_pSource->sendToInRangeSet( effectPacket, true ); } - else if( packetData.m_hitActors.size() > 1 ) + else { // todo: aoe effects } diff --git a/src/world/Network/PacketWrappers/EffectPacket.h b/src/world/Network/PacketWrappers/EffectPacket.h index 3be90b37..ae9df28a 100644 --- a/src/world/Network/PacketWrappers/EffectPacket.h +++ b/src/world/Network/PacketWrappers/EffectPacket.h @@ -63,6 +63,11 @@ namespace Sapphire::Network::Packets::Server FFXIVPacketBase::setTargetActor( targetId ); } + + void setSequence( uint32_t sequence ) + { + m_data.sequence = sequence; + } }; } diff --git a/src/world/Territory/Zone.cpp b/src/world/Territory/Zone.cpp index 4e62c898..bf2b43ac 100644 --- a/src/world/Territory/Zone.cpp +++ b/src/world/Territory/Zone.cpp @@ -864,3 +864,8 @@ void Sapphire::Zone::updateSpawnPoints() } +uint32_t Sapphire::Zone::getNextEffectSequence() +{ + return m_effectCounter++; +} + diff --git a/src/world/Territory/Zone.h b/src/world/Territory/Zone.h index 1e0d359f..d17ce563 100644 --- a/src/world/Territory/Zone.h +++ b/src/world/Territory/Zone.h @@ -63,6 +63,8 @@ namespace Sapphire std::vector< Entity::SpawnGroup > m_spawnGroups; + uint32_t m_effectCounter; + public: Zone(); @@ -161,6 +163,8 @@ namespace Sapphire InstanceContentPtr getAsInstanceContent(); void updateSpawnPoints(); + + uint32_t getNextEffectSequence(); }; }