Skip to content

Annotate SetNavigatorPersonalPosMaxDistance and check it exists before calling it#7155

Open
lL1l1 wants to merge 4 commits into
developfrom
annotations/setnavigatorpersonalpos
Open

Annotate SetNavigatorPersonalPosMaxDistance and check it exists before calling it#7155
lL1l1 wants to merge 4 commits into
developfrom
annotations/setnavigatorpersonalpos

Conversation

@lL1l1

@lL1l1 lL1l1 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description of the proposed changes

Adds annotation to fix undefined global warning.
Check it exists before calling it because its resulting in an error in the current lua deployment because exe isn't automatically deployed with it.

Testing done on the proposed changes

no intellisense warning are given anymore

Checklist

Summary by CodeRabbit

  • New Features

    • Added a new debug/console API to adjust the navigator’s personal-position distance threshold.
    • Documented the new setting, including its default value and related commands.
  • Bug Fixes

    • Updated pathfinding initialization to only apply the threshold when the new navigator setting is available, avoiding failures in environments where it isn’t present.

@lL1l1 lL1l1 requested review from 4z0t and BlackYps June 26, 2026 15:50
@lL1l1 lL1l1 added area: sim Area that is affected by the Simulation of the Game area: requires engine patch related to the engine and no effective workaround is known in Lua type: intellisense labels Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb71def4-0363-49a9-928a-88e77309de06

📥 Commits

Reviewing files that changed from the base of the PR and between 218bd78 and f44d840.

📒 Files selected for processing (1)
  • engine/Sim.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • engine/Sim.lua

📝 Walkthrough

Walkthrough

The PR adds the SetNavigatorPersonalPosMaxDistance(distance) simulation API, updates SetupPathfinding() to call it only when available, and adds a changelog note for the annotation and guard.

Changes

Navigator threshold update

Layer / File(s) Summary
API declaration
engine/Sim.lua
Adds the SetNavigatorPersonalPosMaxDistance(distance) declaration and its navigator grid threshold comments.
Pathfinding setup guard
lua/simInit.lua, changelog/snippets/other.7155.md
SetupPathfinding() now checks for SetNavigatorPersonalPosMaxDistance before calling it, and the changelog records the update.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • FAForever/fa#7020: Updates the same SetupPathfinding() call path with SetNavigatorPersonalPosMaxDistance(9999), which this PR now gates behind a presence check.

Suggested reviewers

  • BlackYps

Poem

A rabbit hopped by moonbeam light,
And checked the navigator just right. 🐇
“If the paw-print function’s there,
I’ll call it with a careful stare,”
Then long-path hops went off all night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: annotating the API and guarding the call.
Description check ✅ Passed The required sections are present and filled with the change, testing, and checklist details.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch annotations/setnavigatorpersonalpos

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

Comment @coderabbitai help to get the list of available commands.

@lL1l1 lL1l1 marked this pull request as ready for review June 26, 2026 15:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lua/simInit.lua (1)

588-592: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer simple nil check over rawget(_G, ...) unless metatable protection is required.

rawget(_G, "SetNavigatorPersonalPosMaxDistance") is defensive against _G metatable __index, but a simple if SetNavigatorPersonalPosMaxDistance then is more idiomatic in Lua and equally safe for standard global access. If this codebase uses rawget consistently for engine API guards, keep it; otherwise, simplify for readability.

 function SetupPathfinding()
-    if rawget(_G, "SetNavigatorPersonalPosMaxDistance") then
+    if SetNavigatorPersonalPosMaxDistance then
         SetNavigatorPersonalPosMaxDistance(9999)
-    end
 end
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lua/simInit.lua` around lines 588 - 592, In SetupPathfinding, replace the
defensive rawget(_G, "SetNavigatorPersonalPosMaxDistance") guard with a simple
direct nil check on SetNavigatorPersonalPosMaxDistance unless this code
intentionally relies on bypassing _G metatable behavior. Keep the call to
SetNavigatorPersonalPosMaxDistance(9999) unchanged, and use the same style as
the rest of the engine API checks in simInit.lua for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lua/simInit.lua`:
- Around line 588-592: In SetupPathfinding, replace the defensive rawget(_G,
"SetNavigatorPersonalPosMaxDistance") guard with a simple direct nil check on
SetNavigatorPersonalPosMaxDistance unless this code intentionally relies on
bypassing _G metatable behavior. Keep the call to
SetNavigatorPersonalPosMaxDistance(9999) unchanged, and use the same style as
the rest of the engine API checks in simInit.lua for consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f92e60df-c097-4290-8ae3-7e2358dbe8d5

📥 Commits

Reviewing files that changed from the base of the PR and between e28b0ce and 218bd78.

📒 Files selected for processing (3)
  • changelog/snippets/other.7155.md
  • engine/Sim.lua
  • lua/simInit.lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: requires engine patch related to the engine and no effective workaround is known in Lua area: sim Area that is affected by the Simulation of the Game type: intellisense

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant