1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Removed old GamePacket

This commit is contained in:
Mordred Admin 2018-07-03 09:20:09 +02:00
parent b784c9e311
commit 50ba02ed27
15 changed files with 8 additions and 225 deletions

View file

@ -1,106 +0,0 @@
#include <stdio.h>
#include "GamePacket.h"
#include <time.h>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include "Util/Util.h"
Core::Network::Packets::GamePacket::GamePacket( uint16_t subType, uint16_t size,
uint32_t id1, uint32_t id2, uint16_t type )
{
m_dataBuf = std::vector< uint8_t >( size );
memset( &m_segHdr, 0, sizeof( m_segHdr ) );
setHeader( size, type, id1, id2, subType, 0x00 );
}
void Core::Network::Packets::GamePacket::setHeader( uint16_t size, uint16_t type, uint32_t id1,
uint32_t id2, uint16_t subType, uint32_t unknown )
{
m_segHdr.size = size;
m_segHdr.type = type;
m_segHdr.source_actor = id1;
m_segHdr.target_actor = id2;
//m_segHdr._reserved_E = 0x00;
m_subType = subType;
m_timeStamp = static_cast< uint32_t >( time( nullptr ) );
if( size > 0 )
{
memcpy( &m_dataBuf[0], &m_segHdr, sizeof( m_segHdr ) );
m_dataBuf[0x10] = 0x14;
*reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x12 ) = m_subType;
}
if( size > 0x18 )
*reinterpret_cast< uint32_t* >( &m_dataBuf[0] + 0x18 ) = m_timeStamp;
}
Core::Network::Packets::GamePacket::GamePacket( char * pData, uint16_t size, bool bWriteStamp )
{
m_dataBuf = std::vector< uint8_t >( size );
memcpy( &m_dataBuf[0], pData, size );
m_unknown2 = 0;
if( bWriteStamp && size > 0x18 )
{
m_timeStamp = static_cast< uint32_t >( time( nullptr ) );
*reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x10 ) = 0x14;
*reinterpret_cast< uint32_t* >( &m_dataBuf[0] + 0x18 ) = m_timeStamp;
}
//m_segHdr._reserved_E = 0;
m_segHdr.size = *reinterpret_cast< uint32_t* >( &m_dataBuf[0] );
m_segHdr.type = *reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x0C );
m_subType = *reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x12 );
m_segHdr.source_actor = *reinterpret_cast< uint32_t* >( &m_dataBuf[0] + 0x04 );
m_segHdr.target_actor = *reinterpret_cast< uint32_t* >( &m_dataBuf[0] + 0x08 );
}
Core::Network::Packets::GamePacket::GamePacket( const Packets::FFXIVARR_PACKET_RAW& packetData )
{
m_segHdr = packetData.segHdr;
m_dataBuf = std::vector< uint8_t >( m_segHdr.size );
memcpy( &m_dataBuf[0] + sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ),
&packetData.data[0],
m_segHdr.size - sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) );
memcpy( &m_dataBuf[0], &m_segHdr, sizeof( Packets::FFXIVARR_PACKET_SEGMENT_HEADER ) );
m_subType = *reinterpret_cast< uint16_t* >( &m_dataBuf[0] + 0x12 );
if( m_segHdr.size > 0x18 )
m_timeStamp = *reinterpret_cast< uint32_t* >( &m_dataBuf[0] + 0x18 );
}
Core::Network::Packets::GamePacket::GamePacket()
{
}
Core::Network::Packets::GamePacket::~GamePacket()
{
}
void Core::Network::Packets::GamePacket::savePacket()
{
char filename[20];
sprintf( filename, "dump_0x%x_%li.dat", m_subType, Util::getTimeMs() );
FILE* fp = nullptr;
fp = fopen( filename, "wb" );
fwrite( &m_dataBuf[0], 1, m_segHdr.size, fp );
fclose( fp );
}
std::string Core::Network::Packets::GamePacket::toString() const
{
return Core::Util::binaryToHexDump( const_cast< uint8_t* >( &m_dataBuf[0] ), getSize() );
}

View file

