Add read-only world boss tracking (AVA2 uitrack port)
Each game core snapshots its timed boss regens once a second and shares them over the original HEADER_GG_RELAY addressed to "#mt_boss", so old cores just miss the player lookup instead of dropping the P2P link. New /mt_features query kind "bosses" (capability bit 256, mask 511) lists the player's channel plus the shared channel 99. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a5293945b7
commit
400e44fae4
@@ -0,0 +1,72 @@
|
||||
# PORT world boss tracking, v1
|
||||
|
||||
Date: 2026-10-15. Read-only port of the AVA2 uitrack world-boss tab. Source: `src/server/game/src/port_boss_track.h` (board, wire format), `port_boss_track.cpp` (regen scan, relay, query), hooks in `main.cpp` (1 s tick), `input_p2p.cpp` (`Relay`) and `port_features.h` (query kind `bosses`, capability bit 256). No new packet header, no DB schema, no gameplay change. AVA2's teleport button is not ported, and its dungeon tab is already covered by the `dungeons` query.
|
||||
|
||||
## Which regens are listed
|
||||
|
||||
A regen is a boss regen when all of these hold:
|
||||
|
||||
- type `MOB`, `GROUP` or `ANYWHERE`;
|
||||
- `time > 0` (it respawns on a timer);
|
||||
- its leader (the mob itself, or member 0 of the group, which `SpawnGroup` makes the master) is a `CHAR_TYPE_MONSTER` with `bRank >= MOB_RANK_BOSS`.
|
||||
|
||||
Each row carries:
|
||||
|
||||
| Field | Source |
|
||||
| --- | --- |
|
||||
| VNUM | leader vnum |
|
||||
| MAP | `regen->lMapIndex` |
|
||||
| X, Y | centre of the regen box minus the map base (map-local units); `0 0` for `ANYWHERE` |
|
||||
| ALIVE, MAX | `regen->count`, `regen->max_count` (capped at 255) |
|
||||
| NEXT | server time when `regen_event` fires next (`now + event_time / passes_per_sec`); 0 when there is no event |
|
||||
| PERIOD | `regen->time` in seconds |
|
||||
|
||||
The regen timer is the original one; the board only reads it. `regen_event` tops the regen up to `max_count` each time it fires, so ALIVE < MAX with a NEXT in the past means "about to spawn".
|
||||
|
||||
## Sharing between cores
|
||||
|
||||
Each game core (not the auth core) scans its own regen list once a second, keeping at most 64 rows. It broadcasts the snapshot when it changes (vnum/map/alive/max/period differ, or NEXT moves by more than 2 s) and otherwise every 60 s as a heartbeat.
|
||||
|
||||
The snapshot goes over the original `HEADER_GG_RELAY`, addressed to the name `#mt_boss`, which no player can have:
|
||||
|
||||
```
|
||||
TPacketGGRelay { header, szName "#mt_boss", lSize }
|
||||
PortBossHeader { uint16 p2p_port; uint8 channel; uint8 count } 4 bytes
|
||||
PortBossWire { uint32 vnum, map; int32 x, y; uint32 period, next; uint8 alive, max } 26 bytes x count
|
||||
```
|
||||
|
||||
A new GG header was not used on purpose: a core without this code would hit "UNKNOWN HEADER" and close the P2P link. An old core instead looks the name up with `FindPC`, finds nobody and drops the payload, logging one `InputP2P::Relay : #mt_boss size N` line per snapshot. A new core consumes the relay before the player lookup. Malformed payloads (short, size mismatch, more than 64 rows) are rejected with one syserr line.
|
||||
|
||||
Remote snapshots are keyed by sender host + P2P port; a newer one replaces the older, and a core that has been silent for 150 s drops out.
|
||||
|
||||
## Query
|
||||
|
||||
```
|
||||
/mt_features 1 REQUEST bosses
|
||||
MTF1 begin REQUEST bosses 0 0 TOTAL 0 SERVER_TIME
|
||||
MTF1 boss REQUEST INDEX VNUM MAP X Y CHANNEL ALIVE MAX NEXT PERIOD
|
||||
MTF1 end REQUEST ROW_COUNT
|
||||
```
|
||||
|
||||
A player sees the rows of their own channel plus channel 99 (the shared core). Rows are sorted by map, vnum and channel, and capped at 128. The usual query rules (throttle, own PC, version check) apply. `bosses` with extra arguments returns `MTF1 error REQUEST unsupported`.
|
||||
|
||||
## Evidence
|
||||
|
||||
- `tests/features/test_bosses.py`:
|
||||
- wiring checks for the Makefile, the main tick, the relay hook order and the query dispatch;
|
||||
- a compiled test of the board covering the broadcast throttle, encode/decode round trip, channel filter, sort, replace, expiry, malformed payloads and the caps.
|
||||
- `tests/features/test_queries.py`: cap 511, dispatch and the extra-argument error.
|
||||
- FreeBSD build in `/root/metin2-features-dev`. 2026-10-15 test on 203 with two channel5 cores:
|
||||
- `first` on 13040 served maps 1/21/41/68; a temporary `second` on 13041 served maps 72/5.
|
||||
- A query on either core returned all 5 boss rows of both cores:
|
||||
- pirate 5001 `ANYWHERE` on maps 21/41;
|
||||
- 2307 on map 68;
|
||||
- 1192 on map 72;
|
||||
- 5161 on map 5.
|
||||
- NEXT values were identical from both sides.
|
||||
- The live channel 1-4 cores and game99 (old binary) each logged the relay line and kept their P2P links; no P2P errors in syserr.
|
||||
- The Makefile has no header dependencies. After changing `port_features.h`, touch `cmd_general.cpp` (its only includer) or the old object is linked. The first test build hit this and still advertised cap 255.
|
||||
|
||||
## Deployment
|
||||
|
||||
Every game core must run the new binary for every boss to be listed; mixing is safe in both directions. Channel 99 rows appear only once game99 runs it.
|
||||
@@ -13,6 +13,7 @@ Request through existing CG chat command:
|
||||
/mt_features 1 REQUEST stats
|
||||
/mt_features 1 REQUEST dungeons
|
||||
/mt_features 1 REQUEST calendar 1 OFFSET
|
||||
/mt_features 1 REQUEST bosses
|
||||
```
|
||||
|
||||
REQUEST: 1..2147483647, independent for each game session's pending command. Subject: unsigned 32-bit nonzero ID. OFFSET: 0..4096. Other versions, excess arguments, oversized tokens, signed/overflow identifiers are rejected. Queries require an own PC descriptor. Per-character throttle: 250 ms. No gameplay mutation, consumption, random draws or database write.
|
||||
@@ -25,11 +26,12 @@ MTF1 begin REQUEST KIND SUBJECT OFFSET TOTAL MODE SERVER_TIME
|
||||
MTF1 row REQUEST INDEX ITEM COUNT RULE MIN MAX WEIGHT GROUP_TOTAL RARE
|
||||
MTF1 stat REQUEST INDEX KEY SIGNED_VALUE
|
||||
MTF1 event REQUEST INDEX EVENT_ID KIND START END CHANNEL EMPIRE ACTIVE
|
||||
MTF1 boss REQUEST INDEX VNUM MAP X Y CHANNEL ALIVE MAX NEXT PERIOD
|
||||
MTF1 end REQUEST ROW_COUNT
|
||||
MTF1 error REQUEST ERROR
|
||||
```
|
||||
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 switchbot (separate `/mt_switchbot` / `MTSB1` protocol, see FEATURE-SWITCHBOT.md). Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
MASK: 1 mob drops, 2 chest preview, 4 own stats, 8 item sources, 16 dungeon snapshots, 32 scheduled calendar, 64 switchbot (separate `/mt_switchbot` / `MTSB1` protocol, see FEATURE-SWITCHBOT.md), 256 world bosses (see FEATURE-BOSS-TRACK.md). The current mask is 511. Unknown capability bits are ignored; unknown versions are rejected. Capability advertises the query implementation; missing quest/config can still return unsupported/schedule_unavailable. The client negotiates before business queries; old servers time out to unsupported, not an empty result.
|
||||
|
||||
Each drop/chest/source page contains at most 8 rows, with consecutive absolute indices. TOTAL is capped at 4096; stats are one complete bounded snapshot (currently the named keys in kPortStats, less than 128). Client commits only a complete, matching begin/rows/end sequence. Unknown/stale request IDs cannot overwrite the current selection. Each line is bounded below 512 bytes; rows contain IDs and values, not server-provided script/names/markup.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user