1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00
sapphire/src/world/Network/Handlers/CFHandlers.cpp

129 lines
4.6 KiB
C++
Raw Normal View History

2018-03-06 22:22:19 +01:00
#include <Common.h>
#include <Network/CommonNetwork.h>
2019-03-08 15:34:38 +01:00
#include <Network/GamePacket.h>
2018-03-06 22:22:19 +01:00
#include <Network/PacketContainer.h>
#include <Exd/ExdData.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
#include <Network/PacketDef/Zone/ClientZoneDef.h>
#include "Manager/TerritoryMgr.h"
#include "Manager/PlayerMgr.h"
#include "Territory/InstanceContent.h"
#include "Network/GameConnection.h"
#include "Network/PacketWrappers/ServerNoticePacket.h"
2023-02-20 15:25:57 +01:00
#include "Network/PacketWrappers/ConditionPacket.h"
#include "ContentFinder/ContentFinder.h"
#include "Session.h"
using namespace Sapphire::Common;
using namespace Sapphire::Network::Packets;
using namespace Sapphire::Network::Packets::WorldPackets;
using namespace Sapphire::World::Manager;
2017-08-17 00:07:42 +02:00
void Sapphire::Network::GameConnection::cfRequestPenalties( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
2017-08-17 00:07:42 +02:00
{
auto dutyInfoPacket = makeZonePacket< Server::FFXIVIpcResponsePenalties >( player.getId() );
auto penaltyMinutes = player.getCFPenaltyMinutes();
if( penaltyMinutes > 255 )
{
// cap it since it's uint8_t in packets
penaltyMinutes = 255;
}
dutyInfoPacket->data().penalties[ 0 ] = static_cast< uint8_t >( penaltyMinutes ); //TODO: What is the second array for?
queueOutPacket( dutyInfoPacket );
}
void Sapphire::Network::GameConnection::requestBonus( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
auto inNeedsPacket = makeZonePacket< Server::FFXIVIpcContentBonus >( player.getId() );
queueOutPacket( inNeedsPacket );
2017-08-17 00:07:42 +02:00
}
void Sapphire::Network::GameConnection::findContent( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
2017-08-17 00:07:42 +02:00
{
auto& teriMgr = Common::Service< TerritoryMgr >::ref();
auto& contentFinder = Common::Service< World::ContentFinder >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcFindContent >( inPacket );
PlayerMgr::sendDebug( player, "Duty register request for terriId#{0}", packet.data().territoryType );
auto contentId = teriMgr.getInstanceContentId( packet.data().territoryType );
if( contentId == 0 )
return;
2017-08-17 00:07:42 +02:00
2022-02-18 19:41:11 +01:00
contentFinder.registerContentRequest( player, contentId, packet.data().flags );
2017-08-17 00:07:42 +02:00
}
void Sapphire::Network::GameConnection::find5Contents( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
2017-08-17 00:07:42 +02:00
{
auto& exdData = Common::Service< Data::ExdData >::ref();
auto& contentFinder = Common::Service< World::ContentFinder >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcFind5Contents >( inPacket );
std::set< uint16_t > selectedContent;
2023-01-17 12:54:42 +01:00
for( auto territoryType : packet.data().territoryTypes )
if( territoryType != 0 )
selectedContent.insert( territoryType );
std::vector< uint32_t > idList;
auto contentFinderList = exdData.getRows< Excel::InstanceContent >();
for( const auto& [ id, instanceContent ] : contentFinderList )
{
if( selectedContent.count( instanceContent->data().TerritoryType ) )
{
idList.push_back( id );
}
}
if( !idList.empty() )
contentFinder.registerContentsRequest( player, idList );
}
void Sapphire::Network::GameConnection::findContentAsRandom( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
auto& contentFinder = Common::Service< World::ContentFinder >::ref();
const auto packet = ZoneChannelPacket< Client::FFXIVIpcFindContentAsRandom >( inPacket );
contentFinder.registerRandomContentRequest( player, packet.data().randomContentType );
}
void Sapphire::Network::GameConnection::cfDutyAccepted( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
PlayerMgr::sendDebug( player, "TODO: Duty accept" );
}
void Sapphire::Network::GameConnection::cancelFindContent( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
2020-05-01 20:19:10 +09:00
{
const auto packet = ZoneChannelPacket< Client::FFXIVIpcCancelFindContent >( inPacket );
PlayerMgr::sendDebug( player, "CancelFindContent: reason: {}", packet.data().cause );
auto& contentFinder = Common::Service< World::ContentFinder >::ref();
contentFinder.withdraw( player );
}
void Sapphire::Network::GameConnection::acceptContent( const Packets::FFXIVARR_PACKET_RAW& inPacket, Entity::Player& player )
{
const auto packet = ZoneChannelPacket< Client::FFXIVIpcAcceptContent >( inPacket );
PlayerMgr::sendDebug( player, "acceptContent: accept: {}, terriId: {}, terryType: {}",
packet.data().accept, packet.data().territoryId, packet.data().territoryType );
auto& contentFinder = Common::Service< World::ContentFinder >::ref();
2022-02-18 19:41:11 +01:00
if( packet.data().accept )
contentFinder.accept( player );
else
contentFinder.withdraw( player );
}