1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

minor cleanup of actionResultBuilder

This commit is contained in:
Mordred 2023-03-13 23:26:50 +01:00
parent f1cd218e85
commit 658d2fa7aa
3 changed files with 21 additions and 14 deletions

View file

@ -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 );

View file

@ -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... );
}
}

View file

@ -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... );
}
}