EngineProtocol.wiki
changeset 745 99da4e68bc64
parent 592 2a5ecd20bf16
child 798 30c5f1ebd552
equal deleted inserted replaced
744:fb9cbe36ee52 745:99da4e68bc64
     1 #summary Protocol for frontend/engine interaction.
     1 #summary Protocol for frontend/engine interaction.
     2 #labels Documentation,Engine,Frontend,Protocol
     2 #labels Documentation,Engine,Frontend,Protocol
     3 
     3 
       
     4 = Engine protocol =
       
     5 
     4 <wiki:toc max_depth="3" />
     6 <wiki:toc max_depth="3" />
     5 
     7 
     6 = Introduction =
     8 == Introduction ==
     7 
     9 
     8 The frontend interacts with the engine in two separate occasions:
    10 The frontend interacts with the engine in two separate occasions:
     9   * map preview generation;
    11   * map preview generation;
    10   * game setup and statistics messages.
    12   * game setup and statistics messages.
    11 
    13 
    12 Messages are always in form of a string of bytes, and the first byte contains the message size (hence the maximum length is 255-1).
    14 Messages are always in form of a string of bytes, and the first byte contains the message size (hence the maximum length is 255-1).
    13 
    15 
    14 = Map Preview =
    16 == Map preview ==
    15 Frontend needs to generate a preview of the map that is going to be used in game; there is no handshaking.
    17 Frontend needs to generate a preview of the map that is going to be used in game; there is no handshaking.
    16 
    18 
    17 Files in which this protocol is implemented: [http://hg.hedgewars.org/hedgewars/file/default/QTfrontend/hwmap.cpp hwmapp.cpp], [http://hg.hedgewars.org/hedgewars/file/default/project_files/HedgewarsMobile/Classes/MapConfigViewController.m MapConfigViewController.m]
    19 Files in which this protocol is implemented: [http://hg.hedgewars.org/hedgewars/file/default/QTfrontend/hwmap.cpp hwmapp.cpp], [http://hg.hedgewars.org/hedgewars/file/default/project_files/HedgewarsMobile/Classes/MapConfigViewController.m MapConfigViewController.m]
    18 
    20 
    19 == Protocol ==
    21 === Protocol ===
    20 || *Frontend*      || *Engine*          || *Format*                  ||
    22 || *Frontend*      || *Engine*          || *Format*                  ||
    21 || UUID            ||                   || {{{eseed { ... }}}}       ||
    23 || UUID            ||                   || {{{eseed { ... }}}}       ||
    22 || Template Filter ||                   || {{{e$template_filter N}}} ||
    24 || Template Filter ||                   || {{{e$template_filter N}}} ||
    23 || Map Type        ||                   || {{{e$mapgen N}}}          ||
    25 || Map Type        ||                   || {{{e$mapgen N}}}          ||
    24 || Maze Value      ||                   || {{{e$maze_size N}}}       ||
    26 || Maze Value      ||                   || {{{e$maze_size N}}}       ||
    25 ||                 || 128x32 byte array || {{{0YSD3 ... FSAD0}}}     ||
    27 ||                 || 128x32 byte array || {{{0YSD3 ... FSAD0}}}     ||
    26 
    28 
    27 == Message Format ==
    29 === Message format ===
    28 === UUID ===
    30 ==== UUID ====
    29 The UUID is a 32 bytes array composed of ASCII characters; groups of letters should be separated by '-'. There are standard function calls to automatically generate this string depending on the tools used.
    31 The UUID is a 32 bytes array composed of ASCII characters; groups of letters should be separated by '-'. There are standard function calls to automatically generate this string depending on the tools used.
    30 
    32 
    31 Example: _eseed {AERTB-62FASDSAD-NNIASDSADASD-12P}_
    33 Example: _eseed {AERTB-62FASDSAD-NNIASDSADASD-12P}_
    32 
    34 
    33 === Template Filter ===
    35 ==== Template filter ====
    34 _N_ selects the type of map that is going to be generated. This command is ignored when MapGen is not 0, but it must be set anyways.
    36 _N_ selects the type of map that is going to be generated. This command is ignored when MapGen is not 0, but it must be set anyways.
    35 
    37 
    36 || *Value* || *Filter Selected* ||
    38 || *Value* || *Filter Selected* ||
    37 || 0       || None              ||
    39 || 0       || None              ||
    38 || 1       || Large             ||
    40 || 1       || Large             ||
    41 || 4       || Cavern            ||
    43 || 4       || Cavern            ||
    42 || 5       || Wacky             ||
    44 || 5       || Wacky             ||
    43 
    45 
    44 Example: _e$template_filter 0_
    46 Example: _e$template_filter 0_
    45 
    47 
    46 === Map Type ===
    48 ==== Map type ====
    47 _N_ is a boolean variable (0/1) that selects standard map generation or maze map generation.
    49 _N_ is a boolean variable (0/1) that selects standard map generation or maze map generation.
    48 
    50 
    49 || *Value* || *Map Type*   ||
    51 || *Value* || *Map Type*   ||
    50 || 0       || Standard Map ||
    52 || 0       || Standard Map ||
    51 || 1       || Maze Map     ||
    53 || 1       || Maze Map     ||
    52 
    54 
    53 Example: _e$mapgen 1_
    55 Example: _e$mapgen 1_
    54 
    56 
    55 === Maze Value ===
    57 ==== Maze value ====
    56 _N_ selects the type of maze selected, similarly to Template Filter
    58 _N_ selects the type of maze selected, similarly to Template Filter
    57 
    59 
    58 || *Value* || *Filter Selected*       ||
    60 || *Value* || *Filter Selected*       ||
    59 || 0       || Small Tunnels           ||
    61 || 0       || Small Tunnels           ||
    60 || 1       || Medium Tunnels          ||
    62 || 1       || Medium Tunnels          ||
    63 || 4       || Medium Floating Islands ||
    65 || 4       || Medium Floating Islands ||
    64 || 5       || Large Floating Islands  ||
    66 || 5       || Large Floating Islands  ||
    65 
    67 
    66 Example: _e$maze_size 4_
    68 Example: _e$maze_size 4_
    67 
    69 
    68 === Image Array ===
    70 ==== Image array ====
    69 The reply from engine is a 128x32 bytes array which contains the preview image in pixel-dot notation: every bit represents a pixel of the image, 1 is black, 0 i white. Clearly it can only contain a monochromatic image, but it can be colored by the rendering engine of the frontend.
    71 The reply from engine is a 128x32 bytes array which contains the preview image in pixel-dot notation: every bit represents a pixel of the image, 1 is black, 0 i white. Clearly it can only contain a monochromatic image, but it can be colored by the rendering engine of the frontend.
    70 
    72 
    71 This image format is supported by many platforms, but it's very easy to parse anyways. The result is always a 256x128 pixel image.
    73 This image format is supported by many platforms, but it's very easy to parse anyways. The result is always a 256x128 pixel image.
    72 
    74 
    73 _No example needed_
    75 _No example needed_
    74 
    76 
    75 = In-Game =
    77 == In-game ==
    76 
    78 
    77 This doc needs more fleshing out, but in the interest of contributing, submitting an image I'd made after reading a GCI task.
    79 This doc needs more fleshing out, but in the interest of contributing, submitting an image I'd made after reading a GCI task.
    78 [http://hg.hedgewars.org/hedgewars/raw-file/default/doc/hwdemo.png HWD file] with a little colour markup of various interesting parts of the game.  BTW, if you ever need to debug a crashing demo, appending 032BFF to the end is a good way to make sure the demo doesn't close too early (see the image for why).
    80 [http://hg.hedgewars.org/hedgewars/raw-file/default/doc/hwdemo.png HWD file] with a little colour markup of various interesting parts of the game.  BTW, if you ever need to debug a crashing demo, appending 032BFF to the end is a good way to make sure the demo doesn't close too early (see the image for why).