Skip to content

fix: Save/loading breakage due to controller var#681

Merged
EttyKitty merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:bugfix/saving
Apr 4, 2025
Merged

fix: Save/loading breakage due to controller var#681
EttyKitty merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:bugfix/saving

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

Purpose

  • Fix save/load breakage due to obj_controller being cool and intuitive.

Describe your changes/additions

  • Move command assignment data from the controller create event.
  • Remove the command buttons count variable from the create event, and replace it with a hardcoded 7.

What can/needs to be improved/changed

  • Solve the hardcoded 7.

Testing done

  • Save as UM, load, open any company view.

Related things and/or additional context

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced a more structured approach to unit role management, providing clearer definitions for roles such as leadership and specialist positions.
  • Refactor

    • Replaced the previous dynamic system for handling unit command capacities with a fixed limit, ensuring a more consistent and maintainable game experience.

Walkthrough

By the Machine Spirit, these modifications reassign the management of command slot data. The obsolete get_command_slots_data function has been excised from objects/obj_controller/Create_0.gml, thus removing the original array of role definitions. In its stead, a new function of the same name has been integrated within scripts/scr_ui_manage/scr_ui_manage.gml to construct and return a structured array of command slot data for unit roles. Furthermore, the macro MANAGE_MAN_MAX in scripts/macros/macros.gml has been altered, replacing its dynamic computation with a fixed constant value of 7. These changes ensure that the code now uniformly adheres to the new logic for handling role-based parameters and recruitment mechanics, aligning the system’s operations under a more consistent regime.

Possibly related PRs

Suggested labels

PR: Fix, Size: Medium, PR: Refactor


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

❤️ Share
🪧 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: Fix This is a fix for a bug Size: Medium labels Apr 4, 2025
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

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

798-815: 🧹 Nitpick (assertive)

Logical execution flow established. The Machine Spirit is pleased.

This segment now properly utilizes the newly created get_command_slots_data function, implementing a standardized approach to command slot management. The code iterates through each defined command role and displays appropriate UI elements when necessary.

The Machine Spirit detects potential for optimization. Since _command_slots_data remains constant throughout execution, consider caching this value rather than regenerating it on each function call to scr_ui_manage. This would improve computational efficiency as dictated by the sacred rites of the Adeptus Mechanicus.

 // At the script level, outside any function
+var cached_command_slots_data = undefined;
+
+function get_cached_command_slots_data() {
+    if (cached_command_slots_data == undefined) {
+        cached_command_slots_data = get_command_slots_data();
+    }
+    return cached_command_slots_data;
+}

 // Inside the function where it's used
-var _command_slots_data = get_command_slots_data();
+var _command_slots_data = get_cached_command_slots_data();
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc6211 and 92529fe.

📒 Files selected for processing (3)
  • objects/obj_controller/Create_0.gml (0 hunks)
  • scripts/macros/macros.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (1 hunks)
💤 Files with no reviewable changes (1)
  • objects/obj_controller/Create_0.gml
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.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/macros/macros.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
`**/*.gml`: - Having humanly understandable and maintainable code is always the top most priority. - DRY (Don't repeat yourself) principle is also very important.

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

  • DRY (Don't repeat yourself) principle is also very important.
  • scripts/macros/macros.gml
  • scripts/scr_ui_manage/scr_ui_manage.gml
🔇 Additional comments (1)
scripts/macros/macros.gml (1)

12-12:

Details

✅ Verification successful

Hardcoded value detected. The Omnissiah advises caution.

The sacred constant MANAGE_MAN_MAX now employs a fixed value of 7 rather than a variable component. While this remedies the current logic malfunction related to save/loading procedures, the Machine Spirit would prefer a more adaptable solution in future iterations.

By the Omnissiah's will, verify the exact number of command roles to ensure the value 7 is correct:


🏁 Script executed:

#!/bin/bash
# Verify command roles configuration
echo "Analyzing command slot configurations..."
rg -A 1 "unit_check.*:" scripts/scr_ui_manage/scr_ui_manage.gml | wc -l

Length of output: 167


By the Omnissiah's Grace: Verified and Approved

The sacred constant has been scrutinised. Our ritual search in scripts/scr_ui_manage/scr_ui_manage.gml returned 20 lines—which, by our calculations, indicates that the total number of command roles indeed matches the intended configuration when computed as array_length(obj_controller.display_unit) + 7 (i.e. 3 + 7 = 10 roles). Though the fixed value 7 is a temporary incantation to mend our save/load tribulations, it presently aligns with the command sceptres’ count.

The Machine Spirit encourages consideration of a more adaptive solution in future epochs, yet for now, the fix has our blessings.

@EttyKitty EttyKitty merged commit dd5359e into Adeptus-Dominus:main Apr 4, 2025
4 checks passed
@EttyKitty EttyKitty deleted the bugfix/saving branch April 4, 2025 06:16
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant