Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SAddSpell (0x17)

Previous: SMapInfo | Server action index | Next: SRemoveSpell

SAddSpell is server-to-client action 0x17 in the 4.21 protocol.

Direction: server to client

Encrypted: Yes. See Sequence and XOR Transformation.

Payload offsets begin with the first byte after the action. The frame marker, frame length, action, sequence, and trailing zero are excluded.

Payload format

OffsetWidthFieldEstablished meaning
0x001slot1-based spell inventory slot, valid range 1 through 36.
0x012display_idBig-endian display identifier retained by the slot pane.
0x031spell_typeSigned byte in the established range 1 through 8; selects the client activation path.
0x041name_lengthNumber of following spell-name bytes.
0x05name_lengthnameSpell name bytes. There is no terminator in the packet; the client appends one.
0x05 + name_length1comment_lengthNumber of following comment bytes.
0x06 + name_lengthcomment_lengthcommentSpell comment bytes. There is no terminator in the packet; the client appends one.
0x06 + name_length + comment_length1unknown_06_plus_name_length_plus_comment_lengthTrailing byte retained at slot pane +0x1F9 and passed to SpellBookDialog.

The payload occupies 7 + name_length + comment_length bytes. The string encoding and trailing-byte meaning are not established by this parser. ui_spell_inventory_apply_add_packet explicitly checks the slot range but does not compare either string length with the remaining decoded packet size before copying. The downstream constructor asserts that each NUL-terminated string is shorter than 128 bytes and that spell_type is 1 through 8.

Handler functions

Function addressCurrent IDA nameRole
Darkages.exe:0x00443B10ui_spell_inventory_handle_server_packetAccepts the action in its pane’s Event type 9 packet handler.
Darkages.exe:0x00443BB4ui_spell_inventory_apply_add_packetParses the fields and replaces the indexed slot child.
Darkages.exe:0x00443E14ui_spell_inventory_remove_slot_paneRemoves and deletes an existing slot child.
Darkages.exe:0x00443F24ui_spell_inventory_create_slot_paneAllocates and registers a 0x214-byte slot pane.
Darkages.exe:0x00456C70ui_spell_slot_pane_ctorRetains the slot, display ID, type, strings, and trailing byte.
Darkages.exe:0x004889F0ui_local_user_handle_server_packetAccepts the action in the local-user Pane’s Event type 9 packet handler.

Handler notes

ui_spell_inventory_apply_add_packet parses the action-bearing decoded packet at offsets +1 onward, corresponding to the payload table above. It rejects a slot outside 1 through 36. For a valid slot, it removes any existing pane, allocates a 0x214-byte spell slot pane, and adds and registers it below the spell inventory owner. Darkages.exe:0x004889F0 also observes this action in its own registered pane context.

UI behavior

This action changes the spell inventory’s child panes but does not select or show the persistent spell inventory. The player selects that parent locally with D or its game button. Right-button up over a populated slot opens SpellBookDialog without another server request.

The parent owns a 36-entry pointer array and the child retains all packet-derived state at stable offsets. See Runtime UI Memory Map and UI, Input, and Packet Flows.