mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Bunch of small fixes (coding style, very unlikely errors, warning messages)
This commit is contained in:
parent
a230e1e736
commit
eda9214f81
9 changed files with 51 additions and 34 deletions
|
@ -111,10 +111,10 @@ SharedBuffer<u8> makeOriginalPacket(
|
|||
u32 packet_size = data.getSize() + header_size;
|
||||
SharedBuffer<u8> b(packet_size);
|
||||
|
||||
writeU8(&b[0], TYPE_ORIGINAL);
|
||||
|
||||
memcpy(&b[header_size], *data, data.getSize());
|
||||
|
||||
writeU8(&(b[0]), TYPE_ORIGINAL);
|
||||
if (data.getSize() > 0) {
|
||||
memcpy(&(b[header_size]), *data, data.getSize());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -2266,14 +2266,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||
if(packetdata.getSize() < 1)
|
||||
throw InvalidIncomingDataException("packetdata.getSize() < 1");
|
||||
|
||||
u8 type = readU8(&packetdata[0]);
|
||||
u8 type = readU8(&(packetdata[0]));
|
||||
|
||||
if(type == TYPE_CONTROL)
|
||||
{
|
||||
if(packetdata.getSize() < 2)
|
||||
throw InvalidIncomingDataException("packetdata.getSize() < 2");
|
||||
|
||||
u8 controltype = readU8(&packetdata[1]);
|
||||
u8 controltype = readU8(&(packetdata[1]));
|
||||
|
||||
if( (controltype == CONTROLTYPE_ACK)
|
||||
&& (peer_id <= MAX_UDP_PEERS))
|
||||
|
@ -2398,15 +2398,15 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
|
|||
}
|
||||
else if(type == TYPE_ORIGINAL)
|
||||
{
|
||||
if(packetdata.getSize() < ORIGINAL_HEADER_SIZE)
|
||||
if(packetdata.getSize() <= ORIGINAL_HEADER_SIZE)
|
||||
throw InvalidIncomingDataException
|
||||
("packetdata.getSize() < ORIGINAL_HEADER_SIZE");
|
||||
("packetdata.getSize() <= ORIGINAL_HEADER_SIZE");
|
||||
LOG(dout_con<<m_connection->getDesc()
|
||||
<<"RETURNING TYPE_ORIGINAL to user"
|
||||
<<std::endl);
|
||||
// Get the inside packet out and return it
|
||||
SharedBuffer<u8> payload(packetdata.getSize() - ORIGINAL_HEADER_SIZE);
|
||||
memcpy(*payload, &packetdata[ORIGINAL_HEADER_SIZE], payload.getSize());
|
||||
memcpy(*payload, &(packetdata[ORIGINAL_HEADER_SIZE]), payload.getSize());
|
||||
return payload;
|
||||
}
|
||||
else if(type == TYPE_SPLIT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue