Repository navigation
RakNet crash fixes, performance improvements, fix ordering channels for some RPCs - #883
Merged
Merged
Conversation
ksenonadv
approved these changes
Mar 5, 2024
Collaborator
|
There's no PR on the RakNet repo for the commit you linked here |
Hual
approved these changes
Mar 9, 2024
Member
Author
|
Confirmed by people who are actively using this build, works fine and their crashes are gone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. RakNet Crashes
There are many places in RakNet you seepacket data being deleted using
deleteordelete[]and while it works fine, there are cases where double deletion happens, it's very random so the cause isn't clear yet. But finding the actual problem and fixing was easier than reproducing it (Check here: openmultiplayer/RakNet@3efbe1b...7f4f20d#diff-dcf7bd2af9b6ecac1d8af94416ca373c3a6f7a9528852c176dc36ae02e02223f)2. RakNet related improvements
GetRemoteSystemFromPlayerIDworks internally in RakNet, it loops through all available slots (not taken, not empty, all of them) and tries to search for the samePlayerIDand returnRemoteSystemStructptr for it. A huge improvement can be made by just caching and storing a pointer ofRemoteSystemStructon connect and releasing it on disconnect on open.mp side of the project, to use it for re-implementingGetLastPingforIPlayer::getPingandINetwork::getPing. This also massively helps ScoreAndPingsUpdate RPC since it loops through all players and callsgetPingfor each of them, resulting aplayer count * max playersloop, for full servers it's1000 * 1000iterations for nothing.playerIndexesflat hash map used internally in RakNet, for way fasterPlayerIDand playerindexlookup and use it in different places in RakNet to, again, improve performance noticeably and get rid of unnecessary overhead of looping through all slots every time you want to find a player index based on theirRakNet::PlayerIDwhich is a linear search.2. Fix chat RPC ordering channels
Almost all chat related RPCs had wrong ordering channels defined, as
OrderingChannel_Unordered, while they should be anything ordered, preferablyOrderingChannel_SyncRPC.