feat: Unit Management improvements#538
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe sacred code has been augmented with a new feature within the Suggested labels
Suggested reviewers
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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 functiongroup_selection.The divine PR objectives mention a known issue with the Squad View functionality due to problems with the
group_selectionfunction. This function is invoked here with parameters that may trigger the erroneous behavior.I beseech you to verify that this invocation of
group_selectionhandles the mentioned issue or implement appropriate error handling to prevent corruption of the machine spirit.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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
📒 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 designBy 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 voyagesThis 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 achievedThe removal of the redundant conditional check
obj_controller.managing > 0streamlines 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 OmnissiahReplacing 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 > 0condition 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-ignoreLength 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 ofobj_controller.managing > 0condition.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 optionaldataparameter.Rejoice, for adding
data = falseensures 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)thenupdate(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 functionload_marines_into_shipcreation.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
reloadis true, you correctly attempt to restore units to their last recorded ship. This is consistent with the_load_into_shipusage, and no immediate violations of the machine spirit are detected.
214-214: Click invocation for loading interactions.Your new
point_and_clickusage 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.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 5
🔭 Outside diff range comments (1)
scripts/scr_company_struct/scr_company_struct.gml (1)
191-448: 🛠️ Refactor suggestionFunction
draw_squad_viewdeserves 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 variableviable_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
📒 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 recreatingcompany_data.
Be sure that no other scripts or external references need the oldcompany_dataprior to this cleansing ritual. Otherwise, the omens of the Machine Spirit might become confused.
15-23: Efficient disposal of UI references.
Thisgarbage_collectfunction properly banishes old button objects from existence, ensuring the holy memory is reclaimed.
109-123: Assess the effect ofbreakwithin yourwith (star)block.
Line 120’sbreak;within thewithcontext 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 decrementingcur_squadis 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 invokingfleet_full_ship_array(current_fleet)and then callingcollect_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 inload_marines_into_ship.
This new ritual’s logic forreloadvs. 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_assignmenthas been optimized to remove unnecessary computation cycles. This alteration simplifies the sacred logic by removing the check forobj_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 > 0is 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 > 0condition in thescripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gmlhas been confirmed safe. Our searches unveiled no critical dependencies on the retracted condition, and the invocations related toplanet_selection_actionremain unperturbed.
- Verification through grepped references to "garrison" showed no conflicting usage.
- The presence of
planet_selection_actionin 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.
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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_arrayimplementation inscripts/scr_player_fleet_functions/scr_player_fleet_functions.gmlis correctly providing the expected ship arrays.- The
purpose_code: "manage"is applied consistently across multiple modules (notably inobjects/obj_star_select/Draw_64.gml,objects/obj_fleet_select/Create_0.gml, andscripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml), affirming proper handling of the manage directive.- The
group_selectionfunction, defined inscripts/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.
|
I'm too tired but i'll play test and try merge tomorrow |
OH296
left a comment
There was a problem hiding this comment.
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?
|
on another note please never do anything like this |
|
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 |
|
re this |
9555158 to
c495572
Compare
There was a problem hiding this comment.
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 issuePass missing
reloadparameter to_load_into_ship
Your code conjures_load_into_ship(system, ship, units, q)but the function’s signature demands five arguments. Omission ofreloadmay 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 adeleteto 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_shipfunction. Both theuidandnameproperties of the_last_ship_dataobject are assigned the same value fromobj_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 -20Length 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_datastructure inscripts/scr_vehicle_helpers/scr_vehicle_helpers.gmlis tainted by a data divergence. Both theuidandnameproperties are currently set to the identical value extracted fromobj_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
nameproperty. It should be derived from its own sanctified variable rather than mirroring theuidvalue.- 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 issueCritical inconsistency in data retrieval mechanism detected.
The Machine Spirits will be confused. While the saving function
scr_savecaptures a structured data object withuidandnameproperties forlast_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:
- The code lacks proper error handling when
_unit_dispersement[$ _sys_name]might be undefined.- The Machine Spirit would benefit from knowing the source of the
has_player_forcesvariable, 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
reloadparameter within_load_into_ship
This loyal sub-function receives the holy parameterreloadbut 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 comparingstat_tool_tip_textto"Squad View". Though functional, the Machine-Spirit could be vexed if a small text slip occurs. A dedicated boolean check may bestow resilience.
There was a problem hiding this comment.
Actionable comments posted: 8
♻️ Duplicate comments (4)
scripts/scr_ui_manage/scr_ui_manage.gml (1)
900-916:⚠️ Potential issuePotential ship argument confusion in “Reload”
When invokingload_marines_into_ship(selecting_location, sh_ide, display_unit, true), the second parameter expects a single ship index or ID, yetsh_idemight 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_shipmemory 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 suggestionImplement 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
📒 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 thatmanagingis 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 comparingselected_unit.companytocompany. The code is aligned well.
207-207: Cur_squad assignment is straightforward.
Designatingcur_squad = iafter 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.
Invokingnext_squad(false)ornext_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.
Summoningsend_squad_on_missionwithstar_by_nameis 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 ofp_playerarrays standardises presence check.
has_player_forcesdeduces total allied forces cleanly. Confirmtarget.p_playeralways 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_helpersto the project's resource array is a logical enhancement to support the vehicle management functionality. This script will house the imperative functionset_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_shipdata 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.gmlNo 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 forlast_ship
O most diligent acolyte, thou art storinglast_shipas a mere real number here. Be aware that other scripts appear to invoke.uidupon this same field, suggesting a struct is expected. Ensure that your newly anointedlast_shipdata 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 functionload_marines_into_shipbypasses cargo checks whenreloadistrue. 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_shipfunction 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.
|
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 |
There was a problem hiding this comment.
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_barorno_other_instancesmight be centralised in a helper, ensuring consistent gating.scripts/scr_company_struct/scr_company_struct.gml (1)
192-449: 🛠️ Refactor suggestionStreamline
draw_squad_viewlength.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
📒 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)andload_marines_into_ship(selecting_location, sh_ide, display_unit, true). Verify thatsh_idereferences 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)andload_marines_into_ship(selecting_location, sh_ide, display_unit, true). As custodians of logic and precision, we must verify thatsh_ideindeed 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_ideis defined and assigned appropriately within the codebase.- Confirm that the receiving function
load_marines_into_shipis designed to interpretsh_ideas 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 insend_squad_on_mission.The function summons an
obj_star_selectinstance and callsscr_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.
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (2)
scripts/scr_ui_manage/scr_ui_manage.gml (1)
865-911:⚠️ Potential issueRectify parameter mismatch for 'Reload' operation.
When the sacred “Reload” button is pressed, the function call toload_marines_into_ship(selecting_location, sh_ide, display_unit, true)passessh_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 designationAnd similarly in the else branch:
- uid : "", - name : "", + ship_uid : "", // Empty ship identifier + ship_name : "", // Empty ship designationThis 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
📒 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_jsonin scripts/scr_save/scr_save.gml) mirrors the structure expected during the loading incantation (viareturn_json_from_iniin 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 ofgarbage_collect()prior to creating a freshCompanyStructensures old data is purged, preventing memory leaks or stale references.
Purpose of the PR
Make it easier to manage units.
Describe the solution
Testing done
Reloadbutton.