feat(rust): the live map (phase 14, protocol 11)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 28s
PR Checks / client-build (pull_request) Successful in 27s
PR Checks / frozen-manifest (pull_request) Successful in -1m9s

PLAN.md §30 as approved, plus D119/D120 from the build.

Server:
- rust_map_images (one row per server: picture as MEDIUMBLOB, geometry,
  monuments, DERIVATION_VERSION) and rust_map_overrides; purge.sql pair.
- mapImages.js: D110. The board poll notices a new boot/wipe/seed/size and
  asks map.info; a new key or hash from the free Rust+ cache (or a render
  kept on disk) is fetched in slices, checked against its SHA-256 and stored
  in one statement. One fetch per server, a backoff on failure, `stale`
  abandons a fetch that straddles a map change. Render now (D109) is
  admin-only and watched to completion.
- mapLive.js: D111. One map.live per server per 5 s whoever asks; positions
  are held in memory only.
- model/map: four layers (world, events public; players, bases staff), a
  fleet default plus per-server override (D114), the players layer capped by
  presence (D113), own dot and online first-party clan mates for a linked
  viewer (D115, D117, D118). A layer the viewer may not see is absent from
  the answer, never sent and hidden.
- Routes: public /servers/:id/map, /map/image (immutable under its hash),
  /map/live; admin /servers/:id/map/fetch and /render; the Map card on the
  visibility PUT. Swagger fragment and frozen manifest regenerated.

Client:
- A Map tab: Leaflet over the picture in CRS.Simple, the game's own grid
  (labels only when a cell is wide enough to hold one), a legend that lists
  hidden layers with who can see them, polled every 10 s while visible.
