Skip to content

Fix integration test error#89

Open
Lokilife wants to merge 3 commits intospace-exodus:mainfrom
Lokilife:fix-integration-error
Open

Fix integration test error#89
Lokilife wants to merge 3 commits intospace-exodus:mainfrom
Lokilife:fix-integration-error

Conversation

@Lokilife
Copy link

@Lokilife Lokilife commented Feb 9, 2026

About the PR

Why / Balance

How to test

Media

Requirements

  • I have read and am following the Pull Request and Changelog Guidelines.
  • I have added media to this PR or it does not require an ingame showcase.
  • I can confirm this PR contains no AI-generated content, and did not use any AI-generated content.

Breaking changes

Changelog

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of tailed entity removal by ensuring all physics joints are properly disconnected before deletion, preventing potential gameplay anomalies.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

Switches tail-segment handling to use the entity's parent context and adds guards and explicit joint removal: OnComponentShutdown removes joints and clears segments before deletion, InitializeTailSegments and segment spawning use ParentUid, and segment velocity/rotation updates skip segments without a valid parent.

Changes

Cohort / File(s) Summary
Tailed entity lifecycle & joint cleanup
Content.Shared/_Exodus/Tailed/TailedEntitySystem.cs
Remove physics joints between head and tail segments in OnComponentShutdown before queuing deletions; clear TailSegments. Use the head's ParentUid (not MapUid) in InitializeTailSegments and when spawning segments; adjust control flow to return early if parent is invalid.
Segment transform guards in mover
Content.Shared/Movement/Systems/SharedMoverController.Tailed.cs
Add checks using segment transforms to skip segments whose Transform.ParentUid is invalid in ApplySegmentVelocities and UpdateSegmentRotation; add Robust.Shared.Map import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Fix tailed entity test error #88 — Related changes to tail initialization and joint handling; this PR adds physics-component guards during joint creation which overlaps with parent/context and joint logic here.

Suggested labels

size/XS

Poem

🐰 I nudge the joints and hop away,
I tidy tails before they stray,
Parented paths and graceful ends,
Segments cleared as order mends,
A rabbit's cheer for cleaner code today! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Fix integration test error' is vague and does not clearly summarize the main changes, which involve modifications to tail entity joint handling and parent validation in movement systems. Replace with a more specific title that describes the actual changes, such as 'Refactor tail entity system to use parent UID and add parent validation' or 'Fix tail segment joint removal and add parent validation checks'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@github-actions github-actions bot added the size/S label Feb 9, 2026
Copy link

@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

🤖 Fix all issues with AI agents
In `@Content.Shared/_Exodus/Tailed/TailedEntitySystem.cs`:
- Around line 54-60: The removal loop in the tail shutdown uses prev
unconditionally, which can produce mismatched joint IDs when some segments lack
a PhysicsComponent; update the loop in the removal path (the foreach over
component.TailSegments that calls _joint.RemoveJoint) to mirror
InitializeTailSegments by first checking for a PhysicsComponent on the current
segment, only calling _joint.RemoveJoint and updating prev when that
PhysicsComponent exists, ensuring joint IDs match creation and dangling joints
are not left behind.

@Lokilife
Copy link
Author

Lokilife commented Feb 9, 2026

Кролик полезный

@Lokilife Lokilife force-pushed the fix-integration-error branch from 64f8cbe to 8cdf89f Compare February 9, 2026 16:04
Copy link

@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 (1)
Content.Shared/_Exodus/Tailed/TailedEntitySystem.cs (1)

81-91: ⚠️ Potential issue | 🟠 Major

Convert world position to parent-local coordinates before spawning segments.

spawnPos is derived from world-space operations (GetWorldPosition and GetWorldRotation), but EntityCoordinates(parentUid, spawnPos) interprets it as a local offset relative to parentUid. This works only when parentUid is the map entity. If the tailed entity is parented to a grid or container, segments spawn at incorrect locations.

Convert to local coordinates using GetInvWorldMatrix before creating EntityCoordinates:

Proposed fix
-            var segment = PredictedSpawnAtPosition(comp.Prototype, new EntityCoordinates(parentUid, spawnPos));
+            var localPos = _transform.GetInvWorldMatrix(parentUid).Transform(spawnPos);
+            var segment = PredictedSpawnAtPosition(comp.Prototype, new EntityCoordinates(parentUid, localPos));
🤖 Fix all issues with AI agents
In `@Content.Shared/Movement/Systems/SharedMoverController.Tailed.cs`:
- Around line 136-139: The GetWorldPosition call on the segment is happening
before the parent validity check, which could produce incorrect results if the
parent is invalid. Move the guard that checks if
segmentXform.ParentUid.IsValid() to occur before calling
_transform.GetWorldPosition(segment), so invalid parent segments are skipped
before attempting the position lookup. Follow the same pattern used in the
ApplySegmentVelocities method where the parent validity check happens first,
then the transform operations proceed only for valid parents.

Comment on lines 136 to +139
var segmentPos = _transform.GetWorldPosition(segment);
var segmentXform = Transform(segment);
if (!segmentXform.ParentUid.IsValid())
continue;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

GetWorldPosition is called before the parent validity check.

_transform.GetWorldPosition(segment) on line 136 runs before the ParentUid.IsValid() guard on line 138. If the segment has no valid parent, this call may produce a garbage position or throw. Move the guard above the position lookup, consistent with how ApplySegmentVelocities handles it (lines 64–68).

Proposed fix
         var segment = tail.TailSegments[i];
+        var segmentXform = Transform(segment);
+        if (!segmentXform.ParentUid.IsValid())
+            continue;
+
         var segmentPos = _transform.GetWorldPosition(segment);
-        var segmentXform = Transform(segment);
-        if (!segmentXform.ParentUid.IsValid())
-            continue;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var segmentPos = _transform.GetWorldPosition(segment);
var segmentXform = Transform(segment);
if (!segmentXform.ParentUid.IsValid())
continue;
var segmentXform = Transform(segment);
if (!segmentXform.ParentUid.IsValid())
continue;
var segmentPos = _transform.GetWorldPosition(segment);
🤖 Prompt for AI Agents
In `@Content.Shared/Movement/Systems/SharedMoverController.Tailed.cs` around lines
136 - 139, The GetWorldPosition call on the segment is happening before the
parent validity check, which could produce incorrect results if the parent is
invalid. Move the guard that checks if segmentXform.ParentUid.IsValid() to occur
before calling _transform.GetWorldPosition(segment), so invalid parent segments
are skipped before attempting the position lookup. Follow the same pattern used
in the ApplySegmentVelocities method where the parent validity check happens
first, then the transform operations proceed only for valid parents.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments