Session control, mesh leftovers, lobby values and card trade
Second part of “Session, mesh and lobby
layers under the battle protocol”: what was left
open there, read from PDUWP.exe. Nothing was
checked against a packet capture, so the best
grade is M (read in code);
dumped tables are H. Names are
ours. The summary and the capture checklist are
in converter/NETCOMPAT.md.
Session object and member table (M)
The game’s own session object is at 0x140594e70 (the member table 0x140595ea8 is its
- 0x1038):
| off | field |
|---|---|
| 0x00 | u32 role: 0 off, 2 member / not hosting (set by the initialiser 0x140125010), 3 host (0x140125150). The handlers also accept 1; nothing writes 1 |
| 0x08 | u32 open for joins (host; 1 on creation and on the return to the lobby 0x140187b70, rewritten by the start routine 0x140187e80 and by lobby script commands) |
| 0x0C | u32 real player ids (1 in this build: ids come from the platform; 0 would make ids from the address) |
| 0x10 | s32 own member id: −1 until accepted, 0 = host, 1..3 = joiners |
| 0x14 | u64 own platform user id, then u32 own flags word (0x14051d420 / 0x14051d428): the “player key”, 12 bytes |
| 0x20, 0x24 | u32, u32 “member table changed” marks (set by every add / leave) |
| 0x2C | s32 join result (below) |
| 0x30 | u32 maximum players: 2 or 4 (0x14051c0a4) |
| 0x34 | u32 member slots = maximum − 1 (the table holds the other members only) |
| 0x38 | u32 number of private (reserved) slots |
| 0x3C | u32 silence limit in session ticks: 150 (0x96, passed by 0x140190940) |
| 0x40 | u64 session id of the chosen session |
| 0x58 | 0x130: the host’s address block |
| 0x208 | 8 search results of 0x1C0 (a type 1 reply each) |
| 0x1010 / 0x1018 | game data callback: 0x140190c80 |
An address block is 0x130 bytes: {u32 length, u8[300] device address} (own one from 0x140281320).
Member record (0x298; completes the table of the first part):
| off | field |
|---|---|
| 0x00 | u32 in use |
| 0x04 | s32 member id (= net index 0..3) |
| 0x08 | s32 keep-alive countdown: 15 after every datagram sent to the member |
| 0x0C | s32 silence countdown: reloaded with 150 on every datagram received from the member |
| 0x10 | s32 ping countdown (15) |
| 0x18 | f64 the member’s echoed ping time (−2.0 until the first echo) |
| 0x20 | u32 holds a private slot |
| 0x24 | u32 no-voice flag |
| 0x28 | address block the datagrams are sent to (where its packets came from) |
| 0x158 | address block the member reported about itself (passed on to the others) |
| 0x288 | player key (u64 user id, u32 flags) |
Lookup by member id 0x1401266c0; add 0x140126740; a second table 0x140582900 (16 bytes per member id: player key, in-use) mirrors the keys for the platform side.
Session control messages (M; handler table H)
All are one datagram: mesh header (custom 0), then {u16 length = body + 6, u16 0x1200, u16 type, s16 sender’s member id}, then the body. Offsets below are from the start of the wrapper (body at 0x08). The generic sender is 0x140125560. On every received wrapper, whatever the type, the receiver reloads the silence countdown of the member whose id is in the wrapper (0x1401253ea).
| type | length word | datagram | sender | handler | meaning |
|---|---|---|---|---|---|
| 0 | – | – | none found | 0x140125cf0 | no effect (an old search broadcast) |
| 1 | 446 | 448 | 0x1401255e0 | 0x140125d10 | session description, the answer to type 9 |
| 2 | 330 | 332 | 0x140125950 | 0x140125d50 | join request |
| 3 | 22 | 24 | 0x140125a20 | 0x140125e40 | join reply: accepted with a member id, or refused |
| 4 | 6 | 8 | session tick 0x140126bd0 | 0x140125d40 | keep-alive (no body, no effect beyond the silence reload) |
| 5 | 326 | 328 | 0x140125810 | 0x140125f70 | member introduction (host → member, about another member) |
| 6 | 6 | 8 | 0x140126aa0, session tick | 0x140126080 | leave / “I dropped you” |
| 7 | – | – | none found | 0x140126100 | stores a body value in the silence countdown, which the common reload overwrites: no effect |
| 8 | game + 6 | – | 0x140125430 | game packet arrival | game data |
| 9 | – | – | none found | 0x140126160 | “describe your session”: a host answers type 1, or type 3 with a refusal |
| 10 | 22 | 24 | 0x140126260 | 0x1401261f0 | ping and its echo |
Type 2, join request (joiner → host address):
| off | type | field |
|---|---|---|
| 0x08 | s32 | sender’s member id (−1) |
| 0x0C | u32 | wants a private slot (0 from the session list; the invite / friend flag 0x14051d3a4 on a join by address) |
| 0x10 | 0x130 | the joiner’s own address block |
| 0x140 | u64, u32 | the joiner’s player key |
Type 3, join reply (host → the address the request came from):
| off | type | field |
|---|---|---|
| 0x08 | s32 | result: 1..3 = accepted, this is your member id; 5 = not hosting or closed; 6 = full; 7 = closed, sent only to a type 9 when the session’s flag + 0x188 is set |
| 0x0C | u64, u32 | the host’s player key |
Type 5, member introduction:
| off | type | field |
|---|---|---|
| 0x08 | s32 | member id of the member described |
| 0x0C | 0x130 | that member’s reported address block |
| 0x13C | u64, u32 | that member’s player key |
Type 10, ping: {f64 sender’s clock at 0x08, u32 flags at 0x10}. A receiver that knows the sender: flags bit 0 clear → sets bit 0 and sends the same 24 bytes back to where they came from; bit 0 set → stores the f64 in the member’s echoed-time field.
Type 1, session description (not needed for a join through the platform session; L field meanings): u64 session id at 0x08, the host’s address block, the host’s member id, flags, a count of members (in use + 1) and the session’s settings words, 0x1B8 body. The handler takes it only while searching (object + 4 = 2) and when its u64 equals the search’s own value (+ 0x1008); results are kept apart by their first 0x148 bytes.
The join, step by step:
- The joiner learns the host’s device address from the platform session, copies it into the session object (0x1401265b0; from a search result 0x1401264e0) and sends type 2 to it (0x140181210 on a join by address; 0x140184210 from the list). Join result (object + 0x2C) = 4 “waiting”. The request is sent once; the join-by-address path then waits 150 frames for the host to appear in its member table and gives up after that; the list path sets a 60-frame timer (L).
- The host (role 3, open): picks the lowest free member id (0x1401263b0; never its own id, so 1..3). Refuses with 6 when the public slots are used up (members without a private slot ≥ maximum − private slots − 1) unless the request asks for a private slot, or when no id is free; with 5 when it is not hosting or closed.
- On success the host adds the member (send address = where the request came from, reported address and key from the request), answers type 3 with the id, and then sends type 5 for every ordered pair of its members (0x140125ac0: to each member i, about each other member j), so the newcomer learns everyone and everyone learns the newcomer. This is repeated in full on every join; a receiver ignores a member it has.
- The joiner, on type 3 with 1..3: adds the host as member 0 (send address = where the reply came from, reported address = the stored host address, key from the reply) and takes the id as its own. Any other value is stored as the join result (the lobby script reads it through 0x140215dc0).
- On type 5 a member adds the described member with both address blocks = the reported one. The mesh then connects the two (endpoint pair, hello) and the lobby exchange of the first part starts as soon as game packets flow.
Staying in and leaving:
- The session tick 0x140126bd0 and the ping sender 0x140126260 run once per network update (0x140190bb0, from the per-frame update 0x14017cd00), after all waiting datagrams were read. Per member: the keep-alive countdown goes down by one; at 0 a type 4 goes out and it is 15 again (any game packet to the member also resets it, so type 4 only appears when nothing else is sent). The silence countdown goes down by one; at 0 the member is dropped: a type 6 is sent to it, its record is freed, the game hook 0x140191610 clears its lobby state and both “changed” marks are set. 150 ticks without any datagram from a member is therefore the drop rule (2.5 s at 60 updates per second; the update rate is L).
- Ping: while the application state 0x1404bbc60 is 12, every 15 ticks per member.
- Leave 0x140126aa0: a type 6 (no body) to every member, then all records are freed. A receiver of type 6 frees the sender’s record and runs the same game hook. Lobby message 21 makes every receiver run this leave itself (the session is over for all).
- Host choice: the host is whoever created the session: member id 0, never reassigned. There is no host migration in the game’s session layer: when member 0 leaves or times out its record is freed like any other, ids stay, and nobody takes over the host’s tasks (accepting joins, lobby types 2 / 5 / 6 / 9, the host settings in the player info). The lobby script can ask “is member 0 present” (0x1401842a0 through the command 0x140216040) and act on it (L: what the script does). On the platform side the session-changed handler 0x1400e89c0 handles a changed host device token and ends the session with an error when no new host can be named (L, not read line by line).
Mesh: resend and time-out, searched to the end (M)
- The pending list of flagged (0x8000) messages (manager + 0x28d8) has four users: add (0x140028a40), remove on acknowledge (0x14002a6a0), clear on shutdown (0x14003a060) and a “send all pending again” method 0x14002a540 (snapshot 0x14002a4b0, then the normal send for each). That method is reachable only through the component’s public interface (wrappers 0x14002a440, 0x14002eaa0); no timer or thread inside the mesh calls it. The game never flags a message, so the list stays empty and nothing is ever resent here.
- The two timer routines only send (endpoint retry every 1000 ms; hello / heartbeat every 2048 ms). The 2048 ms routine first removes connections whose device is no longer in the session’s member list (0x140038b30). There is no heartbeat time-out: received heartbeats only raise an event and feed statistics. A silent peer is dropped by the session layer’s 150-tick rule above and by the game layer’s countdowns.
Lobby values that were open (M unless noted)
- Player info 0x38 / 0x3C (host only): the session’s free private slots (0x14051ede0) and free public slots (0x14050e13c), recounted by 0x1401832a0 after every member change: public = maximum − private total (0x140519ab8) − members without a private slot (the host counts as one); private = private total − members holding one. Two script commands move a slot between the kinds while one is free (0x140213e60 / 0x140213e90). Clients only display them.
- Player info 0x18, the 64-bit value: the sender’s 0x14051c0b0, a counter of its save clamped to 0..999 999 by its only adder (0x1401835c0) and also reported to the platform statistics (0x1400bf1f0); when the lobby flag 0x1405277d0 is set, the entry of the table 0x1405277d8 (built by 0x1401880f0) for the own index instead. The script reads it per player (0x140213a20). L for the name (points or credits shown in the lobby).
- Player info 0x20, the menu choice: an integer the lobby script sets for the own player (command 0x140213b80; also raises the “changed” marks so it is sent again) and reads for any player (0x140213a10); −1 = none. The exe gives it no meaning; the host packs all four into the start table. Its meaning is in the lobby script (L; lead: the script that calls the command at 0x140213b80).
- Lobby type 4: no sender in this build (the lobby tick is only ever called with forced type 10 or none), and the mark its handler sets is never read. Ignore it.
- Lobby counter: 0x1405277c0 goes up by one in the phase tick 0x140187460, which is a script command (its address is in the script command table) run by the lobby script once per script frame; the lobby tick sends on every 3rd count. Phase handlers: table 0x1403e83d8, 9 entries of {tick, enter} (H). The frames per second of the lobby script are L (not measured).
Card trade, lobby types 11..20 (M flow, L for the card routines)
A trade is its own session kind (session game type 11, 0x140527ab8), two players: role 1 = the creator (0x140185990, 0x140219a70), role 2 = the joiner (0x140186380, 0x140115a80). Every handler first checks the own role and the trade state 0x140527abc, so a peer whose role is 0 ignores all ten types: declining needs no message. A compatible peer declines by never creating or joining a session of game type 11.
All trade packets are bare 0x18 headers; the creator’s offer flag rides in the header’s net index field of type 13. Repeats are every 10th tick; timers (0x140527ab4) in ticks.
| type | from → to | sent | effect on the receiver |
|---|---|---|---|
| 11 | joiner → creator | every 10 ticks in state 2 once the creator’s info is in (0x140192330) | creator 2 → 3; answers 16 to all |
| 16 | creator | answer to 11 | joiner 2 → 3, timer 900 (choosing) |
| 13 | creator → joiner | every 10 ticks in state 4 (0x1401923a0), header + 8 = offer flag 0x140527ab0 | joiner (state ≥ 3): flag set → state 5 and the cards are put up (0x140185170), else state 4; answers 18 |
| 18 | joiner | answer to 13 | creator in 4: offer flag set → 5 (timer 150), else 9 |
| 14 | joiner → creator | every 10 ticks in state 5 until 19 arrives | creator 5 → 6, timer 450, its card put up (0x140185170); answers 19 |
| 19 | creator | answer to 14 | joiner in 5: latch 0x1405279fc; its timer then runs to state 6 |
| 15 | joiner → creator | every 10 ticks in state 6 | creator (no save running) 6 → 7, the exchange is written (0x140185240); answers 20 |
| 20 | creator | answer to 15 | joiner 6 → 7, the exchange is written |
| 12, 17 | – | – | empty handlers |
States: 1 idle, 2 waiting for the partner, 3 choosing, 4 offer shown, 5 agreed, 6 committing, 7 done, 8 / 9 cancelled or failed (a timer ran out, the partner (member 1) left, or the offer was withdrawn). Ticks: creator 0x140192050, joiner 0x1401921c0.
Battle leftovers (M)
Message 7 (stage object event), bytes 0x10..0x12: 0x10 = the number of hits this event takes from the object’s hit counter (the writers send 1; the receiver subtracts it from object + 0x4E and breaks the object when the counter would reach 0); 0x11 = the contact’s second byte (the surface / material code of the hit, copied into the contact the receiver rebuilds); 0x12 = the hitting body’s answer to its “kind of hit” query (virtual + 8), passed on as the last argument of the break wrapper 0x1401fdc60 and of the object’s hit reaction (virtual + 0xE8); it is the same flag as byte 0x12 of message 6. Local writer site 0x1401fd780; codes 0x45 / 0x46 are sent only in game modes 4 and 5 for objects with net flags (+ 0x100) set.
Message 22, first value: the sender’s C + 0x60, set at match set-up from 0x1404bc8c0 (0 on reset). The receiver, for a remote body only, runs 0x140250480: it stores the value in the remote body’s C + 0x60, marks C + 0x171a8, puts the body at its start point and remakes a per-player resource from (player, this value, C + 0x58) through 0x14019e430. So it is a per-player set-up choice that the others need before the first frame. L for the name (lead: what fills 0x1404bc8c0).
Position message 0x1C / 0x1E: both are character effect ids (the id space of the character effect spawner 0x14018d2f0, attach mode 4 at the body point C + 0x12f00 + 0xBE0, marked looping). A (0x1C): up to two instances (handles + 0xC38, + 0xC3C), started locally from 0x14025c734; B (0x1E): one instance (+ 0xC44), started locally by skill code at 0x140270b00. Neither is a sound cue.
Skill object net class and flags (who sets 0x1000): in game modes 4 and 5 the flag routine 0x14026e860 (called when an object is made, 0x140263a00, 0x14026d15b) gives every skill object a net class at + 0x28 and flags at + 0x24:
class which objects 1 skill record field 0x52 ≠ 0; or, with 0x52 = 0, kinds 4, 7, 9, 0xA, 0xF, 0x10, 0x14, and kind 8 with field 0x7C = 0 5 kinds 3, 0xC, 0xD, 0xE (0x52 = 0) 3 kind 8 with field 0x7C ≠ 0 2 every other object that has an owner body (+ 0x48) 4 every other object without one flag set for 0x200 every class 0x400 when 0x14026ec50 says so (by class; local owner / local player tests) 0x800 class 2 only with a local owner; all other classes always 0x1000 (announce my end, message 5) class 2 with a local owner; classes 3 and 4 always; class 5 with a local owner (the separate setter 0x14026f4b6); never classes 0, 1 0x2000 (wait for the owner’s word) class 2 with no or a remote owner; class 3; class 4 when its player (+ 0x40) is remote; class 5 0x4000 (take anyone’s word) class 2 with no or a remote owner; class 3; class 4 when its player is local; class 5 0x8000 class 2 with no or a local owner; all other classes “Local” = the player object’s flag + 0x34 is non-zero. The two setters of 0x1000 are 0x14026eaed (this table) and 0x14026f4b6 (class 5); a search of the skill object code found no third (M).
Implementation notes for the rebuild
- Join as a client: after the mesh hello with the host, send one type 2 (own address block, player key, private-slot wish); expect type 3 with the own member id 1..3 or a refusal 5 / 6; add member 0; then accept type 5 introductions and connect to each. Put the own member id in the wrapper of every datagram from then on.
- Host: answer type 2 with the lowest free id or 5 / 6, then send type 5 for every ordered pair of members; answer a type 9 with type 3 (5 / 6 / 7) at least.
- Per member: reload a 150-tick silence countdown on every datagram; send type 4 after 15 ticks without sending; answer a type 10 whose flag bit 0 is clear by echoing it with the bit set; on type 6 or silence free the member and clear its lobby state.
- Leaving: type 6 to every member. No host migration: when member 0 goes, treat the session as over (return to the lobby list).
- Mesh: answer flagged messages; never expect a resend or a heartbeat time-out.
- Player info: host fills 0x38 / 0x3C with free private / public slots; 0x18 with the save’s counter; 0x20 with the script’s choice (−1 until known). Ignore lobby type 4.
- Card trade: never enter a game type 11 session; ignore types 11..20.
- Skill objects need the net class table to decide whose word ends an object; position fields 0x1C / 0x1E are looping character effects to start / stop on change.