Changeset - r25246:253d54089251
[Not reviewed]
master
0 2 0
Rubidium - 3 years ago 2021-04-18 08:27:04
rubidium@openttd.org
Codechange: move the logic shrinking of the packets into the Packet itself
2 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/network/core/packet.cpp
Show inline comments
 
@@ -73,6 +73,11 @@ void Packet::PrepareToSend()
 
	this->buffer[1] = GB(this->size, 8, 8);
 

	
 
	this->pos  = 0; // We start reading from here
 

	
 
	/* Reallocate the packet as in 99+% of the times we send at most 25 bytes and
 
	 * keeping the other 1400+ bytes wastes memory, especially when someone tries
 
	 * to do a denial of service attack! */
 
	this->buffer = ReallocT(this->buffer, this->size);
 
}
 

	
 
/**
src/network/core/tcp.cpp
Show inline comments
 
@@ -65,11 +65,6 @@ void NetworkTCPSocketHandler::SendPacket
 

	
 
	packet->PrepareToSend();
 

	
 
	/* Reallocate the packet as in 99+% of the times we send at most 25 bytes and
 
	 * keeping the other 1400+ bytes wastes memory, especially when someone tries
 
	 * to do a denial of service attack! */
 
	packet->buffer = ReallocT(packet->buffer, packet->size);
 

	
 
	/* Locate last packet buffered for the client */
 
	p = this->packet_queue;
 
	if (p == nullptr) {
0 comments (0 inline, 0 general)