Skip to content

fix: Add safe-guards for scr_orbiting_player_fleet function#994

Merged
OH296 merged 1 commit intoAdeptus-Dominus:mainfrom
OH296:orbiting_player_fleet_bug
Aug 28, 2025
Merged

fix: Add safe-guards for scr_orbiting_player_fleet function#994
OH296 merged 1 commit intoAdeptus-Dominus:mainfrom
OH296:orbiting_player_fleet_bug

Conversation

@OH296
Copy link
Copy Markdown
Collaborator

@OH296 OH296 commented Aug 28, 2025

Purpose and Description

  • Self-descriptive.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 28, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Enhanced fleet tracking: identify orbiting fleets by faction and locate the nearest player fleet.
    • Imperial fleet strength is now computed and available for game logic and UI.
    • Added a distance helper to improve consistency in proximity checks.
  • Documentation
    • Added inline usage notes for new fleet and utility functions.
  • Chores
    • Serpha Jump Pack now tagged as “ancient”, affecting filters and any systems tied to ancient gear.

Walkthrough

By the Omnissiah’s datum-cogitation: adds four fleet utility functions (orbiting lookup, distance helper, player-fleet finder, imperial strength aggregation) within scr_fleet_functions.gml and updates a weapon gear tag in scr_weapon.gml. Notes indicate a duplicate scr_orbiting_player_fleet block present. Documentation comments were introduced.

Changes

Cohort / File(s) Summary of Changes
Fleet utilities
scripts/scr_fleet_functions/scr_fleet_functions.gml
Added scr_orbiting_fleet(faction, system="none"); added object_distance(obj_1, obj_2); added scr_orbiting_player_fleet(system="none") with -1 default and system-delegation; added sector_imperial_fleet_strength() setting imp_ships and max_fleet_strength; inserted documentation blocks; potential duplicate definition of scr_orbiting_player_fleet noted.
Weapon data tag
scripts/scr_weapon/scr_weapon.gml
Updated global.gear.mobility."Serpha Jump Pack" tags from ["jump"] to ["jump","ancient"].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

PR: Fix, Size: Medium

Suggested reviewers

  • EttyKitty
  • Blogaugis

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit 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:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: Small Type: Fix This is a fix for a bug labels Aug 28, 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
scripts/scr_fleet_functions/scr_fleet_functions.gml (2)

515-535: Syntax error + faulty self-check in scr_orbiting_player_fleet. Purge the scrapcode.

  • Stray ‘s’ after a brace (Line 519) will not compile.
  • else if lacks parentheses (Line 523) — invalid GML.
  • Inverted struct check makes the main branch unreachable; instances are structs, so !(is_struct(self)) is false.
  • Missing instance_exists guard before distance use.

Apply this rite of correction:

-function scr_orbiting_player_fleet(system = "none"){
-    if (system == "none" && !(is_struct(self)) && object_index == obj_star){
-        var _fleet = instance_nearest(x, y, obj_p_fleet);
-        if (object_distance(self, _fleet) > 0){s
-            return -1
-        } else{
-            return _fleet.id;
-        }
-    } else if system != "none"){
-        try{
-            with (system){
-                return scr_orbiting_player_fleet();
-            }
-        } catch(_exception){
-            handle_exception(_exception);
-        }
-    }
-    return -1;
-}
+function scr_orbiting_player_fleet(system = "none"){
+    // Called from a star or delegated via `with (system)`.
+    if (system == "none"){
+        if (object_index != obj_star) return -1;
+        var _fleet = instance_nearest(x, y, obj_p_fleet);
+        if (!instance_exists(_fleet)) return -1;
+        return (point_distance(x, y, _fleet.x, _fleet.y) == 0) ? _fleet.id : -1;
+    } else if (system != "none"){
+        try {
+            with (system) {
+                return scr_orbiting_player_fleet("none");
+            }
+        } catch(_exception) {
+            handle_exception(_exception);
+        }
+    }
+    return -1;
+}

537-558: Assignment in conditional mutates fleet position; use equality.

if (x=xx && y==yy) assigns x, corrupting state and breaking logic. Replace with comparison.

-    with (obj_en_fleet){
-        if (x=xx && y==yy){
+    with (obj_en_fleet){
+        if (x==xx && y==yy){
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6969e6e and dedfa14.

📒 Files selected for processing (2)
  • scripts/scr_fleet_functions/scr_fleet_functions.gml (3 hunks)
  • scripts/scr_weapon/scr_weapon.gml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.gml

⚙️ CodeRabbit configuration file

**/*.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.

Files:

  • scripts/scr_weapon/scr_weapon.gml
  • scripts/scr_fleet_functions/scr_fleet_functions.gml
**/*.*

⚙️ CodeRabbit configuration file

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

Files:

  • scripts/scr_weapon/scr_weapon.gml
  • scripts/scr_fleet_functions/scr_fleet_functions.gml
🔇 Additional comments (6)
scripts/scr_weapon/scr_weapon.gml (1)

2890-2891: Tag augmentation acknowledged; no logic impact.

Adding "ancient" to the Serpha Jump Pack’s tags is consistent with other ancient gear tags. Sanctified.

scripts/scr_fleet_functions/scr_fleet_functions.gml (5)

434-455: Docs read clean and match behaviour.

The specification for scr_orbiting_fleet is clear and aligned with the implementation. Machine-spirits appeased.


456-478: Orbiting-by-faction lookup looks correct.

Co-location check, faction match, and idle action gate are sound.


481-495: Utility docs are clear.

object_distance contract is concise and useful for orbit checks.


501-514: Approved: scr_orbiting_player_fleet call sites handle –1 sentinel correctly; no “none” comparisons found.


560-580: Verify p_owner array indexing in the obj_star loop
The current loop (for (var i = 0; i <= planets; i++)) may read p_owner[0] or overshoot the array. Confirm whether p_owner is 1-indexed—if so, iterate i = 1 through planets; if it’s 0-indexed, use i < planets.

@OH296 OH296 merged commit 0ba628b into Adeptus-Dominus:main Aug 28, 2025
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Small Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant