mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Clean up some packet-related code
This commit is contained in:
parent
5e89371ecd
commit
ee9258cefd
11 changed files with 94 additions and 239 deletions
|
@ -49,7 +49,13 @@ const char* NetworkPacket::getString(u32 from_offset) const
|
|||
{
|
||||
checkReadOffset(from_offset, 0);
|
||||
|
||||
return (char*)&m_data[from_offset];
|
||||
return reinterpret_cast<const char*>(&m_data[from_offset]);
|
||||
}
|
||||
|
||||
void NetworkPacket::skip(u32 count)
|
||||
{
|
||||
checkReadOffset(m_read_offset, count);
|
||||
m_read_offset += count;
|
||||
}
|
||||
|
||||
void NetworkPacket::putRawString(const char* src, u32 len)
|
||||
|
@ -311,24 +317,6 @@ NetworkPacket& NetworkPacket::operator>>(u8& dst)
|
|||
return *this;
|
||||
}
|
||||
|
||||
u8 NetworkPacket::getU8(u32 offset)
|
||||
{
|
||||
checkReadOffset(offset, 1);
|
||||
|
||||
return readU8(&m_data[offset]);
|
||||
}
|
||||
|
||||
u8* NetworkPacket::getU8Ptr(u32 from_offset)
|
||||
{
|
||||
if (m_datasize == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
checkReadOffset(from_offset, 1);
|
||||
|
||||
return &m_data[from_offset];
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u16& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 2);
|
||||
|
@ -339,13 +327,6 @@ NetworkPacket& NetworkPacket::operator>>(u16& dst)
|
|||
return *this;
|
||||
}
|
||||
|
||||
u16 NetworkPacket::getU16(u32 from_offset)
|
||||
{
|
||||
checkReadOffset(from_offset, 2);
|
||||
|
||||
return readU16(&m_data[from_offset]);
|
||||
}
|
||||
|
||||
NetworkPacket& NetworkPacket::operator>>(u32& dst)
|
||||
{
|
||||
checkReadOffset(m_read_offset, 4);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue