commit 8f66b2ba9a45ab4b8180dc4d0c24170532aee4fc
parent 19ea11f1c5a2d732add3920ebfaa2c3e5dd9d9e3
Author: anon <anon@example.com>
Date: Sun, 25 Oct 2026 04:30:29 +0000
Fix native NPC target inspection replies
Diffstat:
4 files changed, 194 insertions(+), 28 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -939,14 +939,6 @@ and unresolved indoor lifecycle are explicit in [flight](docs/vehicles.md#yalmah
its original InfoPacket reply; C adapters fix reached `_strdate` and
`strcspn` crashes. Description verification and reference persistence follow.
See [player information](docs/character-info.md).
-- [ ] Fix T-key target inspection hanging indefinitely on NPCs. Reproduce the
- native request/reply and loading-window path, and verify inspection of other
- players too. The current `handleCharacterInfo` explicitly rejects NPCs;
- establish their complete reply contract. Check: targeting an NPC or player
- and pressing T finishes loading
- the correct actor's information/stats window. Cover rapid target changes,
- disappearing targets, invalid identities, reconnect and restart, without
- showing stale information or disrupting combat health delivery.
- [x] Correct native reference description stats. Check: a level-150 Engineer
reference shows the actual level/profession/title, rather than level 0 and
no profession. The reference callback now scopes normal-stat mode around
@@ -1290,7 +1282,7 @@ and server restarts. Turn every reproduced bug into a focused regression test.
- [ ] Audit combat scheduling and outcomes. Cover range boundaries, moving or
unavailable targets, repeated starts/stops, timing changes, equipment changes,
two attackers, lethal and nonlethal hits, queued native results and HP agreement.
- Include player inspection while a weapon hit is queued: original InfoPacket
+ Include player and NPC inspection while a weapon hit is queued: original InfoPacket
applies absolute remote HP without an animation guard, so it shares the
unresolved healing/hit ordering problem. Verify the server, owner and observer
through impact and subsequent regeneration; see [inspection](docs/character-info.md).
diff --git a/docs/character-info.md b/docs/character-info.md
@@ -1,7 +1,8 @@
-# Player inspection and references
+# Character inspection and player references
-The original 14.9.1 client requests player information with CharacterAction
-105. Alt+left-click creates a reference; G creates one for the selected target.
+The original 14.9.1 client requests character information with CharacterAction
+105. T inspects the selected player or NPC. Alt+left-click creates a player
+reference; G creates one for the selected target.
Reference creation waits for the server's InfoPacket response before adding
the player to Knowledge. The existing SimpleChar nickname is retained.
@@ -10,7 +11,7 @@ the player to Knowledge. The existing SimpleChar nickname is retained.
Original KKR SHA-256 is
`a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0`.
`N3Msg_RequestInfoPacket` 0x1002c720 -> 0x10056420 constructs action 105.
-`InfoPacketIIR_t` uses key `0x4d38242e` and the requested player's identity.
+`InfoPacketIIR_t` uses key `0x4d38242e` and the requested character's identity.
Serializer 0x1005b9a0 and decoder 0x1005bbd0 establish this mandatory payload:
| Offset | Value |
@@ -38,10 +39,12 @@ default 1: KKR constructor 0x10072760 initializes stat 10 separately from Level
Execute 0x1007faa0 resolves the target actor, applies the packet through
0x1005b1a0, stores it in the character control and sends module 20/event 0xbb.
It does not safely handle an absent target. The server only answers for a
-connected player on the requester's current playfield after both world clients
-are ready and their equipment effects have replayed. It serializes replies
-with actor spawn/removal. Self-inspection is supported.
-NPC inspection and the optional extension schemas remain unfinished.
+represented character on the requester's current playfield. Players require
+ready world clients with their equipment effects replayed; NPCs require an
+entry in the requester's spawned-interest set and no replacement corpse.
+A corpse is represented by identity51050, not the required SimpleChar50000.
+Replies serialize with actor spawn/removal. Self-inspection is supported;
+optional extension schemas remain unfinished.
Original DDR SHA-256 is
`3c937161de8f690351c3c08e158431417cee9ced77a41b677e7123b61a8c9883`.
@@ -201,3 +204,74 @@ Runtime artifacts and diagnostic commands are in `local/reference-smoke/`,
`local/reference-debug/`, `local/knowledge-smoke/` and
`local/reference-research/`. `mode.md` retains the original constructor,
mode-writer, renderer-caller and callback ABI evidence.
+
+## T-key NPC inspection
+
+The original DDR general information entry1006d8f0 selects NPC renderer10071120
+through IsNpc, and player renderer1006fc30 otherwise. The NPC renderer's first
+phase requests the ordinary InfoPacket, records the pending identity and shows
+`Please wait / Transfering information`. InfoPacketAvailable10075780 re-enters
+the general route with ready=true; only the matching pending identity completes
+the description. The server previously rejected every NPC request, leaving this
+window pending indefinitely. The fix admits represented NPCs through the same
+message path as player inspection.
+
+The NPC renderer uses the spawn nickname and level, Consider's danger result,
+BreedHostility204, Side33 and the mandatory description string. It does not read
+player profession/title progression. The shared decoder needs no NPC-specific
+extension. Current NPCs have no authored description, hostility, organization or
+pet master, so those fields remain empty/zero. InfoPacket does not replace the
+spawn nickname.
+
+NPC replies retain native raw regeneration inputs: health delta3/interval30 and
+nano delta3/interval30. The NPC update loop independently applies combat and
+idle recovery; sending player breed/stamina formulas or already adjusted
+combat intervals would change native prediction. NPC headers use Profession255
+(the byte representation of the native -1 default), ProfessionLevel1,
+TitleLevel1, spawn sex and VisualProfession0. This is a reconstruction for
+unauthored NPC metadata, not a recovered original-server packet trace. Native
+initializer10072760 and the NPC renderer establish these defaults and their
+consumer boundaries; current creature HP/balance remains separately provisional.
+
+Fresh original DDR evidence:
+
+- General dispatch: `ev_701b6773ebeb5bb20f73104867570079622149f180b7640b4f58873f68a25e75`.
+- NPC request/wait and completed renderer: `ev_73ad440c2c1cf0e5abfa030b6e106a48f4069dfcdc57c5d84319d12f358e6bc5`.
+- Reply callback: `ev_4870e557f1a993dae5d62d3d87397ed82b358683673d7edd1d13b687c7f74a7e`.
+
+Complete exports, matching snapshots and the independent NPC-field audit are
+retained in `local/npc-inspection-research/`. The owned REA session was exported
+and closed. The shared wire/initializer evidence above remains applicable.
+
+The regression first reproduced the missing reply, then public-handler tests
+verified exact NPC bytes, repeatable snapshots, preserved recovery clocks and
+no database writes. Additional cases reject unseen/removed/cross-zone NPCs,
+replacement corpses, forged owners, stale sessions and loading/unready clients.
+Native wire dispatch tests cover both player and NPC requests. Inspection and
+NPC recovery passed under the race detector in 108.431 seconds; `go vet` passed
+for all tracked Go packages.
+
+Two headed GPU Chromium clients reproduced the original Leet loading hang:
+CharacterAction105 was sent, but no NPC InfoPacket arrived; self-inspection
+completed on the same connection. With the fix, Leet and Reet of Paradise
+windows show their level and native danger text. The other player's window
+shows the correct name, Fixer profession, Embezzler title and level50; self
+shows the level150 Enforcer's title. Rapid target switching and a fresh browser
+connection complete the matching description and clear the pending identity.
+Read-only native samples and captured NPC replies retain raw regeneration
+3/30/3/30. No page or adapter errors occurred, and no client change was needed.
+
+High player levels/professions and positions were explicit temporary GM
+fixtures. Target selection, T inspection and reconnect used the native client.
+These checks are idle inspection checks; the queued-hit HP ordering limitation
+above remains open for both player and NPC snapshots. Screenshots, before/after
+wire captures, rendered native text, GPU identity and verifiers are retained
+under `local/npc-inspection-smoke/`.
+
+Both owned browser contexts were closed. Cleanup removed the two temporary
+players, preserved Visitor8 and verified foreign keys, database integrity and
+unchanged hashes for unrelated rows. The sole shared HTTPS preview was
+restarted with the fix.
+
+The complete tracked Go suite (`go test ./server/... ./tools/data/export_gamedata
+-count=1 -timeout=30m`) passed: server 714.783 seconds, game data 7.770 seconds.
diff --git a/server/character_info.go b/server/character_info.go
@@ -7,15 +7,21 @@ import (
func characterInfoPacket(player *character) []byte {
// The five byte stats are Profession, ProfessionLevel, TitleLevel, VisualSex and VisualProfession.
- // ProfessionLevel retains the native default 1; displayed Level is a separate spawn stat.
- profession := byte(max(1, player.profession))
- body := []byte{0, profession, 1, byte(player.titleLevel()), byte(player.appearance >> 7 & 3), profession}
- body = binary.BigEndian.AppendUint32(body, 0) // PetMaster; ordinary players have no owner.
+ // NPCs retain native defaults, including the byte representation of profession -1.
+ profession, visualProfession, title := byte(255), byte(0), byte(1)
+ regeneration := [4]uint32{3, 30, 3, 30}
+ if !player.npc {
+ profession = byte(max(1, player.profession))
+ visualProfession, title = profession, byte(player.titleLevel())
+ resources := teamResourceStats(player)
+ regeneration = [4]uint32{resources[0][1], resources[1][1], resources[2][1], resources[3][1]}
+ }
+ body := []byte{0, profession, 1, title, byte(player.appearance >> 7 & 3), visualProfession}
+ body = binary.BigEndian.AppendUint32(body, 0) // PetMaster; current actors have no owner.
body = binary.BigEndian.AppendUint16(body, 0) // Side XP bonus is not implemented.
- // InfoPacket shares the native resource values used by team snapshots.
- resources := teamResourceStats(player)
- for _, value := range []uint32{player.health, player.maximumHealth(), resources[0][1], resources[1][1], resources[2][1], resources[3][1], 0, 0} {
+ // Publish raw regeneration inputs; the NPC tick applies its combat/idle rules.
+ for _, value := range []uint32{player.health, player.maximumHealth(), regeneration[0], regeneration[1], regeneration[2], regeneration[3], 0, 0} {
body = binary.BigEndian.AppendUint32(body, value)
}
// BreedHostility, clan and the four counted name/description strings are empty.
@@ -40,8 +46,17 @@ func (server *server) handleCharacterInfo(client *worldClient, body []byte) erro
target := server.characters[binary.BigEndian.Uint32(body[24:28])]
if server.clients[client.id] != client || !client.target || !client.ready || client.loading ||
binary.BigEndian.Uint32(body[4:8]) != 50000 || binary.BigEndian.Uint32(body[8:12]) != client.id ||
- target == nil || target.npc || target.playfield != owner.playfield || server.clients[target.id] == nil ||
- !server.clients[target.id].ready || server.clients[target.id].loading {
+ target == nil || target.playfield != owner.playfield {
+ server.mutex.Unlock()
+ return nil
+ }
+ // Native InfoPacket execution dereferences an already spawned SimpleChar.
+ represented := client.npcs[target.id] && target.corpse == nil
+ if !target.npc {
+ recipient := server.clients[target.id]
+ represented = recipient != nil && recipient.ready && !recipient.loading
+ }
+ if !represented {
server.mutex.Unlock()
return nil
}
diff --git a/server/character_info_test.go b/server/character_info_test.go
@@ -59,7 +59,7 @@ func TestCharacterInfoSelfUsesProfileStatsWithoutAbsorbingModifiers(t *testing.T
}
func TestCharacterInfoRejectsUnrepresentedOrUnauthenticatedRequests(t *testing.T) {
- for _, scenario := range []string{"missing", "npc", "other zone", "offline", "foreign owner", "sender type", "target type", "argument", "action", "key", "legacy", "not ready", "loading", "target not ready", "target loading", "replaced"} {
+ for _, scenario := range []string{"missing", "unseen npc", "other zone", "offline", "foreign owner", "sender type", "target type", "argument", "action", "key", "legacy", "not ready", "loading", "target not ready", "target loading", "replaced"} {
t.Run(scenario, func(t *testing.T) {
world, connections := newTeamWorld(t)
client := world.clients[1]
@@ -67,7 +67,7 @@ func TestCharacterInfoRejectsUnrepresentedOrUnauthenticatedRequests(t *testing.T
switch scenario {
case "missing":
binary.BigEndian.PutUint32(request[24:28], 90)
- case "npc":
+ case "unseen npc":
world.characters[2].npc = true
case "other zone":
world.characters[2].playfield = 705
@@ -177,3 +177,88 @@ func TestCharacterInfoNativeWireDispatch(t *testing.T) {
t.Fatalf("native inspection dispatch: %v %x", err, reply)
}
}
+
+func TestCharacterInfoNPCUsesNativeDefaultsWithoutChangingRecovery(t *testing.T) {
+ for _, fighting := range []uint32{0, 1} {
+ world, conn := newRangedWorld(t)
+ npc := world.characters[1000000]
+ npc.health, npc.level, npc.fighting = 20, 200, fighting
+ npc.stats.Abilities.Stamina, npc.stats.Abilities.Psychic = 900, 900
+ auditCheckpointWrites(t, world)
+
+ for range 2 {
+ if err := world.handleCharacterInfo(world.clients[1], teamRequest(1, 105, 1000000, 0)); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ if len(conn.packets) != 2 || !bytes.Equal(conn.packets[0], conn.packets[1]) {
+ t.Fatal("represented NPC did not return a repeatable inspection reply")
+ }
+ packet := conn.packets[0]
+ if binary.BigEndian.Uint32(packet[24:28]) != 1000000 {
+ t.Fatal("NPC reply used the requester's identity")
+ }
+ if got := hex.EncodeToString(packet[29:81]); got != "00ff010101000000000000000000001400000064000000030000001e000000030000001e00000000000000000000000000000000" {
+ t.Fatal("NPC metadata or raw regeneration inputs changed", got)
+ }
+ if npc.health != 20 || npc.fighting != fighting || npc.regenerationSeconds != 0 || !npc.regenerationAt.IsZero() {
+ t.Fatal("inspection changed the NPC's health or recovery clock")
+ }
+ if writes := checkpointWrites(t, world); len(writes) != 0 {
+ t.Fatal("NPC inspection wrote durable state", writes)
+ }
+ }
+}
+
+func TestCharacterInfoNPCRejectsTargetsWithoutASimpleCharacter(t *testing.T) {
+ for _, scenario := range []string{"unseen", "other zone", "removed", "corpse", "foreign owner", "loading", "not ready", "replaced"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, conn := newCombatWorld()
+ npc, client := world.characters[1000000], world.clients[1]
+ request := teamRequest(1, 105, 1000000, 0)
+ switch scenario {
+ case "unseen":
+ delete(client.npcs, npc.id)
+ case "other zone":
+ npc.playfield = 705
+ case "removed":
+ delete(world.characters, npc.id)
+ case "corpse":
+ npc.health, npc.corpse = 0, &npcCorpse{}
+ case "foreign owner":
+ binary.BigEndian.PutUint32(request[8:12], 2)
+ case "loading":
+ client.loading = true
+ case "not ready":
+ client.ready = false
+ case "replaced":
+ world.clients[1] = &worldClient{id: 1, ready: true}
+ }
+
+ err := world.handleCharacterInfo(client, request)
+
+ if err != nil || len(conn.packets) != 0 || len(client.absorbedBonuses) != 0 {
+ t.Fatal("an unrepresented NPC received an unsafe SimpleChar reply", err)
+ }
+ })
+ }
+}
+
+func TestCharacterInfoNPCNativeWireDispatch(t *testing.T) {
+ world := newCheckpointWorld(t)
+ client := connectZoningClient(t, world, true)
+ request := targetPacket(characterActionPacket(1, [5]uint32{105, 50000, 1000000, 0, 0}))
+
+ if _, err := client.Write(request); err != nil {
+ t.Fatal(err)
+ }
+ reply, err := readPacket(client)
+
+ if err != nil || len(reply) != 81 || binary.BigEndian.Uint32(reply[16:20]) != 0x4d38242e || binary.BigEndian.Uint32(reply[24:28]) != 1000000 {
+ t.Fatalf("native NPC inspection dispatch: %v %x", err, reply)
+ }
+ if !bytes.Equal(reply[49:65], []byte{0, 0, 0, 3, 0, 0, 0, 30, 0, 0, 0, 3, 0, 0, 0, 30}) {
+ t.Fatal("native NPC inspection changed raw recovery inputs")
+ }
+}