mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 00:47:45 +00:00
Tempoary bound check for GamePacket
This commit is contained in:
parent
5fedd0c1df
commit
4ecc5cef54
1 changed files with 5 additions and 0 deletions
|
@ -38,27 +38,32 @@ public:
|
|||
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() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue