Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds server-side cleanup logic for clients that disconnect silently (e.g., crash / dropped disconnect), and improves reliability of entity-removal broadcasts.
Changes:
- Track
lastSeenAtper connected client and evict clients with no inbound traffic for 10 seconds. - Refactor disconnect removal into
removePlayer()and invoke it from both explicit disconnects and timeouts. - Mark entity-removal/death packets as
PacketFlags::Reliable, and trigger region streaming refresh after player respawn.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/server/Server.cpp |
Updates packet dispatch to refresh lastSeenAt, adds timeout eviction, refactors player removal, and marks some removal/death packets reliable. |
include/server/Server.hpp |
Declares new helper methods removePlayer() and timeoutSilentClients(). |
include/server/PlayerInfo.hpp |
Adds lastSeenAt timestamp to support silent-client timeouts. |
Comments suppressed due to low confidence (1)
src/server/Server.cpp:572
timeoutSilentClients()rebuilds the iterator using an index after callingremovePlayer(it), but this assumesremovePlayer()always erases an element. IfremovePlayer()returns without erasing (e.g., entity not found),itis reset to the same position and the loop can repeatedly hit the timeout path. A more robust pattern is to haveremovePlayer()return the next valid iterator (or a bool indicating removal) so this loop can always make progress.
for (auto it = players.begin(); it != players.end();)
{
if (currTick - it->lastSeenAt > CLIENT_TIMEOUT)
{
std::cout << "[Server] Client '" << it->movement->getName()
<< "' timed out (no packets for "
<< std::chrono::duration_cast<std::chrono::seconds>(CLIENT_TIMEOUT).count()
<< "s), removing.\n";
size_t idx = static_cast<size_t>(it - players.begin());
removePlayer(it);
it = players.begin() + idx;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Devinci24
approved these changes
May 22, 2026
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.



bug fixes