10 #include "packet.h" |
10 #include "packet.h" |
11 #include "../../newgrf_config.h" |
11 #include "../../newgrf_config.h" |
12 |
12 |
13 /** |
13 /** |
14 * @file udp.h Basic functions to receive and send UDP packets. |
14 * @file udp.h Basic functions to receive and send UDP packets. |
|
15 * |
|
16 * |
|
17 * *** Requesting game information from a server *** |
|
18 * |
|
19 * This describes the on-the-wire structure of the request and reply |
|
20 * packet of the NetworkGameInfo (see game.h) data. |
|
21 * |
|
22 * --- Points of attention --- |
|
23 * - all > 1 byte integral values are written in little endian, |
|
24 * unless specified otherwise. |
|
25 * Thus, 0x01234567 would be sent as {0x67, 0x45, 0x23, 0x01}. |
|
26 * - all sent strings are of variable length and terminated by a '\0'. |
|
27 * Thus, the length of the strings is not sent. |
|
28 * - years that are leap years in the 'days since X' to 'date' calculations: |
|
29 * (year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0)) |
|
30 * |
|
31 * --- Request --- |
|
32 * Bytes: Description: |
|
33 * 2 size of the whole packet, in this case 3 |
|
34 * 1 type of packet, in this case PACKET_UDP_CLIENT_FIND_SERVER (0) |
|
35 * This packet would look like: { 0x03, 0x00, 0x00 } |
|
36 * |
|
37 * --- Reply --- |
|
38 * Version: Bytes: Description: |
|
39 * all 2 size of the whole packet |
|
40 * all 1 type of packet, in this case PACKET_UDP_SERVER_RESPONSE (1) |
|
41 * all 1 the version of this packet's structure |
|
42 * |
|
43 * 4+ 1 number of GRFs attached (n) |
|
44 * 4+ n * 20 unique identifier for GRF files. Constists of: |
|
45 * - one 4 byte variable with the GRF ID |
|
46 * - 16 bytes (sent sequentially) for the MD5 checksum |
|
47 * of the GRF |
|
48 * |
|
49 * 3+ 4 current game date in days since 1-1-0 (DMY) |
|
50 * 3+ 4 game introduction date in days since 1-1-0 (DMY) |
|
51 * |
|
52 * 2+ 1 maximum number of companies allowed on the server |
|
53 * 2+ 1 number of companies on the server |
|
54 * 2+ 1 maximum number of spectators allowed on the server |
|
55 * |
|
56 * 1+ var string with the name of the server |
|
57 * 1+ var string with the revision of the server |
|
58 * 1+ 1 the language run on the server |
|
59 * (0 = any, 1 = English, 2 = German, 3 = French) |
|
60 * 1+ 1 whether the server uses a password (0 = no, 1 = yes) |
|
61 * 1+ 1 maximum number of clients allowed on the server |
|
62 * 1+ 1 number of clients on the server |
|
63 * 1+ 1 number of spectators on the server |
|
64 * 1 & 2 2 current game date in days since 1-1-1920 (DMY) |
|
65 * 1 & 2 2 game introduction date in days since 1-1-1920 (DMY) |
|
66 * 1+ var string with the name of the map |
|
67 * 1+ 2 width of the map in tiles |
|
68 * 1+ 2 height of the map in tiles |
|
69 * 1+ 1 type of map: |
|
70 * (0 = temperate, 1 = arctic, 2 = desert, 3 = toyland) |
|
71 * 1+ 1 whether the server is dedicated (0 = no, 1 = yes) |
15 */ |
72 */ |
16 |
73 |
17 ///** Sending/receiving of UDP packets **//// |
74 ///** Sending/receiving of UDP packets **//// |
18 |
75 |
19 bool NetworkUDPListen(SOCKET *udp, const uint32 host, const uint16 port, const bool broadcast); |
76 bool NetworkUDPListen(SOCKET *udp, const uint32 host, const uint16 port, const bool broadcast); |