diff --git a/src/world/Action/ActionResultBuilder.cpp b/src/world/Action/ActionResultBuilder.cpp index 898a7c18..d6bc36a4 100644 --- a/src/world/Action/ActionResultBuilder.cpp +++ b/src/world/Action/ActionResultBuilder.cpp @@ -124,19 +124,17 @@ std::shared_ptr< FFXIVPacketBase > ActionResultBuilder::createActionResultPacket if( targetCount > 1 ) // use AoeEffect packets { - auto actionResult = std::make_shared< EffectPacket >( m_sourceChara->getId(), targetList[ 0 ]->getId(), m_actionId ); + auto actionResult = makeEffectPacket( m_sourceChara->getId(), targetList[ 0 ]->getId(), m_actionId ); actionResult->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); actionResult->setRequestId( m_requestId ); actionResult->setResultId( m_resultId ); uint8_t targetIndex = 0; - for( auto it = m_actorResultsMap.begin(); it != m_actorResultsMap.end(); ++it ) + for( auto& [ actor, actorResultList ] : m_actorResultsMap ) { - // get all effect results for an actor - auto actorResultList = it->second; - if( it->first ) - taskMgr.queueTask( World::makeActionIntegrityTask( m_resultId, it->first, actorResultList, 300 ) ); + if( actor ) + taskMgr.queueTask( World::makeActionIntegrityTask( m_resultId, actor, actorResultList, 300 ) ); for( auto& result : actorResultList ) { @@ -157,23 +155,21 @@ std::shared_ptr< FFXIVPacketBase > ActionResultBuilder::createActionResultPacket else // use Effect for single target { uint32_t mainTargetId = targetList.empty() ? m_sourceChara->getId() : targetList[ 0 ]->getId(); - auto actionResult = std::make_shared< EffectPacket1 >( m_sourceChara->getId(), mainTargetId, m_actionId ); + auto actionResult = makeEffectPacket1( m_sourceChara->getId(), mainTargetId, m_actionId ); actionResult->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); actionResult->setRequestId( m_requestId ); actionResult->setResultId( m_resultId ); - for( auto it = m_actorResultsMap.begin(); it != m_actorResultsMap.end(); ++it ) + for( auto& [ actor, actorResultList ] : m_actorResultsMap ) { - // get all effect results for an actor - auto actorResultList = it->second; - - if( it->first ) - taskMgr.queueTask( World::makeActionIntegrityTask( m_resultId, it->first, actorResultList, 300 ) ); + if( actor ) + taskMgr.queueTask( World::makeActionIntegrityTask( m_resultId, actor, actorResultList, 300 ) ); for( auto& result : actorResultList ) { auto effect = result->getCalcResultParam(); - if( result->getTarget() == m_sourceChara && result->getCalcResultParam().Type != Common::ActionEffectType::CALC_RESULT_TYPE_SET_STATUS_ME ) + if( result->getTarget() == m_sourceChara && + result->getCalcResultParam().Type != Common::ActionEffectType::CALC_RESULT_TYPE_SET_STATUS_ME ) actionResult->addSourceEffect( effect ); else actionResult->addTargetEffect( effect ); diff --git a/src/world/Network/PacketWrappers/EffectPacket.h b/src/world/Network/PacketWrappers/EffectPacket.h index 82f73c1b..9e190a34 100644 --- a/src/world/Network/PacketWrappers/EffectPacket.h +++ b/src/world/Network/PacketWrappers/EffectPacket.h @@ -92,4 +92,10 @@ namespace Sapphire::Network::Packets::WorldPackets::Server uint8_t m_sourceEffectCount{ 0 }; }; + template< typename... Args > + std::shared_ptr< EffectPacket > makeEffectPacket( Args... args ) + { + return std::make_shared< EffectPacket >( args... ); + } + } \ No newline at end of file diff --git a/src/world/Network/PacketWrappers/EffectPacket1.h b/src/world/Network/PacketWrappers/EffectPacket1.h index 37393d37..b6752374 100644 --- a/src/world/Network/PacketWrappers/EffectPacket1.h +++ b/src/world/Network/PacketWrappers/EffectPacket1.h @@ -83,5 +83,10 @@ namespace Sapphire::Network::Packets::WorldPackets::Server uint8_t m_sourceEffectCount{ 0 }; }; + template< typename... Args > + std::shared_ptr< EffectPacket1 > makeEffectPacket1( Args... args ) + { + return std::make_shared< EffectPacket1 >( args... ); + } }