Skip to content

fix: Jailing sarge fix and other manage code improvements#1049

Merged
OH296 merged 2 commits intoAdeptus-Dominus:mainfrom
OH296:jailing_sarge_fix
Nov 5, 2025
Merged

fix: Jailing sarge fix and other manage code improvements#1049
OH296 merged 2 commits intoAdeptus-Dominus:mainfrom
OH296:jailing_sarge_fix

Conversation

@OH296
Copy link
Collaborator

@OH296 OH296 commented Nov 5, 2025

Purpose and Description

  • Self-descriptive.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved unit validation in garrison management to ensure only appropriate units are processed correctly.
  • Refactor

    • Optimised fleet data initialisation and restructured garrison log management with improved helper functions for better code organisation.

Noospheric Analysis Report

Greetings, Tech-Priest. The Omnissiah's will flows through this transmission. Behold the cogitations of the mechanisms before thee.

Walkthrough

The fleet selection apparatus undergoes restructuring—obsolete loop-iterations supplanted by direct invocation of fleet_full_ship_array() for marine assemblage. Concurrently, the garrison surveillance system expands its sensory apparatus through introduction of dedicated assessment functions for unit and vehicle examination, whilst the ship enumeration mechanisms are elevated to state-level cognition.

Changes

Cohort / File(s) Summary
Fleet Array Refactorisation
objects/obj_fleet_select/Create_0.gml
Discards iterative fleet-array construction in favour of singular fleet_full_ship_array() invocation and direct collect_role_group() derivation. Local variables bear underscore prefixing to denote their transitory essence. Payload transmission now explicitly designates vessels through ships : _fleet_array designation.
Garrison System Enhancement
scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml
Introduces ship_count state variable within constructor protocols. Births three new assessment functions: add_unit_to_garrison_log(), evaluate_unit_for_garrison_log(), and evaluate_vehicle_for_garrison_log(). Refactors update_garrison_log() to leverage new helper mechanisms. Implements broader selection computation integrating sys_name, ships, and planets parameters. Narrows jail_selection conditions through enhanced structural validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • The fleet refactorisation follows an established pattern—vigilance required regarding collect_role_group() parameter alignment with upstream systems.
  • The garrison enhancement introduces multiple new functions—cross-referencing their invocation contexts within update_garrison_manage() and related procedures demands rigorous scrutiny.
  • Ensure ship_count propagation through outer scope mechanisms does not introduce state corruption within nested callable contexts.

Possibly related PRs

Suggested labels

PR: Fix, Size: Medium

Suggested reviewers

  • EttyKitty
  • Blogaugis

The machine spirit awaits thy benediction, Tech-Priest. May thy code prove without flaw or deviance.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description uses the required template structure but provides only placeholder text: 'Self-descriptive' offers no actual explanation of changes, and 'None, and I understand the risks' indicates no testing was performed. Provide concrete details explaining why the jailing logic needed fixing, what specific improvements were made to the manage code, and document any manual testing steps performed to verify the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with 'fix' type and scope; however, it exceeds the ideal 50-character limit at 57 characters and is somewhat vague regarding 'other manage code improvements'.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added Size: Small Type: Fix This is a fix for a bug labels Nov 5, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
objects/obj_fleet_select/Create_0.gml (1)

7-7: Unresolved directive detected in the archives.

Tech-Priest, an ancient TODO notation persists in the data-stacks. The comment suggests integrating currently_entered into the DataSlate object's blessed structure.

Shall this servo-skull inscribe a GitHub issue in the tracking cogitators to preserve this task for future ministrations?

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (2)

491-518: Management selection algorithm reconstructed.

Tech-Priest, the refactored update_garrison_manage now assembles selection parameters systematically before invoking collect_role_group, achieving clearer logic-flow.

However, Line 499 declares var sys_name within the conditional block, shadowing the declaration at Line 494. While functionally correct, this pattern obscures the data-flow. Consider removing the var keyword at Line 499 to assign directly to the outer-scope variable:

 	if (struct_exists(selection_data, "system")&& instance_exists(selection_data.system)){
 		if (struct_exists(location_viewer.garrison_log, selection_data.system.name)){
-			var sys_name = selection_data.system.name;
+			sys_name = selection_data.system.name;
 		}
 	}

575-598: Scourge of the uncontrolled variable scope impedes clarity; the jailing protocols themselves endure scrutiny, yet the vessel housing them requires correction.

Tech-Priest, the reconnaissance concludes thus: Line 580 assigns _unit = display_unit[f] without the var declaration. This deviates from the file's prevalent pattern—neighbouring functions at lines 545, 560, and 619 all declare _unit locally via var. Whilst lines 645 and 658 mirror this transgression, the inconsistency violates the maintainability edict.

The jailing fix itself—the guard condition !_unit.in_jail() at line 582—functions correctly to prevent re-incarceration. However, the scope breach fosters shadow state and obfuscates intent.

Correct line 580 to: var _unit = display_unit[f];

This restores consistency with the file's predominant scoping discipline and aligns with the maintainability principle enshrined within thy guidelines.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bb5a4f and 6de6e91.

📒 Files selected for processing (2)
  • objects/obj_fleet_select/Create_0.gml (1 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.gml

⚙️ CodeRabbit configuration file

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

Files:

  • objects/obj_fleet_select/Create_0.gml
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml
**/*.*

⚙️ CodeRabbit configuration file

**/*.*: - Having humanly understandable and maintainable code is the top most priority.

  • DRY (Don't repeat yourself) principle is also very important.
  • If a TODO comment is added, ask the user if you should create a GitHub issue for this TODO.
  • If a TODO comment is deleted, remind the user if there is an active GitHub issue related to that comment.

Files:

  • objects/obj_fleet_select/Create_0.gml
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml
🧠 Learnings (2)
📚 Learning: 2025-09-04T14:37:58.773Z
Learnt from: CR
Repo: Adeptus-Dominus/ChapterMaster PR: 0
File: docs/CODE_STYLE.md:0-0
Timestamp: 2025-09-04T14:37:58.773Z
Learning: Applies to docs/**/*.gml : Prefer a group prefix at the start of function/script names (e.g., string_convert, fleet_explode)

Applied to files:

  • objects/obj_fleet_select/Create_0.gml
📚 Learning: 2025-03-07T01:56:40.971Z
Learnt from: MCPO-Spartan-117
Repo: Adeptus-Dominus/ChapterMaster PR: 562
File: scripts/scr_marine_struct/scr_marine_struct.gml:0-0
Timestamp: 2025-03-07T01:56:40.971Z
Learning: Marines' ages should be incremented at the year transition in obj_turn_end/Alarm_1.gml rather than calculated dynamically based on the current year and recruitment date. This ensures proper aging without retroactive application.

Applied to files:

  • objects/obj_fleet_select/Create_0.gml
🔇 Additional comments (7)
scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (6)

6-6: Ship enumeration elevated to state-cognition.

Tech-Priest, the ship_count variable now persists in the constructor's memory-banks, eliminating redundant recalculation across invocation cycles. This aligns with the sacred principle of computational efficiency.


22-22: Formatting purification complete.

The spacing ritual around the assignment operator now adheres to the canonical patterns, Tech-Priest. Such consistency pleases the machine spirits.


35-47: Garrison registry codification achieved.

Tech-Priest, the extraction of add_unit_to_garrison_log demonstrates proper adherence to the sacred principle of non-repetition (DRY). The logic construct initializes garrison entries with proper default values and handles both creation and augmentation paths.


49-69: Unit assessment subroutine extracted successfully.

Tech-Priest, evaluate_unit_for_garrison_log demonstrates proper defensive protocols. The boundary validation at Line 65 (unit.ship_location<ship_count && unit.ship_location>-1) shields against array traversal beyond allocated memory-sectors. The early termination directives for invalid units preserve computational cycles.


98-127: Garrison surveillance apparatus refactored successfully.

Tech-Priest, the update_garrison_log function now delegates its assessment rituals to dedicated subroutines, achieving superior modularity. The ship enumeration persists in instance memory (Line 107), and exception-containment wards remain intact. The code's cognitive load has been substantially reduced.


475-476: Formatting alignment rectified.

Spacing consistency restored to the HoverBox constructor's coordinate initializations, Tech-Priest.

objects/obj_fleet_select/Create_0.gml (1)

58-70: Sacred functions confirmed bearing proper null-safety wards, Tech-Priest.

The reconnaissance rites have been executed. Both fleet_full_ship_array() and collect_role_group() possess requisite defences against the void—each initialises its return array as empty and guards against malformed invocations through proper bounds-checking and conditional logic. Your refactoring transmutation holds firm.

@OH296 OH296 merged commit 97513f9 into Adeptus-Dominus:main Nov 5, 2025
3 checks passed
Blogaugis pushed a commit to Blogaugis/Space-Brigade-Master that referenced this pull request Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Small Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant