-
Notifications
You must be signed in to change notification settings - Fork 29
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
Rework/save load system #209
base: main
Are you sure you want to change the base?
Rework/save load system #209
Conversation
…e part of save system rework)
|
||
} | ||
controller = obj_controller.serialize(); | ||
ini = obj_ini.serialize(); |
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.
it's bit hard to see in Github's PR, but the main idea is to simply call (de)serializers from relevant objects and script, and just save/load them as one big json.
@@ -1648,3 +1648,422 @@ if (vih>=5){ | |||
remov=string_length(string(temp[65])+string(temp[66])+string(temp[67])+string(temp[68])+string(temp[69]))+1; | |||
|
|||
action_set_alarm(2, 0); | |||
|
|||
#region serialization |
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.
thinking about extracting this whole region into a separate file
popup_master_crafted, | ||
select_wounded, | ||
terra_direction, | ||
stc: { |
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.
as you can see, I reorganized variables a little, I wanted to see how a more data-driven approach would look like, and I like it so far
@@ -8,7 +8,7 @@ | |||
"option_windows_copy_exe_to_dest": false, | |||
"option_windows_copyright_info": "", | |||
"option_windows_description_info": "Become the 40,000th warhammer", | |||
"option_windows_disable_sandbox": false, | |||
"option_windows_disable_sandbox": true, |
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.
this is required to allow handling files in game executable folder
|
||
if (save_part=3){txt="Charting Sector";with(obj_controller){scr_save(2,obj_saveload.save_number);}trickle=10;save_part=4;} | ||
if (save_part = 6) { | ||
txt = "Praise to the Machine God"; |
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.
I'll re-add these last
Serialization part is done, about 40% of the rework is done. Next step: Also updated attached save file. |
# Conflicts: # objects/obj_star/Create_0.gml # scripts/scr_load/scr_load.gml
Heretics, | ||
Necrons = 13 | ||
Placeholder_1, // 12, not used anywhere currently, will be removed after creating proper structs for Factions | ||
Necrons // 13 |
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.
small tweaks to eFACTION enum
} | ||
|
||
function serialize_marine_struct(company, marine){ | ||
var copy_marine_struct = obj_ini.TTRPG[company, marine]; //grab marine structure |
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.
var copy_marine_struct = obj_ini.TTRPG[company, marine]; //grab marine structure | |
var copy_marine_struct = obj_ini.TTRPG[company][marine]; //grab marine structure |
// General data and init | ||
|
||
var _planetary_feature_data = { | ||
_index: index, |
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.
_index: index, | |
index: index, |
keys can't be variables unless variable_struct_set() is used so may as well just use index over _index
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.
the point of the underscore, is to denote that this is a bookkeeping variable, which should not be touched during save-editing. I'll add comments to make this clearer. I did this way because I'm not sure if the order of elements in an array are preserved during jsonification and dejsonification.
chaos_corruption_level: chaos[company_index][entity_in_company_index], | ||
experience: experience[company_index][entity_in_company_index], | ||
age: age[company_index][entity_in_company_index], | ||
is_special: spe[company_index][entity_in_company_index], // TODO Got no idea what this does |
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.
this contains phychic power data, i'm currently trying to move all this into the struct then this can be deprecated
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.
ok, I'll remove this
entity_in_company_index = 1; | ||
|
||
// HQ Marines?? | ||
for (entity_in_company_index = 1; entity_in_company_index <= 30; entity_in_company_index++) { |
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.
this should be role data
|
||
// General data and init | ||
|
||
var _planetary_feature_data = { |
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.
planetary features contain a much greater array of data and methods than are being serialised here, you may have catered for this already but just need to check
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.
yes, this is covered in my local code, just didn't push everything yet
var _planet_data = { | ||
_index: p, | ||
//name: _planet, // TODO this is basically is_planet, does it make sense to store this? |
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.
not unless we start giving dedicated names/nicknames to planets
influence: p_influence[p], | ||
raided: p_raided[p], | ||
problems: [], |
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.
problems: [], | |
problems: [], | |
operatives:json_stringify(p_operatives[p]) |
p_operatives stores a struct with no methods so i presume stringifying it will be sufficient
in #245, I propose removing |
Goal
The primary goal is to simplify and stabilize the save system and to implement some additional improvements, as described in #171
Requires #237
Description
My main idea is to split (de)serialization logic to it's own objects, e.g.
obj_ini
is responsible for creating and loading it's own data via structs. This way, everything gets encapsulated and it becomes much clearer which variables/entities belongs to which object. Additionally, the structs are very easy to (de)serialize using GMLs out of the box tools/scripts. The new format is json.Benefits
serialize()
can be simply called when restarting the game, which will make the whole process way easier and more robustserialize()
anddeserialize()
of relevant object(s)Pitfalls
Additional info
I did some clean up and beautifications in save related files, but the actual changes are in:
Resolves #171
Attached example save file: save5.json