6 <wiki:toc max_depth="3" /> |
6 <wiki:toc max_depth="3" /> |
7 |
7 |
8 == Introduction == |
8 == Introduction == |
9 |
9 |
10 The frontend interacts with the engine in two separate occasions: |
10 The frontend interacts with the engine in two separate occasions: |
11 * map preview generation; |
11 * map preview generation; |
12 * game setup and statistics messages. |
12 * game setup and statistics messages. |
13 |
13 |
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). |
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). |
15 |
15 |
16 == Map preview == |
16 == Map preview == |
17 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. |
18 |
18 |
19 Files in which this protocol is implemented: [https://hg.hedgewars.org/hedgewars/file/default/QTfrontend/hwmap.cpp hwmapp.cpp], [https://hg.hedgewars.org/hedgewars/file/default/project_files/HedgewarsMobile/Classes/MapConfigViewController.m MapConfigViewController.m] |
19 Files in which this protocol is implemented: [https://hg.hedgewars.org/hedgewars/file/default/QTfrontend/hwmap.cpp hwmapp.cpp], [https://hg.hedgewars.org/hedgewars/file/default/project_files/HedgewarsMobile/Classes/MapConfigViewController.m MapConfigViewController.m] |
20 |
20 |
21 === Protocol === |
21 === Protocol === |
22 || *Frontend* || *Engine* || *Format* || |
22 || *Frontend* || *Engine* || *Format* || |
23 || Seed || || {{{eseed { ... }}}} || |
23 || UUID || || {{{eseed { ... }}}} || |
24 || Template Filter || || {{{e$template_filter N}}} || |
24 || Template Filter || || {{{e$template_filter N}}} || |
25 || Map Type || || {{{e$mapgen N}}} || |
25 || Map Type || || {{{e$mapgen N}}} || |
26 || Maze Value || || {{{e$maze_size N}}} || |
26 || Maze Value || || {{{e$maze_size N}}} || |
27 || || 128x32 byte array || {{{0YSD3 ... FSAD0}}} || |
27 || || 128×32 byte array || {{{0YSD3 ... FSAD0}}} || |
28 |
28 |
29 === Message format === |
29 === Message format === |
30 ==== Seed ==== |
30 ==== Seed ==== |
31 In the QT frontend, the seed is a UUID. |
31 In the Qt frontend, the seed is a UUID. |
32 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. |
32 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. |
33 |
33 |
34 This is however just due to convenience. UUIDs are not a particularly good source of entropy and any 1-249 character string can be used. For example. 人算不如天算 is a valid seed. |
34 This is however just due to convenience. UUIDs are not a particularly good source of entropy and any 1-249 character string can be used. For example “人算不如天算” is a valid seed. |
35 |
35 |
36 If the string is of the form AAAAAAAAA|BBBBB (2 pipe separated strings) then only AAAAAAAAA will be used for terrain generation while AAAAAAAAA|BBBBB will be used for everything else. This allows players to use keep a terrain they generated but change the rest of the seed to ensure new positions etc. |
36 If the string is of the form `AAAAAAAAA|BBBBB` (2 pipe separated strings) then only `AAAAAAAAA` will be used for terrain generation while `AAAAAAAAA|BBBBB` will be used for everything else. This allows players to use keep a terrain they generated but change the rest of the seed to ensure new positions etc. |
37 |
37 |
38 Example: _eseed {AERTB-62FASDSAD-NNIASDSADASD-12P}_ |
38 Example: `eseed {AERTB-62FASDSAD-NNIASDSADASD-12P}` |
39 |
39 |
40 ==== Template filter ==== |
40 ==== Template filter ==== |
41 _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. |
41 `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. |
42 |
42 |
43 || *Value* || *Filter Selected* || |
43 || *Value* || *Filter Selected* || |
44 || 0 || None || |
44 || 0 || None || |
45 || 1 || Large || |
45 || 1 || Large || |
46 || 2 || Medium || |
46 || 2 || Medium || |
47 || 3 || Small || |
47 || 3 || Small || |
48 || 4 || Cavern || |
48 || 4 || Cavern || |
49 || 5 || Wacky || |
49 || 5 || Wacky || |
50 |
50 |
51 Example: _e$template_filter 0_ |
51 Example: `e$template_filter 0` |
52 |
52 |
53 ==== Map type ==== |
53 ==== Map type ==== |
54 _N_ is a boolean variable (0/1) that selects standard map generation or maze map generation. |
54 `N` is a boolean variable (0/1) that selects standard map generation or maze map generation. |
55 |
55 |
56 || *Value* || *Map Type* || |
56 || *Value* || *Map Type* || |
57 || 0 || Standard Map || |
57 || 0 || Standard Map || |
58 || 1 || Maze Map || |
58 || 1 || Maze Map || |
59 |
59 |
60 Example: _e$mapgen 1_ |
60 Example: `e$mapgen 1` |
61 |
61 |
62 ==== Maze value ==== |
62 ==== Maze value ==== |
63 _N_ selects the type of maze selected, similarly to Template Filter |
63 `N` selects the type of maze selected, similarly to Template Filter. |
64 |
64 |
65 || *Value* || *Filter Selected* || |
65 || *Value* || *Filter Selected* || |
66 || 0 || Small Tunnels || |
66 || 0 || Small Tunnels || |
67 || 1 || Medium Tunnels || |
67 || 1 || Medium Tunnels || |
68 || 2 || Large Tunnels || |
68 || 2 || Large Tunnels || |
69 || 3 || Small Floating Islands || |
69 || 3 || Small Floating Islands || |
70 || 4 || Medium Floating Islands || |
70 || 4 || Medium Floating Islands || |
71 || 5 || Large Floating Islands || |
71 || 5 || Large Floating Islands || |
72 |
72 |
73 Example: _e$maze_size 4_ |
73 Example: `e$maze_size 4` |
74 |
74 |
75 ==== Image array ==== |
75 ==== Image array ==== |
76 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. |
76 The reply from engine is a 128×32 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. |
77 |
77 |
78 This image format is supported by many platforms, but it's very easy to parse anyways. The result is always a 256x128 pixel image. |
78 This image format is supported by many platforms, but it's very easy to parse anyways. The result is always a 256×128 pixel image. |
79 |
79 |
80 _No example needed_ |
80 _No example needed._ |
81 |
81 |
82 == In-game == |
82 == In-game == |
83 |
83 |
84 This doc needs more fleshing out, but in the interest of contributing, submitting an image I'd made after reading a GCI task. |
84 This document needs more fleshing out, but in the interest of contributing, submitting an image I'd made after reading a GCI task. |
85 [https://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). |
85 [https://hg.hedgewars.org/hedgewars/raw-file/default/doc/hwdemo.png HWD file] with a little colour markup of various interesting parts of the game. By the way, 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 to see why). |