open.mp
open.mp copied to clipboard
RakNet InternalPacketPool & RakPeer::Send improvements and fixes
-
This PR adds a new implementation of
MemoryPoolfrom https://github.com/facebookarchive/RakNet/blob/master/Source/DS_MemoryPool.h , to be only and ONLY used forInternalPacketPool, by replacing the oldInternalPacketPoolclass implementation with newMemoryPool. This is because freeing and allocation new InternalPacket on memory wasn't handled properly in old RakNet, specially freeing them, resulting to many issues and crashes randomly in random occasions that we can't even figure out why. After going through samp-server disassembled code, I realized there are differences, and it's way different than just a simplefreecall ordeleteoperator and it looks more like what RakNet v4 offers, so I made it use that. This can potentially fix the memory leak issue we've had since the beginning of open.mp development, that could've been only noticeable on very long runs. -
Second change is adding new Send functions (also RPC functions, but they're not used, because they don't matter in this case) to take an instance of
NetworkBitStreamfor data, instead of passing raw data and number of bytes. RakNet has other Send functions that can takeRakNet::BitStreamand this is done because allSendfunctions callRakPeer::SendBufferedwhich take number of bits in your data. So using normalRakPeer::Sendfunction which take number of bytes and not bits, meaning it is always aligned and sends extra bits, while it shouldn't really matter on performance and bandwidth level, many servers and protection layers (like custom firewall rules) depend entirely on bit size of the data, and can fail when it's aligned to be valid number of bytes