1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 15:17:46 +00:00

proper action type handling

This commit is contained in:
NotAdam 2019-02-09 19:26:31 +11:00
parent 2d9baddb33
commit d144da7c28
3 changed files with 65 additions and 20 deletions

View file

@ -16,30 +16,32 @@ World::Manager::ActionMgr::ActionMgr( Sapphire::FrameworkPtr pFw ) :
} }
void World::Manager::ActionMgr::handleAoEPlayerAction( Entity::Player& player, uint8_t type, void World::Manager::ActionMgr::handleAoEPlayerAction( Entity::Player& player, uint32_t actionId,
uint32_t actionId, Data::ActionPtr actionData, Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos )
Common::FFXIVARR_POSITION3 pos )
{ {
player.sendDebug( "got aoe act: {0}", actionData->name ); player.sendDebug( "got aoe act: {0}", actionData->name );
auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() ); auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() );
action->setType( static_cast< Common::HandleActionType >( type ) );
action->setPos( pos ); action->setPos( pos );
bootstrapAction( player, action, *actionData ); bootstrapAction( player, action, *actionData );
} }
void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint8_t type, void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId,
uint32_t actionId, Data::ActionPtr actionData, uint64_t targetId ) Data::ActionPtr actionData, uint64_t targetId )
{ {
player.sendDebug( "got act: {0}", actionData->name ); player.sendDebug( "got act: {0}", actionData->name );
auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() ); auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() );
action->setType( static_cast< Common::HandleActionType >( type ) );
bootstrapAction( player, action, *actionData ); bootstrapAction( player, action, *actionData );
} }
void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemActionId )
{
player.sendDebug( "got item act: {0}", itemActionId );
}
void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player, void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
Action::ActionPtr currentAction, Action::ActionPtr currentAction,
Data::Action& actionData ) Data::Action& actionData )

View file

@ -18,11 +18,13 @@ namespace Sapphire::World::Manager
explicit ActionMgr( FrameworkPtr pFw ); explicit ActionMgr( FrameworkPtr pFw );
~ActionMgr() = default; ~ActionMgr() = default;
void handleTargetedPlayerAction( Entity::Player& player, uint8_t type, uint32_t actionId, void handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId,
Data::ActionPtr actionData, uint64_t targetId ); Data::ActionPtr actionData, uint64_t targetId );
void handleAoEPlayerAction( Entity::Player& player, uint8_t type, uint32_t actionId, void handleAoEPlayerAction( Entity::Player& player, uint32_t actionId,
Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos ); Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos );
void handleItemAction( Entity::Player& player, uint32_t itemActionId );
private: private:
void bootstrapAction( Entity::Player& player, Action::ActionPtr currentAction, Data::Action& actionData ); void bootstrapAction( Entity::Player& player, Action::ActionPtr currentAction, Data::Action& actionData );
bool canPlayerUseAction( Entity::Player& player, Action::Action& currentAction, Data::Action& actionData ); bool canPlayerUseAction( Entity::Player& player, Action::Action& currentAction, Data::Action& actionData );

View file

@ -25,19 +25,53 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
const auto sequence = packet.data().sequence; const auto sequence = packet.data().sequence;
const auto targetId = packet.data().targetId; const auto targetId = packet.data().targetId;
player.sendDebug( "Skill type: {0}, sequence: {1}, actionId: {2}, targetId: {3}", type, sequence, actionId, targetId );
auto exdData = m_pFw->get< Data::ExdDataGenerated >(); auto exdData = m_pFw->get< Data::ExdDataGenerated >();
assert( exdData ); assert( exdData );
auto action = exdData->get< Data::Action >( actionId ); switch( type )
{
default:
{
player.sendDebug( "Skill type {0} not supported. Defaulting to normal action", type );
}
case Common::SkillType::Normal:
{
auto action = exdData->get< Data::Action >( actionId );
// ignore invalid actions
if( !action )
return;
auto actionMgr = pFw->get< World::Manager::ActionMgr >();
actionMgr->handleTargetedPlayerAction( player, actionId, action, targetId );
break;
}
case Common::SkillType::ItemAction:
{
auto item = exdData->get< Data::Item >( actionId );
if( !item )
return;
if( item->itemAction == 0 )
return;
player.sendDebug( "Got itemaction for act: {0}", item->itemAction );
break;
}
case Common::SkillType::MountSkill:
{
break;
}
}
// ignore invalid actions
if( !action )
return;
auto actionMgr = pFw->get< World::Manager::ActionMgr >();
actionMgr->handleTargetedPlayerAction( player, type, actionId, action, targetId );
player.sendDebug( "Skill type: {0}, sequence: {1}, actionId: {2}, targetId: {3}", type, sequence, actionId, targetId );
} }
void Sapphire::Network::GameConnection::aoeActionHandler( FrameworkPtr pFw, void Sapphire::Network::GameConnection::aoeActionHandler( FrameworkPtr pFw,
@ -51,6 +85,16 @@ void Sapphire::Network::GameConnection::aoeActionHandler( FrameworkPtr pFw,
const auto sequence = packet.data().sequence; const auto sequence = packet.data().sequence;
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
if( type != Common::SkillType::Normal )
{
player.sendDebug( "Skill type {0} not supported by aoe action handler!", type );
return;
}
player.sendDebug( "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
type, sequence, actionId, pos.x, pos.y, pos.z );
auto exdData = m_pFw->get< Data::ExdDataGenerated >(); auto exdData = m_pFw->get< Data::ExdDataGenerated >();
assert( exdData ); assert( exdData );
@ -61,8 +105,5 @@ void Sapphire::Network::GameConnection::aoeActionHandler( FrameworkPtr pFw,
return; return;
auto actionMgr = pFw->get< World::Manager::ActionMgr >(); auto actionMgr = pFw->get< World::Manager::ActionMgr >();
actionMgr->handleAoEPlayerAction( player, type, actionId, action, pos ); actionMgr->handleAoEPlayerAction( player, actionId, action, pos );
player.sendDebug( "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
type, sequence, actionId, pos.x, pos.y, pos.z );
} }