Skip to content

Fixxx#105

Merged
ldominiq merged 4 commits into
devfrom
fixxx
May 22, 2026
Merged

Fixxx#105
ldominiq merged 4 commits into
devfrom
fixxx

Conversation

@ldominiq

Copy link
Copy Markdown
Owner

bug fixes

@ldominiq ldominiq self-assigned this May 22, 2026
Copilot AI review requested due to automatic review settings May 22, 2026 14:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lastSeenAt per 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 calling removePlayer(it), but this assumes removePlayer() always erases an element. If removePlayer() returns without erasing (e.g., entity not found), it is reset to the same position and the loop can repeatedly hit the timeout path. A more robust pattern is to have removePlayer() 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.

Comment thread src/server/Server.cpp Outdated
@sonarqubecloud

Copy link
Copy Markdown

@ldominiq ldominiq merged commit a29bf47 into dev May 22, 2026
2 checks passed
@ldominiq ldominiq deleted the fixxx branch May 22, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants