OpenTTD Source: src/network/core/tcp_game.h Source File

OpenTTD Source 15.3

tcp_game.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
12#ifndef NETWORK_CORE_TCP_GAME_H
13#define NETWORK_CORE_TCP_GAME_H
14
15#include "os_abstraction.h"
16#include "tcp.h"
17#include "../network_type.h"
18#include <chrono>
19
24 enum PacketGameType : uint8_t {
25 /*
26 * These first ten packets must remain in this order for backward and forward compatibility
27 * between clients that are trying to join directly. These packets can be received and/or sent
28 * by the server before the server has processed the 'join' packet from the client.
29 */
30
31 /* Packets sent by socket accepting code without ever constructing a client socket instance. */
32 PACKET_SERVER_FULL,
33 PACKET_SERVER_BANNED,
34
35 /* Packets used by the client to join and an error message when the revision is wrong. */
36 PACKET_CLIENT_JOIN,
37 PACKET_SERVER_ERROR,
38
39 /* Unused packet types, formerly used for the pre-game lobby. */
40 PACKET_CLIENT_UNUSED,
41 PACKET_SERVER_UNUSED,
42
43 /* Packets used to get the game info. */
44 PACKET_SERVER_GAME_INFO,
45 PACKET_CLIENT_GAME_INFO,
46
47 /* A server quitting this game. */
48 PACKET_SERVER_NEWGAME,
49 PACKET_SERVER_SHUTDOWN,
50
51 /*
52 * Packets after here assume that the client
53 * and server are running the same version. As
54 * such ordering is unimportant from here on.
55 *
56 * The following is the remainder of the packets
57 * sent as part of authenticating and getting
58 * the map and other important data.
59 */
60
61 /* After the join step, the first perform game authentication and enabling encryption. */
62 PACKET_SERVER_AUTH_REQUEST,
63 PACKET_CLIENT_AUTH_RESPONSE,
64 PACKET_SERVER_ENABLE_ENCRYPTION,
65
66 /* After the authentication is done, the next step is identification. */
67 PACKET_CLIENT_IDENTIFY,
68
69 /* After the identify step, the next is checking NewGRFs. */
70 PACKET_SERVER_CHECK_NEWGRFS,
71 PACKET_CLIENT_NEWGRFS_CHECKED,
72
73 /* The server welcomes the authenticated client and sends information of other clients. */
74 PACKET_SERVER_WELCOME,
75 PACKET_SERVER_CLIENT_INFO,
76
77 /* Getting the savegame/map. */
78 PACKET_CLIENT_GETMAP,
79 PACKET_SERVER_WAIT,
80 PACKET_SERVER_MAP_BEGIN,
81 PACKET_SERVER_MAP_SIZE,
82 PACKET_SERVER_MAP_DATA,
83 PACKET_SERVER_MAP_DONE,
84 PACKET_CLIENT_MAP_OK,
85
86 PACKET_SERVER_JOIN,
87
88 /*
89 * At this moment the client has the map and
90 * the client is fully authenticated. Now the
91 * normal communication starts.
92 */
93
94 /* Game progress monitoring. */
95 PACKET_SERVER_FRAME,
96 PACKET_CLIENT_ACK,
97 PACKET_SERVER_SYNC,
98
99 /* Sending commands around. */
100 PACKET_CLIENT_COMMAND,
101 PACKET_SERVER_COMMAND,
102
103 /* Human communication! */
104 PACKET_CLIENT_CHAT,
105 PACKET_SERVER_CHAT,
106 PACKET_SERVER_EXTERNAL_CHAT,
107
108 /* Remote console. */
109 PACKET_CLIENT_RCON,
110 PACKET_SERVER_RCON,
111
112 /* Moving a client.*/
113 PACKET_CLIENT_MOVE,
114 PACKET_SERVER_MOVE,
115
116 /* Configuration updates. */
117 PACKET_CLIENT_SET_NAME,
118 PACKET_SERVER_CONFIG_UPDATE,
119
120 /* A client quitting. */
121 PACKET_CLIENT_QUIT,
122 PACKET_SERVER_QUIT,
123 PACKET_CLIENT_ERROR,
124 PACKET_SERVER_ERROR_QUIT,
125
126 PACKET_END,
127};
128
130struct CommandPacket;
131
137 using CommandQueue = std::vector<CommandPacket>;
138
140 class NetworkGameSocketHandler : public NetworkTCPSocketHandler {
141/* TODO: rewrite into a proper class */
142private:
143 NetworkClientInfo *info = nullptr;
144 bool is_pending_deletion = false;
145
146protected:
147 NetworkRecvStatus ReceiveInvalidPacket(PacketGameType type);
148
153 virtual NetworkRecvStatus Receive_SERVER_FULL(Packet &p);
154
159 virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet &p);
160
172 virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet &p);
173
179 virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet &p);
180
185 virtual NetworkRecvStatus Receive_CLIENT_GAME_INFO(Packet &p);
186
192 virtual NetworkRecvStatus Receive_SERVER_GAME_INFO(Packet &p);
193
202 virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet &p);
203
210 virtual NetworkRecvStatus Receive_CLIENT_IDENTIFY(Packet &p);
211
219 virtual NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p);
220
228 virtual NetworkRecvStatus Receive_CLIENT_AUTH_RESPONSE(Packet &p);
229
236 virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p);
237
243 virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p);
244
249 virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet &p);
250
256 virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet &p);
257
263 virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet &p);
264
270 virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet &p);
271
277 virtual NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet &p);
278
283 virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet &p);
284
289 virtual NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet &p);
290
296 virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet &p);
297
307 virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet &p);
308
316 virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet &p);
317
324 virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet &p);
325
335 virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet &p);
336
347 virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet &p);
348
358 virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet &p);
359
368 virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet &p);
369
378 virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet &p);
379
385 virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet &p);
386
391 virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet &p);
392
398 virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet &p);
399
405 virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet &p);
406
413 virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet &p);
414
419 virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet &p);
420
425 virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet &p);
426
433 virtual NetworkRecvStatus Receive_SERVER_RCON(Packet &p);
434
441 virtual NetworkRecvStatus Receive_CLIENT_RCON(Packet &p);
442
450 virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet &p);
451
456 virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet &p);
457
464 virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet &p);
465
471 virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet &p);
472
479 virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet &p);
480
481 NetworkRecvStatus HandlePacket(Packet &p);
482
483 NetworkGameSocketHandler(SOCKET s);
484public:
485 ClientID client_id = INVALID_CLIENT_ID;
486 uint32_t last_frame = 0;
487 uint32_t last_frame_server = 0;
488 CommandQueue incoming_queue;
489 std::chrono::steady_clock::time_point last_packet{};
490
491 NetworkRecvStatus CloseConnection(bool error = true) override;
492
497 virtual NetworkRecvStatus CloseConnection(NetworkRecvStatus status) = 0;
498 virtual ~NetworkGameSocketHandler() = default;
499
504 inline void SetInfo(NetworkClientInfo *info)
505 {
506 assert(info != nullptr && this->info == nullptr);
507 this->info = info;
508 }
509
514 inline NetworkClientInfo *GetInfo() const
515 {
516 return this->info;
517 }
518
519 NetworkRecvStatus ReceivePackets();
520
521 std::optional<std::string_view> ReceiveCommand(Packet &p, CommandPacket &cp);
522 void SendCommand(Packet &p, const CommandPacket &cp);
523
524 bool IsPendingDeletion() const { return this->is_pending_deletion; }
525
526 void DeferDeletion();
527 static void ProcessDeferredDeletions();
528};
529
530#endif /* NETWORK_CORE_TCP_GAME_H */
NetworkGameSocketHandler
Base socket handler for all TCP sockets.
Definition tcp_game.h:140
NetworkGameSocketHandler::Receive_CLIENT_MOVE
virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet &p)
Request the server to move this client into another company: uint8_t ID of the company the client wan...
Definition tcp_game.cpp:193
NetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN
virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet &p)
Sends that the server will begin with sending the map to the client: uint32_t Current frame.
Definition tcp_game.cpp:167
NetworkGameSocketHandler::Receive_SERVER_MAP_SIZE
virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet &p)
Sends the size of the map to the client.
Definition tcp_game.cpp:168
NetworkGameSocketHandler::ReceivePackets
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
Definition tcp_game.cpp:131
NetworkGameSocketHandler::is_pending_deletion
bool is_pending_deletion
Whether this socket is pending deletion.
Definition tcp_game.h:144
NetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE
virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet &p)
Update the clients knowledge of the max settings: uint8_t Maximum number of companies allowed.
Definition tcp_game.cpp:194
NetworkGameSocketHandler::Receive_SERVER_BANNED
virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet &p)
Notification that the client trying to join is banned.
Definition tcp_game.cpp:154
NetworkGameSocketHandler::Receive_SERVER_SYNC
virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet &p)
Sends a sync-check to the client: uint32_t Frame counter.
Definition tcp_game.cpp:174
NetworkGameSocketHandler::Receive_SERVER_COMMAND
virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet &p)
Sends a DoCommand to the client: uint8_t ID of the company (0..MAX_COMPANIES-1).
Definition tcp_game.cpp:177
NetworkGameSocketHandler::Receive_SERVER_MAP_DONE
virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet &p)
Sends that all data of the map are sent to the client:
Definition tcp_game.cpp:170
NetworkGameSocketHandler::Receive_CLIENT_ACK
virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet &p)
Tell the server we are done with this frame: uint32_t Current frame counter of the client.
Definition tcp_game.cpp:175
NetworkGameSocketHandler::Receive_SERVER_ENABLE_ENCRYPTION
virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p)
Indication to the client that authentication is complete and encryption has to be used from here on f...
Definition tcp_game.cpp:163
NetworkGameSocketHandler::Receive_SERVER_GAME_INFO
virtual NetworkRecvStatus Receive_SERVER_GAME_INFO(Packet &p)
Sends information about the game.
Definition tcp_game.cpp:158
NetworkGameSocketHandler::last_frame
uint32_t last_frame
Last frame we have executed.
Definition tcp_game.h:486
NetworkGameSocketHandler::Receive_SERVER_WELCOME
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p)
The client is joined and ready to receive their map: uint32_t Own client ID.
Definition tcp_game.cpp:164
NetworkGameSocketHandler::GetInfo
NetworkClientInfo * GetInfo() const
Gets the client info of this socket handler.
Definition tcp_game.h:514
NetworkGameSocketHandler::Receive_CLIENT_QUIT
virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet &p)
The client is quitting the game.
Definition tcp_game.cpp:182
NetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED
virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet &p)
Tell the server that we have the required GRFs.
Definition tcp_game.cpp:191
NetworkGameSocketHandler::Receive_SERVER_SHUTDOWN
virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet &p)
Let the clients know that the server is closing.
Definition tcp_game.cpp:186
NetworkGameSocketHandler::Receive_SERVER_FRAME
virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet &p)
Sends the current frame counter to the client: uint32_t Frame counter uint32_t Frame counter max (how...
Definition tcp_game.cpp:173
NetworkGameSocketHandler::ReceiveCommand
std::optional< std::string_view > ReceiveCommand(Packet &p, CommandPacket &cp)
Receives a command from the network.
Definition network_command.cpp:374
NetworkGameSocketHandler::Receive_CLIENT_AUTH_RESPONSE
virtual NetworkRecvStatus Receive_CLIENT_AUTH_RESPONSE(Packet &p)
Send the response to the authentication request: 32 * uint8_t Public key of the client.
Definition tcp_game.cpp:162
NetworkGameSocketHandler::Receive_SERVER_MOVE
virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet &p)
Move a client from one company into another: uint32_t ID of the client.
Definition tcp_game.cpp:192
NetworkGameSocketHandler::Receive_SERVER_AUTH_REQUEST
virtual NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p)
Indication to the client that it needs to authenticate: uint8_t The NetworkAuthenticationMethod to us...
Definition tcp_game.cpp:161
NetworkGameSocketHandler::Receive_SERVER_QUIT
virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet &p)
Notification that a client left the game: uint32_t ID of the client.
Definition tcp_game.cpp:184
NetworkGameSocketHandler::ReceiveInvalidPacket
NetworkRecvStatus ReceiveInvalidPacket(PacketGameType type)
Helper for logging receiving invalid packets.
Definition tcp_game.cpp:147
NetworkGameSocketHandler::Receive_CLIENT_GETMAP
virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet &p)
Request the map from the server.
Definition tcp_game.cpp:165
NetworkGameSocketHandler::client_id
ClientID client_id
Client identifier.
Definition tcp_game.h:485
NetworkGameSocketHandler::CloseConnection
virtual NetworkRecvStatus CloseConnection(NetworkRecvStatus status)=0
Close the network connection due to the given status.
NetworkGameSocketHandler::incoming_queue
CommandQueue incoming_queue
The command-queue awaiting handling.
Definition tcp_game.h:488
NetworkGameSocketHandler::last_packet
std::chrono::steady_clock::time_point last_packet
Time we received the last frame.
Definition tcp_game.h:489
NetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS
virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet &p)
Sends information about all used GRFs to the client: uint8_t Amount of GRFs (the following data is re...
Definition tcp_game.cpp:190
NetworkGameSocketHandler::Receive_CLIENT_JOIN
virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet &p)
Try to join the server: string OpenTTD revision (norev0000 if no revision).
Definition tcp_game.cpp:155
NetworkGameSocketHandler::SetInfo
void SetInfo(NetworkClientInfo *info)
Sets the client info for this socket handler.
Definition tcp_game.h:504
NetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT
virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet &p)
Inform all clients that one client made an error and thus has quit/been disconnected: uint32_t ID of ...
Definition tcp_game.cpp:185
NetworkGameSocketHandler::Receive_CLIENT_RCON
virtual NetworkRecvStatus Receive_CLIENT_RCON(Packet &p)
Send an RCon command to the server: string RCon password.
Definition tcp_game.cpp:189
NetworkGameSocketHandler::last_frame_server
uint32_t last_frame_server
Last frame the server has executed.
Definition tcp_game.h:487
NetworkGameSocketHandler::Receive_SERVER_ERROR
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet &p)
The client made an error: uint8_t Error code caused (see NetworkErrorCode).
Definition tcp_game.cpp:156
NetworkGameSocketHandler::Receive_CLIENT_CHAT
virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet &p)
Sends a chat-packet to the server: uint8_t ID of the action (see NetworkAction).
Definition tcp_game.cpp:178
NetworkGameSocketHandler::info
NetworkClientInfo * info
Client info related to this socket.
Definition tcp_game.h:143
NetworkGameSocketHandler::HandlePacket
NetworkRecvStatus HandlePacket(Packet &p)
Handle the given packet, i.e.
Definition tcp_game.cpp:61
NetworkGameSocketHandler::Receive_CLIENT_GAME_INFO
virtual NetworkRecvStatus Receive_CLIENT_GAME_INFO(Packet &p)
Request game information.
Definition tcp_game.cpp:157
NetworkGameSocketHandler::Receive_CLIENT_MAP_OK
virtual NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet &p)
Tell the server that we are done receiving/loading the map.
Definition tcp_game.cpp:171
NetworkGameSocketHandler::SendCommand
void SendCommand(Packet &p, const CommandPacket &cp)
Sends a command over the network.
Definition network_command.cpp:395
NetworkGameSocketHandler::Receive_SERVER_CHAT
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet &p)
Sends a chat-packet to the client: uint8_t ID of the action (see NetworkAction).
Definition tcp_game.cpp:179
NetworkGameSocketHandler::Receive_SERVER_RCON
virtual NetworkRecvStatus Receive_SERVER_RCON(Packet &p)
Send the result of an issues RCon command back to the client: uint16_t Colour code.
Definition tcp_game.cpp:188
NetworkGameSocketHandler::Receive_CLIENT_COMMAND
virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet &p)
Send a DoCommand to the Server: uint8_t ID of the company (0..MAX_COMPANIES-1).
Definition tcp_game.cpp:176
NetworkGameSocketHandler::Receive_SERVER_JOIN
virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet &p)
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO:...
Definition tcp_game.cpp:172
NetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet &p)
Send information about a client: uint32_t ID of the client (always unique on a server.
Definition tcp_game.cpp:159
NetworkGameSocketHandler::Receive_SERVER_WAIT
virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet &p)
Notification that another client is currently receiving the map: uint8_t Number of clients waiting in...
Definition tcp_game.cpp:166
NetworkGameSocketHandler::Receive_CLIENT_IDENTIFY
virtual NetworkRecvStatus Receive_CLIENT_IDENTIFY(Packet &p)
The client tells the server about the identity of the client: string Name of the client (max NETWORK_...
Definition tcp_game.cpp:160
NetworkGameSocketHandler::Receive_SERVER_FULL
virtual NetworkRecvStatus Receive_SERVER_FULL(Packet &p)
Notification that the server is full.
Definition tcp_game.cpp:153
NetworkGameSocketHandler::CloseConnection
NetworkRecvStatus CloseConnection(bool error=true) override
Functions to help ReceivePacket/SendPacket a bit A socket can make errors.
Definition tcp_game.cpp:40
NetworkGameSocketHandler::Receive_SERVER_MAP_DATA
virtual NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet &p)
Sends the data of the map to the client: Contains a part of the map (until max size of packet).
Definition tcp_game.cpp:169
NetworkGameSocketHandler::Receive_CLIENT_ERROR
virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet &p)
The client made an error and is quitting the game.
Definition tcp_game.cpp:183
NetworkGameSocketHandler::Receive_SERVER_EXTERNAL_CHAT
virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet &p)
Sends a chat-packet for external source to the client: string Name of the source this message came fr...
Definition tcp_game.cpp:180
NetworkGameSocketHandler::Receive_SERVER_NEWGAME
virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet &p)
Let the clients know that the server is loading a new map.
Definition tcp_game.cpp:187
NetworkGameSocketHandler::Receive_CLIENT_SET_NAME
virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet &p)
Gives the client a new name: string New name of the client.
Definition tcp_game.cpp:181
NetworkTCPSocketHandler
Base socket handler for all TCP sockets.
Definition tcp.h:31
NetworkRecvStatus
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition core.h:23
ClientID
ClientID
'Unique' identifier to be given to clients
Definition network_type.h:43
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition network_type.h:44
os_abstraction.h
Network stuff has many things that needs to be included and/or implemented by default.
CommandPacket
Everything we need to know about a command to be able to execute it.
Definition network_internal.h:95
NetworkClientInfo
Container for all information known about a client.
Definition network_base.h:24
Packet
Internal entity of a packet.
Definition packet.h:43
tcp.h
Basic functions to receive and send TCP packets.
PacketGameType
PacketGameType
Enum with all types of TCP packets.
Definition tcp_game.h:24
PACKET_SERVER_UNUSED
@ PACKET_SERVER_UNUSED
Unused.
Definition tcp_game.h:41
PACKET_CLIENT_IDENTIFY
@ PACKET_CLIENT_IDENTIFY
Client telling the server the client's name and requested company.
Definition tcp_game.h:67
PACKET_SERVER_JOIN
@ PACKET_SERVER_JOIN
Tells clients that a new client has joined.
Definition tcp_game.h:86
PACKET_SERVER_MAP_SIZE
@ PACKET_SERVER_MAP_SIZE
Server tells the client what the (compressed) size of the map is.
Definition tcp_game.h:81
PACKET_SERVER_RCON
@ PACKET_SERVER_RCON
Response of the executed command on the server.
Definition tcp_game.h:110
PACKET_SERVER_MAP_BEGIN
@ PACKET_SERVER_MAP_BEGIN
Server tells the client that it is beginning to send the map.
Definition tcp_game.h:80
PACKET_SERVER_SYNC
@ PACKET_SERVER_SYNC
Server tells the client what the random state should be.
Definition tcp_game.h:97
PACKET_CLIENT_GETMAP
@ PACKET_CLIENT_GETMAP
Client requests the actual map.
Definition tcp_game.h:78
PACKET_CLIENT_ERROR
@ PACKET_CLIENT_ERROR
A client reports an error to the server.
Definition tcp_game.h:123
PACKET_SERVER_WAIT
@ PACKET_SERVER_WAIT
Server tells the client there are some people waiting for the map as well.
Definition tcp_game.h:79
PACKET_END
@ PACKET_END
Must ALWAYS be on the end of this list!! (period)
Definition tcp_game.h:126
PACKET_SERVER_CONFIG_UPDATE
@ PACKET_SERVER_CONFIG_UPDATE
Some network configuration important to the client changed.
Definition tcp_game.h:118
PACKET_CLIENT_JOIN
@ PACKET_CLIENT_JOIN
The client telling the server it wants to join.
Definition tcp_game.h:36
PACKET_CLIENT_AUTH_RESPONSE
@ PACKET_CLIENT_AUTH_RESPONSE
The client responds to the authentication request.
Definition tcp_game.h:63
PACKET_CLIENT_NEWGRFS_CHECKED
@ PACKET_CLIENT_NEWGRFS_CHECKED
Client acknowledges that it has all required NewGRFs.
Definition tcp_game.h:71
PACKET_SERVER_ENABLE_ENCRYPTION
@ PACKET_SERVER_ENABLE_ENCRYPTION
The server tells that authentication has completed and requests to enable encryption with the keys of...
Definition tcp_game.h:64
PACKET_SERVER_GAME_INFO
@ PACKET_SERVER_GAME_INFO
Information about the server.
Definition tcp_game.h:44
PACKET_CLIENT_COMMAND
@ PACKET_CLIENT_COMMAND
Client executed a command and sends it to the server.
Definition tcp_game.h:100
PACKET_SERVER_ERROR_QUIT
@ PACKET_SERVER_ERROR_QUIT
A server tells that a client has hit an error and did quit.
Definition tcp_game.h:124
PACKET_SERVER_CLIENT_INFO
@ PACKET_SERVER_CLIENT_INFO
Server sends you information about a client.
Definition tcp_game.h:75
PACKET_CLIENT_SET_NAME
@ PACKET_CLIENT_SET_NAME
A client changes its name.
Definition tcp_game.h:117
PACKET_SERVER_WELCOME
@ PACKET_SERVER_WELCOME
Server welcomes you and gives you your ClientID.
Definition tcp_game.h:74
PACKET_CLIENT_ACK
@ PACKET_CLIENT_ACK
The client tells the server which frame it has executed.
Definition tcp_game.h:96
PACKET_SERVER_BANNED
@ PACKET_SERVER_BANNED
The server has banned you.
Definition tcp_game.h:33
PACKET_SERVER_FRAME
@ PACKET_SERVER_FRAME
Server tells the client what frame it is in, and thus to where the client may progress.
Definition tcp_game.h:95
PACKET_SERVER_EXTERNAL_CHAT
@ PACKET_SERVER_EXTERNAL_CHAT
Server distributing the message from external source.
Definition tcp_game.h:106
PACKET_SERVER_CHAT
@ PACKET_SERVER_CHAT
Server distributing the message of a client (or itself).
Definition tcp_game.h:105
PACKET_SERVER_COMMAND
@ PACKET_SERVER_COMMAND
Server distributes a command to (all) the clients.
Definition tcp_game.h:101
PACKET_SERVER_SHUTDOWN
@ PACKET_SERVER_SHUTDOWN
The server is shutting down.
Definition tcp_game.h:49
PACKET_SERVER_AUTH_REQUEST
@ PACKET_SERVER_AUTH_REQUEST
The server requests the client to authenticate using a number of methods.
Definition tcp_game.h:62
PACKET_CLIENT_RCON
@ PACKET_CLIENT_RCON
Client asks the server to execute some command.
Definition tcp_game.h:109
PACKET_SERVER_NEWGAME
@ PACKET_SERVER_NEWGAME
The server is preparing to start a new game.
Definition tcp_game.h:48
PACKET_SERVER_MOVE
@ PACKET_SERVER_MOVE
Server tells everyone that someone is moved to another company.
Definition tcp_game.h:114
PACKET_CLIENT_UNUSED
@ PACKET_CLIENT_UNUSED
Unused.
Definition tcp_game.h:40
PACKET_SERVER_MAP_DATA
@ PACKET_SERVER_MAP_DATA
Server sends bits of the map to the client.
Definition tcp_game.h:82
PACKET_CLIENT_MAP_OK
@ PACKET_CLIENT_MAP_OK
Client tells the server that it received the whole map.
Definition tcp_game.h:84
PACKET_CLIENT_QUIT
@ PACKET_CLIENT_QUIT
A client tells the server it is going to quit.
Definition tcp_game.h:121
PACKET_CLIENT_MOVE
@ PACKET_CLIENT_MOVE
A client would like to be moved to another company.
Definition tcp_game.h:113
PACKET_SERVER_FULL
@ PACKET_SERVER_FULL
The server is full and has no place for you.
Definition tcp_game.h:32
PACKET_SERVER_QUIT
@ PACKET_SERVER_QUIT
A server tells that a client has quit.
Definition tcp_game.h:122
PACKET_SERVER_ERROR
@ PACKET_SERVER_ERROR
Server sending an error message to the client.
Definition tcp_game.h:37
PACKET_SERVER_CHECK_NEWGRFS
@ PACKET_SERVER_CHECK_NEWGRFS
Server sends NewGRF IDs and MD5 checksums for the client to check.
Definition tcp_game.h:70
PACKET_SERVER_MAP_DONE
@ PACKET_SERVER_MAP_DONE
Server tells it has just sent the last bits of the map to the client.
Definition tcp_game.h:83
PACKET_CLIENT_CHAT
@ PACKET_CLIENT_CHAT
Client said something that should be distributed.
Definition tcp_game.h:104
PACKET_CLIENT_GAME_INFO
@ PACKET_CLIENT_GAME_INFO
Request information about the server.
Definition tcp_game.h:45
CommandQueue
std::vector< CommandPacket > CommandQueue
A "queue" of CommandPackets.
Definition tcp_game.h:137