mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
Merge pull request #331 from NotAdam/packet_work
segment header types, send in range packets and override their target id
This commit is contained in:
commit
6e7f1c6692
5 changed files with 34 additions and 10 deletions
|
@ -130,6 +130,19 @@ struct FFXIVARR_PACKET_RAW
|
||||||
std::vector< uint8_t > data;
|
std::vector< uint8_t > data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the type of the segment
|
||||||
|
* IPC type will contain an additional header: FFXIVARR_PACKET_SEGMENT_HEADER + FFXIVARR_IPC_HEADER + data
|
||||||
|
* The remaining types don't contain an additonal header, FFXIVARR_PACKET_SEGMENT_HEADER + data
|
||||||
|
*/
|
||||||
|
enum FFXIVARR_SEGMENT_TYPE
|
||||||
|
{
|
||||||
|
SEGMENTTYPE_IPC = 3,
|
||||||
|
SEGMENTTYPE_RESPONSE = 7,
|
||||||
|
SEGMENTTYPE_KEEPALIVE = 8,
|
||||||
|
SEGMENTTYPE_ENCRYPTIONHANDSHAKE = 9,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structural representation of the common header for IPC packet segments.
|
* Structural representation of the common header for IPC packet segments.
|
||||||
* NOTE: This is packet segment type 3.
|
* NOTE: This is packet segment type 3.
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
Core::Network::Packets::PacketContainer::PacketContainer()
|
Core::Network::Packets::PacketContainer::PacketContainer( uint32_t segmentTargetOverride ) :
|
||||||
|
m_segmentTargetOverride( segmentTargetOverride )
|
||||||
{
|
{
|
||||||
memset( &m_ipcHdr, 0, sizeof( FFXIVARR_PACKET_HEADER ) );
|
memset( &m_ipcHdr, 0, sizeof( FFXIVARR_PACKET_HEADER ) );
|
||||||
m_ipcHdr.size = sizeof( FFXIVARR_PACKET_HEADER );
|
m_ipcHdr.size = sizeof( FFXIVARR_PACKET_HEADER );
|
||||||
|
@ -52,9 +53,16 @@ void Core::Network::Packets::PacketContainer::fillSendBuffer( std::vector< uint8
|
||||||
|
|
||||||
for( ; it != m_entryList.end(); ++it )
|
for( ; it != m_entryList.end(); ++it )
|
||||||
{
|
{
|
||||||
auto data = (*it)->getData();
|
auto pPacket = (*it);
|
||||||
memcpy( &tempBuffer[0] + sizeof( FFXIVARR_PACKET_HEADER ) + offset, &data[0], (*it)->getSize() );
|
|
||||||
offset += (*it)->getSize();
|
if( m_segmentTargetOverride != 0 && pPacket->getSegmentType() == SEGMENTTYPE_IPC )
|
||||||
|
{
|
||||||
|
pPacket->setTargetActor( m_segmentTargetOverride );
|
||||||
|
}
|
||||||
|
|
||||||
|
auto data = pPacket->getData();
|
||||||
|
memcpy( &tempBuffer[0] + sizeof( FFXIVARR_PACKET_HEADER ) + offset, &data[0], pPacket->getSize() );
|
||||||
|
offset += pPacket->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendBuffer.assign( &tempBuffer[0], &tempBuffer[0] + m_ipcHdr.size );
|
sendBuffer.assign( &tempBuffer[0], &tempBuffer[0] + m_ipcHdr.size );
|
||||||
|
|
|
@ -17,7 +17,7 @@ typedef boost::shared_ptr< FFXIVPacketBase > FFXIVPacketBasePtr;
|
||||||
class PacketContainer
|
class PacketContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketContainer();
|
PacketContainer( uint32_t segmentTargetOverride = 0 );
|
||||||
~PacketContainer();
|
~PacketContainer();
|
||||||
|
|
||||||
void addPacket( FFXIVPacketBasePtr entry );
|
void addPacket( FFXIVPacketBasePtr entry );
|
||||||
|
@ -30,6 +30,9 @@ public:
|
||||||
|
|
||||||
void fillSendBuffer( std::vector< uint8_t >& sendBuffer );
|
void fillSendBuffer( std::vector< uint8_t >& sendBuffer );
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_segmentTargetOverride;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,20 +290,20 @@ void Core::Entity::Actor::sendToInRangeSet( Network::Packets::FFXIVPacketBasePtr
|
||||||
|
|
||||||
// it might be that the player DC'd in which case the session would be invalid
|
// it might be that the player DC'd in which case the session would be invalid
|
||||||
if( pSession )
|
if( pSession )
|
||||||
pSession->getZoneConnection()->queueOutPacket( std::move( pPacket ) );
|
pSession->getZoneConnection()->queueOutPacket( pPacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_inRangePlayers.empty() )
|
if( m_inRangePlayers.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pPacket->setSourceActor( m_id );
|
||||||
|
|
||||||
for( const auto &pCurAct : m_inRangePlayers )
|
for( const auto &pCurAct : m_inRangePlayers )
|
||||||
{
|
{
|
||||||
assert( pCurAct );
|
assert( pCurAct );
|
||||||
pPacket->setSourceActor( m_id );
|
|
||||||
pPacket->setTargetActor( pCurAct->getId() );
|
|
||||||
// it might be that the player DC'd in which case the session would be invalid
|
// it might be that the player DC'd in which case the session would be invalid
|
||||||
// TODO: copy packet to a new unique_ptr then move ownership
|
// TODO: copy packet to a new unique_ptr then move ownership
|
||||||
//pCurAct->queuePacket( pPacket );
|
pCurAct->queuePacket( pPacket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ void Core::Network::GameConnection::processOutQueue()
|
||||||
int32_t totalSize = 0;
|
int32_t totalSize = 0;
|
||||||
|
|
||||||
// create a new packet container
|
// create a new packet container
|
||||||
PacketContainer pRP = PacketContainer();
|
PacketContainer pRP = PacketContainer( m_pSession->getId() );
|
||||||
|
|
||||||
// get next packet off the queue
|
// get next packet off the queue
|
||||||
while( auto pPacket = m_outQueue.pop() )
|
while( auto pPacket = m_outQueue.pop() )
|
||||||
|
|
Loading…
Add table
Reference in a new issue