Skip to content

Commit

Permalink
Merge pull request #957 from openmultiplayer/amir/network-fixes
Browse files Browse the repository at this point in the history
Network fixes
  • Loading branch information
AmyrAhmady authored Aug 8, 2024
2 parents 89cc53c + eb209ea commit 02dca73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Server/Components/LegacyNetwork/legacy_network_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,19 @@ void RakNetLegacyNetwork::onTick(Microseconds elapsed, TimePoint now)
}

IPlayer* player = playerFromRakIndex[pkt->playerIndex];

// We shouldn't be needing this, it's only here IF somehow this is happening again
// So users can report it to us
if (player && player->getID() == -1)
{
rakNetServer.Kick(pkt->playerId);
playerFromRakIndex[pkt->playerIndex] = nullptr;
core->logLn(LogLevel::Warning, "RakNet player %d with open.mp player pool id -1 was found and deleted. Packet ID: %d", pkt->playerIndex, pkt->data[0]);
core->logLn(LogLevel::Warning, "Please contact us by creating an issue in our repository at https://github.com/openmultiplayer/open.mp");
rakNetServer.DeallocatePacket(pkt);
continue;
}

if (player)
{
NetworkBitStream bs(pkt->data, pkt->length, false);
Expand Down
1 change: 1 addition & 0 deletions Server/Components/LegacyNetwork/legacy_network_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class RakNetLegacyNetwork final : public Network, public CoreEventHandler, publi
{
playerFromRakIndex[playerIndex] = nullptr;
}
playerRemoteSystem[peer.getID()] = nullptr;
rakNetServer.Kick(rid);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/RakNet

0 comments on commit 02dca73

Please sign in to comment.