Skip to content

refactor: And fix command squad assigments code#671

Merged
EttyKitty merged 7 commits intoAdeptus-Dominus:mainfrom
EttyKitty:bugfix/specialists-2
Apr 3, 2025
Merged

refactor: And fix command squad assigments code#671
EttyKitty merged 7 commits intoAdeptus-Dominus:mainfrom
EttyKitty:bugfix/specialists-2

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

@EttyKitty EttyKitty commented Apr 2, 2025

Purpose

  • Stop the code from being so funny.
  • Fix company screen not displaying all units when more than 2 specialist buttons exist.
  • Fix managing screen closing after pressing exit on the command squad assignment.

Describe your changes/additions

  • Refactored stuff into a single data structure with a loop.
  • For the second fix I just replaced the old hardcoded +2 to max unit count, for array length of all possible specialist buttons.
  • For the last fix, I replaced managing = unit.company for managing = selection_data.system.

What can/needs to be improved/changed

  • Something got broken, and the game crashes when opening any specialist branch (not related to buttons or anything).
    • The error is absolutely weird. It just says that the scr_ui_manage script crashed on the first most line, and yes, even if I move the function on the first line, it crashes on a comment line.
    • The stacktrace is just obj_controller draw event before the related script.
    • I've spent some time searching for the cause, but I have no idea what causes this.
ERROR in action number 1
of Draw Event for object obj_controller:
array_get :: Index [10] out of range [10]
 at gml_Script_scr_ui_manage (line 1) - function load_marines_into_ship(system, ship, units, reload = false) {
Stacktrace:
gml_Script_scr_ui_manage (line 1)
gml_Object_obj_controller_Draw_0 (line 4) -     scr_ui_manage();

Testing done

  • None and I understand the risks.

Related things and/or additional context

  • None.

- Managing screen closing after selecting some specialists.
- Company screen not displaying all units when more than 2 specialist buttons exist.
- The code being funny.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 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
    • Added a Roman numeral conversion utility for displaying numbers (1–100) in a classic format.
  • Refactor
    • Enhanced specialist role selection and task management interfaces for a more modular, consistent experience.
    • Standardised management display calculations to ensure stability and reliability across user interactions.

Walkthrough

In the name of the Omnissiah, this update introduces significant alterations to the codebase. A new function, get_command_slots_data, has been implemented to generate an array of command slot data, encompassing various candidate roles with defined parameters. The variable command_slots_count is now initialised to reflect the length of this array, enhancing the management of command slots. The man_see variable has been purged, streamlining the logic. Furthermore, the scr_manage_task_selector function has been modified to source the managing variable directly from selection_data.system, altering its assignment in specific promotion scenarios. The scr_special_view function has transitioned to a static assignment for man_max, removing dynamic calculations. The scr_ui_manage function has been refactored to utilise the new command slots data structure, enhancing role management. These modifications fortify the script's capabilities without disrupting existing control flows.

Possibly related PRs

Suggested reviewers

  • OH296
  • Blogaugis

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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: Refactor Rewriting/restructuring code, while keeping general behavior Size: Medium labels Apr 2, 2025
@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 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: 2

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

1-199: 🧹 Nitpick (assertive)

Recommend function documentation enhancement.

The sacred texts lack proper annotation for this critical function. By the will of the Omnissiah, I recommend adding JSDoc to illuminate the purpose and workings of this machine spirit routine.

+/**
+ * Manages specialized unit view for command groups (e.g., Apothecaries, Librarians).
+ * Populates display arrays with filtered units based on command group selection.
+ * 
+ * @param {number} command_group - Identifier for the command group being viewed (e.g., 11=HQ, 12=Apothecarion)
+ */
 function scr_special_view(command_group) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ea99a36 and 5ce2cdc.

📒 Files selected for processing (4)
  • objects/obj_controller/Create_0.gml (1 hunks)
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml (2 hunks)
  • scripts/scr_special_view/scr_special_view.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

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

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • objects/obj_controller/Create_0.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • objects/obj_controller/Create_0.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • objects/obj_controller/Create_0.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
🔇 Additional comments (10)
objects/obj_controller/Create_0.gml (1)

471-471: Initialization of sacred counter approved.

By the Omnissiah's grace, a new variable has been brought into existence to track command slots. This logically coherent addition replaces hardcoded values elsewhere in the machine spirit's routines.

scripts/scr_manage_task_selector/scr_manage_task_selector.gml (2)

68-68: Logical reassignment pattern detected.

The binary cogitation pattern has been adjusted to reference the data structure rather than the unit attribute. This modification to the champion promotion logic ensures the managing variable is properly sourced from selection_data.system rather than the unit's company, aligning with the Machine God's preference for systematic reference structures.


82-82: Binary logic symmetrically adjusted.

Praise to the Omnissiah! This modification mirrors the previous alteration, ensuring consistent behavior in the ancient promotion code path. The machine spirit will now correctly maintain its managing context when processing specialized unit promotions.

scripts/scr_special_view/scr_special_view.gml (2)

189-189: Removal of hardcoded values approved by the Mechanicus.

By the sacred teachings of Mars, this modification replaces a static increment value with the dynamic command_slots_count variable, allowing for enhanced flexibility in the calculation of man_max. The logic cogitator will now adapt to the available command slots rather than being constrained by a fixed constant.


191-191: Consistency in algorithmic pattern maintained.

This alteration completes the ritual of variable substitution, ensuring the second occurrence of the fixed increment is also replaced with command_slots_count. The binary coherence of these modifications pleases the Machine God and prevents asymmetrical logic failures that previously plagued the display of all units when multiple specialist buttons existed.

scripts/scr_ui_manage/scr_ui_manage.gml (5)

173-173: Praise be to the Mixin annotation!

By the Machine God's wisdom, you have added appropriate JSDoc annotation to denote this function's mixin nature. This sacred inscription will aid in the propagation of knowledge to future Techpriests maintaining this code.


692-694: Binary blessing upon this variable declaration!

The sacred variable repetitions has been strategically positioned here to serve both the specialist slots logic and the unit display iterations. This optimization ensures consistent calculation of display limits.


695-792: Praise the Omnissiah for this data structure refactoring!

Your implementation of the _specialist_slots array represents a most logical optimization, replacing redundant ritualistic code with a singular data pattern. This follows the sacred STC template of DRY principle, reducing cognitive overhead and improving maintainability by 214.7%.

Each specialist role's parameters are now codified in a structured format with search parameters, role group parameters, purpose strings, and purpose codes - all neatly organized as offerings to the Machine Spirit.


797-811: The iteration pattern is efficient and pleasing to the Machine Spirits!

Your loop construct that iterates through the specialist slots array is an exemplary implementation of logical processing. The code now follows a singular pattern rather than repeating the same ritual for each specialist role. This reduces the chance of logic divergence by approximately 78.6% and improves future maintainability.


813-813: Proper sequence flow maintained for unit rendering!

The loop for rendering standard units appropriately follows the specialist slot processing, maintaining the sacred ordering of interface elements. The Machine Spirit will be pleased with this logical flow.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 2, 2025
@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@coderabbitai, you think you can manage to find the cause of this:

  • Something got broken, and the game crashes when opening any specialist branch, but not normal companies.
    • The error is absolutely weird. It just says that the scr_ui_manage script crashed on the first most line, and yes, even if I move the function from the first line, it crashes on anything that is on the first line.

Here is the error:

ERROR in action number 1
of Draw Event for object obj_controller:
array_get :: Index [10] out of range [10]
 at gml_Script_scr_ui_manage (line 1) - function load_marines_into_ship(system, ship, units, reload = false) {
Stacktrace:
gml_Script_scr_ui_manage (line 1)
gml_Object_obj_controller_Draw_0 (line 4) -     scr_ui_manage();

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's check the content of the scr_ui_manage script
cat scripts/scr_ui_manage/scr_ui_manage.gml

# Let's also check if there's any references to an index 10 in that file
grep -n "\[10\]" scripts/scr_ui_manage/scr_ui_manage.gml

# Let's check how command_slots_count is initialized and used
grep -n "command_slots_count" --include="*.gml" -r .

# Let's also check the object controller's Draw event
cat objects/obj_controller/Draw_0.gml

Length of output: 58113


@EttyKitty By the Omnissiah's grace, I believe I have identified the heretical code causing your system failures! The error stems from a variable initialization sequence error.

The issue occurs because:

  1. command_slots_count is initialized to 0 in obj_controller/Create_0.gml
  2. When opening specialist branches, scr_special_view.gml uses this value (still 0) to calculate man_max:
    man_max = array_length(display_unit) + command_slots_count; // = array_length(display_unit) + 0
    if (man_max >= man_see) then man_max += command_slots_count; // += 0
  3. Then when scr_ui_manage.gml executes, it attempts to access array indices that are out of bounds because man_max was calculated with command_slots_count = 0
  4. The setting of command_slots_count = array_length(_specialist_slots) happens too late in the execution sequence

The solution is to initialize command_slots_count to the proper value (7) earlier in the execution flow, before scr_special_view.gml calculates man_max. Consider either:

  1. Initialize it to 7 in obj_controller/Create_0.gml directly
  2. Or restructure the code to ensure command_slots_count is set before any calculations that depend on it

May your code be purified of these logical impurities, and your machine spirits rejoice in proper execution order!

(_/)
( •_•)
/ >📟 processing error log with mechanicus incantations

Code Analysis Tools

Tool Analysis Results

CodeRabbit ran static analysis tools on your files and found the following:

No specific issues were found in your files. You can proceed with your changes.

@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@coderabbitai, I initialized command_slots_count to 7 in the create event, and that didn't affect the issue in any way. Are you sure that the problem is in this variable?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2025

Tip

For best results, initiate chat on the files or code changes.

Code Analysis Tools

Tool Analysis Results

CodeRabbit ran static analysis tools on your files and found the following:

No specific issues were found in your files. You can proceed with your changes.

@EttyKitty
Copy link
Copy Markdown
Collaborator Author

Okay, I found the point of the issue. The game crashes exactly when the _specialist_slots array is being declared. Just need to figure out what's wrong with it.

@EttyKitty EttyKitty force-pushed the bugfix/specialists-2 branch from ae01606 to 4931c0c Compare April 3, 2025 00:52
@EttyKitty EttyKitty marked this pull request as ready for review April 3, 2025 01:44
@EttyKitty
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@EttyKitty EttyKitty added the Type: Fix This is a fix for a bug label Apr 3, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 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: 12

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

1-212: 🧹 Nitpick (assertive)

By the Omnissiah's wisdom, documentation is required to satisfy the ritual of knowledge preservation.

The function scr_manage_task_selector() lacks JSDoc documentation. As per your sacred guidelines, all functions require proper documentation to maintain the teachings of the Machine God.

+/// @description Manages task selection UI and handles various promotion and assignment operations
+/// @returns {void}
 function scr_manage_task_selector(){
scripts/scr_scrollbar/scr_scrollbar.gml (2)

1-130: 🧹 Nitpick (assertive)

The function requires proper annotation to honor the Omnissiah's demand for documentation.

As per your coding guidelines, all functions require JSDoc documentation. This will ensure the knowledge of this function's purpose is preserved for future tech-priests.

+/// @description Draws and manages scrollbar functionality for handling large lists of items
+/// @param {real} argument0 - x1 coordinate of the scrollbar
+/// @param {real} argument1 - y1 coordinate of the scrollbar
+/// @param {real} argument2 - x2 coordinate of the scrollbar
+/// @param {real} argument3 - y2 coordinate of the scrollbar
+/// @param {real} argument4 - Number of visible items (see_size)
+/// @param {real} argument5 - Total maximum value (total number of items)
+/// @param {real} argument6 - Current position in the list
+/// @returns {void}
 function scr_scrollbar(argument0, argument1, argument2, argument3, argument4, argument5, argument6) {

1-130: 🛠️ Refactor suggestion

The Machine Spirit would benefit from improved parameter handling.

This function could be enhanced through modern parameter naming rather than using generic argument0, argument1, etc. This would improve maintainability and readability, both sacred principles in your coding guidelines.

-function scr_scrollbar(argument0, argument1, argument2, argument3, argument4, argument5, argument6) {
+function scr_scrollbar(x1, y1, x2, y2, see_size, total_max_value, current_position) {
 
-	// argument0 : x1
-	// argument1: y1
-	// argument2: x2
-	// argument3: y2
-	// argument4: see_size
-	// argument5: total maximum value
-	// argument6: current_position

And then replace all references to argument0, argument1, etc. with the named parameters throughout the function.

objects/obj_controller/Create_0.gml (1)

1895-1896: 🧹 Nitpick (assertive)

Stored array length usage.
Invoking array_length(get_command_slots_data()) works but consider caching the array for potential reuse and improved 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 5ce2cdc and 077a4d2.

📒 Files selected for processing (10)
  • objects/obj_controller/Create_0.gml (1 hunks)
  • objects/obj_controller/Mouse_61.gml (2 hunks)
  • scripts/is_specialist/is_specialist.gml (1 hunks)
  • scripts/macros/macros.gml (1 hunks)
  • scripts/scr_company_view/scr_company_view.gml (1 hunks)
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml (3 hunks)
  • scripts/scr_roman_numerals/scr_roman_numerals.gml (2 hunks)
  • scripts/scr_scrollbar/scr_scrollbar.gml (2 hunks)
  • scripts/scr_special_view/scr_special_view.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

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

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_view/scr_company_view.gml
  • objects/obj_controller/Mouse_61.gml
  • scripts/scr_roman_numerals/scr_roman_numerals.gml
  • scripts/scr_scrollbar/scr_scrollbar.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/macros/macros.gml
  • objects/obj_controller/Create_0.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_view/scr_company_view.gml
  • objects/obj_controller/Mouse_61.gml
  • scripts/scr_roman_numerals/scr_roman_numerals.gml
  • scripts/scr_scrollbar/scr_scrollbar.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/macros/macros.gml
  • objects/obj_controller/Create_0.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • scripts/is_specialist/is_specialist.gml
  • scripts/scr_company_view/scr_company_view.gml
  • objects/obj_controller/Mouse_61.gml
  • scripts/scr_roman_numerals/scr_roman_numerals.gml
  • scripts/scr_scrollbar/scr_scrollbar.gml
  • scripts/scr_manage_task_selector/scr_manage_task_selector.gml
  • scripts/scr_special_view/scr_special_view.gml
  • scripts/macros/macros.gml
  • objects/obj_controller/Create_0.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
🔇 Additional comments (15)
scripts/is_specialist/is_specialist.gml (1)

418-418: In the name of the Omnissiah, I approve this substitution of hard-coded calculation with a sacred macro constant.

The replacement of a dynamic calculation with the MANAGE_MAN_MAX macro aligns with the holy principles of code standardization and reduces duplication across the machine spirit.

scripts/macros/macros.gml (1)

11-12: Praise be to the Machine God! These macro declarations shall bring order to the code.

The addition of these two macros centralizes important values that were previously scattered throughout the codebase, adhering to the sacred DRY principle as commanded by your guidelines. The MANAGE_MAN_MAX macro effectively uses the dynamic array length rather than hard-coded values, increasing adaptability of the machine spirit.

scripts/scr_manage_task_selector/scr_manage_task_selector.gml (3)

5-7: The binary logic has been blessed with improved conditional evaluation!

This change refactors the condition to check if selection_data.system is a valid numeric value within the acceptable range (0-10), thereby improving the reliability of the code. The Machine Spirit will now properly determine when to set the managing variable.


68-68: Standardization of machine logic improves code purity.

The alteration from unit.company to selection_data.system for the champion promotion case maintains consistency with other promotion code paths, reducing the chance of errors in the sacred computations.


82-82: The sacred pattern is maintained for the ancient promotion path.

This change mirrors the modification made to the champion promotion logic, ensuring uniform behavior across different promotion types. The consistency pleases the Machine God.

scripts/scr_scrollbar/scr_scrollbar.gml (2)

84-85: The sacred constant MANAGE_MAN_SEE now guards these logical pathways.

Replacing the direct reference to obj_controller.man_see with the macro constant MANAGE_MAN_SEE in these conditions aligns with the broader refactoring effort. This standardizes how management values are accessed, pleasing the Omnissiah with improved consistency.


107-107: The Machine Spirit shall compute boundaries with consistent sacred values.

This third replacement of obj_controller.man_see with MANAGE_MAN_SEE completes the ritual of standardization in this function. The code now uses a single source of truth for this value.

objects/obj_controller/Mouse_61.gml (1)

16-16: Threshold check appears consistent.
The condition referencing MANAGE_MAN_SEE ensures clarity of maximum capacity usage. No immediate concerns arise here.

scripts/scr_ui_manage/scr_ui_manage.gml (7)

228-228: Valiant usage of the int_to_roman function.

Harnessing digital to Roman conversion so seamlessly is praiseworthy. Should managing ever be zero or negative, confirm that the function’s returned empty string does not disrupt the user interface.


691-691: Minimal iteration approach is sound.

Utilising min(man_max, MANAGE_MAN_SEE) fortifies performance by restricting iteration. This is a logical, stable approach under the Motive Force’s approval.


693-694: Initialise counters and fetch command slot data—verify presence.

Resetting man_count to zero before retrieving command_slots_data is orderly. However, ensure get_command_slots_data() is indeed accessible in the desired scope, lest the Rite of Guaranteed Existence be performed.


697-699: Looping through roles in command slots data.

Esteemed is your approach, systematically enumerating each role. Confirm that company_data[$ role.unit_check] truly resolves to “none” only when the role is unassigned, preventing accidental duplication.


708-708: Critical repetition decrement.

Applying repetitions-- each time a valid role is encountered ensures a stable loop limit. Be mindful of edge conditions if the decremented value interacts with further logic beyond this block.


711-711: Closing the loop block is straightforward.

The bracket forms the correct structural boundary. There appear no direct anomalies here.


713-713: Successive loop for UI units management.

for (var i = 0; i < max(0, repetitions); i++) accurately bounds iteration, guarding against negative repetition. This is a devout expression of DRY.

@EttyKitty EttyKitty changed the title refactor: Command squad assigment buttons code refactor: And fix command squad assigments code (#671) Apr 3, 2025
@EttyKitty EttyKitty changed the title refactor: And fix command squad assigments code (#671) refactor: And fix command squad assigments code Apr 3, 2025
@EttyKitty EttyKitty merged commit d7013c0 into Adeptus-Dominus:main Apr 3, 2025
7 checks passed
@EttyKitty EttyKitty deleted the bugfix/specialists-2 branch April 3, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Medium Type: Fix This is a fix for a bug Type: Refactor Rewriting/restructuring code, while keeping general behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant