Fix reconnect crash (EOCD) and building-placement NullReferenceException#195
Open
chrizZzt wants to merge 1 commit into
Open
Fix reconnect crash (EOCD) and building-placement NullReferenceException#195chrizZzt wants to merge 1 commit into
chrizZzt wants to merge 1 commit into
Conversation
Two independent crashes observed on Timberborn 1.0.13.1 / BeaverBuddies 1.7.1: 1. Client reconnect crash "End of Central Directory record could not be found". After the host connection drops (SocketException: Connection refused), the client receives a short non-map payload (e.g. 213 bytes; real maps are ~420-460 KB) and ClientConnectionService.LoadMap writes it to a save and loads it, so ZipArchive throws during scene load and the game crashes. LoadMap now validates the data (ZIP local-header magic + minimum length) and shows the connection-failed dialog instead of loading a bogus save. 2. NullReferenceException in ReplayEvent.GetEntityID when placing or duplicating a building. GetComponent<EntityComponent>() throws internally (ComponentCache) on a component that isn't registered as an entity yet (e.g. a duplication source while a tool is mid-use); the existing ?. only guards a null component. GetEntityID now catches that and returns null, which callers already handle. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 26, 2026
Owner
|
Thanks for the issues and the PR. I'm traveling and won't be able to look at it until next week, but I'll get back to you then. |
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.
Fixes two independent crashes observed on Timberborn 1.0.13.1 / BeaverBuddies 1.7.1.
Fixes #193
Fixes #194
1. Reconnect crash — "End of Central Directory record could not be found" (#193)
After the host connection drops (
SocketException: Connection refused), the client receives a short non-map payload (e.g. 213 bytes; real maps are ~420–460 KB) as its "first message".ClientConnectionService.LoadMapwrites those bytes into a save and loads them, soZipArchivethrows during scene load (outsideLoadMap, so a local try/catch can't catch it) and the game crashes.Fix: validate the received bytes before loading — a Timberborn save is a ZIP, so it must start with the local-file-header magic
PK\x03\x04and have a minimum length. If the data isn't a valid save, show the existing connection-failed dialog (ShowError(null)) instead of loading a bogus save.2. NullReferenceException in
ReplayEvent.GetEntityID(#194)When placing/duplicating a building,
GetEntityID(DuplicationSource)callscomponent.GetComponent<EntityComponent>(), which throws internally inComponentCache.GetIndex<T>()when the component isn't registered as an entity yet. The existing?.only guards a nullcomponent, not an exception thrown insideGetComponent.Fix: catch the exception and return
null; callers already treat a null entity ID as "not an entity" and fall back to the base behaviour.Notes
Release Steam). I was not able to run an extensive multi-machine co-op session, so a second pair of eyes on the reconnect path is welcome.Error reports/*.zipcrash dumps; details and logs are in the linked issues.Co-authored with assistance from Claude Code.