commit 44c5bbe2acf0595e0b82ad06cd10ad806c078419
parent 6427efcc47bb3c5afbf5e240183b9f4ad7aae020
Author: anon <anon@example.com>
Date: Mon, 26 Oct 2026 02:26:42 +0000
Replicate remote player combat foundations after readiness
Share raw abilities, initiatives and AggDef before replaying equipment and
active effects, and publish accepted slider changes to ready observers in the
same playfield. Preserve separate modifiers and existing training snapshots.
Cover initial/loading/replacement ordering and signed recipients, update native
session fixtures, and document the remaining active observer timer discrepancy.
Verify the complete server/game-data suite, focused race checks, vet and build.
Two headed GPU WASM clients cover cold restoration, training/cancellation,
ordered reconnect, same-instance removal/rewear and live combat observations.
Diffstat:
14 files changed, 347 insertions(+), 27 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -216,14 +216,24 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md).
stat51 nano/consumable/pet contracts and exact original server scheduling
remain open. See [combat modifiers](docs/combat-equipment-modifiers.md#aggdef-timing-modifiers).
- [ ] Establish the original remote-player combat timing replication contract.
- Two-client capture shows owner base AggDef100/trained init0/+5 equipment
- producing100/100cs while its observer retains base AggDef0/raw init5 and
- computes191/198cs. The raw value does not establish effective initiative. Both
- receive identical hit results, but animation clocks can diverge. Trace spawn,
- stat and attack/timing fields before choosing what to replicate; do not infer
- original server policy from client defaults. Captures are in
- `local/aggdef-consumer-smoke/38-aggression-live-observer.json`; source follow-up
- is in `local/remote-combat-timing-research/`.
+ Initial foundations and slider delivery are implemented below, but live
+ animation clocks still diverge: both clients receive raw 51=100/+5 equipment
+ and trained RangedInitiative 2, while the owner runs 100/100cs and the observer
+ keeps 289/295cs. The raw setter
+ recalculates before storing 51; later refresh paths are locally guarded or
+ reset broader combat state. Establish the original active-update policy
+ without synthetic effects, duplicate stats or attack restarts. Identical hit
+ results and matching fresh-start timers do not close this gap. See
+ [remote combat stats](docs/remote-combat-stats.md) and the retained bounded
+ audit in `local/remote-combat-timing-research/active-refresh/`.
+- [x] Supply remote players' raw combat foundations on world entry and
+ replacement: six abilities, four trained initiatives and base AggDef. Publish
+ accepted slider changes to ready same-playfield observers while preserving
+ separate equipment/nano modifiers and existing training snapshots. Check
+ loading/late/replacement observers, signed/invalid values, actor/effect order,
+ different playfields and repeated readiness. Fresh native fights agree at
+ slider 0 and -100; the active-timer discrepancy above remains open. See
+ [receiver evidence and checks](docs/remote-combat-stats.md).
- [ ] Complete the20 original stat51 nano contracts before admitting them.
Allowing scalar51 alone completes none: pet chants also need53153 and target
criteria; Call/Soul programs have unsupported metadata/dictionaries; rage tiers
diff --git a/docs/combat-equipment-modifiers.md b/docs/combat-equipment-modifiers.md
@@ -147,14 +147,15 @@ The defense case distinguishes base-100 from effective-95. Periodic regeneration
can leave the previous SQLite checkpoint behind the live balance, so the debit
check compares the last replicated balance with the durable reservation.
-The observer's raw AggDef/initiative foundations remain different from the
-owner's and can produce different animation clocks despite identical results.
-The native SpecialAttackWeapon timing surface also changes holder state and
-clears modifier entries; it is not a safe generic stat update without further
-ordering work. That replication contract remains a separate TODO. Captures and
+The remote-player snapshot supplies matching raw AggDef/initiative foundations;
+see [remote combat stats](remote-combat-stats.md). Fresh fight clocks agree, but
+an existing observer timer can retain its old durations after a live slider
+change. The native SpecialAttackWeapon timing surface also changes holder state
+and clears modifier entries; it is not a safe generic stat update. The original
+active-update contract remains a separate TODO. AggDef modifier captures and
assertions are in `local/aggdef-consumer-smoke/`; only normal GUI controls drove
-gameplay. Test clients and fixtures were removed, unrelated rows were unchanged,
-and the single HTTPS preview remains available.
+gameplay. Those test clients and fixtures were removed, unrelated rows were
+unchanged, and the single HTTPS preview remains available.
## Verification
diff --git a/docs/remote-combat-stats.md b/docs/remote-combat-stats.md
@@ -0,0 +1,120 @@
+# Remote player combat foundations
+
+Player snapshots send six raw abilities 16..21, trained initiatives 118/119/120/149
+and base AggDef 51 after the compact actor spawn. These are the same foundations
+as the owner's FullCharacter. The native getters add ability trickle and the
+separate equipment/nano modifier map. Sending effective values here would count
+those contributions twice.
+
+World entry includes `server/world.go:playerCombatStatPackets` for an existing
+peer that has finished loading. New, replacement and still-loading players
+publish these foundations after CharacterReady, before their equipment and
+active-nano replay. Sending them immediately after a replacement compact spawn
+can leave the loaded native actor with default foundations.
+The owner still receives its FullCharacter; the NPC interest path retains its
+separate combat-profile packet. Replacing an existing visible actor still
+removes the old actor before spawning its replacement, and repeated ready
+notifications do not replay the foundations or equipment modifiers.
+
+Accepted slider changes publish one ordinary StatIIR 51 to every ready client in
+the player's playfield, including its owner. Ready loading observers already
+have the actor snapshot queued, so they also receive subsequent changes. Other
+playfields and sessions without a queued world snapshot receive nothing. The
+signed slider foundation remains within -100..100; equipment/nano modifiers
+remain separate and can take the effective sum outside those bounds.
+
+Accepted skill training already broadcasts all 75 raw ability/skill foundations
+through SkillIIR, including the four initiatives. It needs no additional copy of
+these eleven spawn updates. Training rejection and unchanged batches continue
+to correct only the requester.
+
+## Native receiver evidence
+
+The maintained `client/game/kkr.dll/lifted-0053.c:sub_360B2E60` StatIIR receiver
+resolves the actor and calls `lifted-0034.c:sub_36075DB0`. That helper immediately
+invokes the raw setter before its optional training-draft snapshot bookkeeping.
+It preserves the additive modifier map. Draft cancellation through 741E0 is not
+an incoming-stat delivery gate.
+
+SkillIIR's `lifted-0038.c:sub_36083D80` applies every map entry through the raw
+setter before its local Skills UI guard. Compact player spawn cannot supply all
+eleven foundations: its physical abilities do not replace Intelligence/Sense/Psychic,
+the initiatives or AggDef. AttackIIR carries a target and mode; attack results
+carry damage, ammunition and result data rather than these foundations.
+
+These receiver capabilities and the reconstruction's observed divergence
+support the current snapshot design. They do not establish the original
+14.9.1 server's recipient, packet-order or scheduling policy. Retained source
+blocks, original evidence references, hashes and bounded searches are in
+`local/remote-combat-timing-research/`, including `training-followup/`.
+
+## Active timer discrepancy remains open
+
+Two headed GPU WASM clients with deliberately distinct abilities
+31/37/41/43/47/53 and trained initiatives 73/0/91/0 agree on all eleven raw
+foundations and Tium 124210's separate worn modifiers. A fresh fight at slider 0
+produces 190/196cs in both clients; a fresh fight at slider -100 produces 290/296cs.
+
+Changing the slider during an existing fight exposes a separate native cache
+problem. Across 250 read-only samples per client, both receive raw 51=-100 and
+retain modifier 51=5. The owner adopts 290/296cs while the observer keeps 190/196cs.
+Receiving the correct stat does not establish that the running observer timer
+has adopted it.
+
+A second 250-sample capture per client uses the final readiness order, trained
+RangedInitiative 2 and a fresh magazine. A delivered hit confirms combat before
+the slider moves from -100 to 100. Both clients retain raw 51=100 and modifier 51=5;
+the owner's running timer becomes 100/100cs while the observer still runs at
+289/295cs. Cold restoration, owner reconnect and a fresh defensive fight all
+agree on the foundations and 289/295cs before this live change.
+
+An active-update check must confirm a delivered weapon hit and a running
+controller after the slider change. An empty magazine can stop combat while
+leaving cached durations visible; those idle samples do not reproduce the live
+issue.
+
+The complete maintained raw setter `lifted-0033.c:sub_3606E030` calls 7AB10 for
+nonidle stat 51 before storing the new foundation. Its recalculation therefore
+reads the old value. Common refresh 714A0 and the subsequent stat-notification
+receiver 04180 have local-actor guards. Ordinary StatIIR returns after 75DB0 with
+no later remote refresh. The bounded direct-call audit found no neutral remote
+packet that stages updated durations for the existing timer.
+
+Genuine additive 51/118/119/120 application/removal recalculates active duration
+fields after changing the modifier map. Effect 53153, equipment binding changes
+and AttackIIR can initialize remote timers, but also reset remaining time,
+registration, flags or weapon state. They are not interchangeable with a stat
+update. The server does not synthesize effects, duplicate stat assignments or
+restart attacks to force this animation cache to change.
+
+Original-server evidence is still needed to choose the correct active-update
+contract. The full direct-call census, 45 selected maintained function blocks
+and the captured discrepancy are retained in
+`local/remote-combat-timing-research/active-refresh/`. Native captures and
+read-only probes driven only by normal GUI gameplay are in
+`local/remote-combat-stats-smoke/`.
+
+## Verification
+
+The focused Go regressions cover raw values with separate modifiers, zero
+trained initiative, signed/invalid sliders, loading/new/replacement observers,
+readiness and effect order, repeated readiness and different playfields. Real
+browser expiry, native dialogue and movement tests consume and verify the new
+snapshot before asserting subsequent session messages. Resurrection reconnect
+checks distinguish the other player's snapshot from changes to the dead
+player's stats and still reject premature resurrection.
+
+Two headed GPU clients verify 18 final-build foundation/modifier states,
+1,000 valid active-timer samples and 23 matching shot pairs. Native training
+accepts RangedInitiative 2 for 6 IP; cancellation preserves that accepted state.
+Cold restoration retains the same rifle and its four remaining rounds.
+Removal returns that instance to ordinary inventory, clears its three worn
+modifiers and retains Strength Boost; reconnect and rewear preserve identity
+without duplicating effects. Wire checks establish ready-before-foundations
+and foundations-before-effects across replacement. Owned shot damage agrees
+with the NPC's durable HP and contribution total.
+
+The verification excludes a failed trace-collection expression and an idle
+exhausted-magazine sample. Test clients and owned fixtures are removed; cleanup
+preserves unrelated rows and passes SQLite foreign-key/integrity checks. The
+single shared HTTPS 8443 preview remains available.
diff --git a/server/browser_stream_test.go b/server/browser_stream_test.go
@@ -448,9 +448,21 @@ func TestExpiredBrowserWorldSessionRemovesLivingTargetAndRetargetsNPC(t *testing
if binary.BigEndian.Uint32(spawn[20:24]) != 0x271b3a6b || binary.BigEndian.Uint32(spawn[28:32]) != 2 {
t.Fatalf("observer did not receive browser player: %x", spawn)
}
+ if err := socket.Write(ctx, websocket.MessageBinary, append(binary.BigEndian.AppendUint64(nil, uint64(len(cookie))), n3Packet(0x570c2039, 50000, 2, nil)...)); err != nil {
+ t.Fatal(err)
+ }
+ ready, err := readPacket(observer)
+ if err != nil || binary.BigEndian.Uint32(ready[20:24]) != 0x570c2039 {
+ t.Fatalf("observer did not receive browser player readiness: %x %v", ready, err)
+ }
+ for _, stat := range []uint32{16, 17, 18, 19, 20, 21, 118, 119, 120, 149, 51} {
+ packet, err := readPacket(observer)
+ if err != nil || binary.BigEndian.Uint32(packet[20:24]) != 0x2b333d6e || binary.BigEndian.Uint32(packet[28:32]) != 2 || binary.BigEndian.Uint32(packet[36:40]) != stat {
+ t.Fatalf("observer did not receive player combat foundations: %x %v", packet, err)
+ }
+ }
world.mutex.Lock()
client := world.clients[2]
- client.ready, client.loading = true, false
npc := world.characters[1000000]
npc.playfield, npc.health = world.characters[1].playfield, 100
npc.threat = map[uint32]int64{1: 5, 2: 10}
diff --git a/server/combat.go b/server/combat.go
@@ -45,7 +45,7 @@ func (server *server) handleCombat(client *worldClient, body []byte) error {
player.aggDef = value
stats := binary.BigEndian.AppendUint32(nil, 51)
stats = binary.BigEndian.AppendUint32(stats, uint32(value))
- updates[client] = append(updates[client], n3Packet(0x2b333d6e, 50000, player.id, stats))
+ server.queueCombat_locked(updates, player, player, n3Packet(0x2b333d6e, 50000, player.id, stats))
}
} else if key == 0x4a41203e || binary.BigEndian.Uint32(body[20:24]) == 0 {
server.stopAttack_locked(player, updates)
diff --git a/server/dialogue_test.go b/server/dialogue_test.go
@@ -174,6 +174,12 @@ func TestNPCConversationBelongsToItsWorldConnection(t *testing.T) {
readPacket(first) // The second player's spawn is broadcast to the first.
second.Write(targetPacket(n3Packet(0x570c2039, 50000, 2, nil)))
readPacket(first)
+ for _, stat := range []uint32{16, 17, 18, 19, 20, 21, 118, 119, 120, 149, 51} {
+ packet, err := readPacket(first)
+ if err != nil || binary.BigEndian.Uint32(packet[16:20]) != 0x2b333d6e || binary.BigEndian.Uint32(packet[24:28]) != 2 || binary.BigEndian.Uint32(packet[29:33]) != stat {
+ t.Fatalf("observer did not receive player combat foundations: %x %v", packet, err)
+ }
+ }
readPacket(second)
openIdaConversation(t, first)
diff --git a/server/main.go b/server/main.go
@@ -370,6 +370,7 @@ func (server *server) serveWorldClient(client *worldClient) error {
if id != character.id && other.playfield == character.playfield && server.clients[id] != nil {
updates = append(updates, characterPacket(other))
if !server.clients[id].loading {
+ updates = append(updates, playerCombatStatPackets(other)...)
updates = append(updates, equippedItemPackets(other)...)
updates = append(updates, activeNanoPackets(other, time.Now())...)
}
diff --git a/server/remote_combat_stats_test.go b/server/remote_combat_stats_test.go
@@ -0,0 +1,123 @@
+package main
+
+import (
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "testing"
+ "time"
+)
+
+func TestRemotePlayerSpawnCarriesUnmodifiedCombatFoundations(t *testing.T) {
+ for _, scenario := range []string{"joining loaded player", "joining loading player", "new player", "replacing player"} {
+ t.Run(scenario, func(t *testing.T) {
+ world, _ := newAggDefEquipmentWorld(t, 124210)
+ player := world.characters[1]
+ world.handleInventory(world.clients[1], inventoryMovePacket(1, 65, 6)[20:])
+ world.advanceEquipment(world.clients[1].equipment.readyAt)
+ player.stats.Abilities = characterAbilitiesStats{7, 11, 13, 17, 19, 23}
+ player.stats.Speed.MeleeInitiative, player.stats.Speed.RangedInitiative = 123, 0
+ player.stats.Speed.PhysicalInitiative, player.stats.Speed.NanoInitiative = 567, 1490
+ player.aggDef = -100
+ player.activeNanos = []activeNano{{program: 27169, caster: 1, expiresAt: time.Now().Add(time.Minute)}}
+ world.characters[2] = &character{id: 2, name: "Observer", playfield: 950, appearance: 277, level: 1, health: 100}
+ keyOffset, valueOffset := 20, 36
+ input := systemPacket(0x1b, []byte{0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0})
+ incoming := &combatInterestConn{}
+ observer := incoming
+ if scenario == "joining loading player" {
+ world.clients[1].loading = true
+ } else if scenario == "new player" || scenario == "replacing player" {
+ observer = &combatInterestConn{}
+ world.clients[2] = &worldClient{id: 2, conn: observer, ready: true, target: true}
+ if scenario == "new player" {
+ delete(world.clients, 1)
+ } else {
+ world.clients[1].conn = &combatInterestConn{}
+ }
+ keyOffset, valueOffset = 16, 29
+ input = systemPacket(0x1b, []byte{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0})
+ input = append(input, n3Packet(0x570c2039, 50000, 1, nil)...)
+ }
+ incoming.input = bytes.NewReader(input)
+
+ err := world.serveWorldClient(&worldClient{conn: incoming, loading: true})
+ if scenario == "joining loading player" {
+ for _, packet := range observer.packets {
+ if binary.BigEndian.Uint32(packet[20:]) == 0x2b333d6e && binary.BigEndian.Uint32(packet[28:]) == 1 {
+ t.Fatal("loading actor received foundations before its ready notification")
+ }
+ }
+ world.clients[2] = &worldClient{id: 2, conn: observer, ready: true}
+ err = world.handleCharacterReady(world.clients[1])
+ }
+ var values [][2]uint32
+ spawned, ready := false, false
+ for _, packet := range observer.packets {
+ if binary.BigEndian.Uint32(packet[keyOffset+8:]) != 1 {
+ continue
+ }
+ switch binary.BigEndian.Uint32(packet[keyOffset:]) {
+ case 0x271b3a6b:
+ spawned = true
+ case 0x570c2039:
+ ready = true
+ case 0x2b333d6e:
+ if !spawned || scenario != "joining loaded player" && !ready {
+ t.Fatal("foundation preceded its actor spawn or readiness")
+ }
+ values = append(values, [2]uint32{binary.BigEndian.Uint32(packet[valueOffset:]), binary.BigEndian.Uint32(packet[valueOffset+4:])})
+ case 0x3b1d2268, 0x35505644, 0x5e477770:
+ if len(values) != 11 {
+ t.Fatal("equipment or nano replay preceded raw combat foundations", values)
+ }
+ case 0x29304349:
+ t.Fatal("observer received the owner's private FullCharacter")
+ }
+ }
+
+ expected := [][2]uint32{{16, 7}, {17, 11}, {18, 13}, {19, 17}, {20, 19}, {21, 23},
+ {118, 123}, {119, 0}, {120, 567}, {149, 1490}, {51, 0xffffff9c}}
+ if err != nil || !spawned || !reflect.DeepEqual(values, expected) || player.equipmentBonus(51) != 5 || player.nanoBonus(16) != 12 {
+ t.Fatal("observer omitted, duplicated or derived a raw combat foundation", err, values)
+ }
+ })
+ }
+}
+
+func TestRemoteAggDefChangesReachOnlyReadySamePlayfieldObservers(t *testing.T) {
+ for _, value := range []int32{-100, -1, 0, 1, 100, -101, 101} {
+ t.Run(fmt.Sprint(value), func(t *testing.T) {
+ world, owner := newCombatWorld()
+ connections := []*combatTestConn{{}, {}, {}, {}}
+ for index, conn := range connections {
+ id := uint32(index + 2)
+ world.characters[id] = &character{id: id, playfield: 950, health: 100}
+ world.clients[id] = &worldClient{id: id, conn: conn, target: true, ready: true}
+ }
+ world.clients[3].ready = false
+ world.characters[4].playfield = 705
+ world.clients[5].loading = true
+ request := n3Packet(0x76793f0d, 50000, 1, binary.BigEndian.AppendUint32(nil, uint32(value)))
+
+ err := world.handleCombat(world.clients[1], request[20:])
+
+ valid := value >= -100 && value <= 100
+ for index, conn := range append([]*combatTestConn{owner}, connections...) {
+ expected := 0
+ if valid && (index == 0 || index == 1 || index == 4) {
+ expected = 1
+ }
+ if err != nil || len(conn.packets) != expected {
+ t.Fatal("slider replication reached the wrong session or zone", index, err, len(conn.packets), expected)
+ }
+ if expected == 1 && (binary.BigEndian.Uint32(conn.packets[0][16:]) != 0x2b333d6e ||
+ binary.BigEndian.Uint32(conn.packets[0][24:]) != 1 || binary.BigEndian.Uint32(conn.packets[0][29:]) != 51 ||
+ int32(binary.BigEndian.Uint32(conn.packets[0][33:])) != value) {
+ t.Fatal("slider replication changed the actor, stat or signed base value")
+ }
+ }
+ })
+ }
+}
diff --git a/server/resurrection_reconnect_test.go b/server/resurrection_reconnect_test.go
@@ -80,6 +80,7 @@ func TestResurrectionReconnectResumesPendingDeath(t *testing.T) {
t.Fatal("reconnect bypassed death or changed its committed outcome")
}
death, seenReady, seenFull := 0, false, false
+ var observerStats [][2]uint32
for _, packet := range packets {
switch binary.BigEndian.Uint32(packet[16:20]) {
case 0x5f52412e:
@@ -93,10 +94,20 @@ func TestResurrectionReconnectResumesPendingDeath(t *testing.T) {
}
death++
}
- case 0x445f2a0b, 0x43197d22, 0x2b333d6e:
+ case 0x2b333d6e:
+ if binary.BigEndian.Uint32(packet[24:28]) != 2 {
+ t.Fatalf("pending reconnect changed the dead player's stats: %x", packet)
+ }
+ observerStats = append(observerStats, [2]uint32{binary.BigEndian.Uint32(packet[29:33]), binary.BigEndian.Uint32(packet[33:37])})
+ case 0x445f2a0b, 0x43197d22:
t.Fatalf("pending reconnect replayed resurrection or a stat outcome: %x", packet)
}
}
+ expectedStats := [][2]uint32{{16, 6}, {17, 6}, {18, 6}, {19, 6}, {20, 6}, {21, 6},
+ {118, 5}, {119, 5}, {120, 5}, {149, 5}, {51, 0}}
+ if !reflect.DeepEqual(observerStats, expectedStats) {
+ t.Fatal("pending reconnect omitted or changed the other player's combat foundations", observerStats)
+ }
if death != 1 {
t.Fatalf("repeated ready produced %d death notifications", death)
}
diff --git a/server/roaming_test.go b/server/roaming_test.go
@@ -39,11 +39,19 @@ func TestRoamingIsSharedBoundedAndZoneScoped(t *testing.T) {
if player.id == 2 {
readPacket(clients[0])
}
- // Drain the ready broadcast to the first observer as well.
+ // Drain readiness and its combat foundations to the first observer as well.
var peer sync.WaitGroup
if player.id == 2 {
peer.Add(1)
- go func() { defer peer.Done(); readPacket(clients[0]) }()
+ go func() {
+ defer peer.Done()
+ for range 12 {
+ if _, err := readPacket(clients[0]); err != nil {
+ t.Error(err)
+ return
+ }
+ }
+ }()
}
client.Write(n3Packet(0x570c2039, 50000, player.id, nil))
if _, err := readPacket(client); err != nil {
diff --git a/server/target_protocol_test.go b/server/target_protocol_test.go
@@ -184,6 +184,12 @@ func TestTargetMovementIsPersistedAndRelayedToReleaseClient(t *testing.T) {
if id == 2 {
client.Write(targetPacket(n3Packet(0x570c2039, 50000, id, nil)))
readPacket(clients[0])
+ for _, stat := range []uint32{16, 17, 18, 19, 20, 21, 118, 119, 120, 149, 51} {
+ packet, err := readPacket(clients[0])
+ if err != nil || binary.BigEndian.Uint32(packet[20:24]) != 0x2b333d6e || binary.BigEndian.Uint32(packet[28:32]) != 2 || binary.BigEndian.Uint32(packet[36:40]) != stat {
+ t.Fatalf("observer did not receive player combat foundations: %x %v", packet, err)
+ }
+ }
readPacket(client)
}
ping := systemPacket(1, nil)
diff --git a/server/world.go b/server/world.go
@@ -174,6 +174,23 @@ func characterPacket(character *character) []byte {
return n3Packet(0x271b3a6b, 50000, character.id, body)
}
+func playerCombatStatPackets(character *character) [][]byte {
+ var packets [][]byte
+ stats := character.baseStats().nativeStats()
+ stats = append(stats, [2]uint32{51, uint32(character.aggDef)})
+ // Remote timing uses the same raw foundations as the owner's FullCharacter.
+ // Native getters derive trickle from these bases and separate wear/nano modifiers.
+ for _, stat := range stats {
+ switch stat[0] {
+ case 16, 17, 18, 19, 20, 21, 51, 118, 119, 120, 149:
+ body := binary.BigEndian.AppendUint32(nil, stat[0])
+ body = binary.BigEndian.AppendUint32(body, stat[1])
+ packets = append(packets, n3Packet(0x2b333d6e, 50000, character.id, body))
+ }
+ }
+ return packets
+}
+
func fullCharacterPacket(character *character) []byte {
// Version 16 begins with six encoded lists, followed by four stat lists.
body := binary.BigEndian.AppendUint32(nil, 16)
diff --git a/server/world_actions.go b/server/world_actions.go
@@ -34,15 +34,16 @@ func (server *server) handleCharacterReady(client *worldClient) error {
server.mutex.Unlock()
return nil
}
- // The observer's new actor must finish loading before OnWear is replayed.
+ // The observer's new actor must finish loading before stats and OnWear replay.
// Repeated ready messages acknowledge the actor without applying effects twice.
- var equipment [][]byte
+ var replay [][]byte
var team [][]byte
var death []byte
resources := make(map[*worldClient][][]byte)
if client.loading {
- equipment = equippedItemPackets(server.characters[client.id])
- equipment = append(equipment, activeNanoPackets(server.characters[client.id], time.Now())...)
+ replay = playerCombatStatPackets(server.characters[client.id])
+ replay = append(replay, equippedItemPackets(server.characters[client.id])...)
+ replay = append(replay, activeNanoPackets(server.characters[client.id], time.Now())...)
team = server.teamPackets_locked(client.id)
server.queueTeamResources_locked(resources, server.characters[client.id])
// Resume the native return request after a disconnect during death.
@@ -56,7 +57,7 @@ func (server *server) handleCharacterReady(client *worldClient) error {
response := n3Packet(0x570c2039, 50000, client.id, nil)
server.broadcast(playfield, client.id, response)
- for _, packet := range equipment {
+ for _, packet := range replay {
server.broadcast(playfield, client.id, packet)
}
server.sendCombatUpdates(resources)
diff --git a/server/world_output_test.go b/server/world_output_test.go
@@ -84,9 +84,13 @@ func TestWorldReplacementRemovesRemoteActorBeforeReplayingEquipment(t *testing.T
keys = append(keys, binary.BigEndian.Uint32(packet[16:20]))
}
- expected := []uint32{0x271b3a6b, 0x570c2039, 0x3b1d2268, 0x35505644, 0x570c2039, 0x36510078}
+ expected := []uint32{0x271b3a6b, 0x570c2039}
+ for range 11 {
+ expected = append(expected, 0x2b333d6e)
+ }
+ expected = append(expected, 0x3b1d2268, 0x35505644, 0x570c2039, 0x36510078)
if scenario == "visible previous session" {
- expected = []uint32{0x36510078, 0x271b3a6b, 0x570c2039, 0x3b1d2268, 0x35505644, 0x570c2039, 0x36510078}
+ expected = append([]uint32{0x36510078}, expected...)
}
if err != nil || !slices.Equal(keys, expected) {
t.Fatalf("replacement must discard cached OnWear effects before replay: %x, %v", keys, err)