2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
|
|
|
#include <Network/CommonNetwork.h>
|
|
|
|
#include <Network/GamePacketNew.h>
|
|
|
|
#include <Logging/Logger.h>
|
|
|
|
#include <Network/PacketContainer.h>
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
2018-03-02 07:22:25 -03:00
|
|
|
|
|
|
|
#include "Zone/TerritoryMgr.h"
|
|
|
|
#include "Zone/Zone.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
|
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
|
|
|
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
|
|
|
|
|
|
|
#include "Forwards.h"
|
2018-03-02 07:22:25 -03:00
|
|
|
#include "Framework.h"
|
|
|
|
#include "Session.h"
|
|
|
|
|
2017-08-17 00:07:42 +02:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
extern Core::Framework g_framework;
|
2017-08-17 00:07:42 +02:00
|
|
|
|
|
|
|
using namespace Core::Common;
|
|
|
|
using namespace Core::Network::Packets;
|
|
|
|
using namespace Core::Network::Packets::Server;
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::cfDutyInfoRequest( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-17 00:07:42 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcCFDutyInfo > dutyInfoPacket( player.getId() );
|
2017-08-17 00:07:42 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
auto penaltyMinutes = player.getCFPenaltyMinutes();
|
2017-08-19 11:28:04 +09:00
|
|
|
if (penaltyMinutes > 255)
|
|
|
|
{
|
|
|
|
// cap it since it's uint8_t in packets
|
|
|
|
penaltyMinutes = 255;
|
|
|
|
}
|
|
|
|
dutyInfoPacket.data().penaltyTime = penaltyMinutes;
|
|
|
|
|
|
|
|
queueOutPacket( dutyInfoPacket );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcCFPlayerInNeed > inNeedsPacket( player.getId() );
|
2017-08-19 11:28:04 +09:00
|
|
|
queueOutPacket( inNeedsPacket );
|
2017-08-17 00:07:42 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::cfRegisterDuty( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player)
|
2017-08-17 00:07:42 +02:00
|
|
|
{
|
2017-08-19 11:28:04 +09:00
|
|
|
// TODO use for loop for this
|
2018-02-05 01:55:10 +11:00
|
|
|
auto contentId1 = inPacket.getValAt< uint16_t >( 0x2E );
|
|
|
|
auto contentId2 = inPacket.getValAt< uint16_t >( 0x30 );
|
|
|
|
auto contentId3 = inPacket.getValAt< uint16_t >( 0x32 );
|
|
|
|
auto contentId4 = inPacket.getValAt< uint16_t >( 0x34 );
|
|
|
|
auto contentId5 = inPacket.getValAt< uint16_t >( 0x36 );
|
2017-08-19 11:28:04 +09:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug("Duty register request");
|
2018-02-05 01:55:10 +11:00
|
|
|
player.sendDebug("ContentId1: " + std::to_string(contentId1));
|
|
|
|
player.sendDebug("ContentId2: " + std::to_string(contentId2));
|
|
|
|
player.sendDebug("ContentId3: " + std::to_string(contentId3));
|
|
|
|
player.sendDebug("ContentId4: " + std::to_string(contentId4));
|
|
|
|
player.sendDebug("ContentId5: " + std::to_string(contentId5));
|
2017-08-19 11:28:04 +09:00
|
|
|
|
|
|
|
// let's cancel it because otherwise you can't register it again
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcCFNotify > cfCancelPacket( player.getId() );
|
2017-08-19 11:28:04 +09:00
|
|
|
cfCancelPacket.data().state1 = 3;
|
|
|
|
cfCancelPacket.data().state2 = 1; // Your registration is withdrawn.
|
|
|
|
queueOutPacket( cfCancelPacket );
|
2018-02-05 01:55:10 +11:00
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
auto cfCondition = g_framework.getExdDataGen().get< Core::Data::ContentFinderCondition >( contentId1 );
|
2018-02-05 01:55:10 +11:00
|
|
|
if( !cfCondition )
|
|
|
|
return;
|
|
|
|
|
2018-03-02 07:22:25 -03:00
|
|
|
auto instance = g_framework.getTerritoryMgr().createInstanceContent( cfCondition->instanceContent );
|
2018-02-05 01:55:10 +11:00
|
|
|
if( !instance )
|
|
|
|
return;
|
|
|
|
|
|
|
|
player.sendDebug( "Created instance with id: " + std::to_string( instance->getGuId() ) );
|
|
|
|
|
|
|
|
player.setInstance( instance );
|
2017-08-17 00:07:42 +02:00
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::cfRegisterRoulette( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player)
|
2017-08-17 00:07:42 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug("Roulette register");
|
2017-08-17 00:07:42 +02:00
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::cfDutyAccepted( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player)
|
2017-08-17 00:07:42 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug("TODO: Duty accept");
|
2017-08-17 00:07:42 +02:00
|
|
|
}
|