author | celestar |
Fri, 23 Feb 2007 08:37:33 +0000 | |
changeset 6121 | 2aae24b0881f |
parent 5870 | 5056f5b1d16a |
permissions | -rw-r--r-- |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
2 |
|
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
3 |
/** |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
4 |
* @file udp.h Basic functions to receive and send UDP packets. |
5545
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
5 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
6 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
7 |
* *** Requesting game information from a server *** |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
8 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
9 |
* This describes the on-the-wire structure of the request and reply |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
10 |
* packet of the NetworkGameInfo (see game.h) data. |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
11 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
12 |
* --- Points of attention --- |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
13 |
* - all > 1 byte integral values are written in little endian, |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
14 |
* unless specified otherwise. |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
15 |
* Thus, 0x01234567 would be sent as {0x67, 0x45, 0x23, 0x01}. |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
16 |
* - all sent strings are of variable length and terminated by a '\0'. |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
17 |
* Thus, the length of the strings is not sent. |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
18 |
* - years that are leap years in the 'days since X' to 'date' calculations: |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
19 |
* (year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0)) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
20 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
21 |
* --- Request --- |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
22 |
* Bytes: Description: |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
23 |
* 2 size of the whole packet, in this case 3 |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
24 |
* 1 type of packet, in this case PACKET_UDP_CLIENT_FIND_SERVER (0) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
25 |
* This packet would look like: { 0x03, 0x00, 0x00 } |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
26 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
27 |
* --- Reply --- |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
28 |
* Version: Bytes: Description: |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
29 |
* all 2 size of the whole packet |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
30 |
* all 1 type of packet, in this case PACKET_UDP_SERVER_RESPONSE (1) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
31 |
* all 1 the version of this packet's structure |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
32 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
33 |
* 4+ 1 number of GRFs attached (n) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
34 |
* 4+ n * 20 unique identifier for GRF files. Constists of: |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
35 |
* - one 4 byte variable with the GRF ID |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
36 |
* - 16 bytes (sent sequentially) for the MD5 checksum |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
37 |
* of the GRF |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
38 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
39 |
* 3+ 4 current game date in days since 1-1-0 (DMY) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
40 |
* 3+ 4 game introduction date in days since 1-1-0 (DMY) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
41 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
42 |
* 2+ 1 maximum number of companies allowed on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
43 |
* 2+ 1 number of companies on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
44 |
* 2+ 1 maximum number of spectators allowed on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
45 |
* |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
46 |
* 1+ var string with the name of the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
47 |
* 1+ var string with the revision of the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
48 |
* 1+ 1 the language run on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
49 |
* (0 = any, 1 = English, 2 = German, 3 = French) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
50 |
* 1+ 1 whether the server uses a password (0 = no, 1 = yes) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
51 |
* 1+ 1 maximum number of clients allowed on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
52 |
* 1+ 1 number of clients on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
53 |
* 1+ 1 number of spectators on the server |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
54 |
* 1 & 2 2 current game date in days since 1-1-1920 (DMY) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
55 |
* 1 & 2 2 game introduction date in days since 1-1-1920 (DMY) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
56 |
* 1+ var string with the name of the map |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
57 |
* 1+ 2 width of the map in tiles |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
58 |
* 1+ 2 height of the map in tiles |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
59 |
* 1+ 1 type of map: |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
60 |
* (0 = temperate, 1 = arctic, 2 = desert, 3 = toyland) |
8e8564046cff
(svn r7888) -Change: add documentation about the 'on-the-wire' structure of the network game information request and reply packets.
rubidium
parents:
5528
diff
changeset
|
61 |
* 1+ 1 whether the server is dedicated (0 = no, 1 = yes) |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
62 |
*/ |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
63 |
|
6121
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
64 |
#ifndef NETWORK_CORE_UDP_H |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
65 |
#define NETWORK_CORE_UDP_H |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
66 |
|
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
67 |
#ifdef ENABLE_NETWORK |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
68 |
|
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
69 |
#include "os_abstraction.h" |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
70 |
#include "core.h" |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
71 |
#include "game.h" |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
72 |
#include "packet.h" |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
73 |
#include "../../debug.h" |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5870
diff
changeset
|
74 |
|
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
75 |
/** Enum with all types of UDP packets. The order MUST not be changed **/ |
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
76 |
enum PacketUDPType { |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
77 |
PACKET_UDP_CLIENT_FIND_SERVER, ///< Queries a game server for game information |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
78 |
PACKET_UDP_SERVER_RESPONSE, ///< Reply of the game server with game information |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
79 |
PACKET_UDP_CLIENT_DETAIL_INFO, ///< Queries a game server about details of the game, such as companies |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
80 |
PACKET_UDP_SERVER_DETAIL_INFO, ///< Reply of the game server about details of the game, such as companies |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
81 |
PACKET_UDP_SERVER_REGISTER, ///< Packet to register itself to the master server |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
82 |
PACKET_UDP_MASTER_ACK_REGISTER, ///< Packet indicating registration has succedeed |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
83 |
PACKET_UDP_CLIENT_GET_LIST, ///< Request for serverlist from master server |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
84 |
PACKET_UDP_MASTER_RESPONSE_LIST, ///< Response from master server with server ip's + port's |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
85 |
PACKET_UDP_SERVER_UNREGISTER, ///< Request to be removed from the server-list |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
86 |
PACKET_UDP_CLIENT_GET_NEWGRFS, ///< Requests the name for a list of GRFs (GRF_ID and MD5) |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
87 |
PACKET_UDP_SERVER_NEWGRFS, ///< Sends the list of NewGRF's requested. |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
88 |
PACKET_UDP_END ///< Must ALWAYS be on the end of this list!! (period) |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
89 |
}; |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
90 |
|
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
91 |
#define DECLARE_UDP_RECEIVE_COMMAND(type) virtual void NetworkPacketReceive_## type ##_command(Packet *p, const struct sockaddr_in *) |
5861
afa0676eedf5
(svn r8437) -Codechange: move often duplicated (in MSU) define to the udp header.
rubidium
parents:
5765
diff
changeset
|
92 |
#define DEF_UDP_RECEIVE_COMMAND(cls, type) void cls ##NetworkUDPSocketHandler::NetworkPacketReceive_ ## type ## _command(Packet *p, const struct sockaddr_in *client_addr) |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
93 |
|
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5619
diff
changeset
|
94 |
/** Base socket handler for all UDP sockets */ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5619
diff
changeset
|
95 |
class NetworkUDPSocketHandler : public NetworkSocketHandler { |
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
96 |
protected: |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5619
diff
changeset
|
97 |
NetworkRecvStatus CloseConnection(); |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5619
diff
changeset
|
98 |
|
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
99 |
/* Declare all possible packets here. If it can be received by the |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
100 |
* a specific handler, it has to be implemented. */ |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
101 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_FIND_SERVER); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
102 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
103 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
104 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_DETAIL_INFO); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
105 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_REGISTER); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
106 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_ACK_REGISTER); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
107 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_GET_LIST); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
108 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
109 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_UNREGISTER); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
110 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_GET_NEWGRFS); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
111 |
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
112 |
|
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
113 |
void HandleUDPPacket(Packet *p, const struct sockaddr_in *client_addr); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
114 |
|
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
115 |
/** |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
116 |
* Function that is called for every GRFConfig that is read when receiving |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
117 |
* a NetworkGameInfo. Only grfid and md5sum are set, the rest is zero. This |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
118 |
* function must set all appropriate fields. This GRF is later appended to |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
119 |
* the grfconfig list of the NetworkGameInfo. |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
120 |
* @param config the GRF to handle |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
121 |
*/ |
5865
4d8c2e5ad9fb
(svn r8446) -Fix (8445): accidentally made a function that should not be abstract abstract.
rubidium
parents:
5864
diff
changeset
|
122 |
virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { NOT_REACHED(); } |
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
123 |
public: |
5864
a95a2849b0e1
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
rubidium
parents:
5861
diff
changeset
|
124 |
/** On destructing of this class, the socket needs to be closed */ |
5619
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
125 |
virtual ~NetworkUDPSocketHandler() { this->Close(); } |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
126 |
|
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
127 |
bool Listen(uint32 host, uint16 port, bool broadcast); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
128 |
void Close(); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
129 |
|
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
130 |
void SendPacket(Packet *p, const struct sockaddr_in *recv); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
131 |
void ReceivePackets(); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
132 |
|
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
133 |
void Send_NetworkGameInfo(Packet *p, const NetworkGameInfo *info); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
134 |
void Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *info); |
9f5a7152403a
(svn r8078) -Codechange: rewrite UDP part of the network code to make use classes. This is only one of the many steps to really cleanup the network code.
rubidium
parents:
5545
diff
changeset
|
135 |
}; |
5469
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
136 |
|
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
137 |
#endif /* ENABLE_NETWORK */ |
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
138 |
|
7edfc643abbc
(svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents:
diff
changeset
|
139 |
#endif /* NETWORK_CORE_UDP_H */ |