Skip to content

Commit 7626ef6

Browse files
committed
refactor: load_json_data() try-catch
1 parent e55b3aa commit 7626ef6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

scripts/scr_marine_struct/scr_marine_struct.gml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,16 +892,23 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data={})
892892
}
893893
return max_h;
894894
};
895+
895896
static increase_max_health = function(increase){
896897
return max_health() + (increase*(1+((constitution - 40)*0.025))); //calculate the effect of unit_health buffs
897898
};
899+
898900
// used both to load unit data from save and to add preset base_stats
899901
static load_json_data = function(data){ //this also allows us to create a pre set of anysort for a marine
900-
var names = variable_struct_get_names(data);
901-
for (var i = 0; i < array_length(names); i++) {
902-
variable_struct_set(self, names[i], variable_struct_get(data, names[i]))
903-
}
902+
try {
903+
var names = variable_struct_get_names(data);
904+
for (var i = 0; i < array_length(names); i++) {
905+
variable_struct_set(self, names[i], variable_struct_get(data, names[i]))
906+
}
907+
} catch (_exception) {
908+
handle_exception(_exception);
909+
}
904910
};
911+
905912
traits = []; //marine trait list
906913
feats = [];
907914
allegiance =faction; //faction alligience defaults to the chapter

0 commit comments

Comments
 (0)