mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-25 05:57:45 +00:00
convert more old incoming packets to structs
This commit is contained in:
parent
09d00b8a7f
commit
833f4f1431
8 changed files with 136 additions and 71 deletions
|
@ -239,6 +239,8 @@ public:
|
|||
/** Gets a reference to the underlying IPC data structure. */
|
||||
T& data() { return m_data; };
|
||||
|
||||
const T& data() const { return m_data; }
|
||||
|
||||
protected:
|
||||
/** Initializes the fields of the header structures */
|
||||
virtual void initialize()
|
||||
|
|
|
@ -46,6 +46,65 @@ struct FFXIVIpcSkillHandler : FFXIVIpcBasePacket< SkillHandler >
|
|||
/* 0010 */ uint64_t targetId;
|
||||
};
|
||||
|
||||
struct FFXIVIpcZoneLineHandler : FFXIVIpcBasePacket< ZoneLineHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t zoneLineId;
|
||||
};
|
||||
|
||||
struct FFXIVIpcDiscoveryHandler : FFXIVIpcBasePacket< DiscoveryHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t positionRef;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEventHandlerReturn : FFXIVIpcBasePacket< ReturnEventHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t eventId;
|
||||
/* 0004 */ uint16_t scene;
|
||||
/* 0006 */ uint16_t param1;
|
||||
/* 0008 */ uint16_t param2;
|
||||
/* 000A */ char pad_000A[2];
|
||||
/* 000C */ uint16_t param3;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEnterTerritoryHandler : FFXIVIpcBasePacket< EnterTeriEventHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t eventId;
|
||||
/* 0004 */ uint16_t param1;
|
||||
/* 0006 */ uint16_t param2;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEventHandlerOutsideRange : FFXIVIpcBasePacket< OutOfRangeEventHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t param1;
|
||||
/* 0004 */ uint32_t eventId;
|
||||
/* 0008 */ Common::FFXIVARR_POSITION3 position;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEventHandlerWithinRange : FFXIVIpcBasePacket< WithinRangeEventHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t param1;
|
||||
/* 0004 */ uint32_t eventId;
|
||||
/* 0008 */ Common::FFXIVARR_POSITION3 position;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEventHandlerEmote : FFXIVIpcBasePacket< EmoteEventHandler >
|
||||
{
|
||||
/* 0000 */ uint64_t actorId;
|
||||
/* 0008 */ uint32_t eventId;
|
||||
/* 000C */ uint16_t emoteId;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEventHandlerTalk : FFXIVIpcBasePacket< TalkEventHandler >
|
||||
{
|
||||
/* 0000 */ uint64_t actorId;
|
||||
/* 0008 */ uint32_t eventId;
|
||||
};
|
||||
|
||||
struct FFXIVIpcPingHandler : FFXIVIpcBasePacket< PingHandler >
|
||||
{
|
||||
/* 0000 */ uint32_t timestamp; // maybe lol..
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,14 +45,14 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
|
|||
{
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
|
||||
auto packet = ZoneChannelPacket< Client::FFXIVIpcClientTrigger >( inPacket );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcClientTrigger >( inPacket );
|
||||
|
||||
auto commandId = packet.data().commandId;
|
||||
auto param1 = packet.data().param1;
|
||||
auto param11 = *reinterpret_cast< uint32_t* >( &packet.data().param1 );
|
||||
auto param12 = *reinterpret_cast< uint32_t* >( &packet.data().param1 + sizeof( uint32_t ) );
|
||||
auto param2 = packet.data().param2;
|
||||
auto param3 = packet.data().param3;
|
||||
const auto& commandId = packet.data().commandId;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& param11 = *reinterpret_cast< const uint32_t* >( &packet.data().param1 );
|
||||
const auto& param12 = *reinterpret_cast< const uint32_t* >( &packet.data().param1 + sizeof( uint32_t ) );
|
||||
const auto& param2 = packet.data().param2;
|
||||
const auto& param3 = packet.data().param3;
|
||||
|
||||
pLog->debug( "[" + std::to_string( m_pSession->getId() ) + "] Incoming action: " +
|
||||
boost::str( boost::format( "%|04X|" ) % ( uint32_t ) ( commandId & 0xFFFF ) ) +
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <Network/PacketContainer.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
#include <sapphire_zone/Event/EventHandler.h>
|
||||
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
||||
|
||||
#include "Network/GameConnection.h"
|
||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
||||
|
@ -38,10 +39,12 @@ void Core::Network::GameConnection::eventHandlerTalk( const Packets::FFXIVARR_PA
|
|||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto actorId = *reinterpret_cast< uint64_t* >( ©.data[0x10] );
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x18] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerTalk >( inPacket );
|
||||
|
||||
const auto& actorId = packet.data().actorId;
|
||||
const auto& eventId = packet.data().eventId;
|
||||
|
||||
auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||
|
||||
std::string eventName = "onTalk";
|
||||
|
@ -81,12 +84,13 @@ void Core::Network::GameConnection::eventHandlerEmote( const Packets::FFXIVARR_P
|
|||
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto actorId = *reinterpret_cast< uint64_t* >( ©.data[0x10] );
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x18] );
|
||||
auto emoteId = *reinterpret_cast< uint16_t* >( ©.data[0x1C] );
|
||||
auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerEmote >( inPacket );
|
||||
|
||||
const auto& actorId = packet.data().actorId;
|
||||
const auto& eventId = packet.data().eventId;
|
||||
const auto& emoteId = packet.data().emoteId;
|
||||
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||
|
||||
std::string eventName = "onEmote";
|
||||
std::string objName = Event::getEventName( eventId );
|
||||
|
@ -118,14 +122,12 @@ void Core::Network::GameConnection::eventHandlerWithinRange( const Packets::FFXI
|
|||
Entity::Player& player )
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x14] );
|
||||
auto param1 = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerWithinRange >( inPacket );
|
||||
|
||||
auto x = *reinterpret_cast< float* >( ©.data[0x18] );
|
||||
auto y = *reinterpret_cast< float* >( ©.data[0x1C] );
|
||||
auto z = *reinterpret_cast< float* >( ©.data[0x20] );
|
||||
const auto& eventId = packet.data().eventId;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& pos = packet.data().position;
|
||||
|
||||
std::string eventName = "onWithinRange";
|
||||
std::string objName = Event::getEventName( eventId );
|
||||
|
@ -134,7 +136,7 @@ void Core::Network::GameConnection::eventHandlerWithinRange( const Packets::FFXI
|
|||
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
pScriptMgr->onWithinRange( player, eventId, param1, x, y, z );
|
||||
pScriptMgr->onWithinRange( player, eventId, param1, pos.x, pos.y, pos.z );
|
||||
|
||||
player.checkEvent( eventId );
|
||||
}
|
||||
|
@ -145,12 +147,11 @@ void Core::Network::GameConnection::eventHandlerOutsideRange( const Packets::FFX
|
|||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x14] );
|
||||
auto param1 = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerOutsideRange >( inPacket );
|
||||
|
||||
auto x = *reinterpret_cast< float* >( ©.data[0x18] );
|
||||
auto y = *reinterpret_cast< float* >( ©.data[0x1C] );
|
||||
auto z = *reinterpret_cast< float* >( ©.data[0x20] );
|
||||
const auto& eventId = packet.data().eventId;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& pos = packet.data().position;
|
||||
|
||||
std::string eventName = "onOutsideRange";
|
||||
std::string objName = Event::getEventName( eventId );
|
||||
|
@ -159,7 +160,7 @@ void Core::Network::GameConnection::eventHandlerOutsideRange( const Packets::FFX
|
|||
|
||||
player.eventStart( player.getId(), eventId, Event::EventHandler::WithinRange, 1, param1 );
|
||||
|
||||
pScriptMgr->onOutsideRange( player, eventId, param1, x, y, z );
|
||||
pScriptMgr->onOutsideRange( player, eventId, param1, pos.x, pos.y, pos.z );
|
||||
|
||||
player.checkEvent( eventId );
|
||||
}
|
||||
|
@ -168,11 +169,12 @@ void Core::Network::GameConnection::eventHandlerEnterTerritory( const Packets::F
|
|||
Entity::Player& player )
|
||||
{
|
||||
auto pScriptMgr = g_fw.get< Scripting::ScriptMgr >();
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
auto param1 = *reinterpret_cast< uint16_t* >( ©.data[0x14] );
|
||||
auto param2 = *reinterpret_cast< uint16_t* >( ©.data[0x16] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEnterTerritoryHandler >( inPacket );
|
||||
|
||||
const auto& eventId = packet.data().eventId;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& param2 = packet.data().param2;
|
||||
|
||||
std::string eventName = "onEnterTerritory";
|
||||
|
||||
|
@ -197,13 +199,12 @@ void Core::Network::GameConnection::eventHandlerEnterTerritory( const Packets::F
|
|||
void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
{
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto eventId = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
auto scene = *reinterpret_cast< uint16_t* >( ©.data[0x14] );
|
||||
auto param1 = *reinterpret_cast< uint16_t* >( ©.data[0x16] );
|
||||
auto param2 = *reinterpret_cast< uint16_t* >( ©.data[0x18] );
|
||||
auto param3 = *reinterpret_cast< uint16_t* >( ©.data[0x1C] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcEventHandlerReturn >( inPacket );
|
||||
const auto& eventId = packet.data().eventId;
|
||||
const auto& scene = packet.data().scene;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& param2 = packet.data().param2;
|
||||
const auto& param3 = packet.data().param3;
|
||||
|
||||
std::string eventName = Event::getEventName( eventId );
|
||||
|
||||
|
|
|
@ -92,11 +92,11 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
|
|||
if( player.getGmRank() <= 0 )
|
||||
return;
|
||||
|
||||
auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand1 >( inPacket );
|
||||
auto commandId = packet.data().commandId;
|
||||
auto param1 = packet.data().param1;
|
||||
auto param2 = packet.data().param2;
|
||||
auto param3 = packet.data().param3;
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand1 >( inPacket );
|
||||
const auto& commandId = packet.data().commandId;
|
||||
const auto& param1 = packet.data().param1;
|
||||
const auto& param2 = packet.data().param2;
|
||||
const auto& param3 = packet.data().param3;
|
||||
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->debug( player.getName() + " used GM1 commandId: " + std::to_string( commandId ) +
|
||||
|
@ -310,9 +310,11 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
|
|||
}
|
||||
case GmCommand::Item:
|
||||
{
|
||||
if( param2 < 1 || param2 > 99 )
|
||||
auto quantity = param2;
|
||||
|
||||
if( quantity < 1 || quantity > 999 )
|
||||
{
|
||||
param2 = 1;
|
||||
quantity = 1;
|
||||
}
|
||||
|
||||
if( ( param1 == 0xcccccccc ) )
|
||||
|
@ -321,7 +323,7 @@ void Core::Network::GameConnection::gm1Handler( const Packets::FFXIVARR_PACKET_R
|
|||
return;
|
||||
}
|
||||
|
||||
if( !targetPlayer->addItem( -1, param1, param2 ) )
|
||||
if( !targetPlayer->addItem( -1, param1, quantity ) )
|
||||
player.sendUrgent( "Item " + std::to_string( param1 ) + " not found..." );
|
||||
break;
|
||||
}
|
||||
|
@ -489,10 +491,10 @@ void Core::Network::GameConnection::gm2Handler( const Packets::FFXIVARR_PACKET_R
|
|||
auto pLog = g_fw.get< Logger >();
|
||||
auto pServerZone = g_fw.get< ServerZone >();
|
||||
|
||||
auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcGmCommand2 >( inPacket );
|
||||
|
||||
auto commandId = packet.data().commandId;
|
||||
auto param1 = std::string( packet.data().param1 );
|
||||
const auto& commandId = packet.data().commandId;
|
||||
const auto& param1 = std::string( packet.data().param1 );
|
||||
|
||||
pLog->debug( player.getName() + " used GM2 commandId: " + std::to_string( commandId ) + ", params: " + param1 );
|
||||
|
||||
|
|
|
@ -42,16 +42,16 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::FFXIV
|
|||
Entity::Player& player )
|
||||
{
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
auto seq = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
auto action = *reinterpret_cast< uint8_t* >( ©.data[0x14] );
|
||||
auto fromSlot = *reinterpret_cast< uint8_t* >( ©.data[0x20] );
|
||||
auto toSlot = *reinterpret_cast< uint8_t* >( ©.data[0x34] );
|
||||
auto seq = *reinterpret_cast< uint32_t* >( ©.data[0x1] );
|
||||
auto action = *reinterpret_cast< uint8_t* >( ©.data[0x4] );
|
||||
auto fromSlot = *reinterpret_cast< uint8_t* >( ©.data[0x10] );
|
||||
auto toSlot = *reinterpret_cast< uint8_t* >( ©.data[0x24] );
|
||||
|
||||
auto fromContainer = *reinterpret_cast< uint16_t* >( ©.data[0x1C] );
|
||||
auto toContainer = *reinterpret_cast< uint16_t* >( ©.data[0x30] );
|
||||
auto fromContainer = *reinterpret_cast< uint16_t* >( ©.data[0xC] );
|
||||
auto toContainer = *reinterpret_cast< uint16_t* >( ©.data[0x20] );
|
||||
|
||||
// todo: check packet handler in game and see if this is sent as a u16 or u32
|
||||
auto splitCount = *reinterpret_cast< uint16_t* >( ©.data[0x38] );
|
||||
auto splitCount = *reinterpret_cast< uint16_t* >( ©.data[0x28] );
|
||||
|
||||
auto ackPacket = makeZonePacket< FFXIVIpcInventoryActionAck >( player.getId() );
|
||||
ackPacket->data().sequence = seq;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <Database/DatabaseDef.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <Network/PacketDef/Zone/ClientZoneDef.h>
|
||||
#include "Network/GameConnection.h"
|
||||
|
||||
#include "Zone/TerritoryMgr.h"
|
||||
|
@ -299,8 +300,8 @@ void Core::Network::GameConnection::zoneLineHandler( const Core::Network::Packet
|
|||
{
|
||||
auto pTeriMgr = g_fw.get< TerritoryMgr >();
|
||||
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
auto zoneLineId = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcZoneLineHandler >( inPacket );
|
||||
const auto& zoneLineId = packet.data().zoneLineId;
|
||||
|
||||
player.sendDebug( "Walking ZoneLine " + std::to_string( zoneLineId ) );
|
||||
|
||||
|
@ -346,17 +347,18 @@ void Core::Network::GameConnection::discoveryHandler( const Core::Network::Packe
|
|||
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
|
||||
auto ref_position_id = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
auto packet = ZoneChannelPacket< Client::FFXIVIpcDiscoveryHandler >( inPacket );
|
||||
const auto& positionRef = packet.data().positionRef;
|
||||
|
||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
||||
|
||||
auto pQR = pDb->query( "SELECT id, map_id, discover_id "
|
||||
"FROM discoveryinfo "
|
||||
"WHERE id = " + std::to_string( ref_position_id ) + ";" );
|
||||
"WHERE id = " + std::to_string( positionRef ) + ";" );
|
||||
|
||||
if( !pQR->next() )
|
||||
{
|
||||
player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) + " not found. " );
|
||||
player.sendNotice( "Discovery ref pos ID: " + std::to_string( positionRef ) + " not found. " );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -365,7 +367,7 @@ void Core::Network::GameConnection::discoveryHandler( const Core::Network::Packe
|
|||
discoveryPacket->data().map_part_id = pQR->getUInt( 3 );
|
||||
|
||||
player.queuePacket( discoveryPacket );
|
||||
player.sendNotice( "Discovery ref pos ID: " + std::to_string( ref_position_id ) );
|
||||
player.sendNotice( "Discovery ref pos ID: " + std::to_string( positionRef ) );
|
||||
|
||||
player.discover( pQR->getUInt16( 2 ), pQR->getUInt16( 3 ) );
|
||||
|
||||
|
@ -409,10 +411,9 @@ void Core::Network::GameConnection::blackListHandler( const Core::Network::Packe
|
|||
void Core::Network::GameConnection::pingHandler( const Core::Network::Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
{
|
||||
Packets::FFXIVARR_PACKET_RAW copy = inPacket;
|
||||
auto inVal = *reinterpret_cast< uint32_t* >( ©.data[0x10] );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcPingHandler >( inPacket );
|
||||
|
||||
queueOutPacket( boost::make_shared< PingPacket>( player, inVal ) );
|
||||
queueOutPacket( boost::make_shared< Server::PingPacket >( player, packet.data().timestamp ) );
|
||||
|
||||
player.setLastPing( static_cast< uint32_t >( time( nullptr ) ) );
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ using namespace Core::Network::ActorControl;
|
|||
void Core::Network::GameConnection::skillHandler( const Packets::FFXIVARR_PACKET_RAW& inPacket,
|
||||
Entity::Player& player )
|
||||
{
|
||||
auto packet = ZoneChannelPacket< Client::FFXIVIpcSkillHandler >( inPacket );
|
||||
const auto packet = ZoneChannelPacket< Client::FFXIVIpcSkillHandler >( inPacket );
|
||||
|
||||
auto type = packet.data().type;
|
||||
auto action = packet.data().actionId;
|
||||
auto useCount = packet.data().useCount;
|
||||
auto targetId = packet.data().targetId;
|
||||
const auto& type = packet.data().type;
|
||||
const auto& action = packet.data().actionId;
|
||||
const auto& useCount = packet.data().useCount;
|
||||
const auto& targetId = packet.data().targetId;
|
||||
|
||||
player.sendDebug( "Skill type:" + std::to_string( type ) );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue