Fixed crashed caused by sending messages that have been read previously
(which were sent with incorrect length).
This commit is contained in:
parent
45b2fef88a
commit
6d1e5dc8ae
@ -152,6 +152,12 @@ public:
|
||||
/** Returns the remaining length of the network string. */
|
||||
unsigned int size() const { return (int)m_buffer.size()-m_current_offset; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the send size, which is the full length of the buffer. A
|
||||
* difference to size() happens if the string to be sent was previously
|
||||
* read, and has m_current_offset != 0. Even in this case the whole
|
||||
* string must be sent. */
|
||||
unsigned int getTotalSize() const { return m_buffer.size(); }
|
||||
// ------------------------------------------------------------------------
|
||||
// All functions related to adding data to a network string
|
||||
/** Add 8 bit unsigned int. */
|
||||
|
@ -69,7 +69,8 @@ void STKPeer::sendPacket(NetworkString *data, bool reliable)
|
||||
Log::verbose("STKPeer", "sending packet of size %d to %s",
|
||||
data->size(), a.toString().c_str());
|
||||
|
||||
ENetPacket* packet = enet_packet_create(data->getData(), data->size(),
|
||||
ENetPacket* packet = enet_packet_create(data->getData(),
|
||||
data->getTotalSize(),
|
||||
(reliable ? ENET_PACKET_FLAG_RELIABLE
|
||||
: ENET_PACKET_FLAG_UNSEQUENCED));
|
||||
enet_peer_send(m_enet_peer, 0, packet);
|
||||
|
Loading…
x
Reference in New Issue
Block a user