v0.1.0NeverDark ModuleBSD-2-Clause

nd-mcp for axil-nd, ported from SIC to libxylem.

GitHub
git clone https://github.com/tty-pt/nd-mcp

Documentation

axil-nd-mcp

nd-mcp for axil-nd, ported from SIC to libxylem.

Implements the Binary Client Protocol (BCP #b) for real-time WebSocket communication between the NeverDark engine and pure-C isomorphic clients (htdocs/nd.wasm and apps/nd-native).

Role & Subsystem

nd-mcp bridges the game engine's internal events (HD_OBJ, HD_OBS, player changes) into compact binary frames transmitted over WebSocket connections (DF_WEBSOCKET).

Wire Protocol (#b)

Packets begin with the magic prefix #b followed by a 1-byte channel identifier (iden):

OpcodeNamePayloadDescription
0BCP_ITEMref, loc, flags, type, actions, name, unparse, icon, artFull item/room/entity serialization
1BCP_VIEWnd_map_data_t (400B)Packed binary 7x7 map grid (biomes, exits, doors, glyphs)
2BCP_VIEW_BUFFERstringANSI/text formatted room buffer (fallback)
3BCP_ROOMexits bitmaskRoom topology
4BCP_ENTITYflagsEntity status and attributes
5BCP_AUTH_FAILUREreason code (int)Login/auth failure
6BCP_AUTH_SUCCESSplayer_ref (uint32)Successful login
7BCP_OUTobj_ref, loc_refEntity left room / despawned
8BCP_TODtod (uint32)Time of day cycle
9BCP_ACTIONid, label, iconDynamic client action button registration
10BCP_REGIONstage_drv, map_drv, layout, flagsHierarchical presentation governance frame

Dynamic feature modules register channels on HD_BCP (e.g. bcp_hp=10, bcp_stats=11, bcp_equipment=12, bcp_mp=13).

XY Hooks & Exports

  • fbcp(player_ref, len, iden, data): Generic BCP frame broadcast.
  • fbcp_view(player_ref, map): Emit 400-byte packed binary map grid (nd_map_data_t) over opcode 1.
  • fbcp_view_buf(player_ref, view_buf): Emit formatted ASCII room buffer over opcode 2.
  • fbcp_item(player_ref, obj_ref, dynflags): Serialize object to player.
  • mcp_bar(iden, player_ref, val, max): Send status gauge update.
  • mcp_action(player_ref, id, label, icon): Register client action button.
  • mcp_content_in(loc_ref, thing_ref) / mcp_content_out: Room observation dispatch.

Install & Build

make
make install

Installs lib/libnd-mcp.so and include/uapi/mcp.h.

Maintained by:tty-pt