Skip to content

refactor: consolidate play packet routing into a declarative descriptor table - #554

Draft
carabistouflette wants to merge 1 commit into
Steel-Foundation:masterfrom
carabistouflette:pr10-play-descriptor-table
Draft

refactor: consolidate play packet routing into a declarative descriptor table#554
carabistouflette wants to merge 1 commit into
Steel-Foundation:masterfrom
carabistouflette:pr10-play-descriptor-table

Conversation

@carabistouflette

Copy link
Copy Markdown
Contributor

Type of change

  • Block implementation
  • Item implementation
  • Command implementation
  • Entity implementation
  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Performance improvement

Description

Consolidates the five dispatch sites for scheduled serverbound play packets — decode_play_packet, execution(), can_process_before_join, can_process_during_domain_handshake, and handle() — into a single declarative PLAY_PACKET_DESCRIPTORS table of PlayPacketDescriptor entries (id, decode fn, execution class, join gates, handler fn). Previously these lived in five hand-maintained matches that could drift independently (e.g. adding a packet to decode but forgetting its concurrency class).

  • ScheduledPlayPacket carries its resolved descriptor, so execution class, gates, and handler dispatch are single lookups resolved once at decode time.
  • Per-action concurrency (PlayerCommand, PlayerAction) is preserved through per-descriptor execution functions with their original audit comments.
  • Immediate packets (keep alive, ping request, chunk batch received) keep their dedicated decode path; the join-gate id checks fall back to explicit immediate ids so pre-join/during-handshake behavior is unchanged.
  • decode_play_packet shrinks to an immediate-packet match plus one descriptor lookup.

How this was tested

  • All classification, routing, and domain-gate tests preserved and passing: cargo test -p steel-core --lib connection::java (15 tests) and cargo test -p steel-core --lib (2422 tests); cargo clippy -r --all-targets clean.
  • Dispatch cost is one linear scan over 37 ids per decode (vs the previous match) — dominated by payload decode I/O, measured as noise; no behavioral change intended.

Screenshots / logs

N/A.

Checklist

  • Code builds w/o errors or warnings
  • Self-reviewed the diff
  • Docs updated (if applicable) — N/A
  • No leftover debug code / comments

Additional notes

  • Contingency from the plan: if binary size or fn-pointer overhead is flagged, the table can be macro-generated instead.
  • Env: Linux, Rust nightly, Minecraft protocol 776 (0.15.2+mc26.2).

…or table

The five dispatch sites for scheduled serverbound play packets (decode,
execution class, pre-join gate, domain-handshake gate, and handler
invocation) previously lived in separate hand-maintained matches and could
drift independently. They are now consolidated into one
PLAY_PACKET_DESCRIPTORS table of PlayPacketDescriptor entries:

- decode closures produce the ScheduledPlayPacketKind from the payload
- execution closures keep the audited per-kind (and per-action for
  PlayerCommand/PlayerAction) concurrency classes, including their comments
- gate flags replace the hand-maintained before-join and domain-handshake id
  lists; immediate packets (keep alive, ping, chunk batch) keep their
  dedicated decode path
- ScheduledPlayPacket carries its resolved descriptor, so execution, gates,
  and handler dispatch are single lookups

decode_play_packet shrinks to an immediate-packet match plus one descriptor
lookup. Classification and routing tests are preserved through the new
descriptor-based construction.
@carabistouflette
carabistouflette force-pushed the pr10-play-descriptor-table branch from fe6fd50 to 297b85e Compare August 29, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant