-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Start centralizing all save related data in GameState_t #21122
Conversation
It would probably be good if you create a project for this (I’m just assuming this won’t be a small job.) |
Hm maybe, it's mostly moving globals into the struct, I'll have a look in the next couple days once I have a bit of time. |
Created the issue for this #21193 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. I haven't tested this in-game, but from the changes there shouldn't be any logic changes anyway.
I took the initiative to start the process of moving everything into a central place that is relevant to the save file. This is also how its done in OpenLoco, we need to move all the globals and everything that is going to be saved/loaded into the new struct GameState_t. I avoided touching the existing GameState class as that would end up in more refactor work, once we moved all the things we can look into cleaning up the game loop and get rid of the current GameState thing. There should be as little OOP usage as possible which also makes this struct trivial to copy then. After we have this done we can actually have save/load done in a separate thread and also have an in-game indicator that some work is done without halting the entire game. Moving all the globals and relevant things will be quite a bit of work but this is the only way forward. Also having this a separate state allows to load multiple parks at some point and potentially re-use the format for blueprints/new track format, it also makes the entire track format preview less painful by having a separate state for that.
I started with the first variable gCurrentTicks and layed out the groundworks for the import/export code, now we just need to shove more into it.