[2.0.x] broken save files and migrating things with illegal names for 2.0.x (e.g. items, entities etc.)
Posted: Mon Dec 09, 2024 10:21 pm
The 2.0.7 release notes contain this line: Restricted prototype names to only contain alphanumeric characters, dashes and underscores.
That is a bummer because I have a bunch of mods where, for 1.x, I used a prefix to differentiate its assets (items, entities, recipes, technology etc.) from other mods.
With the 2.0 release, the prefix became "illegal" (it had a colon ":" in it). I changed the prefix to be compatible for 2.0.
Now, if you try to load an old 1.1 game, all of the entities are gone ("invalid entity") even though there is an upgraded version of the mod available. This is sad because I have a few pretty massive saves that now lose all of those entities and items.
I can not see a way around this currently short of patching the save files (and I don't have a tool that can do that so it is challenging). Does such a tool exist.
The way I see it, there are three ways to deal with this:
- release a tool that you can run on a save file to replace the names of things in he save file to match new prototypes. This seems cumbersome and error prone.
- loosen up the name restrictions again a bit (at least allow the ":" back, then I will go away
)
- make the game migrate these things:
Add an attribute in the data phase to the prototypes like "legacy_name". This accepts all names that the "old" 1.1 game accepted (not the new, restricted name rules like 2.0). Anything encountered when loading a game that matches that "legacy_name" will have its name changed from the "legacy_name" to the "name" value of a prototype.
This is clearly a hacky way to do that ("what if two entities declare the same legacy name? "behave the same way as when two entities declare the same name") but the game does read all game files and should be able to construct an in-memory model of the game that can migrate old content.
Thanks for considering.
That is a bummer because I have a bunch of mods where, for 1.x, I used a prefix to differentiate its assets (items, entities, recipes, technology etc.) from other mods.
With the 2.0 release, the prefix became "illegal" (it had a colon ":" in it). I changed the prefix to be compatible for 2.0.
Now, if you try to load an old 1.1 game, all of the entities are gone ("invalid entity") even though there is an upgraded version of the mod available. This is sad because I have a few pretty massive saves that now lose all of those entities and items.
I can not see a way around this currently short of patching the save files (and I don't have a tool that can do that so it is challenging). Does such a tool exist.
The way I see it, there are three ways to deal with this:
- release a tool that you can run on a save file to replace the names of things in he save file to match new prototypes. This seems cumbersome and error prone.
- loosen up the name restrictions again a bit (at least allow the ":" back, then I will go away

- make the game migrate these things:
Add an attribute in the data phase to the prototypes like "legacy_name". This accepts all names that the "old" 1.1 game accepted (not the new, restricted name rules like 2.0). Anything encountered when loading a game that matches that "legacy_name" will have its name changed from the "legacy_name" to the "name" value of a prototype.
This is clearly a hacky way to do that ("what if two entities declare the same legacy name? "behave the same way as when two entities declare the same name") but the game does read all game files and should be able to construct an in-memory model of the game that can migrate old content.
Thanks for considering.