-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate construction to use int_id and string_id #37436
Conversation
Would it make sense to create separate JSON file with an array of |
The actual object an index points to depend on when the save was created and what mods were loaded, including non-official ones. So that wouldn't work. Let's just call it spilt milk. |
Yeah, it would make some sense if it was a closed list of enums, but can't do anything sane in current case. |
@Qrox: FYI: Blueprint checks started to fail after this one, because order of entries in various requirements vectors of some blueprint recipes changed. What I don't get though is why checks did not fail in this PR. |
This PR was earlier than the blueprint check PR, and that's probably why it didn't fail. What confuses me is that some recipes now seem to have different requirements in addition to changed component order, which shouldn't happen since this PR should at most change the order of requirements (which I failed to realize and left as a todo in the blueprint check PR). Thanks, I'll look into it. |
It seems that
The consolidated requirement becomes
However if the requirement was
It remains unchanged after consolidation. The only way I can think of to ensure symmetry is to only merge two lists if they have the same tool/item requirement ids, but doing so would make the requirement data complicated and fail the complexity check of |
Summary
SUMMARY: Infrastructure "Migrate construction to use int_id and string_id"
Purpose of change
The game was using raw integer to index construction objects, which is inconsistent with the rest of the code. Even more problematically, these raw integer indices were stored to saves directly. Since these indices depend on the loading order of the JSON data, this would cause saved in-progress construction to change type when loaded back after JSON files have been changed.
Describe the solution
Migrated
construction
to useint_id
andstring_id
. Integer indices from old saves are still loaded as-is and converted toint_id
, since I don't see any reliable way to infer the actual object an index was pointing to when it was last saved.On the other hand, the construction code was removing blacklisted objects in the finalization code. Since this could cause problems if the list of construction objects and construction ids are used by external code before finalization, I also added a few debug messages about accessing the list of construction objects or using construction ids before finalization. Also moved finalization of constructions before finalization of crafting recipes, since the latter uses construction objects to do auto requirements calculation.
Additionally, I also fixed the code to properly hide unavailable constructions when toggled to do so, and made it to ignore skill requirements during construction activity with debug hammerspace.
Testing
Loaded a save from before this change with in-progress constructions and they were properly loaded. Then I started new constructions, saved, and loaded, and they were also properly loaded. Tried finishing these constructions without problem. Recipe autocalculation for faction camp projects were also working as before.
Tested toggling unavailable constructions, and all unavailable constructions were hidden. Started construction with debug hammerspace but zero skills, and construction proceeded without problem.