@ -1,104 +0,0 @@
#ifndef _GAMEPACKET_H_
#define _GAMEPACKET_H_
#include "CommonNetwork.h"
#include "Forwards.h"
#include <stdint.h>
#include <string.h>
namespace Core {
namespace Network {
namespace Packets {
class GamePacket
{
public:
GamePacket( uint16_t subType, uint16_t size, uint32_t id1, uint32_t id2, uint16_t type = 0x03 );
GamePacket( char* pData, uint16_t size, bool bWriteStamp = true );
GamePacket( const Packets::FFXIVARR_PACKET_RAW& packetData );
GamePacket( void );
~GamePacket( void );
uint16_t getSize() const
{
return m_segHdr.size;
}
uint16_t getType() const
{
return m_segHdr.type;
}
uint16_t getSubType() const
{
return m_subType;
}
template< class T >
void setValAt( uint16_t pos, T value )
{
assert( m_segHdr.size > pos );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) );
}
template< class T >
T getValAt( uint16_t pos ) const
{
assert( m_segHdr.size > pos );
return *reinterpret_cast< const T* >( &m_dataBuf[0] + pos );
}
void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length )
{
assert( m_segHdr.size > offset );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length );
}
const char* getStringAt( uint16_t pos ) const
{
assert( m_segHdr.size > pos );
return reinterpret_cast< const char* >( &m_dataBuf[0] + pos );
}
void setStringAt( uint16_t pos, const std::string& str )
{
assert( m_segHdr.size > pos );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() );
}
const uint8_t* getData() const
{
return reinterpret_cast< const uint8_t* >( &m_dataBuf[0] );
}
const uint8_t* getDataAt(uint16_t pos) const
{
assert( m_segHdr.size > pos );
return reinterpret_cast< const uint8_t* >( &m_dataBuf[0] + pos );
}
void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 );
std::string toString() const;
void savePacket();
FFXIVARR_PACKET_SEGMENT_HEADER m_segHdr;
protected:
uint16_t m_unknown2;
uint16_t m_subType;
uint32_t m_timeStamp;
std::vector< uint8_t > m_dataBuf;
};
}
}
}
#endif

View file

@ -4,12 +4,15 @@
#include <stdint.h>
#include <iostream>
#include "GamePacket.h"
#include <sstream>
#include <time.h>
#include <boost/make_shared.hpp>
#include <string.h>
#include <memory>
#include "CommonNetwork.h"
#include "PacketDef/Ipcs.h"
namespace Core {
namespace Network {
@ -284,4 +287,4 @@ protected:
} /* Network */
} /* Core */
#endif /*_CORE_NETWORK_PACKETS_CGAMEPACKETNEW_H*/
#endif /*_CORE_NETWORK_PACKETS_CGAMEPACKETNEW_H*/

View file

@ -6,7 +6,8 @@
#include <boost/format.hpp>
#include <chrono>
#include <string.h>
#include <memory>
Core::Network::Packets::PacketContainer::PacketContainer()
{

View file

@ -4,7 +4,6 @@
#include <Network/CommonNetwork.h>
#include <Util/Util.h>
#include <Logging/Logger.h>
#include <Network/GamePacket.h>
#include <Network/GamePacketNew.h>
#include <Network/PacketDef/Lobby/ServerLobbyDef.h>
#include <Network/GamePacketParser.h>

View file

@ -5,7 +5,6 @@
#include <Network/Acceptor.h>
#include <Network/CommonNetwork.h>
#include <Network/GamePacket.h>
#include <Network/PacketContainer.h>
#include <Util/LockedQueue.h>

View file

@ -1,6 +1,5 @@
#include "LobbyPacketContainer.h"
#include <Network/CommonNetwork.h>
#include <Network/GamePacket.h>
#include <Network/GamePacketNew.h>
#include <Crypt/blowfish.h>
#include <Common.h>

View file

@ -8,7 +8,6 @@
#include "Network/PacketWrappers/ActorControlPacket144.h"
#include <Logging/Logger.h>
#include <Network/GamePacket.h>
#include <Network/GamePacketNew.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Util/UtilMath.h>

View file

@ -3,7 +3,6 @@
#include <Common.h>
#include <Util/Util.h>
#include <Util/UtilMath.h>
#include <Network/GamePacket.h>
#include <Logging/Logger.h>
#include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h>

View file

@ -1,5 +1,4 @@
#include <Common.h>
#include <Network/GamePacket.h>
#include <Logging/Logger.h>
#include <Network/PacketContainer.h>
#include <Config/ConfigMgr.h>

View file

@ -1,5 +1,4 @@
#include <Common.h>
#include <Network/GamePacket.h>
#include <Logging/Logger.h>
#include "Zone/Zone.h"

View file

@ -1,6 +1,5 @@
#include <Common.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/GamePacket.h>
#include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h>

View file

@ -1,7 +1,6 @@
#include <set>
#include <Common.h>
#include <Network/GamePacket.h>
#include <Util/Util.h>
#include <Util/UtilMath.h>
#include <Logging/Logger.h>

View file

@ -9,7 +9,6 @@
#include <Network/Acceptor.h>
#include <Network/PacketContainer.h>
#include <Network/GamePacketParser.h>
#include <Network/GamePacket.h>
#include "Zone/Zone.h"

View file

@ -5,7 +5,6 @@
#include <Logging/Logger.h>
#include <Util/Util.h>
#include <Util/UtilMath.h>
#include <Network/GamePacket.h>
#include <Network/GamePacketNew.h>
#include <Exd/ExdDataGenerated.h>
#include <Network/CommonNetwork.h>