Skip to content

Commit b03742f

Browse files
committed
Log the saving process and skip methods
1 parent 9740b6d commit b03742f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

scripts/scr_save/scr_save.gml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ function ini_encode_and_json_advanced(ini_area, ini_code, value){
1717
function scr_save(save_part,save_id) {
1818
var t1 = get_timer();
1919
try{
20+
log_message($"Saving to slot {save_id} - started!");
2021
if (save_part=1) or (save_part=0){
22+
log_message($"Saving to slot {save_id} - part {save_part} started!");
2123
var t=date_current_datetime();
2224
var month=date_get_month(t);
2325
var day=date_get_day(t);
@@ -28,6 +30,7 @@ function scr_save(save_part,save_id) {
2830
if (hour=0) then hour=12;
2931
var mahg=minute;
3032
if (mahg<10) then minute=$"0{mahg}";
33+
log_message($"Saving to slot {save_id} - vars are assigned!");
3134

3235
obj_saveload.GameSave.Save = {
3336
chapter_name: global.chapter_name,
@@ -49,6 +52,7 @@ function scr_save(save_part,save_id) {
4952
en_fleets: instance_number(obj_en_fleet),
5053
sod: random_get_seed(),
5154
}
55+
log_message($"Saving to slot {save_id} - GameSave struct created!");
5256

5357
/// STARS
5458
var num=instance_number(obj_star);
@@ -57,17 +61,20 @@ function scr_save(save_part,save_id) {
5761
var star_json = star_obj.serialize();
5862
array_push(obj_saveload.GameSave.Stars, star_json);
5963
}
64+
log_message($"Saving to slot {save_id} - stars are serialized and stored!");
6065
}
6166

6267

6368
if (save_part=2) or (save_part=0){
69+
log_message($"Saving to slot {save_id} - part {save_part} started!");
6470
// PLAYER FLEET OBJECTS
6571
var num = instance_number(obj_p_fleet);
6672
for (var i=0; i<num; i+=1){
6773
var fleet_obj = instance_find(obj_p_fleet,i);
6874
var obj_p_fleet_json = fleet_obj.serialize();
6975
array_push(obj_saveload.GameSave.PlayerFleet, obj_p_fleet_json);
7076
}
77+
log_message($"Saving to slot {save_id} - player fleets are serialized and stored!");
7178

7279
// ENEMY FLEET OBJECTS
7380
obj_saveload.GameSave.EnemyFleet = [];
@@ -77,20 +84,26 @@ function scr_save(save_part,save_id) {
7784
var obj_en_fleet_json = fleet_obj.serialize();
7885
array_push(obj_saveload.GameSave.EnemyFleet, obj_en_fleet_json);
7986
}
87+
log_message($"Saving to slot {save_id} - enemy fleets are serialized and stored!");
8088
}
8189

8290

8391
if (save_part=3) or (save_part=0){
92+
log_message($"Saving to slot {save_id} - part {save_part} started!");
8493
var obj_controller_json = obj_controller.serialize();
8594
obj_saveload.GameSave.Controller = obj_controller_json;
95+
log_message($"Saving to slot {save_id} - obj_controller is serialized and stored!");
8696
}
8797

8898
if (save_part=4) or (save_part=0){
99+
log_message($"Saving to slot {save_id} - part {save_part} started!");
89100
var obj_ini_json = obj_ini.serialize();
90101
obj_saveload.GameSave.Ini = obj_ini_json;
102+
log_message($"Saving to slot {save_id} - obj_ini is serialized and stored!");
91103
}
92104

93105
if (save_part=5) or (save_part=0){
106+
log_message($"Saving to slot {save_id} - part {save_part} started!");
94107
// TODO Event log somehow
95108
instance_activate_object(obj_event_log);
96109
obj_saveload.GameSave.EventLog = obj_event_log.event;
@@ -114,6 +127,7 @@ function scr_save(save_part,save_id) {
114127
ini_write_real(string(save_id),"time",obj_controller.play_time);
115128
ini_write_real(string(save_id),"seed",global.game_seed);
116129
ini_close();
130+
log_message($"Saving to slot {save_id} - saves.ini saving complete!");
117131

118132
obj_saveload.save[save_id]=1;
119133

@@ -124,7 +138,8 @@ function scr_save(save_part,save_id) {
124138

125139
buffer_write(_gamesave_buffer, buffer_string, _gamesave_string);
126140
buffer_save(_gamesave_buffer, filename);
127-
buffer_delete(_gamesave_buffer)
141+
buffer_delete(_gamesave_buffer);
142+
log_message($"Saving to slot {save_id} - GameSave struct conversion complete!");
128143
}
129144

130145

@@ -135,5 +150,5 @@ function scr_save(save_part,save_id) {
135150
var t2 = get_timer();
136151

137152
var diff = t2 - t1;
138-
show_debug_message($"scr_save save_part {save_part} took {diff} microseconds");
153+
log_message($"scr_save save_part {save_part} took {diff} microseconds");
139154
}

scripts/scr_serialization_functions/scr_serialization_functions.gml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ function copy_serializable_fields(_source, _destination, _exclude = [], _exclude
1616
var _field_name = _all_names[i];
1717
var _field_value = _source[$ _field_name];
1818

19+
if (is_method(_field_value)) {
20+
continue;
21+
}
22+
1923
if (array_contains(_exclude, _field_name)) {
2024
continue; // excluded by the full name
2125
}
@@ -31,17 +35,17 @@ function copy_serializable_fields(_source, _destination, _exclude = [], _exclude
3135
if (is_basic_variable(_field_value)) {
3236
variable_struct_set(_destination, _field_name, _field_value);
3337
}
34-
38+
3539
if (is_array(_field_value)) {
3640
if (!is_basic_array(_field_value, 2)) {
3741
var _source_obj_name = struct_exists(_source, "object_index") ? object_get_name(_source.object_index) : "<non-instance>";
38-
log_warning($"Bad array save: '{_field_name}' internal type found was not a simple type and should probably have it's own serialize function - {_source_obj_name}");
42+
log_warning($"Bad array save: '{_field_name}' internal type found was not a simple type and should probably have it's own serialize function - {_source_obj_name}!");
3943
} else {
4044
variable_struct_set(_destination, _field_name, _field_value);
4145
}
4246
} else if (is_struct(_field_value) && !struct_exists(_destination, _field_name)) {
4347
var _source_obj_name = struct_exists(_source, "object_index") ? object_get_name(_source.object_index) : "<non-instance>";
44-
log_warning($"obj_ini.serialze() - {_source_obj_name} - object contains struct variable '{_field_name}' which has not been serialized. \n\tEnsure that serialization is written into the serialize and deserialization function if it is needed for this value, or that the variable is added to the ignore list to suppress this warning");
48+
log_warning($"obj_ini.serialze() - {_source_obj_name} - object contains struct variable '{_field_name}' which has not been serialized. \n\tEnsure that serialization is written into the serialize and deserialization function if it is needed for this value, or that the variable is added to the ignore list to suppress this warning!");
4549
}
4650
}
4751
}

0 commit comments

Comments
 (0)