Skip to content

Fix entry into existing frost caves - #155

Open
jneb802 wants to merge 1 commit into
mainfrom
fix/frost-cave-saved-interior
Open

jneb802 wants to merge 1 commit into
mainfrom
fix/frost-cave-saved-interior

Conversation

@jneb802

@jneb802 jneb802 commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Align recreated frost cave interiors with their saved dungeon transforms so existing caves place players inside the entrance room.

  • Reproduced on Valnet client 01 with Season 8 8.0.50, production configuration, and Valdev's copy of praetorisSeason8v2. Cave (-576, 220, 2176) placed the player outside the entrance room with Endgame 0.7.0 both enabled and removed.
  • The recreated gateway used the current prefab position while the saved dungeon retained a different position. The correction matches the unique saved generator in the same sector and at the same height, then aligns only the temporary location interior. Saved dungeon rooms and world objects are not modified. Missing network data is retried; ambiguous matches are left unchanged.
  • With the correction and Endgame enabled, the affected cave landed inside the entrance room beside the exit. Entry and exit also passed at a second saved cave (-320, 158, 2048).
  • A previously ungenerated cave (-2944, 136, 6784) generated and entered/exited correctly without a position correction. Two new caves also worked in the original Endgame-on/off comparison.
  • Inspected screenshots and client logs. The baseline and candidate each reported the same 57 shader errors and no other errors in the comparison window. dotnet build PraetorisClient.csproj -c Release passed with 83 existing warnings and no errors.
  • The candidate was built on deployed PraetorisClient 0.1.105 to isolate this change. The branch changes only the new correction file and targets main. Dedicated-server multiplayer validation remains incomplete; production and Valdev were not changed.

Fixes #154.

@github-actions

Copy link
Copy Markdown

No blocking issues found.

Reviewed: Source/World/FrostCaveInterior.cs (new file, 104 lines). The patch hooks LocationProxy.SpawnLocation to attach a throttled MonoBehaviour that aligns a recreated frost cave interior with its saved dungeon generator's ZDO position and rotation.

Correctness of the transform correction (lines 79–81):
The rotation is applied first, then the position delta is computed using generator.transform.position after the rotation has changed it. That ordering is intentional and mathematically correct: the position adjustment savedPosition - generator.transform.position shifts the generator from its post-rotation world position to the saved position, which is the goal.

Retry mechanism: When no ZDO is found (savedGenerator == null, line 69), the method returns without destroying the component, so Unity continues calling Update() on subsequent frames (throttled to once per second by _nextCheck). This correctly handles the remote-client case where the generator ZDO arrives after the proxy.

Ambiguity guard (lines 58–63): If two generators match the prefab hash and Y-height in the sector, the component logs a warning and self-destructs without modifying anything. This prevents a wrong correction from being silently applied.

Nit — _objects as a field: The list is cleared and repopulated on every poll cycle; there is no state shared across calls. Keeping it as a field (private readonly List<ZDO> _objects) is a reasonable allocation-avoidance choice for a per-frame callback, but worth noting it reads like shared state when it is not.

Nit — no existing-component guard in the Postfix: AddComponent<FrostCaveInterior>() is called without checking whether one already exists. Under normal zone-load behaviour SpawnLocation returns true only once per proxy instance, so double-application is not realistically reachable, but a GetComponent guard would make the invariant explicit.

@jneb802

jneb802 commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Historical cause is now documented in MidnightsFX/Valheim_Star_Levels_Expanded#32. A failed SLS reset bypassed Valheim’s prefab-transform restoration, and later resets persisted displaced interiors. This PR remains a client-side repair for existing displaced saves; it does not prevent the server-side generation failure. The unpatched production mirror also reproduced the entrance failure on Valnet client 02 connected to Valdev. Dedicated-server validation of this PR itself is still incomplete.

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.

Align existing frost cave gateways with their saved dungeon

1 participant