Add save/restore support for linked object relationships#8499
Merged
Conversation
LinksManager did not serialize or deserialize object links, so any links created with the LinkedObjects extension were lost after saving and loading game state. Add getSerializedLinks/restoreSerializedLinks methods to LinksManager, wire them into createGameSaveState and restoreGameSaveState, and add a test verifying round-trip persistence. https://claude.ai/code/session_01CbHABHad9Ci3VpG1uMqDH8
Adopt improvements from alternative patch:
- Store ownerObject on IterableLinkedObjects, eliminating the
reverse-lookup hack for finding networkIds during serialization
- Rename methods to getNetworkSyncData/updateFromNetworkSyncData
to match codebase conventions
- Add clearAllLinks() and call it before restore to prevent stale links
- Use compact [string, string] tuple format instead of {a, b} objects
- Use public APIs (evtTools.linkedObjects.linkObjects,
getObjectsLinkedWith) in tests instead of internal methods
- Add test for same-type linked objects persistence
https://claude.ai/code/session_01CbHABHad9Ci3VpG1uMqDH8
clearAllLinks() was destroying links between DoNotSave objects that should have been left untouched. Instead, only clear links for objects whose networkId is in the save state. This preserves links between non-saved objects while still correctly removing stale links between saved objects. Add test verifying DoNotSave object links survive. https://claude.ai/code/session_01CbHABHad9Ci3VpG1uMqDH8
Move link save/restore logic from SaveStateTools.ts into the LinkedObjects extension using registerRuntimeSceneGetSyncDataCallback and registerRuntimeSceneUpdateFromSyncDataCallback, following the established TweenBehavior pattern. SaveState no longer references gdjs.LinksManager, so games without the LinkedObjects extension don't crash. Link data moves from SceneSaveState.linkedObjectLinks to LayoutNetworkSyncData.linkedObjects, gated by a new syncLinkedObjects option in GetNetworkSyncDataOptions. https://claude.ai/code/session_01CbHABHad9Ci3VpG1uMqDH8
NBForgeLab
added a commit
to NBForgeLab/GDevelop
that referenced
this pull request
Apr 8, 2026
* Make the home page navigation sidebar collapsible * Fix potential crashes in the scene editor * Improve logs in case of UseAfterFreeError Only show in developer changelog * Fix potential crashes in the scene editor Don't show in changelog * Display extension details side by side with the extension list on large screens (4ian#8482) * Fix hot-reloading of global object instances (4ian#8489) * Fix "Add or edit variables" button always creating variables for object variables (4ian#8493) * Fix "Add or edit variables" button opening scene variables instead of local variables (4ian#8496) * Add save/restore support for linked object relationships (4ian#8499) Fix 4ian#8497 --------- Co-authored-by: Florian Rival <Florian.rival@gmail.com> Co-authored-by: D8H <Davy.Helard@gmail.com>
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.
Should fix #8497