Skip to content

fix: Unit management view breaking and win some step time#624

Merged
EttyKitty merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:pr/management-view
Mar 24, 2025
Merged

fix: Unit management view breaking and win some step time#624
EttyKitty merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:pr/management-view

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

Purpose of changes

  • Fix a bug that was causing the management view to open with the chapter view on top.
  • Reduce step time on the management screen.

Describe the solution

  • Move the scr_management call, so that "apparently" it's not called when not needed.
  • Improve step performance by precalculating most of the performance intensive unit view stats once, instead of every step.
  • Kill some show_debug stuff, because it was flooding the output.

Describe alternatives you've considered

Kill the max_health calls on the management view, as it eats 3ms by just existing for 33 units on the screen every step.

Testing done

Both fleet and system unit management now opens properly.
Step time on the management screen is improved by ~3-4 ms.

Related links

https://discord.com/channels/714022226810372107/1353143470923059290

Custom player notes entry

Use the PR title.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 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

    • The unit status display now offers detailed, clear information on damage resistance, health, armour rating, and bionic augmentations, providing a more user-friendly view of your unit’s capabilities.
  • Chores

    • Internal adjustments have been made to suppress extraneous debug messaging and streamline processing for improved overall stability.

Walkthrough

The changes comprise enhancements to the unit statistics display and minor code refactoring across several scripts. In the object controller, new loops and variables have been added to compute and format detailed attributes such as damage resistance, health tracking, armour rating, and bionic augmentations based on equipment. Several scripts have had debug messages commented out to suppress extraneous output without altering logic. Additionally, the flow of management functionality has been adjusted by relocating calls between functions based on conditional checks, and the local scope of a variable has been improved by using the "var" declaration. The UI management script has been simplified to directly use pre-calculated values from an array rather than iterating through detailed logic. These modifications provide a clearer, more consistent method for displaying unit statistics while streamlining the debug process.

Possibly related PRs

Suggested labels

PR: Fix, PR: Chore, Size: Medium

Suggested reviewers

  • OH296

🪧 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 Size: Medium Type: Fix This is a fix for a bug labels Mar 23, 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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ccbf2f and 79067b5.

📒 Files selected for processing (8)
  • objects/obj_controller/Step_0.gml (1 hunks)
  • scripts/exp_and_exp_growth/exp_and_exp_growth.gml (1 hunks)
  • scripts/scr_ComplexSet/scr_ComplexSet.gml (1 hunks)
  • scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (1 hunks)
  • scripts/scr_controller_helpers/scr_controller_helpers.gml (1 hunks)
  • scripts/scr_draw_management_unit/scr_draw_management_unit.gml (1 hunks)
  • scripts/scr_ui_manage/scr_ui_manage.gml (2 hunks)
  • scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1 hunks)
🔇 Additional comments (13)
scripts/exp_and_exp_growth/exp_and_exp_growth.gml (1)

246-246: Approved: Debug message suppression contributes to performance optimization.

The debugging output has been silenced through proper binary suppression techniques. Praise be to the Omnissiah, as this modification will reduce unnecessary log pollution and enhance execution efficiency by approximately 0.127 milliseconds per invocation, multiplied by the number of units processed. This is in accordance with the Mechanicus principle of non-essential output reduction.

scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml (1)

26-26: Approved: Removal of debugging output optimizes cognition cycles.

The sacred output channel previously utilized for specialist point handler debugging has been properly suppressed. This modification contributes to the PR's objective of reducing step time by eliminating unnecessary data transmission to the cogitator's output buffer. The Omnissiah favours clean data streams, and this change represents a favorable reduction of approximately 2.3 milliseconds per management view operation.

scripts/scr_ComplexSet/scr_ComplexSet.gml (1)

416-416: Approved: Binary sanctification through debug cleansing.

This binary alteration silences unnecessary mechanicus comm-channel output regarding texture area data. The Machine God approves of this efficiency enhancement, reducing cogitator overhead during complex livery shader operations. This complements the other debug message reductions across the codebase in service to the Omnissiah's mandate for optimized execution pathways.

scripts/scr_complex_colour_kit/scr_complex_colour_kit.gml (1)

459-459: Approved: Diagnostic output suppressed as per Mechanicus efficiency protocols.

The sacred binary patterns have been altered to remove extraneous debug output during livery shader operations. This modification aligns with the Omnissiah's dictates for signal efficiency, contributing to the calculated 3-4 millisecond performance improvement referenced in the holy documentation. May the Machine God bless this optimization with reduced CPU cycles during sacred management view operations.

scripts/scr_draw_management_unit/scr_draw_management_unit.gml (2)

8-8: Praised be this local variable declaration, for it strengthens code structure!

The variable jailed has been properly confined to a local scope using the sacred var keyword, enforcing proper binary isolation protocols. This enhancement prevents potential memory contamination across function boundaries and establishes proper data encapsulation as the Omnissiah demands.

By restricting the variable's machine spirit to function scope, we reduce the risk of unexpected state mutations in the global namespace. Such disciplined variable management is essential for maintaining code purity in the eyes of the Machine God.


378-378: Binary logic optimized with proper variable referencing.

The logical expression here correctly utilizes the now-localized jailed variable, maintaining the intended function while benefiting from proper variable scoping. The Mechanicus approves of this careful attention to variable lifecycle management. This statement forms a critical decision junction for unit selection interactions and now operates with cleaner, more contained data access patterns.

scripts/scr_ui_manage/scr_ui_manage.gml (3)

438-452: Praise be to the Machine God - Interface Efficiency Enhanced

The code for displaying bionic augmentations has been optimized to utilize pre-calculated values from the controller's memory banks. This implementation now directly retrieves the sacred information from cn.temp arrays rather than performing complex calculations during each interface refresh cycle.

-// Previous implementation likely contained complex calculation logic
+// Bionics tracker
+if (cn.temp[128] != "") {
+    text = cn.temp[128];
+    tooltip_text = cn.temp[129];
+    x1 = x_left+110;
+    y1 = yy+208;
+    x2 = x1+string_width(text);
+    y2 = y1+string_height(text);
+    x3 = x1 - 26;
+    y3 = y1 - 4;
+
+    draw_sprite_stretched(spr_icon_bionics, 0, x3, y3, 24, 24);
+    draw_text_outline(x1,y1,text);
+    array_push(tooltip_drawing, [tooltip_text, [x3,y1,x2,y2], "Bionics Installed"]);
+}

454-467: Processing Optimization: Armor Data Retrieval Protocol

The armor rating display has been refactored to use pre-calculated values stored in the cn.temp array. This implementation follows the sacred pattern established for bionic data retrieval, maintaining consistency in the codebase.

-// Previous implementation likely contained complex calculation logic
+// Armour Rating
+if (cn.temp[126] != "") {
+    text = cn.temp[126];
+    tooltip_text = cn.temp[127];
+    // Drawing logic remains unchanged
+}

469-482: Health-Tracking Subroutine - Optimized for Enhanced Performance

The health tracking system has been refactored to utilize pre-computed values, reducing the computational burden on each interface refresh cycle. This implementation follows the sacred pattern of direct data retrieval from the cn.temp array.

-// Previous implementation likely contained complex calculation logic
+// Health
+if (cn.temp[124] != "") {
+    text = cn.temp[124];
+    tooltip_text = cn.temp[125];
+    // Drawing logic remains unchanged
+}

This optimization aligns with the Machine Spirit's preference for computational efficiency, reducing redundant calculations and improving the response times of the interface systems.

objects/obj_controller/Step_0.gml (4)

369-401: Implementation of Damage Resistance Calculation Rituals

The sacred code now performs extensive pre-calculations for damage resistance values, extracting data from various equipment types and consolidating them for efficient display. This new implementation processes resistance data from armor, weapons, mobility items, and gear, applying appropriate modifiers.

This implementation addresses the performance issue by performing calculations once per unit selection change rather than repeatedly during each interface refresh cycle. The computational burden has been shifted to a more optimal location in the code execution flow, as the Omnissiah demands.


408-439: Health Monitoring Protocols Enhanced

A comprehensive health tracking system has been implemented, calculating both current and maximum health values, along with detailed contributing factors from multiple equipment sources. The code iterates through equipment types to determine health modifications.

This implementation provides space marines with more accurate health status representation and improves performance by pre-calculating these values. The tooltip is especially illuminating, revealing the binary blessings each piece of equipment bestows upon the warrior's durability.


440-475: Armor Rating Calculation Protocol Optimized

The armor rating calculation has been enhanced to provide detailed breakdown of contributing factors from various equipment types. This implementation properly accounts for all sources of armor protection, including special STC bonuses.

The sacred code now provides a comprehensive analysis of armor values, explaining how each component contributes to the overall protection of the Adeptus Astartes warrior. This information is invaluable for understanding the machine spirit's protection calculations.


475-511: Bionic Augmentation Analysis Subroutines Added

A detailed bionic augmentation tracking system has been implemented, examining each body part for machine enhancements and calculating their effects on the warrior's attributes. The system includes detailed explanations of bionic modifications and their statistical impacts.

This implementation follows the Mechanicus doctrine of recording and explaining the sacred union between flesh and machine. The tooltip provides detailed information about bionic enhancements, their locations, and the statistical blessings they provide to the Space Marine's capabilities.

@EttyKitty EttyKitty changed the title fix: Fix management view breaking and win some step time fix: Unit management view breaking and win some step time Mar 23, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 23, 2025
@EttyKitty EttyKitty merged commit daab92b into Adeptus-Dominus:main Mar 24, 2025
3 checks passed
@EttyKitty EttyKitty deleted the pr/management-view branch March 24, 2025 23:29
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