- D120: Leaflet is a lazy split chunk beside entry.js, not in it. release.yml
  copies every dist/*.js; checkExternals and build.test.js hold both ends.
- The Map card on Admin -> Rust visibility, with Fetch again and Render now.

Capability `map` declared for the Android app (phase 15).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-09-25 01:06:10 -05:00
parent ac0bcd850a
commit 0cb9bdd1f0
34 changed files with 4680 additions and 28 deletions

View File

@@ -560,6 +560,51 @@ module.exports = {
},
},
},
map: {
type: 'object',
description: 'The live map’s switches and each server’s picture (phase 14).',
properties: {
layers: { type: 'array', items: { type: 'string' }, example: ['world', 'events', 'players', 'bases'] },
fleet: {
type: 'object',
properties: {
world: { $ref: '#/components/schemas/RustAudience' },
events: { $ref: '#/components/schemas/RustAudience' },
players: { $ref: '#/components/schemas/RustAudience' },
bases: { $ref: '#/components/schemas/RustAudience' },
mates: { type: 'boolean', example: true },
},
},
servers: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string', example: 'main' },
name: { type: 'string', example: 'Main · Vanilla' },
overrides: { type: 'object', description: 'Each layer and `mates`, or null to follow the fleet.' },
effective: { type: 'object' },
picture: {
type: 'object',
nullable: true,
properties: {
source: { type: 'string', enum: ['companion', 'rendered', 'none'] },
mapKey: { type: 'string' },
hasPicture: { type: 'boolean' },
bytes: { type: 'integer' },
worldSize: { type: 'integer' },
fetchedAt: { type: 'string', format: 'date-time', nullable: true },
},
},
renderStallSeconds: { type: 'integer', description: 'About how long Render now would stall this server.', example: 9 },
fetching: { type: 'boolean' },
rendering: { type: 'boolean' },
lastError: { type: 'string', nullable: true },
},
},
},
},
},
news: {
type: 'object',
description: 'Whether a published news post is also said in each server’s in-game chat. Off by default (D104).',
@@ -580,6 +625,167 @@ module.exports = {
},
},
},
RustMapLayer: {
type: 'object',
description: 'Whether this viewer gets one map layer, and which audience does. A hidden layer never says what it holds.',
properties: {
visible: { type: 'boolean', example: false },
audience: { $ref: '#/components/schemas/RustAudience' },
cappedByPresence: {
type: 'boolean',
description: 'Players layer only: narrower than its own switch because who may see who is online is narrower (D113).',
example: true,
},
},
},
RustMap: {
type: 'object',
description: 'One server’s map, as this viewer may see it (GET /public/rust/servers/{id}/map).',
properties: {
serverId: { type: 'string', example: 'main' },
mapKey: { type: 'string', nullable: true, example: '3000.1234.1' },
picture: {
type: 'object',
nullable: true,
description: 'Null when the game has no picture of its map.',
properties: {
path: { type: 'string', description: 'Relative to /api/v1, with the picture’s hash in it.', example: '/public/rust/servers/main/map/image?v=28da6e8a' },
source: { type: 'string', enum: ['companion', 'rendered'], example: 'companion' },
fetchedAt: { type: 'string', format: 'date-time', nullable: true },
},
},
geometry: {
type: 'object',
nullable: true,
description: 'How world coordinates reach a pixel: s = (width − 2 × oceanMargin) / worldSize, px = (x + worldSize/2) × s + oceanMargin, and z the same way up from the bottom edge.',
properties: {
worldSize: { type: 'integer', example: 3000 },
oceanMargin: { type: 'integer', description: 'In pixels, unscaled.', example: 500 },
width: { type: 'integer', example: 2500 },
height: { type: 'integer', example: 2500 },
gridCells: { type: 'integer', description: 'Cells per side, from the game’s own grid.', example: 20 },
gridCellSize: { type: 'number', description: 'Metres.', example: 150 },
background: { type: 'string', nullable: true, example: '#0B3B4A' },
},
},
monuments: {
type: 'array',
description: 'Present only when the viewer may see the world layer.',
items: {
type: 'object',
properties: {
value: { type: 'string', example: 'harbor_1#2' },
kind: { type: 'string', example: 'harbor_1' },
label: { type: 'string', example: 'Harbor' },
grid: { type: 'string', nullable: true, example: 'O3' },
x: { type: 'number', example: 678.1 },
z: { type: 'number', example: 1005.7 },
},
},
},
layers: {
type: 'object',
properties: {
world: { $ref: '#/components/schemas/RustMapLayer' },
events: { $ref: '#/components/schemas/RustMapLayer' },
players: { $ref: '#/components/schemas/RustMapLayer' },
bases: { $ref: '#/components/schemas/RustMapLayer' },
},
},
mates: {
type: 'object',
description: 'Whether this viewer gets their own position and their online clan mates’ (D115).',
properties: {
visible: { type: 'boolean', example: true },
on: { type: 'boolean', description: 'Is the switch on for this server?', example: true },
linked: { type: 'boolean', description: 'Has this viewer linked a Steam account?', example: true },
signedIn: { type: 'boolean', description: 'Is this viewer signed in at all?', example: true },
},
},
pollMs: { type: 'integer', example: 10000 },
},
},
RustMapLive: {
type: 'object',
description: 'What moves on one server’s map, cut down to this viewer (GET /public/rust/servers/{id}/map/live). A layer the viewer may not see is ABSENT, not empty.',
properties: {
live: { type: 'boolean', description: 'False when the game did not answer; `reason` says why.', example: true },
reason: { type: 'string', nullable: true },
mapKey: { type: 'string', nullable: true, example: '3000.1234.1' },
world: {
type: 'array',
items: {
type: 'object',
properties: {
kind: { type: 'string', enum: ['cargo', 'heli', 'chinook', 'bradley', 'supply', 'crate'], example: 'cargo' },
x: { type: 'number', example: 812.4 },
z: { type: 'number', example: -1320.6 },
hackLeftSec: { type: 'integer', description: 'A locked crate being hacked: seconds left.', example: 540 },
hacked: { type: 'boolean', example: false },
},
},
},
events: {
type: 'array',
items: {
type: 'object',
properties: {
kind: { type: 'string', enum: ['zone', 'crate', 'npc'], example: 'zone' },
runId: { type: 'string', example: '41' },
x: { type: 'number' },
z: { type: 'number' },
radius: { type: 'number', description: 'A zone’s.', example: 60 },
name: { type: 'string', description: 'A zone’s.', example: 'Harbor brawl' },
prefab: { type: 'string', description: 'A crate’s or NPC’s allowlist key.', example: 'crate.elite' },
},
},
},
players: {
type: 'array',
items: {
type: 'object',
properties: {
steamId: { type: 'string', example: '76561198000000000' },
name: { type: 'string', example: 'Wanderer' },
x: { type: 'number' },
z: { type: 'number' },
sleeping: { type: 'boolean', example: false },
online: { type: 'boolean', example: true },
},
},
},
playersTruncated: { type: 'boolean', description: 'More sleepers than the plugin’s MapMaxSleepers.' },
bases: {
type: 'array',
description: 'Positions only: no owner, no authorised list, no shop name.',
items: {
type: 'object',
properties: {
kind: { type: 'string', enum: ['tc', 'vending'], example: 'tc' },
x: { type: 'number' },
z: { type: 'number' },
},
},
},
basesTruncated: { type: 'boolean', description: 'More than the plugin’s MapMaxBases.' },
mates: {
type: 'array',
description: 'The viewer’s own positions (their sleeper too) and their online first-party clan mates on this server.',
items: {
type: 'object',
properties: {
steamId: { type: 'string' },
name: { type: 'string' },
x: { type: 'number' },
z: { type: 'number' },
sleeping: { type: 'boolean' },
online: { type: 'boolean' },
self: { type: 'boolean', description: 'One of the viewer’s own accounts.' },
},
},
},
},
},
RustClanAudience: {
type: 'string',
enum: ['members', 'signed_in', 'public'],
@@ -676,6 +882,11 @@ module.exports = {
additionalProperties: { type: 'boolean' },
example: { main: true },
},
map: {
type: 'object',
description: 'The live map’s switches. `fleet` maps a layer to an audience and `mates` to true or false; `servers` maps a server id to the same shape, where null follows the fleet.',
example: { fleet: { players: 'signed_in', mates: true }, servers: { pve: { players: 'public' }, pvp: { players: null } } },
},
},
},
RustSidecarProbe: {