Skip to content

A cast could put a character inside a wall - #2320

Merged
erwan-joly merged 2 commits into
NosCoreIO:masterfrom
denislauri1999:pr/us-position-walkable
Aug 28, 2026
Merged

A cast could put a character inside a wall#2320
erwan-joly merged 2 commits into
NosCoreIO:masterfrom
denislauri1999:pr/us-position-walkable

Conversation

@denislauri1999

@denislauri1999 denislauri1999 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

u_s carries a position, and UpdateAttackerPosition wrote it straight into PositionX/PositionY. WalkPacketHandler refuses a destination that is not walkable; this path had no such check, so the same movement was allowed by one road and refused by the other.

The guard is the walk path's own IsWalkable, so the two agree by construction rather than by two copies of a rule.

Tested: NosCore.GameObject.Tests 442/442 and NosCore.PacketHandlers.Tests 410/410, solution builds with zero warnings. Not played - I do not start the servers.

Summary by CodeRabbit

  • Bug Fixes
    • Characters are no longer moved onto non-walkable tiles during battle positioning.
    • Invalid or unavailable destination coordinates now leave the attacker’s position unchanged.

WalkPacketHandler refuses a destination that is not walkable, along with four other checks -
server speed, distance against speed/2, the coordinate checksum and travel time. UpdateAttackerPosition
writes the same two fields from a client-supplied position with no check at all, so anything the
walk path refuses can be had by sending it in a u_s packet instead.

This adds back the one check that needs nothing the packet lacks: IsWalkable, exactly as
WalkPacketHandler calls it. The distance and speed rules are deliberately left out - u_s carries
no speed, and a per-step bound of speed/2 would refuse the teleport skills, which legitimately
move a character further (Skill.dat declares them as BCard type 30 subtype 21, up to 8 fields for
the Mage's Teleport).

A null MapInstance still allows the move, so nothing changes for entities that have no map yet.

TESTED. Builds clean. NOT covered by a unit test: reaching UpdateAttackerPosition needs a real
MapInstance, whose constructor takes eleven dependencies, and the fixture for it would be larger
than the fix. Saying so rather than implying otherwise. The equivalent guard was written and
tested on the other code base this comes from, where the decision is a pure function.

Not played - the servers were not started.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 44aa1cae-4910-4b95-9250-fe8a2b43d97f

📥 Commits

Reviewing files that changed from the base of the PR and between f44a8a9 and c158583.

📒 Files selected for processing (1)
  • src/NosCore.GameObject/Services/BattleService/BattleService.cs
💤 Files with no reviewable changes (1)
  • src/NosCore.GameObject/Services/BattleService/BattleService.cs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

UpdateAttackerPosition now ignores missing coordinates and prevents movement to non-walkable tiles on the current map.

Changes

Battle Position Validation

Layer / File(s) Summary
Validate attacker destination coordinates
src/NosCore.GameObject/Services/BattleService/BattleService.cs
UpdateAttackerPosition returns when MapX or MapY is missing. It updates the position only when the destination tile is walkable.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c1585

The change prevents cast movement from placing a character in a non-walkable position while keeping movement validation consistent; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing a cast from placing a character inside a wall.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

}
}

// WalkPacketHandler refuses a destination that is not walkable; this path wrote the same

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

useless comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in c158583 — the comment is gone, the guard itself is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@erwan-joly
erwan-joly merged commit afb0401 into NosCoreIO:master Aug 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants