Skip to content

Networking

Daniel Foerster edited this page Apr 11, 2018 · 1 revision

Overview

Networking is a huge pain in tmwA/ManaPlus, stuff is scattered all over. We should keep a common descriptor module to convert more friendly events to and from an efficient wire protocol. JSON may be used for the development protocol, but production will be better for using a custom HDED (high-density event description) format in the vein of tmwA. For speed we may use ENet (via pyenet) atop UDP, instead of TCP.

Stack diagram

Server Logic
    ⇅
Server Event System
    ⇅
Netevent Conversion Layer
    ⇅
ENet Code
    ⇅
Internet
    ⇅
ENet Code
    ⇅
Netevent Conversion Layer
    ⇅
Client Event System
    ⇅
Client Logic

Example HDED conversion

Uses an event description map and the struct library.

Packed unsigned short | Packed 32-bit unsigned int | Packed signed short | Packed signed short
----------------------+----------------------------+---------------------+--------------------
0x53 0x3F             | 0x00 0x00 0x41 0xD8        | 0xFB 0x4D           | 0x01 0xE2
----------------------+----------------------------+---------------------+--------------------
Python event name     | Being ID                   | X location          | Y location
----------------------+----------------------------+---------------------+--------------------
"being-moved"         | 16856                      | -1203               | 482
Clone this wiki locally