Skip to content

A spaced mate name reached the client as two fields - #2336

Merged
erwan-joly merged 1 commit into
NosCoreIO:masterfrom
denislauri1999:pr/spaced-name-escaping
Aug 30, 2026
Merged

A spaced mate name reached the client as two fields#2336
erwan-joly merged 1 commit into
NosCoreIO:masterfrom
denislauri1999:pr/spaced-name-escaping

Conversation

@denislauri1999

@denislauri1999 denislauri1999 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #2281, which merged before this landed.

The defect

A mate whose name contains a space reaches the client as two fields. Serialized on master, a mate named Joyeux Mouton:

in    2 333 2000001 0 0 0 0 0 0 0 3 42 1 0 -1 Joyeux Mouton 0 -1 0 0 ...
sc_p  0 333 2000001 0 0 0 ... 1 15 0 Joyeux Mouton 0
sc_n  0 333 2000001 0 0 0 ... 1 15 Joyeux Mouton -1 0 -1 -1 -1 -1

Every field after the name is shifted by one. It is reachable without renaming anything: the fallback when a mate was never renamed is the creature's own name, and plenty of those carry a space.

Why the serializer does not cover it

Serializer.StringSerializer holds a Replace(splitter, "^"), but the splitter it is handed is index.SpecialSeparator, which is null for an ordinary property. IsNullOrEmpty(splitter) is then true and the value is returned untouched; the space between fields is added afterwards, by PacketSerializer, and never enters the substitution. So a plain space-separated field keeps its own spaces, and none of the three properties the mate name goes into declares a special separator.

Worth a separate look, not changed here: if that Replace is meant to guard the field separator rather than a special one, fixing it in NosCore.Packets would let this line and every other manual substitution in the tree go away.

What changed

MateExtensions.DisplayName puts the substitution back, in one place, so all three generators get it.

What was tested

  • ASpacedMateNameReachesTheClientAsOneFieldAsync builds a real Serializer over the packet assembly and asserts on the serialized line for in, sc_p and sc_n. The existing tests asserted on the packet object, which is why the shift went unnoticed.
  • Red first: with the substitution removed the new test fails on all three lines with the output quoted above; with it back, all three carry Joyeux^Mouton.
  • TheCreatureNameIsUsedWhenTheMateWasNeverRenamedAsync now expects the escaped form.
  • dotnet build NosCore.sln at 0 warnings, dotnet test green with the CI filter (533 in NosCore.GameObject.Tests).
  • Not played. We do not run a NosCore server, so no client has been in front of this. The claim rests on the serialized lines above, not on a screen.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed mate names containing spaces so they are transmitted and displayed as a single field.
    • Updated localized and custom creature names to use the correct serialized format.
  • Tests

    • Added coverage verifying that spaced mate names reach the client correctly.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 28 minutes.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a5a2cbd9-4338-4aa8-b00c-33bdd1ed1ac7

📥 Commits

Reviewing files that changed from the base of the PR and between f0e156d and 2082055.

📒 Files selected for processing (2)
  • Directory.Packages.props
  • test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs

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: 8714436c-caec-424c-907a-752d069769a3

📥 Commits

Reviewing files that changed from the base of the PR and between b11805a and f0e156d.

📒 Files selected for processing (2)
  • src/NosCore.GameObject/Ecs/Extensions/MateExtensions.cs
  • test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs

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


Walkthrough

Mate display names now replace spaces with ^ before serialization. Tests verify the encoded name for spawn, pet, and partner packets and update the default creature-name expectation.

Changes

Mate Name Serialization

Layer / File(s) Summary
Display-name encoding and packet coverage
src/NosCore.GameObject/Ecs/Extensions/MateExtensions.cs, test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs
DisplayName encodes spaces as ^ for custom and localized creature names. Tests verify Joyeux^Mouton across spawn, pet, and partner packets.

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

Merge Risk: ⚪ Minimal · up to f0e15

This change keeps mate names containing spaces within a single client packet field across the affected packets. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 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: fixing spaced mate names that previously reached the client as two fields.
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 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.

return mate.NpcMonster.Name.TryGetValue(language, out var localized)
? localized
: mate.NpcMonster.Name[RegionType.EN];
return name.Replace(' ', '^');

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.

that should be handled by the serializer already

A mate named "Joyeux Mouton" split its own field and shifted every field after
it on in, sc_p and sc_n. It needed no renaming to reach: the fallback when a
mate was never renamed is the creature's own name, and plenty carry a space.

The serializer owns the substitution as of 21.1.1, so DisplayName returns the
name as it is and the packets carry it unchanged. The test that pinned the
caret on the packet object now pins it on the wire, where it belongs, across
all three packets.
@erwan-joly
erwan-joly force-pushed the pr/spaced-name-escaping branch from f0e156d to 2082055 Compare August 30, 2026 02:08
@erwan-joly
erwan-joly merged commit f7581f3 into NosCoreIO:master Aug 30, 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