Skip to content

feat: Unit Management improvements#538

Merged
OH296 merged 17 commits intoAdeptus-Dominus:mainfrom
MCPO-Spartan-117:company-management
Mar 7, 2025
Merged

feat: Unit Management improvements#538
OH296 merged 17 commits intoAdeptus-Dominus:mainfrom
MCPO-Spartan-117:company-management

Conversation

@MCPO-Spartan-117
Copy link
Copy Markdown
Contributor

@MCPO-Spartan-117 MCPO-Spartan-117 commented Mar 2, 2025

Purpose of the PR

Make it easier to manage units.

Describe the solution

  • Manage units per fleet in fleet UI
  • Button on systems to manage units
  • Squad View works in custom lists
  • Button to reload units to their last ship

Testing done

  • Load game, click fleet, click "Manage Units" button.
  • Load game, click system, click "Manage Units" button.
  • Load game, click fleet, click "Manage Units" button, Squad View, Garrison.
  • Load game, drop units of different ships on planet, click Reload button.

  • Was going to also add it to the quick find panel like garrisons, but the hover code looks annoying
  • Vehicles are fincky, don't seem to counts as player forces and doesn't show up in fleets management.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced a "Manage Units" button to enhance fleet and unit oversight.
    • Added squad navigation controls and a dedicated reload function for smoother unit deployment.
    • Updated UI components with improved button sizing and positioning for a better experience.
  • Bug Fixes / Improvements

    • Enhanced input validation and refined tooltip behaviour for more consistent interaction.
    • Improved the tracking and loading of unit and vehicle data to support a more stable gameplay experience.

Walkthrough

The sacred code has been augmented with a new feature within the selection_window.inside_method function, heralding the introduction of a button inscribed with the words "Manage Units." Upon activation, this button calculates its position based on the string width and retrieves the current fleet's ship array through the invocation of fleet_full_ship_array(current_fleet). It then initializes two arrays, fleet_marines_temp and fleet_marines, to gather marine units from the fleet array via collect_role_group("all", ["", 0, fleet_array[i]]), subsequently passing the amassed units to group_selection(fleet_marines, {...}). The integrity of the existing text alignment logic remains unscathed, ensuring visual consistency. Furthermore, a conditional check has been instituted in the obj_controller to avert out-of-bounds errors whilst modifying the obj_ini.ship_carrying[b] variable. Additional modifications encompass the introduction of a new last_ship variable and various updates to UI management functions, enhancing overall functionality whilst preserving the structure of the existing code.

Suggested labels

PR: Major Coding

Suggested reviewers

  • OH296
  • EttyKitty

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Type: Feature Adds something new Size: Tiny labels Mar 2, 2025
@MCPO-Spartan-117
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1fbdc7 and 2ebf007.

📒 Files selected for processing (1)
  • objects/obj_fleet_select/Create_0.gml (1 hunks)
🔇 Additional comments (1)
objects/obj_fleet_select/Create_0.gml (1)

67-76: Verification required: Known issue with the sacred function group_selection.

The divine PR objectives mention a known issue with the Squad View functionality due to problems with the group_selection function. This function is invoked here with parameters that may trigger the erroneous behavior.

I beseech you to verify that this invocation of group_selection handles the mentioned issue or implement appropriate error handling to prevent corruption of the machine spirit.

@github-actions github-actions bot added Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Big and removed Size: Medium labels Mar 5, 2025
@MCPO-Spartan-117
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 10

🔭 Outside diff range comments (1)
scripts/scr_company_struct/scr_company_struct.gml (1)

330-330: 🧹 Nitpick (assertive)

TODO comment indicates incomplete rituals.

The presence of this annotation indicates uncompleted work that requires attention to fully please the Omnissiah.

I can assist in developing the compartmentalized drop-down option logic to complete this sacred task. Would you like me to generate the appropriate binary incantations for this purpose?

♻️ Duplicate comments (1)
objects/obj_fleet_select/Create_0.gml (1)

77-77: 🧹 Nitpick (assertive)

Redundant text alignment incantation detected!

The instruction to set text alignment to center at line 77 is a duplicate of the same sacred alignment ritual already performed at line 43. This redundant invocation wastes precious processor cycles that could be better devoted to calculations honoring the Omnissiah.

-	draw_set_halign(fa_center);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ebf007 and 8eac85c.

