# _mp_client_game_in
_mp_client_game_inTracks the mutable mp client game in value used by the mp platform subsystem.
src/mp_platform.mlImplements UDP multiplayer host/join handshake and runtime packet pump.
doomstat.ml → src/doomstat.mlmp_state.ml → src/mp_state.mlstd/fs.ml as fs → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/fs.ml external dependencystd/math.ml → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/math.ml external dependencystd/net.ml as net → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/net.ml external dependencystd/string.ml as str → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/string.ml external dependencystd/time.ml as time → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/time.ml external dependency_mp_client_game_inTracks the mutable mp client game in value used by the mp platform subsystem.
_mp_client_game_outTracks the mutable mp client game out value used by the mp platform subsystem.
_mp_client_hostStores the mutable mp client host text used by the mp platform subsystem.
_mp_client_host_nameStores the mutable mp client host name text used by the mp platform subsystem.
_mp_client_last_ping_msTracks the mutable mp client last ping ms value used by the mp platform subsystem.
_mp_client_last_ping_tx_msTracks the mutable mp client last ping tx ms value used by the mp platform subsystem.
_mp_client_last_pong_msTracks the mutable mp client last pong ms value used by the mp platform subsystem.
_mp_client_last_seen_msTracks the mutable mp client last seen ms value used by the mp platform subsystem.
_mp_client_peer_idTracks the mutable mp client peer id value used by the mp platform subsystem.
_mp_client_ping_sentTracks the mutable mp client ping sent value used by the mp platform subsystem.
_mp_client_ping_seqTracks the mutable mp client ping seq value used by the mp platform subsystem.
_mp_client_pong_recvTracks the mutable mp client pong recv value used by the mp platform subsystem.
_mp_client_portTracks the mutable mp client port value used by the mp platform subsystem.
_mp_client_rtt_msTracks the mutable mp client rtt ms value used by the mp platform subsystem.
_mp_client_slotTracks the mutable mp client slot value used by the mp platform subsystem.
_mp_client_slot_namesStores the mp client slot names collection used by the mp platform subsystem.
_mp_debug_send_attemptTracks the mutable mp debug send attempt value used by the mp platform subsystem.
_mp_debug_send_errTracks the mutable mp debug send err value used by the mp platform subsystem.
_mp_debug_send_idxfailTracks the mutable mp debug send idxfail value used by the mp platform subsystem.
_mp_debug_send_okTracks the mutable mp debug send ok value used by the mp platform subsystem.
_mp_game_queue_droppedTracks the mutable mp game queue dropped value used by the mp platform subsystem.
_mp_game_queue_headTracks the mutable mp game queue head value used by the mp platform subsystem.
_mp_game_queue_nodesStores the mp game queue nodes collection used by the mp platform subsystem.
_mp_game_queue_payloadsStores the mp game queue payloads collection used by the mp platform subsystem.
_mp_game_queue_tailTracks the mutable mp game queue tail value used by the mp platform subsystem.
_mp_host_frag_limit_cfgTracks the mutable mp host frag limit cfg value used by the mp platform subsystem.
_mp_host_map_cfgStores the mutable mp host map cfg text used by the mp platform subsystem.
_mp_host_max_players_cfgTracks the mutable mp host max players cfg value used by the mp platform subsystem.
_mp_host_mode_cfgTracks the mutable mp host mode cfg value used by the mp platform subsystem.
_mp_host_next_peer_idTracks the mutable mp host next peer id value used by the mp platform subsystem.
_mp_host_peersStores the mp host peers collection used by the mp platform subsystem.
_mp_host_skill_cfgTracks the mutable mp host skill cfg value used by the mp platform subsystem.
_mp_host_time_limit_cfgTracks the mutable mp host time limit cfg value used by the mp platform subsystem.
_mp_peer_t struct
_mp_platform_event_log_pathStores the mutable mp platform event log path text used by the mp platform subsystem.
_mp_platform_last_errorStores the mutable mp platform last error text used by the mp platform subsystem.
_mp_platform_last_statusStores the mutable mp platform last status text used by the mp platform subsystem.
_mp_roleTracks the mutable mp role value used by the mp platform subsystem.
_mp_sockHolds the optional mp sock resource used by the mp platform subsystem.
const _MPPLAT_ACC = "ACC"Defines the mpplat acc text used by the mp platform subsystem.
const _MPPLAT_CLIENT_HOST_TIMEOUT_MS = 10000Defines mpplat client host timeout ms for the mp platform subsystem.
const _MPPLAT_CLIENT_PING_INTERVAL_MS = 1000Defines mpplat client ping interval ms for the mp platform subsystem.
const _MPPLAT_CONTROL_MAX = 512Defines the maximum mpplat control max accepted by the mp platform subsystem.
const _MPPLAT_DEN = "DEN"Defines the mpplat den text used by the mp platform subsystem.
const _MPPLAT_FIONBIO = 2147772030Defines mpplat fionbio for the mp platform subsystem.
const _MPPLAT_GAME_MAGIC0 = 77Defines mpplat game magic0 for the mp platform subsystem.
const _MPPLAT_GAME_MAGIC1 = 68Defines mpplat game magic1 for the mp platform subsystem.
const _MPPLAT_GAME_MAGIC2 = 71Defines mpplat game magic2 for the mp platform subsystem.
const _MPPLAT_GAME_MAGIC3 = 49Defines mpplat game magic3 for the mp platform subsystem.
const _MPPLAT_GAME_PAYLOAD_MAX = 1391Defines the maximum mpplat game payload max accepted by the mp platform subsystem.
const _MPPLAT_GAME_QUEUE_CHUNK = 256Defines mpplat game queue chunk for the mp platform subsystem.
const _MPPLAT_GAME_QUEUE_MAX = 2048Defines the maximum mpplat game queue max accepted by the mp platform subsystem.
const _MPPLAT_HOST_PEER_TIMEOUT_MS = 30000Defines mpplat host peer timeout ms for the mp platform subsystem.
const _MPPLAT_HOST_PING_INTERVAL_MS = 1000Defines mpplat host ping interval ms for the mp platform subsystem.
const _MPPLAT_LEAVE = "LEAVE"Defines the mpplat leave text used by the mp platform subsystem.
const _MPPLAT_MAX_PLAYERS = 4Defines the maximum mpplat max players accepted by the mp platform subsystem.
const _MPPLAT_PING = "PING"Defines the mpplat ping text used by the mp platform subsystem.
const _MPPLAT_PONG = "PONG"Defines the mpplat pong text used by the mp platform subsystem.
const _MPPLAT_PROTO = "MDMP1"Defines the mpplat proto text used by the mp platform subsystem.
const _MPPLAT_PUMP_BUDGET_MS = 4Defines mpplat pump budget ms for the mp platform subsystem.
const _MPPLAT_PUMP_MAX_PACKETS = 192Defines the maximum mpplat pump max packets accepted by the mp platform subsystem.
const _MPPLAT_PUMP_MIN_PACKETS = 48Defines the minimum mpplat pump min packets accepted by the mp platform subsystem.
const _MPPLAT_RECV_MAX = 1400Defines the maximum mpplat recv max accepted by the mp platform subsystem.
const _MPPLAT_REQ = "REQ"Defines the mpplat req text used by the mp platform subsystem.
const _MPPLAT_ROLE_CLIENT = 2Defines mpplat role client for the mp platform subsystem.
const _MPPLAT_ROLE_HOST = 1Defines mpplat role host for the mp platform subsystem.
const _MPPLAT_ROLE_NONE = 0Defines mpplat role none for the mp platform subsystem.
const _MPPLAT_SO_RCVTIMEO = 4102Defines mpplat so rcvtimeo for the mp platform subsystem.
const _MPPLAT_TIMEDOUT = 10060Defines mpplat timedout for the mp platform subsystem.
const _MPPLAT_TIMEOUT_MS = 2500Defines mpplat timeout ms for the mp platform subsystem.
const _MPPLAT_WOULDBLOCK = 10035Defines mpplat wouldblock for the mp platform subsystem.
function _MPPlatform_AllocHostPeerId()Allocates next available host-side peer id for a joining client.
inline function _MPPlatform_AllocHostSlot()Allocates a free player slot [1..MAXPLAYERS-1] for a joining client.
function _MPPlatform_ClientHandlePacket(payload, peerIp, peerPort)Processes runtime client-side maintenance packets after join.
| Parameter | Type | Default | Description |
|---|---|---|---|
payload | dynamic | — | Payload value supplied to `_MPPlatform_ClientHandlePacket`. |
peerIp | dynamic | — | Peer ip value supplied to `_MPPlatform_ClientHandlePacket`. |
peerPort | dynamic | — | Peer port value supplied to `_MPPlatform_ClientHandlePacket`. |
inline function _MPPlatform_CloseSocketOnly()Closes active UDP socket if currently open.
inline function _MPPlatform_EnsurePeerTelemetry(p)Ensures host peer struct has telemetry fields initialized.
| Parameter | Type | Default | Description |
|---|---|---|---|
p | dynamic | — | Object or data record consumed by the operation. |
function _MPPlatform_ExpireHostPeers()Removes host peers that timed out and emits status updates.
inline function _MPPlatform_FindHostPeerBySlot(slot)Returns host peer index for a given slot, or -1 if not found.
| Parameter | Type | Default | Description |
|---|---|---|---|
slot | dynamic | — | Slot value supplied to `_MPPlatform_FindHostPeerBySlot`. |
inline function _MPPlatform_FindHostPeerIndex(ip, port)Finds existing host peer entry by ip/port tuple.
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | dynamic | — | Ip value supplied to `_MPPlatform_FindHostPeerIndex`. |
port | dynamic | — | Port value supplied to `_MPPlatform_FindHostPeerIndex`. |
inline function _MPPlatform_GameChecksum16(payload, n)Computes a lightweight 16-bit checksum across gameplay payload bytes.
| Parameter | Type | Default | Description |
|---|---|---|---|
payload | dynamic | — | Payload value supplied to `_MPPlatform_GameChecksum16`. |
n | dynamic | — | Number of values to process. |
function _MPPlatform_HostHandlePacket(payload, peerIp, peerPort)Processes host-side incoming UDP packet for join/ping flow.
| Parameter | Type | Default | Description |
|---|---|---|---|
payload | dynamic | — | Payload value supplied to `_MPPlatform_HostHandlePacket`. |
peerIp | dynamic | — | Peer ip value supplied to `_MPPlatform_HostHandlePacket`. |
peerPort | dynamic | — | Peer port value supplied to `_MPPlatform_HostHandlePacket`. |
function _MPPlatform_HostSendAccept(ip, port, slot, peerId)Sends an accept packet with server-authoritative lobby settings.
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | dynamic | — | Ip value supplied to `_MPPlatform_HostSendAccept`. |
port | dynamic | — | Port value supplied to `_MPPlatform_HostSendAccept`. |
slot | dynamic | — | Slot value supplied to `_MPPlatform_HostSendAccept`. |
peerId | dynamic | — | Peer id value supplied to `_MPPlatform_HostSendAccept`. |
inline function _MPPlatform_HostSendDeny(ip, port, reasonCode, reasonText, includeHash)Sends a host-side join denial packet with optional server hash context.
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | dynamic | — | Ip value supplied to `_MPPlatform_HostSendDeny`. |
port | dynamic | — | Port value supplied to `_MPPlatform_HostSendDeny`. |
reasonCode | dynamic | — | Reason code value supplied to `_MPPlatform_HostSendDeny`. |
reasonText | dynamic | — | Reason text value supplied to `_MPPlatform_HostSendDeny`. |
includeHash | dynamic | — | Include hash value supplied to `_MPPlatform_HostSendDeny`. |
function _MPPlatform_InitClientSlotNames(localName)Initializes deterministic client-side slot name cache.
| Parameter | Type | Default | Description |
|---|---|---|---|
localName | dynamic | — | Local name value supplied to `_MPPlatform_InitClientSlotNames`. |
inline function _MPPlatform_IsGamePacket(payload)Checks whether payload uses MiniDoom gameplay UDP frame format.
| Parameter | Type | Default | Description |
|---|---|---|---|
payload | dynamic | — | Payload value supplied to `_MPPlatform_IsGamePacket`. |
inline function _MPPlatform_IsPeerIdUsed(pid)Checks whether a host peer id is already occupied.
| Parameter | Type | Default | Description |
|---|---|---|---|
pid | dynamic | — | Pid value supplied to `_MPPlatform_IsPeerIdUsed`. |
inline function _MPPlatform_IsSlotUsed(slot)Checks whether a host player slot index is already used by a peer.
| Parameter | Type | Default | Description |
|---|---|---|---|
slot | dynamic | — | Slot value supplied to `_MPPlatform_IsSlotUsed`. |
inline function _MPPlatform_IsWouldBlockError(v)Checks whether a net error maps to WSAEWOULDBLOCK.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
function _MPPlatform_LogEvent(line)Emits one machine-readable transport event to stdout and the configured process-local log.
| Parameter | Type | Default | Description |
|---|---|---|---|
line | dynamic | — | Map line or text line affected by the operation. |
function _MPPlatform_NormalizeIPv4(value)Validates dotted-decimal IPv4 input and returns the canonical form used by udpRecvFrom endpoints.
| Parameter | Type | Default | Description |
|---|---|---|---|
value | dynamic | — | Value consumed by the operation. |
inline function _MPPlatform_PeerIngame(p)Returns true when peer ingame marker is truthy (bool true or non-zero int).
| Parameter | Type | Default | Description |
|---|---|---|---|
p | dynamic | — | Object or data record consumed by the operation. |
function _MPPlatform_PopGamePacket()Dequeues one gameplay packet as [node,payload], or void when empty.
inline function _MPPlatform_PushConsoleMessage(msg)Sends a short HUD message to the local console player when available.
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | dynamic | — | Msg value supplied to `_MPPlatform_PushConsoleMessage`. |
inline function _MPPlatform_QueueDepth()Returns queued gameplay packet count waiting for d_net consumption.
function _MPPlatform_QueueEnsureCapacity(required)Grows game packet queue storage in chunks so enqueue stays O(1) in steady state.
| Parameter | Type | Default | Description |
|---|---|---|---|
required | dynamic | — | Required value supplied to `_MPPlatform_QueueEnsureCapacity`. |
function _MPPlatform_QueueGamePacket(node, payload)Enqueues gameplay packet payload for d_net/i_net processing.
| Parameter | Type | Default | Description |
|---|---|---|---|
node | dynamic | — | Node value supplied to `_MPPlatform_QueueGamePacket`. |
payload | dynamic | — | Payload value supplied to `_MPPlatform_QueueGamePacket`. |
function _MPPlatform_RemoveHostPeerByIndex(idx, withMessage)Removes host peer entry and emits leave status if requested.
| Parameter | Type | Default | Description |
|---|---|---|---|
idx | dynamic | — | Zero-based element or table index. |
withMessage | dynamic | — | With message value supplied to `_MPPlatform_RemoveHostPeerByIndex`. |
inline function _MPPlatform_SanitizeField(s0)Removes wire-delimiter/control bytes from textual packet fields.
| Parameter | Type | Default | Description |
|---|---|---|---|
s0 | dynamic | — | S0 value supplied to `_MPPlatform_SanitizeField`. |
inline function _MPPlatform_SendFields(sock, ip, port, fields)Encodes and sends a textual UDP packet with field separators.
| Parameter | Type | Default | Description |
|---|---|---|---|
sock | dynamic | — | Sock value supplied to `_MPPlatform_SendFields`. |
ip | dynamic | — | Ip value supplied to `_MPPlatform_SendFields`. |
port | dynamic | — | Port value supplied to `_MPPlatform_SendFields`. |
fields | dynamic | — | Fields value supplied to `_MPPlatform_SendFields`. |
inline function _MPPlatform_SetError(msg)Stores user-facing error text for multiplayer host/join operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | dynamic | — | Msg value supplied to `_MPPlatform_SetError`. |
inline function _MPPlatform_SetNonBlocking(sock, enabled)Configures UDP socket to non-blocking mode.
| Parameter | Type | Default | Description |
|---|---|---|---|
sock | dynamic | — | Sock value supplied to `_MPPlatform_SetNonBlocking`. |
enabled | dynamic | — | Whether the requested feature should be enabled. |
inline function _MPPlatform_SetRecvTimeout(sock, timeoutMs)Configures socket receive timeout in milliseconds.
| Parameter | Type | Default | Description |
|---|---|---|---|
sock | dynamic | — | Sock value supplied to `_MPPlatform_SetRecvTimeout`. |
timeoutMs | dynamic | — | Timeout ms value supplied to `_MPPlatform_SetRecvTimeout`. |
inline function _MPPlatform_SetStatus(msg)Stores latest status string for menu/UI display.
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | dynamic | — | Msg value supplied to `_MPPlatform_SetStatus`. |
inline function _MPPlatform_ToBytesCopy(v)Normalizes bytes/array payload values to bytes (fast-path avoids copy for bytes).
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
inline function _MPPlatform_ToInt(v, fallback)Converts mixed numeric values to stable integer values.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
fallback | dynamic | — | Value returned when the requested conversion or lookup is unavailable. |
function _MPPlatform_UnwrapGamePayload(packet)Decodes gameplay frame and returns payload bytes.
| Parameter | Type | Default | Description |
|---|---|---|---|
packet | dynamic | — | Packet value supplied to `_MPPlatform_UnwrapGamePayload`. |
function _MPPlatform_UpsertHostPeer(ip, port, name)Creates or refreshes a host peer entry and returns its assigned player slot (1..3).
| Parameter | Type | Default | Description |
|---|---|---|---|
ip | dynamic | — | Ip value supplied to `_MPPlatform_UpsertHostPeer`. |
port | dynamic | — | Port value supplied to `_MPPlatform_UpsertHostPeer`. |
name | dynamic | — | Resource or object name to resolve. |
inline function _MPPlatform_WaitPulse()Keeps GUI/audio responsive while host/join control flow waits on network I/O.
function _MPPlatform_WrapGamePayload(localSlot, payload)Encodes gameplay payload in MiniDoom gameplay UDP frame format.
| Parameter | Type | Default | Description |
|---|---|---|---|
localSlot | dynamic | — | Local slot value supplied to `_MPPlatform_WrapGamePayload`. |
payload | dynamic | — | Payload value supplied to `_MPPlatform_WrapGamePayload`. |
extern function ioctlsocket(s as ptr, cmd as i32, argp as bytes) from "ws2_32.dll" returns intToggles socket mode (blocking/non-blocking) for UDP polling.
| Parameter | Type | Default | Description |
|---|---|---|---|
s | ptr | — | `ptr` value supplied as s to `ioctlsocket`. |
cmd | i32 | — | `i32` value supplied as cmd to `ioctlsocket`. |
argp | bytes | — | `bytes` value supplied as argp to `ioctlsocket`. |
Returns: Result returned by the native `ioctlsocket` binding as `int`.
function MP_PlatformGetActiveSlots()Returns array of currently active player slots (always includes host slot 0).
function MP_PlatformGetDebugOverlayText()Returns multiplayer debug text for in-game overlay rendering.
function MP_PlatformGetLastError()Returns the last multiplayer platform error message.
function MP_PlatformGetLastStatus()Returns latest multiplayer runtime status string.
inline function MP_PlatformGetLocalPlayerSlot()Returns local player slot index used by Doom net layer.
function MP_PlatformGetNodeCount()Returns active doom net node count for local multiplayer role.
function MP_PlatformGetNumPlayers()Returns known active player count for local multiplayer role.
function MP_PlatformGetPlayerNameBySlot(slot)Resolves player display name for a given Doom slot index.
| Parameter | Type | Default | Description |
|---|---|---|---|
slot | dynamic | — | Slot value supplied to `MP_PlatformGetPlayerNameBySlot`. |
function MP_PlatformGetSessionMap()Returns server-confirmed map token for active session.
function MP_PlatformGetSessionMode()Returns server-confirmed multiplayer mode for active session.
function MP_PlatformGetSessionSkill()Returns server-confirmed multiplayer skill for active session.
function MP_PlatformHostGame(port, mode, skill, mapname, maxPlayers, fragLimit, timeLimit)Starts a non-blocking UDP host endpoint for join handshakes.
| Parameter | Type | Default | Description |
|---|---|---|---|
port | dynamic | — | Port value supplied to `MP_PlatformHostGame`. |
mode | dynamic | — | Mode value supplied to `MP_PlatformHostGame`. |
skill | dynamic | — | Skill value supplied to `MP_PlatformHostGame`. |
mapname | dynamic | — | Mapname value supplied to `MP_PlatformHostGame`. |
maxPlayers | dynamic | — | Max players value supplied to `MP_PlatformHostGame`. |
fragLimit | dynamic | — | Frag limit value supplied to `MP_PlatformHostGame`. |
timeLimit | dynamic | — | Time limit value supplied to `MP_PlatformHostGame`. |
inline function MP_PlatformIsClientConnected()Returns true when local runtime has an active client connection.
inline function MP_PlatformIsHosting()Reports whether local runtime is currently acting as UDP host.
function MP_PlatformJoinGame(host, port, playerName)Sends UDP join request and waits with timeout for host response.
| Parameter | Type | Default | Description |
|---|---|---|---|
host | dynamic | — | Host value supplied to `MP_PlatformJoinGame`. |
port | dynamic | — | Port value supplied to `MP_PlatformJoinGame`. |
playerName | dynamic | — | Player name value supplied to `MP_PlatformJoinGame`. |
inline function MP_PlatformNetRecv()Pops one queued gameplay packet as [node,payload], or void if none.
function MP_PlatformNetSend(node, payload)Sends a gameplay packet payload to a Doom remote node.
| Parameter | Type | Default | Description |
|---|---|---|---|
node | dynamic | — | Node value supplied to `MP_PlatformNetSend`. |
payload | dynamic | — | Payload value supplied to `MP_PlatformNetSend`. |
function MP_PlatformPump()Processes non-blocking UDP packets for host/client maintenance.
function MP_PlatformSetEventLogPath(path)Selects an optional per-process diagnostics file used by CLI loopback tests and support logs.
| Parameter | Type | Default | Description |
|---|---|---|---|
path | dynamic | — | Filesystem path to process. |
function MP_PlatformSetPlayerNameBySlot(slot, name)Updates one checked slot name in the host peer table or client-side authoritative cache.
| Parameter | Type | Default | Description |
|---|---|---|---|
slot | dynamic | — | Slot value supplied to `MP_PlatformSetPlayerNameBySlot`. |
name | dynamic | — | Resource or object name to resolve. |
function MP_PlatformShutdown()Shuts down multiplayer UDP runtime state and closes sockets.
extern function setsockopt(s as ptr, level as int, optname as int, optval as bytes, optlen as int) from "ws2_32.dll" symbol "setsockopt" returns intConfigures the receive timeout on the owned WinSock UDP handle.
| Parameter | Type | Default | Description |
|---|---|---|---|
s | ptr | — | `ptr` value supplied as s to `setsockopt`. |
level | int | — | `int` value supplied as level to `setsockopt`. |
optname | int | — | `int` value supplied as optname to `setsockopt`. |
optval | bytes | — | `bytes` value supplied as optval to `setsockopt`. |
optlen | int | — | `int` value supplied as optlen to `setsockopt`. |
Returns: Result returned by the native `setsockopt` binding as `int`.