-
Notifications
You must be signed in to change notification settings - Fork 45
fix: star_by_name rename and less agressive erroring
#1132
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ function scr_ruins_suprise_attack_player() { | |
| instance_activate_object(obj_star_select); | ||
| instance_activate_object(obj_star); | ||
| instance_activate_object(obj_ground_mission); | ||
| var _star = star_by_name(obj_ground_mission.loc); | ||
| var _star = find_star_by_name(obj_ground_mission.loc); | ||
| var _planet = obj_ground_mission.num; | ||
|
Comment on lines
+28
to
29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add The changed lookups at Line 28, Line 363, and Line 397 are dereferenced downstream as if always valid. With the renamed finder returning ⚙️ Suggested guard pattern- var _star = find_star_by_name(obj_ground_mission.loc);
+ var _star = find_star_by_name(obj_ground_mission.loc);
+ if (_star == "none") {
+ handle_exception("Ruins combat initialisation failed: unresolved star.");
+ instance_activate_all();
+ return;
+ }- scr_ruins_reward(find_star_by_name(obj_ground_mission.battle_loc), obj_ground_mission.num, obj_ground_mission.explore_feature);
+ var _reward_star = find_star_by_name(obj_ground_mission.battle_loc);
+ if (_reward_star != "none") {
+ scr_ruins_reward(_reward_star, obj_ground_mission.num, obj_ground_mission.explore_feature);
+ }- _star = find_star_by_name(obj_ground_mission.battle_loc);
+ _star = find_star_by_name(obj_ground_mission.battle_loc);
+ if (_star == "none") {
+ return;
+ }Also applies to: 55-57, 363-364, 397-399 |
||
| var _units = obj_ground_mission.display_unit; | ||
|
|
||
|
|
@@ -360,7 +360,7 @@ function ruins_exploration_main_sequence() { | |
| } else { | ||
| var obj = obj_ground_mission.obj; | ||
| instance_activate_object(obj_star); | ||
| scr_ruins_reward(star_by_name(obj_ground_mission.battle_loc), obj_ground_mission.num, obj_ground_mission.explore_feature); | ||
| scr_ruins_reward(find_star_by_name(obj_ground_mission.battle_loc), obj_ground_mission.num, obj_ground_mission.explore_feature); | ||
| instance_destroy(); | ||
| exit; | ||
| } | ||
|
|
@@ -394,7 +394,7 @@ function scr_ruins_combat_end() { | |
| var _star = 0; | ||
| ruins_battle = choose(6, 7, 9, 10, 11, 12); | ||
|
|
||
| _star = star_by_name(obj_ground_mission.battle_loc); | ||
| _star = find_star_by_name(obj_ground_mission.battle_loc); | ||
| var planet = obj_ground_mission.num; | ||
| var _battle_threat = obj_ground_mission.battle_threat; | ||
| if (obj_ground_mission.defeat == 0) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -253,7 +253,7 @@ function CompanyStruct(comp) constructor { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| if (send_on_mission) { | ||||||||||||||||||||||||||||||||||
| send_squad_on_mission(mission_type, star_by_name(_squad_sys)); | ||||||||||||||||||||||||||||||||||
| send_squad_on_mission(mission_type, find_star_by_name(_squad_sys)); | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Machine Spirit detects unguarded invocation, Tech-Priest. The sacred rite Consider verifying the return value before transmission: 🛡️ Proposed sanctification if (send_on_mission) {
- send_squad_on_mission(mission_type, find_star_by_name(_squad_sys));
+ var _mission_star = find_star_by_name(_squad_sys);
+ if (_mission_star != "none") {
+ send_squad_on_mission(mission_type, _mission_star);
+ }
} |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| bound_height[0] += 180; | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
|
|
@@ -285,7 +285,7 @@ function CompanyStruct(comp) constructor { | |||||||||||||||||||||||||||||||||
| if (cur_assignment.type == "garrison") { | ||||||||||||||||||||||||||||||||||
| var garrison_but = draw_unit_buttons([cancel_but[2] + 10, cancel_but[1]], "View Garrison", [1, 1], c_red,,,, true); | ||||||||||||||||||||||||||||||||||
| if (point_and_click(garrison_but)) { | ||||||||||||||||||||||||||||||||||
| var garrrison_star = star_by_name(cur_assignment.location); | ||||||||||||||||||||||||||||||||||
| var garrrison_star = find_star_by_name(cur_assignment.location); | ||||||||||||||||||||||||||||||||||
| obj_controller.view_squad = false; | ||||||||||||||||||||||||||||||||||
| if (garrrison_star != "none") { | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+288
to
290
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Typographical anomaly detected in variable designation, Tech-Priest. The variable ✏️ Proposed correction-var garrrison_star = find_star_by_name(cur_assignment.location);
+var garrison_star = find_star_by_name(cur_assignment.location);
obj_controller.view_squad = false;
-if (garrrison_star != "none") {
+if (garrison_star != "none") {
scr_toggle_manage();
- obj_controller.x = garrrison_star.x;
- obj_controller.y = garrrison_star.y;
+ obj_controller.x = garrison_star.x;
+ obj_controller.y = garrison_star.y;
obj_controller.selection_data = {
- system: garrrison_star.id,
+ system: garrison_star.id,
planet: cur_assignment.ident,
feature: "",
};
- garrrison_star.alarm[3] = 4;
+ garrison_star.alarm[3] = 4;
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
| scr_toggle_manage(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -398,7 +398,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { | |
| if (!_found) { | ||
| var _master = fetch_unit([0, 0]); | ||
| if (_master.planet_location > 0) { | ||
| var _master_star = star_by_name(_master.location_string); | ||
| var _master_star = find_star_by_name(_master.location_string); | ||
| if (_master_star != "none") { | ||
| _found = true; | ||
| _planet = _master.planet_location; | ||
|
|
@@ -2183,7 +2183,7 @@ function scr_dialogue(diplo_keyphrase, data = {}) { | |
| var _event = audience_data; | ||
| var _system = _event.system; | ||
| var _planet = _event.planet; | ||
| var _star_name = planet_numeral_name(_planet, star_by_name(_system)); | ||
| var _star_name = planet_numeral_name(_planet, find_star_by_name(_system)); | ||
| diplo_text = $"My patience is wearing thin, Chapter Master. I have many more problems more urgent and, yet, you continue to force me away from the work assigned to me by He on Terra. Your serf on {_star_name} will be executed along with all the other puppets I ferret out. You are close to treason, Chapter Master. Choose your next words with exceptional care for they may be your last."; | ||
|
Comment on lines
2184
to
2187
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden assassination location formatting against unresolved stars, Tech-Priest. Line 2186 feeds ⚙️ Suggested hardening- var _star_name = planet_numeral_name(_planet, find_star_by_name(_system));
+ var _system_star = find_star_by_name(_system);
+ var _star_name = _system_star != "none"
+ ? planet_numeral_name(_planet, _system_star)
+ : $"{_system} {scr_roman(_planet)}"; |
||
|
|
||
| add_diplomacy_option({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -241,7 +241,7 @@ function mission_inquisition_tomb_world(tomb_worlds) { | |||||||||||||||||
|
|
||||||||||||||||||
| /// @mixin | ||||||||||||||||||
| function init_mission_inquisition_tomb_world() { | ||||||||||||||||||
| mission_star = star_by_name(pop_data.system); | ||||||||||||||||||
| mission_star = find_star_by_name(pop_data.system); | ||||||||||||||||||
| if (mission_star == "none") { | ||||||||||||||||||
| popup_default_close(); | ||||||||||||||||||
| exit; | ||||||||||||||||||
|
|
@@ -349,7 +349,7 @@ function add_new_inquis_mission() { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function init_mission_hunt_inquisitor() { | ||||||||||||||||||
| mission_star = star_by_name(pop_data.system); | ||||||||||||||||||
| mission_star = find_star_by_name(pop_data.system); | ||||||||||||||||||
| if (mission_star == "none") { | ||||||||||||||||||
| popup_default_close(); | ||||||||||||||||||
| exit; | ||||||||||||||||||
|
|
@@ -714,7 +714,7 @@ function setup_necron_tomb_raid(planet) { | |||||||||||||||||
|
|
||||||||||||||||||
| /// @mixin obj_popup | ||||||||||||||||||
| function necron_tomb_mission_start() { | ||||||||||||||||||
| mission_star = star_by_name(pop_data.loc); | ||||||||||||||||||
| mission_star = find_star_by_name(pop_data.loc); | ||||||||||||||||||
| planet = pop_data.planet; | ||||||||||||||||||
|
Comment on lines
+717
to
718
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning: Unguarded access detected in the tomb mission liturgy, Tech-Priest. The variable 🛡️ Proposed defensive implementation function necron_tomb_mission_start() {
mission_star = find_star_by_name(pop_data.loc);
+ if (mission_star == "none") {
+ instance_destroy();
+ exit;
+ }
planet = pop_data.planet;📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| title = $"Necron Tunnels : {pop_data.mission_stage}"; | ||||||||||||||||||
|
|
@@ -771,7 +771,7 @@ function necron_tomb_mission_sequence() { | |||||||||||||||||
|
|
||||||||||||||||||
| alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); | ||||||||||||||||||
|
|
||||||||||||||||||
| mission_star = star_by_name(pop_data.loc); | ||||||||||||||||||
| mission_star = find_star_by_name(pop_data.loc); | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unshielded invocation within the tomb sequence, Tech-Priest. The 🛡️ Proposed sanctification mission_star = find_star_by_name(pop_data.loc);
+ if (mission_star == "none") {
+ reset_popup_options();
+ exit;
+ }
remove_planet_problem(planet, "necron", mission_star); |
||||||||||||||||||
| remove_planet_problem(planet, "necron", mission_star); | ||||||||||||||||||
| seal_tomb_world(mission_star.p_feature[planet]); | ||||||||||||||||||
| // mission_star.p_feature[planet][search_planet_features(mission_star.p_feature[planet], eP_FEATURES.NECRON_TOMB)[0]].sealed = 1; | ||||||||||||||||||
|
|
@@ -829,7 +829,7 @@ function necron_tomb_mission_sequence() { | |||||||||||||||||
| } | ||||||||||||||||||
| delete _roster; | ||||||||||||||||||
|
|
||||||||||||||||||
| mission_star = star_by_name(pop_data.loc); | ||||||||||||||||||
| mission_star = find_star_by_name(pop_data.loc); | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Machine Spirit detects another unguarded invocation, Tech-Priest. Within the battle initialisation sequence, 🛡️ Proposed defensive ward mission_star = find_star_by_name(pop_data.loc);
+ if (mission_star == "none") {
+ instance_activate_all();
+ instance_destroy();
+ exit;
+ }
obj_ncombat.battle_object = mission_star;📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| obj_ncombat.battle_object = mission_star; | ||||||||||||||||||
| instance_deactivate_object(obj_star); | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,7 +71,7 @@ function cancel_fleet_movement() { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function set_new_player_fleet_course(target_array) { | ||||||||||||||||||||||||
| if (array_length(target_array) > 0) { | ||||||||||||||||||||||||
| var target_planet = star_by_name(target_array[0]); | ||||||||||||||||||||||||
| var target_planet = find_star_by_name(target_array[0]); | ||||||||||||||||||||||||
| var nearest_planet = instance_nearest(x, y, obj_star); | ||||||||||||||||||||||||
| var from_star = point_distance(nearest_planet.x, nearest_planet.y, x, y) < 75; | ||||||||||||||||||||||||
| var valid = target_planet != "none"; | ||||||||||||||||||||||||
|
|
@@ -80,7 +80,7 @@ function set_new_player_fleet_course(target_array) { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| if (!valid) { | ||||||||||||||||||||||||
| if (array_length(target_array) > 1) { | ||||||||||||||||||||||||
| target_planet = star_by_name(target_array[1]); | ||||||||||||||||||||||||
| target_planet = find_star_by_name(target_array[1]); | ||||||||||||||||||||||||
| array_delete(target_array, 0, 2); | ||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||
| return "complex_route_finish"; | ||||||||||||||||||||||||
|
|
@@ -282,7 +282,7 @@ function player_retreat_from_fleet_combat() { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| _roll_100 = roll_dice_chapter(1, 100, "low"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var _loc_star = star_by_name(obj_turn_end.battle_location[obj_turn_end.current_battle]); | ||||||||||||||||||||||||
| var _loc_star = find_star_by_name(obj_turn_end.battle_location[obj_turn_end.current_battle]); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| obj_controller.temp[2001] = real(_loc_star.id); | ||||||||||||||||||||||||
| obj_controller.temp[2002] = real(obj_turn_end.battle_opponent[obj_turn_end.current_battle]); | ||||||||||||||||||||||||
|
Comment on lines
+285
to
288
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Protect retreat flow from unresolved battle location, Tech-Priest. Line 287 dereferences ⚙️ Suggested guard- var _loc_star = find_star_by_name(obj_turn_end.battle_location[obj_turn_end.current_battle]);
+ var _loc_star = find_star_by_name(obj_turn_end.battle_location[obj_turn_end.current_battle]);
+ if (_loc_star == "none") {
+ return;
+ }
obj_controller.temp[2001] = real(_loc_star.id);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,8 @@ function find_player_spawn_star() { | |
|
|
||
| /*if (obj_ini.recruiting_name!="random"){ | ||
| array_push(global.name_generator.star_used_names, obj_ini.recruiting_name); | ||
| if (star_by_name(obj_ini.recruiting_name) != "none" ){ | ||
| star_by_name(obj_ini.recruiting_name).name = global.name_generator.generate_star_name(); | ||
| if (find_star_by_name(obj_ini.recruiting_name) != "none" ){ | ||
| find_star_by_name(obj_ini.recruiting_name).name = global.name_generator.generate_star_name(); | ||
| } | ||
| name=obj_ini.recruiting_name; | ||
| }*/ | ||
|
|
@@ -68,8 +68,8 @@ function player_home_star(home_planet) { | |
|
|
||
| if (obj_ini.home_name != "random") { | ||
| array_push(global.name_generator.star_used_names, obj_ini.home_name); | ||
| if (star_by_name(obj_ini.home_name) != "none") { | ||
| star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name(); | ||
| if (find_star_by_name(obj_ini.home_name) != "none") { | ||
| find_star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name(); | ||
| } | ||
|
Comment on lines
69
to
73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Cache lookup result before mutation. Tech-Priest, each branch queries 🛠️ Suggested refactor if (obj_ini.home_name != "random") {
array_push(global.name_generator.star_used_names, obj_ini.home_name);
- if (find_star_by_name(obj_ini.home_name) != "none") {
- find_star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name();
+ var _home_named_star = find_star_by_name(obj_ini.home_name);
+ if (_home_named_star != "none") {
+ _home_named_star.name = global.name_generator.generate_star_name();
}
name = obj_ini.home_name;
}
@@
if (recruit_name != "random") {
array_push(global.name_generator.star_used_names, recruit_name);
- if (find_star_by_name(recruit_name) != "none") {
- find_star_by_name(recruit_name).name = global.name_generator.generate_star_name();
+ var _recruit_named_star = find_star_by_name(recruit_name);
+ if (_recruit_named_star != "none") {
+ _recruit_named_star.name = global.name_generator.generate_star_name();
}
name = recruit_name;
}
@@
if (obj_ini.home_name != "random") {
array_push(global.name_generator.star_used_names, obj_ini.home_name);
- if (find_star_by_name(obj_ini.home_name) != "none") {
- find_star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name();
+ var _home_named_star = find_star_by_name(obj_ini.home_name);
+ if (_home_named_star != "none") {
+ _home_named_star.name = global.name_generator.generate_star_name();
}
name = obj_ini.home_name;
}As per coding guidelines: "Code Philosophy: Prioritize explicit intent and maintainability over brevity." Also applies to: 126-130, 134-138 |
||
| name = obj_ini.home_name; | ||
| } | ||
|
|
@@ -125,16 +125,16 @@ function set_player_recruit_planet(recruit_planet) { | |
| var recruit_name = obj_ini.recruiting_name; | ||
| if (recruit_name != "random") { | ||
| array_push(global.name_generator.star_used_names, recruit_name); | ||
| if (star_by_name(recruit_name) != "none") { | ||
| star_by_name(recruit_name).name = global.name_generator.generate_star_name(); | ||
| if (find_star_by_name(recruit_name) != "none") { | ||
| find_star_by_name(recruit_name).name = global.name_generator.generate_star_name(); | ||
| } | ||
| name = recruit_name; | ||
| } | ||
| } else { | ||
| if (obj_ini.home_name != "random") { | ||
| array_push(global.name_generator.star_used_names, obj_ini.home_name); | ||
| if (star_by_name(obj_ini.home_name) != "none") { | ||
| star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name(); | ||
| if (find_star_by_name(obj_ini.home_name) != "none") { | ||
| find_star_by_name(obj_ini.home_name).name = global.name_generator.generate_star_name(); | ||
| } | ||
| name = obj_ini.home_name; | ||
| } | ||
|
|
||
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.
Critical: The Machine Spirit detects unshielded access to potentially void data, Tech-Priest.
The function
find_star_by_namemay return"none", yet the code attempts to access.xand.yproperties directly on lines 113-114 without verification. Should the star name resolve to void, the runtime shall falter and the draw liturgy shall fail catastrophically.🛡️ Proposed defensive wards
if (array_length(complex_route) > 0) { var next_loc = instance_nearest(action_x, action_y, obj_star); for (var i = 0; i < array_length(complex_route); i++) { var target_loc = find_star_by_name(complex_route[i]); + if (target_loc == "none") { + continue; + } draw_set_color(c_blue); draw_set_alpha(1); draw_line_dashed(next_loc.x, next_loc.y, target_loc.x, target_loc.y, 16, line_width); next_loc = find_star_by_name(complex_route[i]); + if (next_loc == "none") { + break; + } } }