commit d9ff8a1a58e0df1b35da4a2eb54505dd9782a6b5
parent d34d4f7ab9bdbe1fa7b139fc353aa27f9b04e299
Author: anon <anon@example.com>
Date: Thu, 22 Oct 2026 22:23:27 +0000
Keep worn template equipment reusable after removal
Diffstat:
7 files changed, 85 insertions(+), 19 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -346,7 +346,7 @@ checks are recorded in [treatment kits](docs/treatment-kit.md).
under the applicable requirements and ending use restores ordinary movement.
- [x] Restore the Kodaik's shipped materials in the WASM client. Check: its two
textured surfaces render for the driver and observer after equip and reconnect.
-- [ ] Re-equip the Kodaik after removing it without reconnecting. Check: using
+- [x] Re-equip the Kodaik after removing it without reconnecting. Check: using
the returned inventory item emits a native wear request and restores the car.
- [ ] Use one flying vehicle. Check: altitude and movement modes replicate to an
observer and zoning does not leave the character stuck in the wrong mode.
diff --git a/docs/backpacks.md b/docs/backpacks.md
@@ -73,8 +73,9 @@ Ordinary items without separate live objects use FullCharacter entry flag 1.
Flag 2 selects identity-object lookup; a visible icon alone does not instantiate
that object. Keeping an ordinary pistol at flag 2 made the server accept a put
while the client left its source row untouched. The native template branch moves
-the complete entry instead. Worn items and backpacks retain flag 2. A later
-proper WeaponItemFullUpdate creates the weapon object when it is equipped.
+the complete entry instead. The equipped Kinetic Axe and Small Backpack retain
+flag 2, with separate WeaponItemFullUpdate/ChestFullUpdate object creation.
+Template equipment such as armor and vehicles uses flag 1 even when worn.
Evidence for the flag test and both transfer branches:
`ev_07063ae8fa3a3b6248a0d15562f619930d9db0b3e22375bfc5451088c54d6013`
and `ev_997b50913c907c830e4ced831d12c72906e0c2d05d956375785e4ff8859f5cf5`.
diff --git a/docs/inventory-stacks.md b/docs/inventory-stacks.md
@@ -49,8 +49,9 @@ Direction and checks are supported by
`ev_22f06fb27128af42a5babde5a290d6fd9f24bcd92d075f86a813261a0a2e60ae`
and `ev_d87a842dd8417af8e91dcb61a97596d71ff6fce8b6bca2b6110cdabd783afcc6`.
-Stack mutations require inventory entry flag `0x1`. Initial Essence and other
-ordinary template rows use flag 1; worn items and backpacks use flag 2. Local split clones use
+Stack mutations require inventory entry flag `0x1`. Essence and other template
+items use flag 1, including worn template equipment. The equipped Kinetic Axe
+and Small Backpack use flag 2 for their separate live identities. Local split clones use
`0x21` and a zero instance identity. The row stores a ushort quantity at offset
6 and its QL/low/high triple at offsets 16/20/24. Persistent server IDs remain
owned state, while stack requests address page/slot and carry no new instance
diff --git a/docs/inventory.md b/docs/inventory.md
@@ -33,7 +33,7 @@ encoded length is `(items + 1) * 1009`. Each entry has these network-order field
| Field | Size | Initial individual-item value |
| --- | --- | --- |
| Logical slot | 4 | 48 through 77 on the 14.9.1 wire |
-| Entry flags | 2 | 1 for ordinary templates; 2 for worn items and backpacks |
+| Entry flags | 2 | 1 for template items; 2 for separate live item identities |
| Count | 2 | 1 |
| Instance type and ID | 8 | Template type and persistent server ID |
| Low and high template | 8 | Same exact template ID |
@@ -46,10 +46,11 @@ The maintained client source establishes the 32-byte wire entry:
two shorts, identity and template information. `sub_360011B0` in
`client/game/kkr.dll/lifted-0000.c` reads the final four integers.
The 14.9.1 conversion inserts its seventh list after the variable-length
-inventory, rather than at an offset valid only for an empty list. Ordinary
-items use template flag 1 so native transfers can move their inventory entries
-without requiring a separate live object. Worn items and initialized backpacks
-retain live flag 2. The [backpack protocol](backpacks.md) explains this distinction.
+inventory, rather than at an offset valid only for an empty list. Template
+items use flag 1 even when worn, so native transfers and subsequent use do not
+require a separate live object. The equipped Kinetic Axe and Small Backpack
+use flag 2; their native object updates are sent separately. The
+[backpack protocol](backpacks.md) explains this distinction.
`ContainerAddItem` (`0x47537a24`) carries source page/slot, target owner identity
and destination slot. The server accepts only an authenticated current session's
diff --git a/docs/vehicles.md b/docs/vehicles.md
@@ -186,11 +186,46 @@ run passed 23 evidence checks in `local/vehicle-material-smoke/verification.json
Only expected connection-refused messages during deliberate restarts were
recorded. All test clients and the temporary server were closed afterward.
-Live re-equip after removal remains a separate TODO: in this run the returned
-inventory item emitted no new native wear request until the driver reconnected.
-The reconnected driver could equip it normally, and the observer rendered its
-textured form. The cause of that repeat-use UI behavior is not established.
-
The maintained full server suite passed in 91.528 seconds. Five race-enabled
passes over vehicle lifecycle, material initialization, native character
conversion and clothing flags passed in 96.323 seconds.
+
+## Template equipment reuse
+
+FullCharacter uses entry flag 1 for template equipment, including worn vehicles,
+armor, implants, belts and NCU. Flag 2 denotes a separate live item identity;
+it is retained for the equipped Kinetic Axe and Small Backpack, whose object
+updates are sent separately. Worn template effects still initialize once.
+
+Native `kkr.dll` possession helper `100619d0`, reached by UseItem `1002acd0`,
+accepts template rows directly. A live-identity row instead requires the
+corresponding dynel, except for the explicit Chest path. FullCharacter worn
+initialization `1005f150` accepts either row kind and derives its effects from
+the template. Container movement `1005dd60` resolves destination 111 to the
+first free ordinary slot and calls `1002d380` to swap complete row pointers.
+It clears temporary flag 0x40 but preserves the item-kind flag.
+
+A live-identity flag on a worn Kodaik therefore leaves the returned inventory
+row unusable when no ArmorItem dynel exists. Read-only WASM captures reproduced
+that state: slot 48, flag 2, no dynel, and no subsequent wear request. With
+template flag 1, the same native row survives removal and re-equips normally.
+The server's snapshot flags match the actual item representation; no new
+client adapter or acknowledgement behavior is needed.
+
+Two WASM clients exercised three car removal/reuse cycles without reconnecting.
+Both click-pick/drop and right-click HUD1 removal worked. The native row kept
+its identity, count, quality and template flag. RunSpeed's modifier alternated
+between 0 and 150; form, scale and fighting features changed once per operation.
+The worn Metaplast chest retained AC 5/1, removed to zero and re-equipped to
+5/1 through ordinary right-clicks. The observer had the same car and armor
+effects, and health and cash were unchanged. The isolated run passed 30 evidence
+checks with no client errors. Original-byte audits, packets, screenshots and
+probes are retained in `local/vehicle-reuse-smoke/verification.json` and its
+sibling evidence files. Both clients and the temporary server were closed
+before the full test runs.
+
+The full maintained server suite passed in 91.652 seconds. Five race-enabled
+passes over snapshot item kinds and armor, belt, implant, weapon and backpack
+restoration passed in 95.493 seconds. Regression tests retain live flags for
+the actual weapon and Chest paths while rejecting live flags for template
+equipment.
diff --git a/server/inventory_test.go b/server/inventory_test.go
@@ -26,6 +26,34 @@ func inventoryDeletePacket(owner, slot uint32) []byte {
return n3Packet(0x5e477770, 50000, owner, body)
}
+func TestInventorySnapshotFlagsMatchNativeItemKind(t *testing.T) {
+ for _, scenario := range []struct {
+ name string
+ item ownedItem
+ flags uint16
+ }{
+ {"vehicle", ownedItem{Type: 51022, Template: 117294, Quality: 15, Slot: 1}, 1},
+ {"armor", ownedItem{Type: 51022, Template: 85686, Quality: 1, Slot: 21}, 1},
+ {"implant", ownedItem{Type: 51022, Template: 101173, Quality: 1, Slot: 37}, 1},
+ {"belt", ownedItem{Type: 51022, Template: 36783, Quality: 1, Slot: 7}, 1},
+ {"NCU", ownedItem{Type: 51022, Template: 36779, Quality: 1, Slot: 9}, 1},
+ {"worn weapon", ownedItem{Type: 51018, Template: 209283, Quality: 1, Slot: 6}, 2},
+ {"inventory weapon", ownedItem{Type: 51018, Template: 209283, Quality: 1, Slot: 64}, 1},
+ {"backpack", ownedItem{Type: 51017, Template: 99228, Quality: 1, Slot: 64}, 2},
+ } {
+ t.Run(scenario.name, func(t *testing.T) {
+ scenario.item.ID, scenario.item.Count = 1, 1
+ player := &character{id: 1, inventory: playerInventory{Items: []ownedItem{scenario.item}}}
+
+ packet := targetPacket(fullCharacterPacket(player))
+
+ if flags := binary.BigEndian.Uint16(packet[41:43]); flags != scenario.flags {
+ t.Fatalf("native inventory kind: got %d, want %d", flags, scenario.flags)
+ }
+ })
+ }
+}
+
func TestInventoryNativeMoveDeleteAndRestart(t *testing.T) {
t.Chdir(t.TempDir())
world := newTestServer(t)
diff --git a/server/world.go b/server/world.go
@@ -165,12 +165,12 @@ func characterPacket(character *character) []byte {
func fullCharacterPacket(character *character) []byte {
// Version 16 begins with six encoded lists, followed by four stat lists.
body := binary.BigEndian.AppendUint32(nil, 16)
- // Ordinary template entries need flag 1; worn items and live Chests use flag 2.
+ // Template entries use flag 1; flag 2 requires a live item identity.
body = binary.BigEndian.AppendUint32(body, uint32(len(character.inventory.Items)+1)*1009)
for _, item := range character.inventory.Items {
- flags := uint32(2)
- if item.Slot >= 64 && !item.isSmallBackpack() {
- flags = 1
+ flags := uint32(1)
+ if item.isSmallBackpack() || item.isKineticAxe() && item.Slot == 6 {
+ flags = 2
}
for _, value := range []uint32{item.Slot, flags<<16 | uint32(item.Count), item.Type, item.ID, item.Template, item.Template, item.Quality, 0} {
body = binary.BigEndian.AppendUint32(body, value)