2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Common.h>
|
|
|
|
#include <common/Network/CommonNetwork.h>
|
|
|
|
#include <common/Network/GamePacketNew.h>
|
|
|
|
#include <common/Logging/Logger.h>
|
|
|
|
#include <common/Network/PacketContainer.h>
|
|
|
|
#include <common/Network/PacketDef/Chat/ServerChatDef.h>
|
|
|
|
#include <common/Database/DatabaseDef.h>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/GameConnection.h"
|
|
|
|
|
|
|
|
#include "Session.h"
|
2018-01-27 23:52:49 +01:00
|
|
|
#include "ServerZone.h"
|
|
|
|
#include "Zone/TerritoryMgr.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Zone/Zone.h"
|
|
|
|
#include "Zone/ZonePosition.h"
|
|
|
|
|
|
|
|
#include "Network/PacketWrappers/InitUIPacket.h"
|
|
|
|
#include "Network/PacketWrappers/PingPacket.h"
|
|
|
|
#include "Network/PacketWrappers/MoveActorPacket.h"
|
|
|
|
#include "Network/PacketWrappers/ChatPacket.h"
|
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
|
|
|
#include "Network/PacketWrappers/EventStartPacket.h"
|
|
|
|
#include "Network/PacketWrappers/EventFinishPacket.h"
|
|
|
|
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
|
|
|
|
2018-01-28 11:16:34 +01:00
|
|
|
#include "DebugCommand/DebugCommandHandler.h"
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
|
|
|
#include "Inventory/Inventory.h"
|
|
|
|
#include "Forwards.h"
|
|
|
|
#include "Event/EventHelper.h"
|
|
|
|
#include "Action/Action.h"
|
|
|
|
#include "Action/ActionTeleport.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-10-27 00:10:13 +02:00
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
extern Core::Logger g_log;
|
|
|
|
extern Core::ServerZone g_serverZone;
|
2018-01-27 23:52:49 +01:00
|
|
|
extern Core::TerritoryMgr g_territoryMgr;
|
2018-01-28 11:16:34 +01:00
|
|
|
extern Core::DebugCommandHandler g_gameCommandMgr;
|
2017-08-08 13:53:47 +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::fcInfoReqHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
GamePacketPtr pPe( new GamePacket( 0xDD, 0x78, player.getId(), player.getId() ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
pPe->setValAt< uint8_t >( 0x48, 0x01 );
|
|
|
|
queueOutPacket( pPe );
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::setSearchInfoHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t inval = inPacket.getValAt< uint32_t >( 0x20 );
|
|
|
|
uint32_t inval1 = inPacket.getValAt< uint32_t >( 0x24 );
|
|
|
|
uint64_t status = inPacket.getValAt< uint64_t >( 0x20 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint8_t selectRegion = inPacket.getValAt< uint8_t >( 0x31 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setSearchInfo( selectRegion, 0, inPacket.getStringAt( 0x32 ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setOnlineStatusMask( status );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
if( player.isNewAdventurer() && !( inval & 0x01000000 ) )
|
2017-08-08 13:53:47 +02:00
|
|
|
// mark player as not new adventurer anymore
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setNewAdventurer( false );
|
2017-08-08 13:53:47 +02:00
|
|
|
else if( inval & 0x01000000 )
|
|
|
|
// mark player as new adventurer
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setNewAdventurer( true );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcSetOnlineStatus > statusPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
statusPacket.data().onlineStatusFlags = status;
|
|
|
|
queueOutPacket( statusPacket );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcSetSearchInfo > searchInfoPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
searchInfoPacket.data().onlineStatusFlags = status;
|
2017-12-08 11:46:47 +01:00
|
|
|
searchInfoPacket.data().selectRegion = player.getSearchSelectRegion();
|
|
|
|
strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
|
2017-08-08 13:53:47 +02:00
|
|
|
queueOutPacket( searchInfoPacket );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendToInRangeSet( ActorControlPacket142( player.getId(), SetStatusIcon,
|
|
|
|
static_cast< uint8_t >( player.getOnlineStatus() ) ), true );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::reqSearchInfoHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcInitSearchInfo > searchInfoPacket( player.getId() );
|
|
|
|
searchInfoPacket.data().onlineStatusFlags = player.getOnlineStatusMask();
|
|
|
|
searchInfoPacket.data().selectRegion = player.getSearchSelectRegion();
|
|
|
|
strcpy( searchInfoPacket.data().searchMessage, player.getSearchMessage() );
|
2017-08-08 13:53:47 +02:00
|
|
|
queueOutPacket( searchInfoPacket );
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::linkshellListHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcLinkshellList > linkshellListPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
queueOutPacket( linkshellListPacket );
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::updatePositionHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
// if the player is marked for zoning we no longer want to update his pos
|
2017-12-08 11:46:47 +01:00
|
|
|
if( player.isMarkedForZoning() )
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
struct testMov
|
|
|
|
{
|
|
|
|
uint32_t specialMovement : 23; // 0x00490FDA
|
|
|
|
uint32_t strafe : 7;
|
|
|
|
uint32_t moveBackward : 1;
|
|
|
|
uint32_t strafeRight : 1; // if 0, strafe left.
|
|
|
|
} IPC_OP_019A;
|
|
|
|
|
|
|
|
struct testMov1
|
|
|
|
{
|
|
|
|
uint16_t bit1 : 1; // 0x00490FDA
|
|
|
|
uint16_t bit2 : 1;
|
|
|
|
uint16_t bit3 : 1;
|
|
|
|
uint16_t bit4 : 1;
|
|
|
|
uint16_t bit5 : 1;
|
|
|
|
uint16_t bit6 : 1;
|
|
|
|
uint16_t bit7 : 1;
|
|
|
|
uint16_t bit8 : 1;
|
|
|
|
uint16_t bit9 : 1; // 0x00490FDA
|
|
|
|
uint16_t bit10 : 1;
|
|
|
|
uint16_t bit11 : 1;
|
|
|
|
uint16_t bit12 : 1;
|
|
|
|
uint16_t bit13 : 1;
|
|
|
|
uint16_t bit14 : 1;
|
|
|
|
uint16_t bit15 : 1;
|
|
|
|
uint16_t bit16 : 1;
|
|
|
|
} IPC_OP_019AB;
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint16_t flags = inPacket.getValAt<uint16_t>( 0x28 );
|
2017-08-08 13:53:47 +02:00
|
|
|
memcpy( &IPC_OP_019AB, &flags, 2 );
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t flags1 = inPacket.getValAt<uint32_t>( 0x24 );
|
2017-08-08 13:53:47 +02:00
|
|
|
memcpy( &IPC_OP_019A, &flags1, 4 );
|
|
|
|
|
|
|
|
//g_log.Log(LoggingSeverity::debug, "" + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit1)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit2)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit3)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit4)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit5)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit6)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit7)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit8)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit9)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit10)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit11)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit12)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit13)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit14)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit15)
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019AB.bit16)
|
|
|
|
// + " " + boost::lexical_cast<std::string>((int)flags));
|
|
|
|
|
|
|
|
//g_log.Log(LoggingSeverity::debug, "\n" + boost::lexical_cast<std::string>((int)IPC_OP_019A.specialMovement) + "\n"
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafe) + "\n"
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.moveBackward) + "\n"
|
|
|
|
// + boost::lexical_cast<std::string>((int)IPC_OP_019A.strafeRight));
|
|
|
|
|
|
|
|
//g_log.Log(LoggingSeverity::debug, pInPacket->toString());
|
|
|
|
|
|
|
|
//pInPacket->debugPrint();
|
|
|
|
|
|
|
|
bool bPosChanged = false;
|
2017-12-08 11:46:47 +01:00
|
|
|
if( ( player.getPos().x != inPacket.getValAt< float >( 0x2c ) ) ||
|
|
|
|
( player.getPos().y != inPacket.getValAt< float >( 0x30 ) ) ||
|
|
|
|
( player.getPos().z != inPacket.getValAt< float >( 0x34 ) ) )
|
2017-08-08 13:53:47 +02:00
|
|
|
bPosChanged = true;
|
2017-12-08 11:46:47 +01:00
|
|
|
if( !bPosChanged && player.getRotation() == inPacket.getValAt< float >( 0x20 ) )
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setRotation( inPacket.getValAt< float >( 0x20 ) );
|
|
|
|
player.setPosition( inPacket.getValAt< float >( 0x2c ),
|
|
|
|
inPacket.getValAt< float >( 0x30 ),
|
|
|
|
inPacket.getValAt< float >( 0x34 ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
if( ( player.getCurrentAction() != nullptr ) && bPosChanged )
|
|
|
|
player.getCurrentAction()->setInterrupted();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
// if no one is in range, don't bother trying to send a position update
|
2017-12-08 11:46:47 +01:00
|
|
|
if( !player.hasInRangeActor() )
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint8_t unk = inPacket.getValAt< uint8_t >( 0x29 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint16_t moveType = inPacket.getValAt< uint16_t >( 0x28 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
uint8_t unk1 = 0;
|
|
|
|
uint8_t unk2 = 0;
|
|
|
|
uint8_t unk3 = unk;
|
|
|
|
uint16_t unk4 = 0;
|
|
|
|
|
|
|
|
// HACK: This part is hackish, we need to find out what all theese things really do.
|
|
|
|
switch( moveType )
|
|
|
|
{
|
|
|
|
case MoveType::Strafe:
|
|
|
|
{
|
|
|
|
if( IPC_OP_019A.strafeRight == 1 )
|
|
|
|
unk1 = 0xbf;
|
|
|
|
else
|
|
|
|
unk1 = 0x5f;
|
|
|
|
unk4 = 0x3C;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
unk1 = 0xFF;
|
|
|
|
unk2 = 0x06;
|
|
|
|
unk4 = 0x18;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// case MoveType::Land:
|
|
|
|
// {
|
|
|
|
// unk1 = 0x7F;
|
|
|
|
// //unk2 = 0x40;
|
|
|
|
// unk4 = 0x3C;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case MoveType::Jump:
|
|
|
|
// {
|
|
|
|
// unk1 = 0x7F;
|
|
|
|
// if(unk == 0x01)
|
|
|
|
// {
|
|
|
|
// // unk2 = 0x20;
|
|
|
|
// //unk4 = 0x32;
|
|
|
|
// unk4 = 0x32;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// // unk2 = 0xA0;
|
|
|
|
// unk4 = 0x3C;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// case MoveType::Fall:
|
|
|
|
// {
|
|
|
|
// unk1 = 0x7F;
|
|
|
|
// //unk2 = 0xA0;
|
|
|
|
// unk4 = 0x3C;
|
|
|
|
//
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
default:
|
|
|
|
{
|
2017-08-11 22:56:30 +01:00
|
|
|
if( static_cast< int32_t >( IPC_OP_019A.moveBackward ) )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
unk1 = 0xFF;
|
|
|
|
unk2 = 0x06;
|
|
|
|
unk4 = 0x18; // animation speed?
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unk1 = 0x7F;
|
|
|
|
unk4 = 0x3C; // animation speed?
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
MoveActorPacket movePacket( player, unk1, unk2, unk3, unk4 );
|
|
|
|
player.sendToInRangeSet( movePacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-06 00:13:29 +02:00
|
|
|
void Core::Network::GameConnection::reqEquipDisplayFlagsHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-10-05 20:24:58 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
g_log.info( "[" + std::to_string( player.getId() ) + "] Setting EquipDisplayFlags to " + std::to_string( inPacket.getValAt< uint8_t >( 0x20 ) ) );
|
|
|
|
player.setEquipDisplayFlags( inPacket.getValAt< uint8_t >( 0x20 ) );
|
2017-10-05 20:24:58 +02:00
|
|
|
}
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::zoneLineHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t zoneLineId = inPacket.getValAt< uint32_t >( 0x20 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) );
|
2017-08-09 15:02:24 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
auto pZone = player.getCurrentZone();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-01-27 23:52:49 +01:00
|
|
|
auto pLine = g_territoryMgr.getTerritoryPosition( zoneLineId );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-11-28 00:09:36 +01:00
|
|
|
Common::FFXIVARR_POSITION3 targetPos{};
|
2017-08-08 13:53:47 +02:00
|
|
|
uint32_t targetZone;
|
|
|
|
float rotation = 0.0f;
|
|
|
|
|
|
|
|
if( pLine != nullptr )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "ZoneLine " + std::to_string( zoneLineId ) + " found." );
|
2017-08-08 13:53:47 +02:00
|
|
|
targetPos = pLine->getTargetPosition();
|
|
|
|
targetZone = pLine->getTargetZoneId();
|
|
|
|
rotation = pLine->getTargetRotation();
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcPrepareZoning > preparePacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
preparePacket.data().targetZone = targetZone;
|
|
|
|
|
|
|
|
//ActorControlPacket143 controlPacket( pPlayer, ActorControlType::DespawnZoneScreenMsg,
|
2017-12-08 11:46:47 +01:00
|
|
|
// 0x03, player.getId(), 0x01, targetZone );
|
|
|
|
player.queuePacket( preparePacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No zoneline found, revert to last zone
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendUrgent( "ZoneLine " + std::to_string( zoneLineId ) + " not found." );
|
2017-08-08 13:53:47 +02:00
|
|
|
targetPos.x = 0;
|
|
|
|
targetPos.y = 0;
|
|
|
|
targetPos.z = 0;
|
2018-01-27 23:52:49 +01:00
|
|
|
targetZone = pZone->getTerritoryId();
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.performZoning( targetZone, targetPos, rotation);
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::discoveryHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t ref_position_id = inPacket.getValAt< uint32_t >( 0x20 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-10-27 00:10:13 +02:00
|
|
|
auto pQR = g_charaDb.query( "SELECT id, map_id, discover_id "
|
|
|
|
"FROM discoveryinfo "
|
|
|
|
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-10-27 00:10:13 +02:00
|
|
|
if( !pQR->next() )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) + " not found. " );
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcDiscovery > discoveryPacket( player.getId() );
|
2017-10-27 00:10:13 +02:00
|
|
|
discoveryPacket.data().map_id = pQR->getUInt( 2 );
|
|
|
|
discoveryPacket.data().map_part_id = pQR->getUInt( 3 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.queuePacket( discoveryPacket );
|
|
|
|
player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::playTimeHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcPlayTime > playTimePacket( player.getId() );
|
|
|
|
playTimePacket.data().playTimeInMinutes = player.getPlayTime() / 60;
|
|
|
|
player.queuePacket( playTimePacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::initHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
// init handler means this is a login procedure
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setIsLogin( true );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-02-04 18:53:19 +01:00
|
|
|
player.sendZonePackets();
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::blackListHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-08-17 17:30:00 +02:00
|
|
|
uint8_t count = inPacket.getValAt< uint8_t >( 0x21 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcBlackList > blackListPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
blackListPacket.data().sequence = count;
|
|
|
|
// TODO: Fill with actual blacklist data
|
|
|
|
//blackListPacket.data().entry[0].contentId = 1;
|
|
|
|
//sprintf( blackListPacket.data().entry[0].name, "Test Test" );
|
|
|
|
queueOutPacket( blackListPacket );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::pingHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-08-17 17:30:00 +02:00
|
|
|
int32_t inVal = inPacket.getValAt< int32_t >( 0x20 );
|
2017-12-08 11:46:47 +01:00
|
|
|
PingPacket pingPacket( player, inVal );
|
2017-08-08 13:53:47 +02:00
|
|
|
queueOutPacket( pingPacket );
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setLastPing( static_cast< uint32_t >( time( nullptr ) ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::finishLoadingHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2018-02-10 01:21:31 +01:00
|
|
|
player.getCurrentZone()->onFinishLoading( player );
|
2018-02-07 00:00:48 +01:00
|
|
|
|
2017-08-08 13:53:47 +02:00
|
|
|
// player is done zoning
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setLoadingComplete( true );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
// if this is a login event
|
2017-12-08 11:46:47 +01:00
|
|
|
if( player.isLogin() )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
// fire the onLogin Event
|
2017-12-08 11:46:47 +01:00
|
|
|
player.onLogin();
|
|
|
|
player.setIsLogin( false );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// spawn the player for himself
|
2017-12-08 11:46:47 +01:00
|
|
|
player.spawn( player.getAsPlayer() );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
// notify the zone of a change in position to force an "inRangeActor" update
|
2018-02-10 01:21:31 +01:00
|
|
|
player.getCurrentZone()->changeActorPosition( player );
|
2017-08-08 13:53:47 +02:00
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::socialListHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint8_t type = inPacket.getValAt< uint8_t >( 0x2A );
|
|
|
|
uint8_t count = inPacket.getValAt< uint8_t >( 0x2B );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
if( type == 0x02 )
|
|
|
|
{ // party list
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcSocialList > listPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
listPacket.data().type = 2;
|
|
|
|
listPacket.data().sequence = count;
|
|
|
|
|
2017-08-11 22:56:30 +01:00
|
|
|
int32_t entrysizes = sizeof( listPacket.data().entries );
|
2017-08-08 13:53:47 +02:00
|
|
|
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
|
|
|
|
|
2018-01-27 23:52:49 +01:00
|
|
|
listPacket.data().entries[0].bytes[2] = player.getCurrentZone()->getTerritoryId();
|
2017-08-08 13:53:47 +02:00
|
|
|
listPacket.data().entries[0].bytes[3] = 0x80;
|
|
|
|
listPacket.data().entries[0].bytes[4] = 0x02;
|
|
|
|
listPacket.data().entries[0].bytes[6] = 0x3B;
|
|
|
|
listPacket.data().entries[0].bytes[11] = 0x10;
|
2017-12-08 11:46:47 +01:00
|
|
|
listPacket.data().entries[0].classJob = static_cast< uint8_t >( player.getClass() );
|
|
|
|
listPacket.data().entries[0].contentId = player.getContentId();
|
|
|
|
listPacket.data().entries[0].level = player.getLevel();
|
2018-01-27 23:52:49 +01:00
|
|
|
listPacket.data().entries[0].zoneId = player.getCurrentZone()->getTerritoryId();
|
2017-08-08 13:53:47 +02:00
|
|
|
listPacket.data().entries[0].zoneId1 = 0x0100;
|
|
|
|
// TODO: no idea what this does
|
|
|
|
//listPacket.data().entries[0].one = 1;
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
memcpy( listPacket.data().entries[0].name, player.getName().c_str(), strlen( player.getName().c_str() ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
// TODO: actually store and read language from somewhere
|
|
|
|
listPacket.data().entries[0].bytes1[0] = 0x01;//flags (lang)
|
|
|
|
// TODO: these flags need to be figured out
|
|
|
|
//listPacket.data().entries[0].bytes1[1] = 0x00;//flags
|
2017-12-08 11:46:47 +01:00
|
|
|
listPacket.data().entries[0].onlineStatusMask = player.getOnlineStatusMask();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
queueOutPacket( listPacket );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( type == 0x0b )
|
|
|
|
{ // friend list
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcSocialList > listPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
listPacket.data().type = 0x0B;
|
|
|
|
listPacket.data().sequence = count;
|
|
|
|
memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( type == 0x0e )
|
|
|
|
{ // player search result
|
|
|
|
// TODO: implement player search
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::chatHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
std::string chatString( inPacket.getStringAt( 0x3a ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t sourceId = inPacket.getValAt< uint32_t >( 0x24 );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2017-09-23 00:45:30 +09:00
|
|
|
if( chatString.at( 0 ) == '!' )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
|
|
|
// execute game console command
|
2018-01-28 11:16:34 +01:00
|
|
|
g_gameCommandMgr.execCommand( const_cast< char * >( chatString.c_str() ) + 1, player );
|
2017-08-08 13:53:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ChatType chatType = static_cast< ChatType >( inPacket.getValAt< uint8_t >( 0x38 ) );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
//ToDo, need to implement sending GM chat types.
|
2017-12-08 11:46:47 +01:00
|
|
|
ChatPacket chatPacket( player, chatType, chatString );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
switch( chatType )
|
|
|
|
{
|
|
|
|
case ChatType::Say:
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.getCurrentZone()->queueOutPacketForRange( player, 50, chatPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ChatType::Yell:
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.getCurrentZone()->queueOutPacketForRange( player, 6000, chatPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ChatType::Shout:
|
|
|
|
{
|
2018-01-28 11:16:34 +01:00
|
|
|
player.getCurrentZone()->queueOutPacketForRange( player, 6000, chatPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
player.getCurrentZone()->queueOutPacketForRange( player, 50, chatPacket );
|
2017-08-08 13:53:47 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: this handler needs to be improved for timed logout, also the session should be instantly removed
|
|
|
|
// currently we wait for the session to just time out after logout, this can be a problem is the user tries to
|
|
|
|
// log right back in.
|
|
|
|
// Also the packet needs to be converted to an ipc structure
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::logoutHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-08 13:53:47 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ZoneChannelPacket< FFXIVIpcLogout > logoutPacket( player.getId() );
|
2017-08-08 13:53:47 +02:00
|
|
|
logoutPacket.data().flags1 = 0x02;
|
|
|
|
logoutPacket.data().flags2 = 0x2000;
|
|
|
|
queueOutPacket( logoutPacket );
|
2017-11-14 23:55:38 +01:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setMarkedForRemoval();
|
2017-08-22 21:36:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Core::Network::GameConnection::tellHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-22 21:36:20 +02:00
|
|
|
{
|
2017-08-22 23:53:20 +02:00
|
|
|
std::string targetPcName = inPacket.getStringAt( 0x21 );
|
|
|
|
std::string msg = inPacket.getStringAt( 0x41 );
|
2017-08-22 21:36:20 +02:00
|
|
|
|
2017-08-22 23:53:20 +02:00
|
|
|
auto pSession = g_serverZone.getSession( targetPcName );
|
|
|
|
|
|
|
|
if( !pSession )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
ChatChannelPacket< FFXIVIpcTellErrNotFound > tellErrPacket( player.getId() );
|
2017-08-22 23:53:20 +02:00
|
|
|
strcpy( tellErrPacket.data().receipientName, targetPcName.c_str() );
|
2017-08-23 17:39:59 +02:00
|
|
|
sendSinglePacket( tellErrPacket );
|
|
|
|
|
2017-08-22 23:53:20 +02:00
|
|
|
g_log.debug( "TargetPc not found" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pTargetPlayer = pSession->getPlayer();
|
|
|
|
|
|
|
|
if( pTargetPlayer->hasStateFlag( PlayerStateFlag::BetweenAreas ) ||
|
|
|
|
pTargetPlayer->hasStateFlag( PlayerStateFlag::BetweenAreas1 ) )
|
|
|
|
{
|
|
|
|
// send error for player between areas
|
2017-08-23 23:58:14 +02:00
|
|
|
// TODO: implement me
|
2017-08-22 23:53:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pTargetPlayer->hasStateFlag( PlayerStateFlag::BoundByDuty ) ||
|
|
|
|
pTargetPlayer->hasStateFlag( PlayerStateFlag::BoundByDuty1 ) )
|
|
|
|
{
|
|
|
|
// send error for player bound by duty
|
2017-08-23 23:58:14 +02:00
|
|
|
// TODO: implement me
|
2017-08-22 23:53:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pTargetPlayer->getOnlineStatus() == OnlineStatus::Busy )
|
|
|
|
{
|
|
|
|
// send error for player being busy
|
2017-08-23 23:58:14 +02:00
|
|
|
// TODO: implement me ( i've seen this done with packet type 67 i think )
|
2017-08-22 23:53:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
ChatChannelPacket< FFXIVIpcTell > tellPacket( player.getId() );
|
2017-08-22 23:53:20 +02:00
|
|
|
strcpy( tellPacket.data().msg, msg.c_str() );
|
2017-12-08 11:46:47 +01:00
|
|
|
strcpy( tellPacket.data().receipientName, player.getName().c_str() );
|
2017-08-23 23:58:14 +02:00
|
|
|
// TODO: do these have a meaning?
|
2017-08-22 23:53:20 +02:00
|
|
|
//tellPacket.data().u1 = 0x92CD7337;
|
|
|
|
//tellPacket.data().u2a = 0x2E;
|
|
|
|
//tellPacket.data().u2b = 0x40;
|
|
|
|
pTargetPlayer->queueChatPacket( tellPacket );
|
2017-08-22 21:36:20 +02:00
|
|
|
|
2017-09-23 00:45:30 +09:00
|
|
|
}
|
2017-11-22 00:29:42 +09:00
|
|
|
|
|
|
|
void Core::Network::GameConnection::performNoteHandler( const Packets::GamePacket& inPacket,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-11-22 00:29:42 +09:00
|
|
|
{
|
2017-12-09 13:55:55 +09:00
|
|
|
ZoneChannelPacket< FFXIVIpcPerformNote > performPacket( player.getId() );
|
2017-11-22 00:29:42 +09:00
|
|
|
|
2017-12-09 13:14:06 +09:00
|
|
|
auto inVal = inPacket.getDataAt( 0x20 );
|
2017-12-09 13:09:56 +09:00
|
|
|
memcpy( &performPacket.data().data[0], inVal, 32 );
|
2017-11-22 00:29:42 +09:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendToInRangeSet( performPacket );
|
2017-11-22 00:29:42 +09:00
|
|
|
}
|