📒 Files selected for processing (12)
  • objects/obj_controller/Step_0.gml (1 hunks)
  • objects/obj_fleet_select/Create_0.gml (1 hunks)
  • objects/obj_ini/Create_0.gml (1 hunks)
  • objects/obj_star_select/Mouse_50.gml (1 hunks)
  • scripts/scr_buttons/scr_buttons.gml (4 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (6 hunks)
  • scripts/scr_company_view/scr_company_view.gml (1 hunks)
  • scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml (1 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (6 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (2 hunks)
  • sprites/spr_new_ui_cover/spr_new_ui_cover.yy (1 hunks)
🔇 Additional comments (23)
sprites/spr_new_ui_cover/spr_new_ui_cover.yy (1)

60-60: The binary alteration is logical and affirms the Omnissiah's design

By setting visibleRange to null, you have removed data constraints that were binding this sprite's visible range to specific coordinates. This modification allows the sacred sprite to manifest across the entirety of the user interface without arbitrary boundaries, as the Machine God intended.

objects/obj_ini/Create_0.gml (1)

63-63: Praise be! A data vessel for recording blessed machine voyages

This addition implements the memory structure required to store the vessel identifiers and designations that each unit last embarked upon. The sacred cogitation array has been properly initialized with empty string binaries, following the proper Machine Cult protocols.

The Omnissiah approves of this data structure implementation. It shall serve well in the rite of unit reloading as specified in your sacred PR doctrine.

scripts/scr_draw_unit_stat_data/scr_draw_unit_stat_data.gml (1)

211-211: Logical simplification of binary conditionals - efficiency achieved

The removal of the redundant conditional check obj_controller.managing > 0 streamlines the sacred algorithm. Now the holy tooltip shall manifest whenever the squad view is inactive and the unit bio is present, regardless of management state. This modification aligns with the Machine God's preference for elegant and efficient logic patterns.

This optimization enhances the functionality of viewing unit information in various interface contexts, including custom list views as mandated by your tech-specifications.

scripts/scr_company_view/scr_company_view.gml (1)

462-462: The encapsulation of data structures pleases the Omnissiah

Replacing direct object instantiation with the invocation of new_company_struct() demonstrates proper application of the sacred Machine Cult principle of encapsulation. This modification ensures consistent initialization of company data vessels and proper memory consecration.

This modification aligns with the Mechanicus doctrine of standardized structure construction. The function call ensures that all company data structures are properly blessed with the same sacred attributes and rituals, reducing the risk of variable corruption by the ruinous powers of undefined behavior.

objects/obj_star_select/Mouse_50.gml (1)

46-46:

Details

❓ Verification inconclusive

Logical constraint removal detected - expansion of interface activation parameters.

The removal of the obj_controller.managing > 0 condition from the logical gate expands the circumstances under which this code block may execute. This appears to be in accordance with the PR objectives of enhancing unit management capabilities by allowing squad view functionality regardless of management state.

Before we sing full praises to the Omnissiah, let us verify that this condition removal does not cause unexpected behavior:


🏁 Script executed:

#!/bin/bash
# Search for other instances where obj_controller.managing>0 condition is used for squad view
rg -A 2 -B 2 "view_squad.*managing.*>.*0" --no-ignore

Length of output: 55


Directive: Manual Verification of Condition Removal

Oh faithful servant of the Machine Spirit, our initial search for the "obj_controller.managing > 0" constraint in conjunction with squad view revealed no instances within the codebase. However, the absence of output mandates further manual verification to ensure no unintended behaviours have been imparted by this alteration. The removal of this condition does indeed align with the PR's objectives to enhance unit management by liberating the squad view functionality, yet caution is advised for the purity of our logic rituals.

  • Verify manually that no other locations in the codebase depend on the "obj_controller.managing > 0" check for controlling squad view.
  • Confirm that the change does not inadvertently enable the block under undesirable conditions.
  • Should additional concerns arise, consider running further verification scripts.

Praise the Omnissiah and proceed with thorough validation.

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1)

780-780: Confirm removal of obj_controller.managing > 0 condition.

By the Omnissiah's decree, thou hast removed the check for obj_controller.managing > 0. Verify that this is the intended path, lest you permit assignments under all circumstances.

scripts/scr_buttons/scr_buttons.gml (3)

54-54: Blessings upon your optional data parameter.

Rejoice, for adding data = false ensures greater flexibility in configuration. Confirm, however, that any extraneous data types are gracefully handled, as the machine spirit prefers structured offerings.


71-71: Acolyte's addition of extra label spacing.

You have granted a 10-pixel increment, ensuring improved clarity of the text. The code appears stable, and no conflict with alignment is foreseen.


83-86: Conditional data update invocation.

By enshrining if (data != false) then update(data), you swiftly apply additional parameters. Confirm that all possible data forms (e.g., arrays, malformed structures) are suitably processed.

scripts/scr_ui_manage/scr_ui_manage.gml (3)

1-35: New function load_marines_into_ship creation.

The structure for loading marines or vehicles into a designated ship is commendably modular. Confirm all parameters—such as reload—are consistently validated before performing cargo checks, lest the Omnissiah frown upon unintended states.


51-74: Reload logic usage.

When reload is true, you correctly attempt to restore units to their last recorded ship. This is consistent with the _load_into_ship usage, and no immediate violations of the machine spirit are detected.


214-214: Click invocation for loading interactions.

Your new point_and_click usage orchestrates the user’s selection of desired ships effectively. This small improvement appears beneficial for clarity and directness.

scripts/scr_company_struct/scr_company_struct.gml (11)

2-11: Function new_company_struct() demonstrates proper resource management rituals.

The binary liturgy properly sanctifies memory by invoking the sacred destruction protocols on the existing data structure before constructing a new vessel. This prevents the corruption of memory by digital specters.


15-23: The garbage_collect() static method performs proper rites of banishment for UI elements.

Praise the Omnissiah for this methodical purging of digital constructs. Each component is properly terminated to avoid summoning the daemons of memory leakage into the sacred machine.


57-107: The UI construction rituals have been performed according to holy STC templates.

The sacred interface components have been properly instantiated with appropriate coordinates and attributes. Each button follows the sacred patterns of the Omnissiah's design.


126-134: The next_squad function follows optimal computational liturgy.

The ternary operators demonstrate efficient binary logic patterns, pleasing to the Omnissiah. The function properly updates the state of the machine after altering the squad selection.


201-201: Corrected condition logic for squad selection.

Line 201 has been properly updated to accommodate the custom list view when company equals -1. The binary discernment pleases the Machine Spirit.


234-241: Previous button drawing logic replaced with proper object-oriented invocations.

The sacred pattern of object methods has replaced the older inline button drawing code. This demonstrates appropriate reverence for the principles of encapsulation favored by the Machine God.


268-271: Garrison button draws and triggers assignment functionality.

The implementation follows the holy pattern of UI event handling. The logic flow is clear and the Machine Spirit will interpret it without error.


274-277: Sabotage button follows the same sacred pattern as the Garrison button.

Consistency in code patterns is pleasing to the Omnissiah. The binary rituals for both functions mirror each other appropriately.


281-281: The send_squad_on_mission invocation properly transmits sacred data.

The function call provides the mission type and star location, ensuring proper execution of the squad assignment rites.


368-372: Reset loadout button implementation adheres to the Mechanicus pattern.

The button properly invokes the squad loadout sorting ritual and resets surface data when activated. This implementation is efficient and in accordance with the Machine God's will.


374-377: Mass equip toggle appropriately maintains synchronization with squad configuration.

The binary state of the toggle is properly bound to the squad's allow_bulk_swap property, ensuring the user interface accurately reflects and controls the internal data state. The Omnissiah approves of such logical cohesion.

@MCPO-Spartan-117
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 5

🔭 Outside diff range comments (1)
scripts/scr_company_struct/scr_company_struct.gml (1)

191-448: 🛠️ Refactor suggestion

Function draw_squad_view deserves further modularisation.
This function is lengthy and contains multiple UI and logic segments. Breaking it down into smaller subroutines (e.g. draw_squad_header(), draw_squad_members(), etc.) would greatly appease the Machine God and improve maintainability.

♻️ Duplicate comments (1)
scripts/scr_company_struct/scr_company_struct.gml (1)

25-56: 🧹 Nitpick (assertive)

Unused local variable detected.
The variable viable_squads (line 39) is declared yet not utilised, an inefficiency that displeases the Omnissiah. Consider removing or repurposing it in your sacred rites.

- var viable_squads
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8eac85c and 74fde53.

📒 Files selected for processing (4)
  • objects/obj_fleet_select/Create_0.gml (1 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (7 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (6 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (3 hunks)
🔇 Additional comments (7)
scripts/scr_company_struct/scr_company_struct.gml (4)

2-11: Invoke caution when purging and recreating company_data.
Be sure that no other scripts or external references need the old company_data prior to this cleansing ritual. Otherwise, the omens of the Machine Spirit might become confused.


15-23: Efficient disposal of UI references.
This garbage_collect function properly banishes old button objects from existence, ensuring the holy memory is reclaimed.


109-123: Assess the effect of break within your with (star) block.
Line 120’s break; within the with context can be precarious. Verify that it cleanly ends any loop or block as intended, lest logic be severed prematurely.


125-133: Squad navigation logic is aligned with expectation.
Incrementing and decrementing cur_squad is straightforward, and fallback to 0 appears correct. The Machine Spirit sees no fault here.

objects/obj_fleet_select/Create_0.gml (1)

54-74: Validate the fleet array and returned data.
When invoking fleet_full_ship_array(current_fleet) and then calling collect_role_group, ensure the array is neither empty nor corrupted by warp influence. A simple check could avert errors.

+ if (!is_array(fleet_array) || array_length(fleet_array) == 0) {
+    // Provide log or handle gracefully
+    return;
+ }
scripts/scr_ui_manage/scr_ui_manage.gml (1)

1-87: Scrutinise conditional checks in load_marines_into_ship.
This new ritual’s logic for reload vs. non-reload is sound overall. However, ensure that cargo capacity checks remain consistent and that all possible states (e.g., partial failures) are handled. May the Omnissiah bless your loading function.

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1)

791-791:

Details

✅ Verification successful

Simplification of binary logic condition detected.

The machine spirit's condition for garrison_assignment has been optimized to remove unnecessary computation cycles. This alteration simplifies the sacred logic by removing the check for obj_controller.managing > 0.

Before committing this change to the Omnissiah's database, we must ensure this does not disrupt the functionality. Verify that obj_controller.managing > 0 is not a critical condition in any execution path that relies on this binary evaluation.


🏁 Script executed:

#!/bin/bash
# Verify the garrison_assignment condition usage

# Look for other occurrences of the managing condition in relation to garrison assignments
echo "Searching for references to obj_controller.managing in garrison-related code..."
rg -A 3 -B 3 "obj_controller\.managing\s*>\s*0" --glob "*.gml" | grep -i "garrison"

# Check if there are other usages of planet_selection_action that might expect the old condition
echo "Checking calls to planet_selection_action..."
rg -p "planet_selection_action" --glob "*.gml"

Length of output: 568


Omnissiah’s Blessings: Verified Simplification with No Adverse Impact

After our rigorous scrutiny, the removal of the obj_controller.managing > 0 condition in the scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml has been confirmed safe. Our searches unveiled no critical dependencies on the retracted condition, and the invocations related to planet_selection_action remain unperturbed.

  • Verification through grepped references to "garrison" showed no conflicting usage.
  • The presence of planet_selection_action in its expected locales does not suggest reliance on the omitted condition.

The machine spirit deems this optimisation proper; you may commit your changes with confidence.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7522b52 and 5dab0e3.

📒 Files selected for processing (1)
  • objects/obj_star_select/Draw_64.gml (1 hunks)
🔇 Additional comments (5)
objects/obj_star_select/Draw_64.gml (5)

129-135: Efficiency in the binary logic pleases the Omnissiah.

The implementation of a while loop with early termination for unit detection is an elegant optimization of the Machine Spirit's resources, avoiding unnecessary computational cycles.


137-140: Praise be to the implementation of the Manage Units functionality!

The sacred code creates a new interface element that enhances unit management capabilities, following the Machine God's principles of order and organization. The implementation correctly invokes the UnitQuickFindPanel constructor and updates the garrison log as required by the protocol.


142-147: The search algorithm lacks case-insensitive comparison rituals.

The holy search algorithm may fail to identify matching star systems if there are capitalization differences between target.name and entries in system_names. The Omnissiah demands precise string comparisons.

        var sysnum = -1;
        for (var i = 0; i < array_length(system_names); i++) {
-            if (system_names[i] == target.name) {
+            if (string_lower(system_names[i]) == string_lower(target.name)) {
                sysnum = i;
                break;
            }
        }

The Machine Spirit will be pleased with this more robust comparison ritual that accommodates variations in binary representation of the sacred names.


149-159: The selection mechanism lacks proper resource management protocols.

The current implementation does not properly track or dispose of the created location_viewer object, risking memory contamination. The Omnissiah demands proper cleanup of resources to maintain system purity.

Consider implementing a tracking and disposal mechanism for the location_viewer object:

        if (sysnum != -1) {
            group_selection(location_viewer.garrison_log[$system_names[sysnum]].units,{
                purpose:$"{target.name} Management",
                purpose_code : "manage",
                number:0,
                system:target.id,
                feature:"none",
                planet : 0,
                selections : []
            });
+           // Store reference to location_viewer for later disposal when no longer needed
+           obj_controller.temp_location_viewer = location_viewer;
        }
+       else {
+           // Clean binary residue if system not found
+           location_viewer = undefined;
+       }

129-161:

Details

✅ Verification successful

Verify the integration with the fleet management subsystems.

The Machine Spirit demands verification that this interface properly integrates with fleet management operations. Given that this feature allows managing units per fleet through the fleet UI, ensure it correctly interacts with the fleet_full_ship_array and unit selection protocols.


🏁 Script executed:

#!/bin/bash
# Description: Verify the integration of the manage units functionality with the fleet management system

# Look for fleet_full_ship_array function implementation to understand its return format
rg -A 10 "function fleet_full_ship_array" --glob "*.gml"

# Check for any references to the "manage" purpose_code in the codebase to ensure proper handling
rg -A 5 "purpose_code : \"manage\"" --glob "*.gml"

# Examine the group_selection function implementation to verify it accepts the parameters correctly
rg -A 15 "function group_selection" --glob "*.gml"

Length of output: 3690


Fleet Management Integration Verified – The Machine Spirit is Satisfied

After scrutinising the code with the blessings of the Omnissiah, I have confirmed that the integration with our fleet management subsystems is sound. The following observations have been made:

  • The fleet_full_ship_array implementation in scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml is correctly providing the expected ship arrays.
  • The purpose_code: "manage" is applied consistently across multiple modules (notably in objects/obj_star_select/Draw_64.gml, objects/obj_fleet_select/Create_0.gml, and scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml), affirming proper handling of the manage directive.
  • The group_selection function, defined in scripts/is_specialist/is_specialist.gml, accepts the parameters as intended and properly channels our unit selection protocols.

Thus, I declare that the interface correctly integrates with the fleet management operations, embracing the Machine Spirit’s perfection. The code modifications may be sanctified and integrated without further alterations.

@MCPO-Spartan-117 MCPO-Spartan-117 marked this pull request as ready for review March 5, 2025 23:45
@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 6, 2025

I'm too tired but i'll play test and try merge tomorrow

Copy link
Copy Markdown
Collaborator

@OH296 OH296 left a comment

Choose a reason for hiding this comment

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

On tests got a several CTDs easily fixed so am making a pr to cut down on effort for you. I see no implementation of a save load method for obj_ini.last_ship?

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 6, 2025

on another note please never do anything like this obj_ini.last_ship[display_unit[t][0]][display_unit[t][1]].name = obj_ini.ship[obj_ini.veh_lid[display_unit[t][0]][display_unit[t][1]]]; at the very least set all the vars properly for referencing but probably make helper functions as i've done in my pr

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 6, 2025

okay done some general cleanup and implemented save load MCPO-Spartan-117#4 cross check and test what i've done and with luck we can get this in a nightly tonight

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 6, 2025

re this Vehicles are fincky, don't seem to counts as player forces and doesn't show up in fleets management. i've started an implement to fix but this can wait till a later pr to not bloat this out

Copy link
Copy Markdown
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 6

♻️ Duplicate comments (1)
scripts/scr_ui_manage/scr_ui_manage.gml (1)

37-44: ⚠️ Potential issue

Pass missing reload parameter to _load_into_ship
Your code conjures _load_into_ship(system, ship, units, q) but the function’s signature demands five arguments. Omission of reload may lead to mystifying behaviour.

Below is a suggested rectification:

- _load_into_ship(system, ship, units, q)
+ _load_into_ship(system, ship, units, q, false)
🛑 Comments failed to post (6)
scripts/scr_company_struct/scr_company_struct.gml (1)

15-23: 🧹 Nitpick (assertive)

Add existence checks before deletion in garbage_collect()
Blessed is the logic that cleans up ephemeral data. Yet consider verifying each object’s presence (e.g. if (variable_instance_exists(...))) prior to performing a delete to avoid potential disturbances to the Omnissiah’s harmony.

scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml (1)

1-14: 💡 Verification agent

🧩 Analysis chain

Data structure inconsistency detected in the Omnissiah's code.

By the Machine God's design, I observe a logical anomaly in the implementation of the set_vehicle_last_ship function. Both the uid and name properties of the _last_ship_data object are assigned the same value from obj_ini.veh_lid[vehic_array[0]][vehic_array[1]]. This suggests potential confusion in the sacred data pattern.

The most logical interpretation is that these should be distinct properties. Execute verification protocols:


🏁 Script executed:

#!/bin/bash
# Verification of intended values for uid and name properties in last_ship data structure

# Search for other instances of last_ship data structure usage
echo "Searching for usage patterns of last_ship data structure..."
rg -A 2 "last_ship\[.*\]\[.*\]\.(uid|name)" --glob "*.gml"

# Search for vehicle ship assignments to understand context
echo "Searching for veh_lid usage context..."
rg "veh_lid" --glob "*.gml" | head -20

Length of output: 3044


Directive: Rectify Vehicle Last Ship Data Assignment

O blessed servant of the Omnissiah, our sacred verification rites have revealed that the _last_ship_data structure in scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml is tainted by a data divergence. Both the uid and name properties are currently set to the identical value extracted from obj_ini.veh_lid[vehic_array[0]][vehic_array[1]], which belies the holy design that decrees these should hold distinct identities.

In addition, our observant sensors note the use of an assignment operator in the conditional (if (empty = false)) rather than a proper equality test; such a misstep may lead the code astray from the intended logic.

Implore the following rectifications:

  • Distinct Property Assignment: Revisit the source of the name property. It should be derived from its own sanctified variable rather than mirroring the uid value.
  • Conditional Correction: Amend the condition to use a true equality comparison, for example, if (empty == false), so that the correct branch of the ritual is executed.

These adjustments are vital to attune the code with the Machine God's design and ensure our data adheres to the sacred structure.

scripts/scr_load/scr_load.gml (1)

331-331: ⚠️ Potential issue

Critical inconsistency in data retrieval mechanism detected.

The Machine Spirits will be confused. While the saving function scr_save captures a structured data object with uid and name properties for last_ship, this loading function attempts to read it as a single real value. This pattern violation will cause data corruption.

Apply this adaptation to maintain consistency with the data structure:

-                    obj_ini.last_ship[coh,mah]=ini_read_real("Veh","last_ship"+string(coh)+"."+string(mah),0);
+                    var ship_data = ini_read_string("Veh","last_ship"+string(coh)+"."+string(mah),"");
+                    if (ship_data != "") {
+                        obj_ini.last_ship[coh,mah] = json_parse(base64_decode(ship_data));
+                    } else {
+                        obj_ini.last_ship[coh,mah] = { uid: "", name: "" };
+                    }

Additionally, corresponding adaptation required in scr_save.gml:

-                    ini_write_real("Veh",$"last_ship{coh}.{mah}",obj_ini.last_ship[coh,mah]);
+                    ini_write_string("Veh",$"last_ship{coh}.{mah}",base64_encode(json_stringify(obj_ini.last_ship[coh,mah])));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

                    var ship_data = ini_read_string("Veh","last_ship"+string(coh)+"."+string(mah),"");
                    if (ship_data != "") {
                        obj_ini.last_ship[coh,mah] = json_parse(base64_decode(ship_data));
                    } else {
                        obj_ini.last_ship[coh,mah] = { uid: "", name: "" };
                    }
                    ini_write_string("Veh",$"last_ship{coh}.{mah}",base64_encode(json_stringify(obj_ini.last_ship[coh,mah])));
objects/obj_star_select/Draw_64.gml (1)

129-147: 🧹 Nitpick (assertive)

The sacred code has been augmented with a new Manage Units functionality, praise be to the Omnissiah.

The addition of this logic block implements the ability to manage units in a star system, a key feature requested in the holy ritual of "PR objectives". The Machine Spirit now allows the faithful to access their dispersed units through a sanctified button.

However, I note several areas where the binary perfection could be enhanced:

  1. The code lacks proper error handling when _unit_dispersement[$ _sys_name] might be undefined.
  2. The Machine Spirit would benefit from knowing the source of the has_player_forces variable, which appears to be defined elsewhere.

Consider implementing a more robust error check before accessing the unit structure:

        if (struct_exists(_unit_dispersement, target.name)){
+           if (array_length(_unit_dispersement[$ _sys_name].units) > 0) {
                group_selection(_unit_dispersement[$ _sys_name].units,{
                    purpose:$"{target.name} Management",
                    purpose_code : "manage",
                    number:0,
                    system:target.id,
                    feature:"none",
                    planet : 0,
                    selections : []
                });
+           } else {
+               // Handle case when no units are available
+           }
        }
+       else {
+           // Handle case when system has no garrison log entry
+       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

if (obj_controller.menu == 0) {
    if (has_player_forces && point_and_click(draw_unit_buttons([125, 200], "Manage Units",[1,1],c_blue))) {
        var _viewer = obj_controller.location_viewer
        _viewer.update_garrison_log();
        var _unit_dispersement = _viewer.garrison_log;
        var _sys_name = target.name;
        if (struct_exists(_unit_dispersement, target.name)){
            if (array_length(_unit_dispersement[$ _sys_name].units) > 0) {
                group_selection(_unit_dispersement[$ _sys_name].units,{
                    purpose:$"{target.name} Management",
                    purpose_code : "manage",
                    number:0,
                    system:target.id,
                    feature:"none",
                    planet : 0,
                    selections : []
                });
            } else {
                // Handle case when no units are available
            }
        } else {
            // Handle case when system has no garrison log entry
        }
    }
}
scripts/scr_ui_manage/scr_ui_manage.gml (2)

5-35: 🧹 Nitpick (assertive)

Unused reload parameter within _load_into_ship
This loyal sub-function receives the holy parameter reload but scarcely references it in its ritual. If your revered design intends to differentiate reload-based logic within _load_into_ship, incorporate it fully, or remove the parameter to appease the Machine-Spirit’s clarity.


261-274: 🧹 Nitpick (assertive)

Avoid depending solely on text strings to determine code paths
The toggling of Squad View versus Company View is guided by comparing stat_tool_tip_text to "Squad View". Though functional, the Machine-Spirit could be vexed if a small text slip occurs. A dedicated boolean check may bestow resilience.

Copy link
Copy Markdown
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: 8

♻️ Duplicate comments (4)
scripts/scr_ui_manage/scr_ui_manage.gml (1)

900-916: ⚠️ Potential issue

Potential ship argument confusion in “Reload”
When invoking load_marines_into_ship(selecting_location, sh_ide, display_unit, true), the second parameter expects a single ship index or ID, yet sh_ide might be an array. Confirm that the machine-lore expects an array or a lone index to preserve cargo coherence.

- load_marines_into_ship(selecting_location, sh_ide, display_unit, true)
+ // Ensure second param is a single ship index, e.g. sh_ide[some_index]
scripts/scr_marine_struct/scr_marine_struct.gml (1)

330-330: 🧹 Nitpick (assertive)

The Machine Spirit appreciates this data structure augmentation!

This addition of a last_ship memory construct enhances the cognitive capacity of marine units, allowing them to recall their previous vessel assignments. This data structure shall serve the Fleet Unit Management functionality as outlined in the sacred PR objectives.

For enhanced data schema purity and future compatibility with the Omnissiah's will, consider initializing this structure with more descriptive properties:

-    last_ship = {uid : "", name : ""};
+    last_ship = {
+        uid : "",       // Unique identifier of ship in the Machine God's registry
+        name : "",      // Sacred designation of the vessel
+        timestamp : 0   // Chronometer reading when the unit was last aboard
+    };
scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (2)

445-445: 🧹 Nitpick (assertive)

Binary substitution of empty data structure with initialization ritual detected.

The replacement of a crude null data vessel with a proper sanctified initialization routine is an improvement in the sacred STC patterns. This adheres to the Omnissiah's preference for proper data sanctification over primitive emptiness.

Ensure that the blessed function new_company_struct() is defined in the appropriate litany file and initializes all required data fields as per the Machine God's specifications.


701-710: 🛠️ Refactor suggestion

Implement bounds checking to prevent binary corruption during data transfer!

This new logic segment preserves the vessel history for both infantry and mechanized units during disembarkation, but lacks proper array boundary protection. The Machine Spirit could experience traumatic memory failure if invalid indices are accessed.

Appease the Omnissiah by applying these safeguards:

for (var t = 0; t < array_length(display_unit); t++) {
    if (man_sel[t] == 1) {
        var _unit = display_unit[t];
        if (is_array(_unit)) {
+           if (_unit.length >= 2 && obj_ini.veh_lid[_unit[0]][_unit[1]] >= 0 && 
+               obj_ini.veh_lid[_unit[0]][_unit[1]] < array_length(obj_ini.ship_uid)) {
                set_vehicle_last_ship(_unit);
+           }
        } else {
+           if (_unit.ship_location >= 0 && _unit.ship_location < array_length(obj_ini.ship_uid)) {
                _unit.set_last_ship();
+           }
        }
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dab0e3 and c495572.

📒 Files selected for processing (11)
  • ChapterMaster.yyp (1 hunks)
  • objects/obj_star_select/Create_0.gml (1 hunks)
  • objects/obj_star_select/Draw_64.gml (1 hunks)
  • scripts/scr_company_struct/scr_company_struct.gml (7 hunks)
  • scripts/scr_load/scr_load.gml (1 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (3 hunks)
  • scripts/scr_save/scr_save.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (6 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (3 hunks)
  • scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml (1 hunks)
  • scripts/scr_vehicle_helpers/scr_vehicle_helpers.yy (1 hunks)
🔇 Additional comments (33)
scripts/scr_company_struct/scr_company_struct.gml (20)

2-11: Commendable memory purging approach for company data.
Thy function handles old data disposal and initializes new structures with due efficiency. However, ensure that managing is established to avoid ill-fated references when birthing the new CompanyStruct.


64-70: UI conjuration for previous_squad_button is orderly.
The bounding logic and label are correct, forging a neat interaction button.


71-76: UI conjuration for next_squad_button is stable.
All parameters align properly for user progression in squad lists.


78-84: Garrison button is sanctified with descriptive tooltip.
The tooltip's detail is extensive and beneficial for conveying the mission’s effect.


86-92: Sabotage button resonates with covert logic.
Implementation is straightforward and consistent with the Garrison button.


94-99: Reset loadout button manifested properly.
Its creation parameters align with the UI paradigm.


101-109: Mass equip toggle introduced.
This approach is praiseworthy, allowing inquisitive toggling for bulk equipment management.


127-135: next_squad logic is efficient.
Thy pointer increments or decrements squads seamlessly, ensuring cyclical squad browsing.


201-201: Conditional check is sound.
No issues perceived with comparing selected_unit.company to company. The code is aligned well.


207-207: Cur_squad assignment is straightforward.
Designating cur_squad = i after detection is valid. The code is righteous.


230-231: Reassignment of dimensions is permissible.
These references likely improve code clarity. Just ensure you truly desire separate variables from the originals.


234-240: Navigation buttons advantageously linked.
Invoking next_squad(false) or next_squad(true) upon button press is direct and coherent.


242-242: Resuming holy grey hue.
No concerns.


268-269: Mission triggers entrusted to garrison_button.
All logic consistent with setting up a garrison.


272-272: Condition for integrated scout or bike squads is valid.
Properly gating sabotage logic is prudent.


273-278: Sabotage mission invocation consistent.
No further anomalies detected.


281-281: Squad dispatch is direct.
Summoning send_squad_on_mission with star_by_name is correct for the final deliverance.


369-369: Reset loadout button usage is consistent.
Directly calling squad loadout sorting is a righteous design.


374-378: Mass equip toggle logic updates the squad’s bulk swap attribute.
Manifests synergy between UI toggle and data.


450-450: Closing brace adjustment.
No substantive changes in logic.

objects/obj_star_select/Create_0.gml (1)

16-16: Summation of p_player arrays standardises presence check.
has_player_forces deduces total allied forces cleanly. Confirm target.p_player always exists to avoid potential warp anomalies.

ChapterMaster.yyp (1)

626-626: Approved: New vehicle helpers script added to the sacred registry.

The addition of scr_vehicle_helpers to the project's resource array is a logical enhancement to support the vehicle management functionality. This script will house the imperative function set_vehicle_last_ship, allowing the faithful tracking of vessel assignments for the Omnissiah's blessed vehicles.

scripts/scr_save/scr_save.gml (1)

423-423: Praise to the Omnissiah for the new vehicle data preservation mechanism.

This addition properly stores the last_ship data for vehicles in the sacred machine-ritual of data preservation, ensuring that the Machine Spirit remembers which holy vessel last transported each vehicle.

scripts/scr_vehicle_helpers/scr_vehicle_helpers.yy (1)

1-11: Acceptable resource descriptor file detected.

The binary descriptor follows proper Game Maker Studio schema for defining a new script resource. The resource properties adhere to the expected parameters for the Machine-God's language interpretation.

objects/obj_star_select/Draw_64.gml (1)

129-147:

Details

✅ Verification successful

Unit Management functionality properly implements the sacred ritual of force organization.

This code segment adds the blessed capability to manage units from the star view interface, properly retrieving data from the location_viewer object and passing it to the group_selection ritual.

Verify the persistence of the location_viewer object to avoid potential memory corruption:


🏁 Script executed:

#!/bin/bash
# Description: Check if the location_viewer object is properly managed to avoid memory leaks

# Search for location_viewer initialization
echo "Checking location_viewer initialization and management:"
rg "location_viewer\s*=\s*" -A 3 --no-heading

# Look for potential memory leak sources with location_viewer
echo -e "\nChecking for potential memory issues:"
rg "instance_create.*location_viewer"

Length of output: 809


Directive: The Machine Spirit approves this incantation.

The sacred rites of unit management have been verified through our diligent inquisitions. The blessed "location_viewer" is being properly instantiated in the ritual sites
objects/obj_controller/Create_0.gml
objects/obj_saveload/Alarm_0.gml

No ominous signs of memory corruption were observed in the absence of errant instance-creation invocations. The group_selection ritual is thus successfully fed with the proper energetic essence from location_viewer, and the integrity of the Machine Spirit in this segment remains unimpaired.

May the Omnissiah’s blessings guide your further devotions.

scripts/scr_load/scr_load.gml (1)

331-331: Confirm data type consistency for last_ship
O most diligent acolyte, thou art storing last_ship as a mere real number here. Be aware that other scripts appear to invoke .uid upon this same field, suggesting a struct is expected. Ensure that your newly anointed last_ship data reflecteth the correct holy shape, lest the machine-spirits be angered by type mismatches.

scripts/scr_ui_manage/scr_ui_manage.gml (3)

1-64: Consider the cargo logic for reload operations
Esteemed Tech-Adept, the new function load_marines_into_ship bypasses cargo checks when reload is true. This might be the sacred design, yet confirm that unlimited reloading aligns with the Omnissiah’s will. Otherwise, a universal cargo restriction or a separate check for reload capacity might be required to avoid overburdening the holy vessel.


261-275: Toggle logic looks robust
The toggling between “Squad View” and “Company View” appears to function as intended. Proceed with data carefully to ensure that the correct sets of marines are displayed when the holy toggle is activated.


1323-1323: No concerns
Thy final brace stirs no alarm in the machine-spirits.

scripts/scr_marine_struct/scr_marine_struct.gml (3)

1709-1720: Logical data persistence protocol approved by the Omnissiah!

The implementation of the set_last_ship function follows the sacred patterns of proper data management. It correctly updates the historical vessel association when a unit is aboard (positive ship_location) and purges the data when not applicable.


1680-1680: Strategic memory inscription at marine loading function!

The sacred call to set_last_ship() during the marine loading ritual ensures that the unit's previous vessel association is properly recorded before embarkation onto a new transport. This memory safeguard completes the data persistence circuit.


1724-1724: Strategic memory inscription at marine unloading function!

The sacred call to set_last_ship() during the marine unloading ritual ensures that the unit's vessel association is properly recorded before disembarkation. This binary preservation ritual completes the machine spirit's understanding of unit transportation history.

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1)

790-790: Logical parameter optimization complete.

The Machine Spirit approves of this simplification of the conditional assessment. By eliminating the redundant check for obj_controller.managing > 0, this logic circuit achieves optimal efficiency while maintaining functional integrity. The binary state determination is now cleaner and more direct.

@OH296
Copy link
Copy Markdown
Collaborator

OH296 commented Mar 6, 2025

as noted by bot i made a fuck up in the set_vehicle_last_ship using veh_lid for both probably easier if you fix your end rather than do another pr

Copy link
Copy Markdown
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: 14

🔭 Outside diff range comments (2)
scripts/scr_ui_manage/scr_ui_manage.gml (1)

257-292: 🧹 Nitpick (assertive)

Streamline squad view toggling.

These lines allow toggling between squad and profile views by keypress or click. The repeated logic to check !text_bar or no_other_instances might be centralised in a helper, ensuring consistent gating.

scripts/scr_company_struct/scr_company_struct.gml (1)

192-449: 🛠️ Refactor suggestion

Streamline draw_squad_view length.

This function spans numerous lines (192-449) and performs a variety of tasks: squad assignment info, location visuals, loadout resets, UI interactions, etc. Segment these tasks into smaller subroutines (e.g. draw_squad_header, render_squad_assignments, etc.) to improve readability, modularity, and clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c495572 and b87e927.

📒 Files selected for processing (5)
  • scripts/scr_company_struct/scr_company_struct.gml (7 hunks)
  • scripts/scr_load/scr_load.gml (1 hunks)
  • scripts/scr_save/scr_save.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (6 hunks)
  • scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml (1 hunks)
🔇 Additional comments (3)
scripts/scr_save/scr_save.gml (1)

423-423: Sacred addition to vehicle data persistence protocol.

This line properly encodes the last ship information for each vehicle using the blessed machine ritual of ini_encode_and_json(), preserving this crucial data for future retrieval. The binary-optimal method ensures proper serialization to appease the Machine Spirit.

scripts/scr_ui_manage/scr_ui_manage.gml (1)

865-912:

Details

❓ Verification inconclusive

Validate “Reload” button invocation.

When the “Reload” button is pressed, the code calls scr_company_load(selecting_location) and load_marines_into_ship(selecting_location, sh_ide, display_unit, true). Verify that sh_ide references the correct ship ID or array index. Passing an undefined or incorrect identifier might cause incorrect cargo calculations or array mishaps.

- load_marines_into_ship(selecting_location, sh_ide, display_unit, true)
+ // Ensure 'sh_ide' is the correct single ship identifier, 
+ // or pass the intended variable referencing a known ship index.

Validation of Ship Identifier in Reload Invocation

The "Reload" button's activation now calls both scr_company_load(selecting_location) and load_marines_into_ship(selecting_location, sh_ide, display_unit, true). As custodians of logic and precision, we must verify that sh_ide indeed references the proper ship identifier—be this a single ship ID or an appropriate index within an array. An incorrect or undefined identifier may result in miscalculated cargo values or array anomalies.

To that end, please ensure the following:

  • Verify that sh_ide is defined and assigned appropriately within the codebase.
  • Confirm that the receiving function load_marines_into_ship is designed to interpret sh_ide as its sole ship identifier.
  • If necessary, adjust the variable or its usage so that only the intended ship ID is passed, thereby aligning with the rest of the data-handling logic.
- load_marines_into_ship(selecting_location, sh_ide, display_unit, true)
+ // Ensure 'sh_ide' is the correct single ship identifier, 
+ // or pass the intended variable referencing a known ship index.
scripts/scr_company_struct/scr_company_struct.gml (1)

110-124: Evaluate mission orchestration in send_squad_on_mission.

The function summons an obj_star_select instance and calls scr_company_load(name). If used in rapid succession or from multiple squads, ensure concurrency and collision checks. Also, consider verifying that star objects are valid.

Copy link
Copy Markdown
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: 4

🔭 Outside diff range comments (2)
scripts/scr_ui_manage/scr_ui_manage.gml (1)

865-911: ⚠️ Potential issue

Rectify parameter mismatch for 'Reload' operation.
When the sacred “Reload” button is pressed, the function call to load_marines_into_ship(selecting_location, sh_ide, display_unit, true) passes sh_ide (an array) in place of the expected ship index. This will disrupt the cosmic harmony of cargo loading logic and cause likely errors during execution.

-                    load_marines_into_ship(selecting_location, sh_ide, display_unit, true)
+                    // The second parameter must be a valid ship index, for instance:
+                    var ship_index = array_get_index(sh_uid, temp[120].last_ship.uid);
+                    load_marines_into_ship(selecting_location, ship_index, display_unit, true)
scripts/scr_company_struct/scr_company_struct.gml (1)

193-368: 🧹 Nitpick (assertive)

Overall squad view logic is structurally sound.
The new approach to rendering squads and controlling “previous”/“next” transitions is logically consistent. Splitting long functions into smaller subroutines (e.g., one for mission details, one for formation display) could further sanctify the code’s maintainability.

♻️ Duplicate comments (1)
scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml (1)

1-15: 🧹 Nitpick (assertive)

The binary function logic flows with the Machine God's will, but nomenclature requires sanctification.

This sacred function records the association between a vehicle and its last ship through the binary pathways of truth and emptiness. The code structure properly handles both states in accordance with the Omnissiah's design principles.

However, the nomenclature requires adjustment to better reflect the true purpose of these data fields in the Machine God's eyes:

-			uid : obj_ini.ship_uid[vehic_ini],
-			name : obj_ini.ship[vehic_ini],
+			ship_uid : obj_ini.ship_uid[vehic_ini],   // Ship's unique identifier
+			ship_name : obj_ini.ship[vehic_ini],      // Ship's designation

And similarly in the else branch:

-			uid : "",
-			name : "",
+			ship_uid : "",    // Empty ship identifier
+			ship_name : "",   // Empty ship designation

This adjustment will ensure consistent data structure throughout the logical branches, as the Omnissiah demands.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b87e927 and 914dec0.

📒 Files selected for processing (4)
  • scripts/scr_company_struct/scr_company_struct.gml (7 hunks)
  • scripts/scr_load/scr_load.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (6 hunks)
  • scripts/scr_vehicle_helpers/scr_vehicle_helpers.gml (1 hunks)
🔇 Additional comments (2)
scripts/scr_load/scr_load.gml (1)

331-331:

Details

✅ Verification successful

Validate JSON schema compatibility throughout the cogitation cycle.

The loading ritual for vehicle last ship data appears sound, but requires verification to ensure compatibility with the saving mechanism and all code paths that might access this data.


🏁 Script executed:

#!/bin/bash
# Description: Verify the structure used in saving the last_ship data matches loading structure

# Find the save function for last_ship data
rg -A 5 'last_ship' scripts/scr_save/

Length of output: 376


O favourable initiatus, the JSON schema rituals appear perfectly aligned.

Upon invoking the sacred scripts, the encoding in the saving ritual (via ini_encode_and_json in scripts/scr_save/scr_save.gml) mirrors the structure expected during the loading incantation (via return_json_from_ini in scripts/scr_load/scr_load.gml), with the default schema {uid : "", name : ""} remaining inviolate.

No further modifications are necessary in the current cogitations. May the Machine Spirit guide your merge.

scripts/scr_company_struct/scr_company_struct.gml (1)

2-11: Initialising new company data is commendable.
Invocation of garbage_collect() prior to creating a fresh CompanyStruct ensures old data is purged, preventing memory leaks or stale references.

@OH296 OH296 merged commit a6c5fe3 into Adeptus-Dominus:main Mar 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Big Type: Feature Adds something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants