Skip to content

Add save/restore support for linked object relationships#8499

Merged
4ian merged 5 commits intomasterfrom
claude/fix-object-link-persistence-uE7WY
Apr 8, 2026
Merged

Add save/restore support for linked object relationships#8499
4ian merged 5 commits intomasterfrom
claude/fix-object-link-persistence-uE7WY

Conversation

@4ian
Copy link
Copy Markdown
Owner

@4ian 4ian commented Apr 8, 2026

Should fix #8497

claude and others added 5 commits April 8, 2026 13:52
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
@4ian 4ian merged commit 88d6366 into master Apr 8, 2026
5 of 6 checks passed
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>
@4ian 4ian deleted the claude/fix-object-link-persistence-uE7WY branch April 9, 2026 13:50
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.

Object links do not persist with save/load state

2 participants