Skip to content

docs(protocol): P_ChatMessage detail page (Chr$(250-254) prefix dispatch)#290

Merged
CoreyRDean merged 2 commits into
developfrom
docs/p-chatmessage
May 26, 2026
Merged

docs(protocol): P_ChatMessage detail page (Chr$(250-254) prefix dispatch)#290
CoreyRDean merged 2 commits into
developfrom
docs/p-chatmessage

Conversation

@CoreyRDean
Copy link
Copy Markdown
Collaborator

Summary

Fourth per-packet detail page after P_InventoryUpdate, P_StandardUpdate, and P_AttackActor. Documents the catch-all text channel.

P_ChatMessage is the largest single packet handler in the codebase (~530 lines from ServerNet.bb:183 to :712). The wire payload is free-form text; discrimination happens via:

  • C→S: Left$(M\MessageData$, 1) = / or \ enters the slash-command parser; everything else falls into the general-chat broadcast.
  • S→C: first-byte colour escape (Chr$(250)Chr$(254)) selects render colour; non-escape text falls into the chat-bubble or normal-text path.

What's covered

  • Five colour escapes (250 RGB-custom, 251 green, 252 magenta, 253 red, 254 yellow) with their channel mapping and the single Chr$(250) emitter (BVM_OUTPUT at ScriptingCommands.bb:2785).
  • ~25 slash commands catalogued with their gates (DM-only vs. open), their chain-walk family (FirstOnlinePlayer for /yell//g//gm//pm//allplayers; FirstInZone for /me/general-chat; FirstSlave for /pet; Party\Player[0..7] for /p), and their emit-target shape (self-only vs. area-broadcast vs. server-wide vs. party vs. single-target).
  • Seven validation gates — including the load-bearing Account-Null discipline (A.Account = Object.Account(AI\Account) : If A <> Null And A\IsDM = True) that prevents server crash from a mid-logout DM typing a /command. Audit-comment at ServerNet.bb:200-202 is the canonical exemplar.
  • Privilege classification distinction: slash commands dispatch directly from the packet handler — Account\IsDM is the only gate, BVM_RequirePrivileged is not in play. The /script command at ServerNet.bb:385 is the only chat path that elevates a spawned ThreadScript to privileged=1.
  • Soft-fail discipline: mid-warp AreaInstance Null guard, unknown-command notify, ignore-list filter on every fan-out.

PR history cross-references

  • PR #287/pet walks the per-leader FirstSlave chain (replacing global Each ActorInstance scan).
  • PR #288 and predecessors — /yell//g//gm//pm//allplayers walk the FirstOnlinePlayer chain.
  • PRs #154 / #155 / #176 / #182#188Object.AreaInstance Null discipline sweep covering /me, /players, and general-chat fallback.

Test plan

  • CI green (markdown / link check)
  • Regenerated docs/protocol/index.md — row 16's Detail column now links to the new page (verified)
  • All cross-page links (P_AttackActor.md, P_StandardUpdate.md, encoding.md, handler-conventions.md) resolve to existing files
  • Source citations spot-checked at ServerNet.bb:200-202, :266-273, :385, :691, :705-710, :1213 (ClientNet) — all accurate as of HEAD

🤖 Generated with Claude Code

…tch)

Documents the catch-all text-channel packet. The wire payload is free-form
text -- discrimination happens via Left$ semantics on C->S (slash/backslash
command vs. general chat) and first-byte colour escape on S->C (250 RGB-
custom, 251 green, 252 magenta, 253 red, 254 yellow, anything else plain).

Catalogues ~25 slash commands with their gates (DM-only vs. open), the
chain-walk family per command (FirstOnlinePlayer for /yell//g//gm//pm//
allplayers; FirstInZone for /me/general-chat; FirstSlave for /pet; Party
array for /p), and the seven validation gates the handler relies on --
most importantly the Account-Null discipline that prevents server crash
from a mid-logout DM typing a /command.

Captures the privilege classification distinction: slash commands are
dispatched directly from the packet handler (Account\IsDM is the only
gate; BVM_RequirePrivileged is not in play here), and the /script command
is the *only* path from chat that elevates a spawned ThreadScript to
privileged=1.

Cross-references the FirstOnlinePlayer / FirstSlave / FirstInZone work
(PR #287, predecessors of #288), the Object.AreaInstance Null discipline
sweep (#154/#155/#176/#182-#188), and the BVM_OUTPUT emitter at
ScriptingCommands.bb:2785 -- the sole producer of Chr$(250) custom-RGB
lines.

Regenerated docs/protocol/index.md so row 16's Detail column now links
to the new page.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CoreyRDean CoreyRDean requested a review from a team as a code owner May 26, 2026 17:14
… help

Three doc corrections from the reviewer audit:

1. Chr$(250) is NOT exclusively emitted by BVM_OUTPUT -- the engine also
   uses it for critical-damage notifications at three sites in
   GameServer.bb:432/469/507 (one per CombatFormula variant). Updated the
   colour-escape table row and the "See also" footnote to acknowledge
   the second emitter.

2. /help line citation `ServerNet.bb:40-108` was wrong. The actual
   functions live at `:31-60` (SendChatHelp entry) and `:65-109`
   (SendChatHelpDetail per-topic dispatcher). Both ranges now cited.

3. "every command is localizable" was overstated. /help and /? are
   hardcoded at ServerNet.bb:680 (`Case "HELP", "?"`) pending an
   LS_SCHelp localization entry. Doc now calls out the exception.

Bonus source bug the reviewer flagged: SendChatHelpDetail at
ServerNet.bb:95 described /script as `/script <name>[,<params>]` --
the actual handler at :379-385 splits on comma into Name + Func, so
the second arg is a function name, not params. Corrected the in-game
help string to `/script <name>,<func> -- run script's function as self`.

Compile verified clean across Server/Client/GUE/Project Manager (-t).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3404937cde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


- **Self-only** notifications (errors, confirmations, `/players` results) — sent to `AI\RNID`.
- **Area broadcast** (`/me`, general chat) — walks `AInstance\FirstInZone` chain, sends per actor with `RNID > 0`.
- **Server-wide broadcast** (`/yell`, `/gm`, `/g`) — walks `FirstOnlinePlayer` chain.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Correct broadcast scope for /g and /gm

This bullet says /yell, /gm, and /g are all server-wide broadcasts, but in ServerNet.bb the /gm path filters recipients to DM accounts (A\IsDM = True) and /g filters to matching guild/team IDs (A2\TeamID = AI\TeamID). Describing them as server-wide misstates who receives P_ChatMessage and can mislead anyone building tooling or tests from this protocol doc.

Useful? React with 👍 / 👎.

Comment on lines +69 to +70
| `/warp <area>, <x>, <z>` | DM | Server-side warp. |
| `/warpother <name>, <area>, <x>, <z>` | DM | Warp another player. |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fix /warp and /warpother parameter docs

The command catalog documents coordinate-style syntax (<x>, <z>), but the P_ChatMessage handler actually parses area plus an instance token (Split$(Params$, 2/3, ",")) and then calls SetArea(...) without reading X/Z values in this code path. This mismatch will cause admins/devs to use an unsupported command form and get behavior that ignores the documented coordinates.

Useful? React with 👍 / 👎.

@CoreyRDean CoreyRDean merged commit b63aab0 into develop May 26, 2026
1 check passed
@CoreyRDean CoreyRDean deleted the docs/p-chatmessage branch May 26, 2026 17:19
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.

1 participant