Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
ClientGhostWatchdog
Client-side watchdog mod for players connecting to Valheim servers that detects dropped connections and disconnects cleanly to prevent ghost desyncs.
CHANGELOG
Changelog
All notable changes to ClientGhostWatchdog will be documented in this file.
[1.1.0] - 2026-09-17
Fixed & Improved
- My Very Lame Peer Check: I had a dumb
if (serverPeer == null) continue;check thinking it would just wait for the peer to hook up. Turns out, when a mod likeServerCharactersabruptly yanks the cord on your connection,GetServerPeer()becomesnull, which meant my watchdog was happily spinning in an infinitecontinue;loop doing nothing while players were stranded in ghost limbo. I misread the underlying behavior on this one. If you're spawned in the world and the server peer vanishes, it now catches it, saves your character, and pulls you back to the menu. - Unswallowing Native Disconnects: I was being a bit too eager with my custom popup and accidentally bulldozing native's actual error messages. If an admin kicked or banned you, or the server shut down, my code was just crapping all over it to tell you it saved you from a ghost connection instead of letting you know the actual disconnect reason. Now checks if the game already has a legitimate error status before putting my message over it.
- Cleaned Up Connection Status Checks: Cleaned up my previously messy checks. Instead of silently dying in the background if the connection dropped, it now distinguishes between pre-spawn loading and in-game disconnects.
- Teleport / Portal Hang Guard: If a portal handshake hangs or desyncs, the watchdog shouldn't stay muted forever. Added a
TeleportTimeoutSecondsconfig (defaults to 30s) that resumes health checks if you get stuck in an infinite portal transition. - Disconnect Notice Delay: Added
DisconnectDelaySeconds(defaults to 5s, range 0 to 30s) so the on-screen center notice actually stays up long enough to read what happened before getting booted to the main menu. Set to 0 for instantaneous logout. - Debug Peer Severance Testing: Added
DebugSimulateSeverKeykeybind andcgw_simulateseverconsole command (requiresEnableDebugLogs) to simulate badly behaved mod peer drops for testing without needing another mod installed. - Consolidated Disconnect Logic: Cleaned up the disconnect code into a single shared helper routine instead of repeating HUD notices and logout calls all over the place.
[1.0.0] - 2026-09-17
Initial Release
- Dedicated Watchdog Coroutine: Background heartbeat monitoring independent of
Game.Updateto prevent frame hitching. - Singleplayer / Host Safety: Automatically inactive on singleplayer sessions or when hosting local servers (
ZNet.instance.IsServer()). - Connection Loss Detection: Monitors
ZRpcsocket peer state and detects server disconnection, timeout silence, and socket closure. - Midpoint Warning Notice: Displays a customizable on-screen warning alert (TopCenter hud notice) before forcing disconnection.
- Clean Disconnect: Triggers graceful return to main menu (
FejdStartup) preserving player save integrity and preventing ghost connection rollbacks. - Configurable: Configurable timeout duration, check intervals, custom warning/disconnect messages, and debug logging.