Posted by: Steve Walmsley
« on: June 04, 2024, 04:07:08 AM »I started getting error "2.5.1 Function #1500: constraint failed UNIQUE constraint failed: FCT_ShipDesignComponents.SDComponentID" every time I save. Doesn't seem to harm anything, although I haven't since tried closing the game and loading the save, as I'm afraid it might not actually be saving or might be corrupting the save.
That sounds like you somehow have two components with the same ID, which shouldn't happen. Unfortunately, if that happens it prevents that table being saved at all. If you have only saved once or twice, you can go back to the one of the auto-backup saves.
Unfortunately I've saved at least two dozen times since then across several in-game years of gameplay. Is there anything I can do to save (literally and figuratively) the game? I'm reasonably comfortable with DB editing from past experience updating the DB to implement "pre-release" changes of prior changelogs.
I hadn't edited this DB at all, so I'm not sure how I wound up with this error. Could it be caused by creating and deleting an identical component and deleting it, either before or after researching? I think I may have done that with a Particle Beam 6 component. Would it be possible to guess which units/ships have the component, delete all of those units, and save again, to see if that solves the problem? Or is it likely unfixable because the issue is not within the DB, it's within the working memory of the program, and being prevented from correctly saving in the DB?
Edit: I copied my entire game folder and ran the exe from there, then compared the ship list and found one ship that had a different mass. That ship had a shield component in research in my version of the game throwing the bug, and it was missing in the saved DB. It looked like everything else was fine (all other components I'd designed recently were there). I saved the DB, and it worked fine, no bug. Based on that, I felt safe closing and restarting my game from my normal folder, and upon re-launch, that shield component was missing from the in-progress research and from the ship that was using it as a prototype, but otherwise everything was fine and it saved with no bug. Problem solved!
Well done on fixing it.