Commit Graph

8 Commits

Author SHA1 Message Date
9fbc01e6a4 Refactor helper assignment in PrefabManager to use Main.helper 2025-12-14 21:55:46 +01:00
5b84511923 Add instance reference to Main and update asset bundle loading in PrefabManager 2025-12-14 21:50:28 +01:00
4277098e13 Fix formatting issues and improve error handling in PrefabManager and LobbyManager 2025-12-14 21:49:32 +01:00
fb6889e310 asd 2025-12-14 21:38:38 +01:00
5e014a74da Fix NullReferenceException crashes when asset bundle is missing
Problem: When the 'serverbrowserpkg' asset bundle file is missing,
the mod crashed at multiple points:
- PrefabManager.PreScriptLoad(): NullReferenceException on line 58
- ServerBrowser.SceneLoaded(): "Object to instantiate is null" at line 312
- Main.TransitionTo(): NullReferenceException at lines 227-228

These crashes made the mod unusable and prevented proper error reporting.

Root cause:
The asset bundle file containing UI prefabs was missing from the mod
directory, causing all prefab references to be null. The code didn't
check for null before using these references.

Solutions:

PrefabManager.cs:
- Add null check after LoadAssetBundle() call (line 31-36)
- Return early with clear error message if bundle is null
- Provide guidance to user about missing file
- Better logging for successful loads

ServerBrowser.SceneLoaded():
- Add prefab null check at method start (line 302-309)
- Return early if prefabs are null
- Prevents crash during UI instantiation
- Clear error messages in log

Main.TransitionTo():
- Add comprehensive null checks before using UI references (line 228)
- If UI not loaded but user tries to access multiplayer menu:
  * Show user-friendly modal dialog
  * Explain the problem clearly
  * Provide reinstall guidance
- Gracefully handle missing UI without crashing

Results:
 No crashes when asset bundle is missing
 Clear, actionable error messages for users
 Graceful degradation - rest of mod still works
 User gets helpful modal instead of silent crash
 Better debugging with detailed logs

Updated README.md with:
- Documentation of all asset bundle fixes
- Code examples showing the changes
- Known Issues section noting missing asset bundle
- Instructions for resolving the issue

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 21:24:55 +01:00
3124f82a2f alap 2025-12-14 21:08:19 +01:00
3a7b81bfd7 save 2025-12-14 21:04:22 +01:00
679c3c9a52 first commit 2025-12-13 14:28:35 +01:00