Skip to content

Joining or syncing a room no longer fails when the host's names move between functions (#107) - #117

Open
tiredunc wants to merge 1 commit into
n-delic:mainfrom
tiredunc:fix/room-sync-name-clash
Open

tiredunc wants to merge 1 commit into
n-delic:mainfrom
tiredunc:fix/room-sync-name-clash

Conversation

@tiredunc

Copy link
Copy Markdown

Fixes #107. Room sync crashed on UNIQUE(project_id, name) in two ways: the host moved a name onto another address (split tail, swap, chain), or two functions shared an address (PS2 overlays) and a rename hit both. Whichever function holds a name now steps aside to its func_XXXXXXXX name until the host's name arrives, and a rename applies to the function that held the old name. Tested: three new regression tests in tests/test_collab.py fail without the fix and pass with it; ruff passes. Also ran live in a room on a PS2 project where the error used to repeat; it now syncs.

…between functions (n-delic#107)

apply_remote_layout wrote the host's names without checking whether another local function still held them, so the split and rename passes crashed on UNIQUE(project_id, name) and the sync retried forever. Whichever function holds a name now steps aside to its func_XXXXXXXX name until the host's own name for it arrives. Overlays can share an address with main code, so a rename now applies to the function that held the old name instead of every function at that address.
@github-actions github-actions Bot added the bug Something isn't working label Oct 25, 2026
@ensapra

ensapra commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

The error still appears when reimporting a project with the old functions
image

@tiredunc

Copy link
Copy Markdown
Author

Thanks for testing this. I think what your screenshot shows is a separate bug from this PR: #117 fixes the room sync (apply_remote_layout), but your log is from a reimport (the "Replacing project files and updating the function analysis" step), which runs different code (_import_split). I could reproduce the same message, UNIQUE constraint failed: functions.project_id, functions.name, by reimporting a PS2 project created on 1.0.6-alpha.3 with 1.0.6-alpha.4 plus this fix. The cause: reimport pairs old and new functions by address using a lookup that keeps one function per address, so a game whose overlay puts a second function at an address the main code already uses leaves one unpaired, and its name collides. I opened #123 for it. If you'd like to try it on your project, the branch is fix/reimport-overlay-twins on my fork.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntegrityError: UNIQUE constraint failed: functions.project_id, functions.name when joining/reimporting a room

2 participants