feat(rust): Dynamic PVP's zones on the feed and the map (PLAN_REDESIGNS §14.3.3)
All checks were successful
PR Checks / client-build (pull_request) Successful in 25s
PR Checks / server-tests (pull_request) Successful in 31s
PR Checks / frozen-manifest (pull_request) Successful in 44s

Stage 4 of the §14.3 integration plan, on protocol 14 (docs
rust-link/PROTOCOL.md §20.7).

- pvp.zone.created is a public kind, pvp.zone.deleted a staff kind. Each row
  is read per viewer by the new dynamicPvp.js: grid for everyone, the event's
  name only for Dynamic PVP's own vanilla events, position and zone id for
  staff only.
- The feed's world filter carries the opening: "A PvP zone opened around the
  downed patrol helicopter · G7 · for 10 min". It names nobody.
- The map gains a fifth layer, `pvp` (PvP zones), public by default with its
  own audience in Admin → Rust visibility, drawn as a red ring with its
  event's name.
- Server settings' plugin line names Dynamic PVP; the swagger schemas and
  route descriptions carry the layer and the integration (fragment
  regenerated); ci/bundle.json ships dynamicPvp.js; README lists it.

Tests: server 611/611 (dynamicPvp.test.js new, catalogue and map extended)
and every check; client 89/89 (feed and map tooltip), build and externals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-10-15 06:12:06 -05:00
parent b5f7fa0f13
commit 549b3a5ffd
20 changed files with 569 additions and 30 deletions

View File

@@ -21,7 +21,7 @@ import Empty from './Empty.jsx'
import usePolled from '../hooks/usePolled.js'
import { ago } from '../lib/format.js'
import { boundsOf, countdown, fromLatLng, grid, gridLabel, toLatLng } from '../lib/mapGeometry.js'
import { eventTip, isBoss, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
import { eventTip, isBoss, pvpTip, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
import api, { BASE } from '../api.js'
const STYLE_ID = 'rust-leaflet-css'
@@ -35,6 +35,7 @@ const LAYERS = [
{ id: 'events', label: 'Site events' },
{ id: 'players', label: 'Players' },
{ id: 'bases', label: 'Bases' },
{ id: 'pvp', label: 'PvP zones' },
]
const COLOURS = {
@@ -53,6 +54,7 @@ const COLOURS = {
vending: '#26a69a',
self: '#00e5ff',
mate: '#7cffb2',
pvp: '#ff1744',
}
const WORLD_NAMES = {
@@ -79,7 +81,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const [leaflet, setLeaflet] = useState(null)
const [leafletError, setLeafletError] = useState(null)
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, mates: true })
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, pvp: true, mates: true })
useEffect(() => {
let alive = true
@@ -160,7 +162,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
map.fitBounds(bounds)
const made = {}
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'pvp', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
// The labels are a layer of their own inside the grid's, shown only when a cell
// is wide enough on screen to hold one: at the fitted zoom a 20-cell map's
// labels overlap into a wall of text (found on the phase 14 walk).
@@ -238,7 +240,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const { L } = leaflet
const answer = live.data || {}
const at = (p) => toLatLng(geometry, p.x, p.z)
for (const id of ['world', 'events', 'players', 'bases', 'mates']) made[id].clearLayers()
for (const id of ['world', 'events', 'players', 'bases', 'pvp', 'mates']) made[id].clearLayers()
for (const w of answer.world || []) {
let tip = WORLD_NAMES[w.kind] || w.kind
@@ -274,6 +276,13 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
dot(L, at(b), COLOURS[b.kind] || COLOURS.tc, 4).bindTooltip(b.kind === 'tc' ? 'Tool cupboard' : 'Vending machine').addTo(made.bases)
}
// Dynamic PVP's own zones (§14.3.3): a red ring with its event's name.
for (const z of answer.pvp || []) {
L.circle(at(z), { radius: px(Number(z.radius) || 0), color: COLOURS.pvp, weight: 2, fillOpacity: 0.1 })
.bindTooltip(escape(pvpTip(z)))
.addTo(made.pvp)
}
for (const m of answer.mates || []) {
dot(L, at(m), m.self ? COLOURS.self : COLOURS.mate, m.self ? 8 : 6, 2)
.bindTooltip(escape(m.self ? `You${m.online ? '' : ' (asleep, offline)'}` : m.name || 'Clan mate'))
@@ -299,7 +308,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const map = mapRef.current
const made = groups.current
if (!map || !made) return
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, mates: shown.mates }
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, pvp: shown.pvp, mates: shown.mates }
for (const [id, on] of Object.entries(want)) {
if (on && !map.hasLayer(made[id])) made[id].addTo(map)
if (!on && map.hasLayer(made[id])) map.removeLayer(made[id])
@@ -381,6 +390,7 @@ function Legend({ meta, live, shown, onToggle }) {
events: [COLOURS.event],
players: [COLOURS.online, COLOURS.sleeping],
bases: [COLOURS.tc, COLOURS.vending],
pvp: [COLOURS.pvp],
}
return (

View File

@@ -47,6 +47,9 @@ export const FEED_KINDS = Object.freeze([
// Rust's own world events (protocol 14, PLAN_REDESIGNS §14.3.1): the server
// reads each one for the viewer, so a name is here only where it may be.
'world.event',
// Dynamic PVP's zones opening (§14.3.3). A closing (`pvp.zone.deleted`) is
// staff's and is not asked for here; the map shows a zone go.
'pvp.zone.created',
])
/** The filters the feed offers, and the kinds each one asks the API for. */
@@ -61,7 +64,7 @@ export const FILTERS = Object.freeze([
},
{ id: 'server', label: 'Server', kinds: ['server.wipe', 'server.initialized', 'server.shutdown'] },
{ id: 'bosses', label: 'Bosses', kinds: ['npc.boss.spawned', 'npc.boss.died'] },
{ id: 'world', label: 'World events', kinds: ['world.event'] },
{ id: 'world', label: 'World events', kinds: ['world.event', 'pvp.zone.created'] },
])
export function kindsFor(filterId) {
@@ -151,6 +154,10 @@ export function describe(row) {
case 'world.event':
return worldLine(frame)
case 'pvp.zone.created':
case 'pvp.zone.deleted':
return pvpLine(row.kind, frame)
default:
return { tone: 'other', actor: name, verb: String((row && row.kind) || 'unknown'), subject: null, detail: '' }
}
@@ -303,4 +310,40 @@ function worldLine(frame) {
}
}
/**
* What a Dynamic PVP zone is around, by its event (Dynamic PVP 5.2.0's own
* names). The server sends `event` to the public only for these; a monument's or
* an operator's own event reaches staff as written.
*/
export const PVP_AROUND = Object.freeze({
Helicopter: 'the downed patrol helicopter',
Bradley: 'the destroyed Bradley',
Satellite: 'the crashed satellite',
TimedSupply: 'an airdrop',
SupplySignal: 'a signalled airdrop',
CargoShip: 'the cargo ship',
HackableCrate: 'a locked crate',
ExcavatorIgnition: 'the Giant Excavator',
GhostShip: 'a ghost ship',
DeepSeaIsland: 'a Deep Sea island',
IslandCannon: 'an island cannon',
})
/** How long a zone was given, as a detail: "for 10 min", or cargo's whole visit. */
function pvpLasts(frame) {
const sec = Number(frame.durationSec)
if (!(sec > 0)) return frame.event === 'CargoShip' ? 'while the ship is here' : ''
return sec < 120 ? `for ${Math.round(sec)} s` : `for ${Math.round(sec / 60)} min`
}
/** Dynamic PVP's zones (protocol 14, PLAN_REDESIGNS §14.3.3). The line names nobody. */
function pvpLine(kind, frame) {
const around = PVP_AROUND[frame.event] ? ` around ${PVP_AROUND[frame.event]}` : frame.event ? ` (${frame.event})` : ''
if (kind === 'pvp.zone.deleted') {
return { tone: 'server', actor: null, verb: `The PvP zone${around} has closed`, subject: null, detail: '' }
}
const detail = [frame.grid || null, pvpLasts(frame) || null].filter(Boolean).join(' · ')
return { tone: 'kill', actor: null, verb: `A PvP zone opened${around}`, subject: null, detail }
}
export default { describe, FEED_KINDS, FILTERS, kindsFor }

View File

@@ -42,3 +42,26 @@ export function eventTip(row, titles) {
export function isBoss(row) {
return Boolean(row && (row.boss || row.kind === 'boss'))
}
// ── Dynamic PVP's zones (protocol 14, PLAN_REDESIGNS §14.3.3) ──────────────
/** Dynamic PVP's own events as the map names them; a monument's or an operator's is shown as written. */
export const PVP_NAMES = Object.freeze({
Helicopter: 'Patrol helicopter',
Bradley: 'Bradley APC',
Satellite: 'Satellite crash',
TimedSupply: 'Airdrop',
SupplySignal: 'Signalled airdrop',
CargoShip: 'Cargo ship',
HackableCrate: 'Locked crate',
ExcavatorIgnition: 'Giant Excavator',
GhostShip: 'Ghost ship',
DeepSeaIsland: 'Deep Sea island',
IslandCannon: 'Island cannon',
})
/** A Dynamic PVP ring's tooltip: "PvP zone · Patrol helicopter". */
export function pvpTip(z) {
const name = PVP_NAMES[z.event] || z.event
return name ? `PvP zone · ${name}` : 'PvP zone'
}

View File

@@ -262,7 +262,14 @@ export function integrationsLine(r) {
const line = `${one('BetterChat', r.integrations.betterChat, 'titles and group styles wait for it')}. ${one('PopupNotifications', r.integrations.popupNotifications, 'a popup is refused, and chat still works')}.`
const withEconomics = r.integrations.economics ? `${line} ${economicsLine(r.integrations.economics)}` : line
const withBackpacks = r.integrations.backpacks ? `${withEconomics} ${backpacksLine(r.integrations.backpacks)}` : withEconomics
return r.integrations.truePve ? `${withBackpacks} ${truePveLine(r.integrations.truePve)}` : withBackpacks
const withTruePve = r.integrations.truePve ? `${withBackpacks} ${truePveLine(r.integrations.truePve)}` : withBackpacks
return r.integrations.dynamicPvp ? `${withTruePve} ${dynamicPvpLine(r.integrations.dynamicPvp)}` : withTruePve
}
/** Dynamic PVP (PLAN_REDESIGNS §14.3.3), from protocol 14: its zones on the feed and the map. */
export function dynamicPvpLine(d) {
if (!d.loaded) return 'Dynamic PVP is not loaded — no PvP zones of its own on the feed or the map.'
return `${`Dynamic PVP ${d.version || ''}`.trim()} is loaded — its PvP zones show on the feed and the map.`
}
/** TruePVE (PLAN_REDESIGNS §14.3.2), from protocol 14: what a zone step may do with PvP. */

View File

@@ -384,6 +384,7 @@ const MAP_LAYERS = [
{ id: 'events', label: 'Site events', hint: 'The zones, crates and NPCs this site’s events placed, while they run.' },
{ id: 'players', label: 'Players', hint: 'Where everybody is, with names, and the sleepers.' },
{ id: 'bases', label: 'Bases', hint: 'Tool cupboards and vending machines, as positions only.' },
{ id: 'pvp', label: 'PvP zones', hint: 'Dynamic PVP’s own PvP zones around a downed helicopter, a Bradley, cargo and the rest. Needs Dynamic PVP on the server.' },
]
const RANK = { public: 0, signed_in: 1, staff: 2 }

View File

@@ -203,7 +203,43 @@ test('every type the server knows has its own words, and an unknown one says its
assert.equal(describe(world({ event: 'meteor.landed' })).verb, 'meteor.landed')
})
test('the world filter asks for world events, which the server serves publicly', () => {
assert.deepEqual(kindsFor('world'), ['world.event'])
assert.ok(FEED_KINDS.includes('world.event'))
test('the world filter asks for world events and Dynamic PVP zones opening, which the server serves publicly', () => {
assert.deepEqual(kindsFor('world'), ['world.event', 'pvp.zone.created'])
assert.ok(FEED_KINDS.includes('pvp.zone.created'))
assert.ok(!FEED_KINDS.includes('pvp.zone.deleted'), 'a zone closing is a staff line')
})
// ── Dynamic PVP's zones (protocol 14, PLAN_REDESIGNS §14.3.3) ─────────────
const pvp = (kind, frame) => row(kind, { kind, ...frame })
test('a zone opening says what it is around, where, and for how long, and names nobody', () => {
const heli = describe(pvp('pvp.zone.created', { event: 'Helicopter', grid: 'G7', durationSec: 600 }))
assert.equal(heli.verb, 'A PvP zone opened around the downed patrol helicopter')
assert.equal(heli.detail, 'G7 · for 10 min')
assert.equal(heli.actor, null)
assert.equal(heli.subject, null)
const cargo = describe(pvp('pvp.zone.created', { event: 'CargoShip', grid: 'Q9', durationSec: -1 }))
assert.equal(cargo.verb, 'A PvP zone opened around the cargo ship')
assert.equal(cargo.detail, 'Q9 · while the ship is here')
assert.equal(describe(pvp('pvp.zone.created', { event: 'Bradley', durationSec: 90 })).detail, 'for 90 s')
})
test('a zone the public are not told the event of is just a zone; staff read a monument’s name as written', () => {
assert.equal(describe(pvp('pvp.zone.created', { grid: 'C3' })).verb, 'A PvP zone opened')
assert.equal(describe(pvp('pvp.zone.created', { event: 'Airfield' })).verb, 'A PvP zone opened (Airfield)')
})
test('a zone closing, for a staff reader, says which one closed', () => {
assert.equal(describe(pvp('pvp.zone.deleted', { event: 'Helicopter' })).verb, 'The PvP zone around the downed patrol helicopter has closed')
assert.equal(describe(pvp('pvp.zone.deleted', {})).verb, 'The PvP zone has closed')
})
test('every one of Dynamic PVP’s own events has words, and the server and client agree on which they are', () => {
const { GENERAL_EVENTS } = createRequire(import.meta.url)('../../server/dynamicPvp.js')
for (const event of GENERAL_EVENTS) {
assert.ok(!describe(pvp('pvp.zone.created', { event })).verb.includes(`(${event})`), `${event} has no words of its own`)
}
})

View File

@@ -6,7 +6,9 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { eventTip, isBoss, titlesFrom, unknownRuns } from '../src/lib/mapEvents.js'
import { createRequire } from 'node:module'
import { eventTip, isBoss, pvpTip, PVP_NAMES, titlesFrom, unknownRuns } from '../src/lib/mapEvents.js'
const CALENDAR = {
entries: [
@@ -47,3 +49,13 @@ test('a boss is an event boss or a world one', () => {
test('the run ids still to look up', () => {
assert.deepEqual(unknownRuns([{ runId: '41' }, { runId: '7' }, { runId: '7' }, {}], { 41: 'x' }), ['7'])
})
// Dynamic PVP's rings (PLAN_REDESIGNS §14.3.3): its own events by a plain name,
// a monument's or an operator's as written, and nothing at all as just a zone.
test('a Dynamic PVP ring says what it is around', () => {
assert.equal(pvpTip({ event: 'Helicopter' }), 'PvP zone · Patrol helicopter')
assert.equal(pvpTip({ event: 'Airfield' }), 'PvP zone · Airfield')
assert.equal(pvpTip({}), 'PvP zone')
const { GENERAL_EVENTS } = createRequire(import.meta.url)('../../server/dynamicPvp.js')
assert.deepEqual(Object.keys(PVP_NAMES).sort(), [...GENERAL_EVENTS].sort())
})