1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-25 11:07:45 +00:00

duty register rework

This commit is contained in:
collett 2021-08-09 21:19:57 +09:00
parent d8a411b302
commit ac0e246e11
4 changed files with 79 additions and 70 deletions

View file

@ -320,7 +320,7 @@ namespace Sapphire::Network::Packets
FinishLoadingHandler = 0x0217, // updated 5.58 FinishLoadingHandler = 0x0217, // updated 5.58
CFCommenceHandler = 0xF118, // updated 5.35 hotfix CFCommenceHandler = 0x02A3, // updated 5.58
CFCancelHandler = 0x00A9, // updated 5.58 CFCancelHandler = 0x00A9, // updated 5.58
CFRegisterDuty = 0x036A, // updated 5.58 CFRegisterDuty = 0x036A, // updated 5.58

View file

@ -452,6 +452,12 @@ struct FFXIVIpcSaveDataEventHandler :
Common::EventSaveData data; Common::EventSaveData data;
}; };
struct FFXIVIpcCFCommenceHandler :
FFXIVIpcBasePacket< CFCommenceHandler >
{
uint64_t param;
};
} }
#endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H #endif //_CORE_NETWORK_PACKETS_ZONE_CLIENT_IPC_H

View file

@ -121,7 +121,7 @@ Sapphire::Network::GameConnection::GameConnection( Sapphire::Network::HivePtr pH
setZoneHandler( ClientZoneIpcType::CFRegisterDuty, "CFRegisterDuty", &GameConnection::cfRegisterDuty ); setZoneHandler( ClientZoneIpcType::CFRegisterDuty, "CFRegisterDuty", &GameConnection::cfRegisterDuty );
setZoneHandler( ClientZoneIpcType::CFRegisterRoulette, "CFRegisterRoulette", &GameConnection::cfRegisterRoulette ); setZoneHandler( ClientZoneIpcType::CFRegisterRoulette, "CFRegisterRoulette", &GameConnection::cfRegisterRoulette );
setZoneHandler( ClientZoneIpcType::CFCommenceHandler, "CFDutyAccepted", &GameConnection::cfDutyAccepted ); setZoneHandler( ClientZoneIpcType::CFCommenceHandler, "CFDutyAccepted", &GameConnection::cfDutyAccepted );
setZoneHandler( ClientZoneIpcType::CFCancelHandler, "CFCancel", &GameConnection::cfCancel ); //setZoneHandler( ClientZoneIpcType::CFCancelHandler, "CFCancel", &GameConnection::cfCancel );
setZoneHandler( ClientZoneIpcType::ReqEquipDisplayFlagsChange, "ReqEquipDisplayFlagsChange", setZoneHandler( ClientZoneIpcType::ReqEquipDisplayFlagsChange, "ReqEquipDisplayFlagsChange",
&GameConnection::reqEquipDisplayFlagsHandler ); &GameConnection::reqEquipDisplayFlagsHandler );

View file

@ -12,6 +12,7 @@
#include "Network/GameConnection.h" #include "Network/GameConnection.h"
#include "Network/PacketWrappers/ServerNoticePacket.h" #include "Network/PacketWrappers/ServerNoticePacket.h"
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h" #include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
#include "Network/PacketDef/Zone/ClientZoneDef.h"
#include "Session.h" #include "Session.h"
@ -43,9 +44,6 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( const Packets::FFXIVARR_
Entity::Player& player ) Entity::Player& player )
{ {
Packets::FFXIVARR_PACKET_RAW copy = inPacket; Packets::FFXIVARR_PACKET_RAW copy = inPacket;
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();
std::vector< uint16_t > selectedContent; std::vector< uint16_t > selectedContent;
for( uint32_t offset = 0x1E; offset <= 0x26; offset += 0x2 ) for( uint32_t offset = 0x1E; offset <= 0x26; offset += 0x2 )
@ -54,92 +52,96 @@ void Sapphire::Network::GameConnection::cfRegisterDuty( const Packets::FFXIVARR_
if( id == 0 ) if( id == 0 )
break; break;
player.sendDebug( "got contentId#{0}", id ); player.sendDebug( "got contentFinderConditionId#{0}", id );
selectedContent.push_back( id ); selectedContent.push_back( id );
} }
// todo: rand bias problem, will do for now tho // todo: rand bias problem, will do for now tho
auto index = static_cast< uint32_t >( std::rand() ) % selectedContent.size(); auto index = static_cast< uint32_t >( std::rand() ) % selectedContent.size();
auto contentId = selectedContent.at( index ); auto contentFinderConditionId = selectedContent.at( index );
player.sendDebug( "Duty register request for contentid#{0}", contentId ); player.sendDebug( "Duty register request for contentFinderConditionId#{0}", contentFinderConditionId );
player.m_cfNotifiedContent = contentFinderConditionId;
// let's cancel it because otherwise you can't register it again auto notify = makeZonePacket< FFXIVIpcCFNotify >( player.getId() );
/* notify->data().state1 = 8195;
auto cfCancelPacket = makeZonePacket< FFXIVIpcCFNotify >( player.getId() ); notify->data().param3 = 1;
cfCancelPacket->data().state1 = 3; notify->data().param4 = contentFinderConditionId;
cfCancelPacket->data().state2 = 1; // Your registration is withdrawn. player.queuePacket( notify );
queueOutPacket( cfCancelPacket );
*/
auto packet = makeZonePacket< FFXIVIpcCFCancel >( player.getId() );
packet->data().cancelReason = 890;
queueOutPacket( packet );
/*auto cfCondition = exdData.get< Sapphire::Data::ContentFinderCondition >( contentId );
if( !cfCondition )
return;*/
auto instance = teriMgr.createInstanceContent( /*cfCondition->content*/ contentId );
if( !instance )
return;
auto pInstance = instance->getAsInstanceContent();
pInstance->bindPlayer( player.getId() );
player.sendDebug( "Created instance with id#", instance->getGuId() );
auto sourceZoneGuId = player.getCurrentTerritory()->getGuId();
player.setInstance( instance );
if( player.isPartyLeader() )
{
player.foreachPartyMember( [ &player, &pInstance, sourceZoneGuId ]( Entity::PlayerPtr m )
{
if( m->getId() == player.getId() )
return;
if( m->hasStateFlag( PlayerStateFlag::InNpcEvent ) )
{
player.sendUrgent( "Cannot teleport {} to the instance, target in event.", m->getName() );
m->sendUrgent( "Too busy to join instance created by {}.", player.getName() );
return;
}
if( m->getCurrentTerritory()->getGuId() != sourceZoneGuId )
{
player.sendUrgent( "Cannot teleport {} to the instance, target in different zone.", m->getName() );
m->sendUrgent( "Too far to join instance created by {}.", player.getName() );
return;
}
player.sendUrgent( "Teleporting {} to the instance...", m->getName() );
m->sendUrgent( "Joining instance created by {}.", player.getName() );
pInstance->bindPlayer( m->getId() );
m->setInstance( pInstance );
} );
}
} }
void Sapphire::Network::GameConnection::cfRegisterRoulette( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Sapphire::Network::GameConnection::cfRegisterRoulette( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player ) Entity::Player& player )
{ {
/*
auto cfCancelPacket = makeZonePacket< FFXIVIpcCFNotify >( player.getId() );
cfCancelPacket->data().state1 = 3;
cfCancelPacket->data().state2 = 1; // Your registration is withdrawn.
queueOutPacket( cfCancelPacket );
*/
auto packet = makeZonePacket< FFXIVIpcCFCancel >( player.getId() ); auto packet = makeZonePacket< FFXIVIpcCFCancel >( player.getId() );
packet->data().cancelReason = 890; packet->data().cancelReason = 890;
queueOutPacket( packet ); queueOutPacket( packet );
player.sendDebug( "Roulette register" ); player.sendDebug( "Roulette register not implemented." );
} }
void Sapphire::Network::GameConnection::cfDutyAccepted( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Sapphire::Network::GameConnection::cfDutyAccepted( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player ) Entity::Player& player )
{ {
player.sendDebug( "TODO: Duty accept" ); const auto packetIn = ZoneChannelPacket< Client::FFXIVIpcCFCommenceHandler >( inPacket );
} if( packetIn.data().param == 0 )
{
// accept
if( player.m_cfNotifiedContent > 0 )
{
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
auto instance = teriMgr.createInstanceContent( player.m_cfNotifiedContent );
if( !instance )
return;
auto pInstance = instance->getAsInstanceContent();
pInstance->bindPlayer( player.getId() );
player.sendDebug( "Created instance with id#{}", instance->getGuId() );
player.prepareZoning( pInstance->getTerritoryTypeId(), true, 1, 0, 0, 1, 9 );
auto sourceZoneGuId = player.getCurrentTerritory()->getGuId();
player.setInstance( instance );
if( player.isPartyLeader() )
{
player.foreachPartyMember( [ &player, &pInstance, sourceZoneGuId ]( Entity::PlayerPtr m )
{
if( m->getId() == player.getId() )
return;
if( m->hasStateFlag( PlayerStateFlag::InNpcEvent ) )
{
player.sendUrgent( "Cannot teleport {} to the instance, target in event.", m->getName() );
m->sendUrgent( "Too busy to join instance created by {}.", player.getName() );
return;
}
if( m->getCurrentTerritory()->getGuId() != sourceZoneGuId )
{
player.sendUrgent( "Cannot teleport {} to the instance, target in different zone.", m->getName() );
m->sendUrgent( "Too far to join instance created by {}.", player.getName() );
return;
}
m->prepareZoning( pInstance->getTerritoryTypeId(), true, 1, 0, 0, 1, 9 );
player.sendUrgent( "Teleporting {} to the instance...", m->getName() );
m->sendUrgent( "Joining instance created by {}.", player.getName() );
pInstance->bindPlayer( m->getId() );
m->setInstance( pInstance );
} );
}
}
}
else
{
// cancel
player.m_cfNotifiedContent = 0;
auto packet = makeZonePacket< FFXIVIpcCFCancel >( player.getId() );
packet->data().cancelReason = 890;
queueOutPacket( packet );
}
}
/*
void Sapphire::Network::GameConnection::cfCancel( const Packets::FFXIVARR_PACKET_RAW& inPacket, void Sapphire::Network::GameConnection::cfCancel( const Packets::FFXIVARR_PACKET_RAW& inPacket,
Entity::Player& player ) Entity::Player& player )
{ {
@ -147,3 +149,4 @@ void Sapphire::Network::GameConnection::cfCancel( const Packets::FFXIVARR_PACKET
packet->data().cancelReason = 890; packet->data().cancelReason = 890;
queueOutPacket( packet ); queueOutPacket( packet );
} }
*/