OpenTTD Source
20241108-master-g80f628063a
|
Class for handling the client side of the game connection. More...
#include <network_client.h>
Public Member Functions | |
ClientNetworkGameSocketHandler (SOCKET s, const std::string &connection_string) | |
Create a new socket for the client side of the game connection. More... | |
~ClientNetworkGameSocketHandler () | |
Clear whatever we assigned. | |
NetworkRecvStatus | CloseConnection (NetworkRecvStatus status) override |
Close the network connection due to the given status. More... | |
void | ClientError (NetworkRecvStatus res) |
Handle an error coming from the client side. More... | |
Public Member Functions inherited from ZeroedMemoryAllocator | |
void * | operator new (size_t size) |
Memory allocator for a single class instance. More... | |
void * | operator new[] (size_t size) |
Memory allocator for an array of class instances. More... | |
void | operator delete (void *ptr) |
Memory release for a single class instance. More... | |
void | operator delete[] (void *ptr) |
Memory release for an array of class instances. More... | |
Public Member Functions inherited from NetworkGameSocketHandler | |
NetworkRecvStatus | CloseConnection (bool error=true) override |
Functions to help ReceivePacket/SendPacket a bit A socket can make errors. More... | |
void | SetInfo (NetworkClientInfo *info) |
Sets the client info for this socket handler. More... | |
NetworkClientInfo * | GetInfo () const |
Gets the client info of this socket handler. More... | |
NetworkRecvStatus | ReceivePackets () |
Do the actual receiving of packets. More... | |
const char * | ReceiveCommand (Packet &p, CommandPacket &cp) |
Receives a command from the network. More... | |
void | SendCommand (Packet &p, const CommandPacket &cp) |
Sends a command over the network. More... | |
bool | IsPendingDeletion () const |
void | DeferDeletion () |
Public Member Functions inherited from NetworkTCPSocketHandler | |
bool | IsConnected () const |
Whether this socket is currently bound to a socket. More... | |
void | CloseSocket () |
Close the actual socket of the connection. More... | |
virtual void | SendPacket (std::unique_ptr< Packet > &&packet) |
This function puts the packet in the send-queue and it is send as soon as possible. More... | |
SendPacketsState | SendPackets (bool closing_down=false) |
Sends all the buffered packets out for this client. More... | |
virtual std::unique_ptr< Packet > | ReceivePacket () |
Receives a packet for the given client. More... | |
bool | CanSendReceive () |
Check whether this socket can send or receive something. More... | |
bool | HasSendQueue () |
Whether there is something pending in the send queue. More... | |
NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
Construct a socket handler for a TCP connection. More... | |
Public Member Functions inherited from NetworkSocketHandler | |
NetworkSocketHandler () | |
Create a new unbound socket. | |
virtual | ~NetworkSocketHandler ()=default |
Close the socket when destructing the socket handler. | |
void | MarkClosed () |
Mark the connection as closed. More... | |
bool | HasClientQuit () const |
Whether the current client connected to the socket has quit. More... | |
void | Reopen () |
Reopen the socket so we can send/receive stuff again. | |
Static Public Member Functions | |
static NetworkRecvStatus | SendJoin () |
Tell the server we would like to join. | |
static NetworkRecvStatus | SendCommand (const CommandPacket &cp) |
Send a command to the server. More... | |
static NetworkRecvStatus | SendError (NetworkErrorCode errorno) |
Send an error-packet over the network. | |
static NetworkRecvStatus | SendQuit () |
Tell the server we would like to quit. | |
static NetworkRecvStatus | SendAck () |
Send an acknowledgement from the server's ticks. | |
static NetworkRecvStatus | SendAuthResponse () |
Set the game password as requested. More... | |
static NetworkRecvStatus | SendChat (NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data) |
Send a chat-packet over the network. | |
static NetworkRecvStatus | SendSetName (const std::string &name) |
Tell the server that we like to change the name of the client. More... | |
static NetworkRecvStatus | SendRCon (const std::string &password, const std::string &command) |
Send a console command. More... | |
static NetworkRecvStatus | SendMove (CompanyID company) |
Ask the server to move us. More... | |
static bool | IsConnected () |
Check whether the client is actually connected (and in the game). More... | |
static void | Send () |
Send the packets of this socket handler. | |
static bool | Receive () |
Check whether we received/can send some data from/to the server and when that's the case handle it appropriately. More... | |
static bool | GameLoop () |
Actual game loop for the client. More... | |
Static Public Member Functions inherited from NetworkGameSocketHandler | |
static void | ProcessDeferredDeletions () |
Protected Member Functions | |
NetworkRecvStatus | Receive_SERVER_FULL (Packet &p) override |
Notification that the server is full. More... | |
NetworkRecvStatus | Receive_SERVER_BANNED (Packet &p) override |
Notification that the client trying to join is banned. More... | |
NetworkRecvStatus | Receive_SERVER_ERROR (Packet &p) override |
The client made an error: uint8_t Error code caused (see NetworkErrorCode). More... | |
NetworkRecvStatus | Receive_SERVER_CLIENT_INFO (Packet &p) override |
Send information about a client: uint32_t ID of the client (always unique on a server. More... | |
NetworkRecvStatus | Receive_SERVER_AUTH_REQUEST (Packet &p) override |
Indication to the client that it needs to authenticate: uint8_t The NetworkAuthenticationMethod to use. More... | |
NetworkRecvStatus | Receive_SERVER_ENABLE_ENCRYPTION (Packet &p) override |
Indication to the client that authentication is complete and encryption has to be used from here on forward. More... | |
NetworkRecvStatus | Receive_SERVER_WELCOME (Packet &p) override |
The client is joined and ready to receive their map: uint32_t Own client ID. More... | |
NetworkRecvStatus | Receive_SERVER_WAIT (Packet &p) override |
Notification that another client is currently receiving the map: uint8_t Number of clients waiting in front of you. More... | |
NetworkRecvStatus | Receive_SERVER_MAP_BEGIN (Packet &p) override |
Sends that the server will begin with sending the map to the client: uint32_t Current frame. More... | |
NetworkRecvStatus | Receive_SERVER_MAP_SIZE (Packet &p) override |
Sends the size of the map to the client. More... | |
NetworkRecvStatus | Receive_SERVER_MAP_DATA (Packet &p) override |
Sends the data of the map to the client: Contains a part of the map (until max size of packet). More... | |
NetworkRecvStatus | Receive_SERVER_MAP_DONE (Packet &p) override |
Sends that all data of the map are sent to the client: More... | |
NetworkRecvStatus | Receive_SERVER_JOIN (Packet &p) override |
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: uint32_t ID of the client that just joined the game. More... | |
NetworkRecvStatus | Receive_SERVER_FRAME (Packet &p) override |
Sends the current frame counter to the client: uint32_t Frame counter uint32_t Frame counter max (how far may the client walk before the server?) uint32_t General seed 1 (dependent on compile settings, not default). More... | |
NetworkRecvStatus | Receive_SERVER_SYNC (Packet &p) override |
Sends a sync-check to the client: uint32_t Frame counter. More... | |
NetworkRecvStatus | Receive_SERVER_COMMAND (Packet &p) override |
Sends a DoCommand to the client: uint8_t ID of the company (0..MAX_COMPANIES-1). More... | |
NetworkRecvStatus | Receive_SERVER_CHAT (Packet &p) override |
Sends a chat-packet to the client: uint8_t ID of the action (see NetworkAction). More... | |
NetworkRecvStatus | Receive_SERVER_EXTERNAL_CHAT (Packet &p) override |
Sends a chat-packet for external source to the client: string Name of the source this message came from. More... | |
NetworkRecvStatus | Receive_SERVER_QUIT (Packet &p) override |
Notification that a client left the game: uint32_t ID of the client. More... | |
NetworkRecvStatus | Receive_SERVER_ERROR_QUIT (Packet &p) override |
Inform all clients that one client made an error and thus has quit/been disconnected: uint32_t ID of the client that caused the error. More... | |
NetworkRecvStatus | Receive_SERVER_SHUTDOWN (Packet &p) override |
Let the clients know that the server is closing. More... | |
NetworkRecvStatus | Receive_SERVER_NEWGAME (Packet &p) override |
Let the clients know that the server is loading a new map. More... | |
NetworkRecvStatus | Receive_SERVER_RCON (Packet &p) override |
Send the result of an issues RCon command back to the client: uint16_t Colour code. More... | |
NetworkRecvStatus | Receive_SERVER_CHECK_NEWGRFS (Packet &p) override |
Sends information about all used GRFs to the client: uint8_t Amount of GRFs (the following data is repeated this many times, i.e. More... | |
NetworkRecvStatus | Receive_SERVER_MOVE (Packet &p) override |
Move a client from one company into another: uint32_t ID of the client. More... | |
NetworkRecvStatus | Receive_SERVER_CONFIG_UPDATE (Packet &p) override |
Update the clients knowledge of the max settings: uint8_t Maximum number of companies allowed. More... | |
void | CheckConnection () |
Check the connection's state, i.e. More... | |
Protected Member Functions inherited from NetworkGameSocketHandler | |
NetworkRecvStatus | ReceiveInvalidPacket (PacketGameType type) |
Helper for logging receiving invalid packets. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_JOIN (Packet &p) |
Try to join the server: string OpenTTD revision (norev0000 if no revision). More... | |
virtual NetworkRecvStatus | Receive_CLIENT_GAME_INFO (Packet &p) |
Request game information. More... | |
virtual NetworkRecvStatus | Receive_SERVER_GAME_INFO (Packet &p) |
Sends information about the game. More... | |
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_NAME_LENGTH). More... | |
virtual NetworkRecvStatus | Receive_CLIENT_AUTH_RESPONSE (Packet &p) |
Send the response to the authentication request: 32 * uint8_t Public key of the client. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_GETMAP (Packet &p) |
Request the map from the server. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_MAP_OK (Packet &p) |
Tell the server that we are done receiving/loading the map. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_ACK (Packet &p) |
Tell the server we are done with this frame: uint32_t Current frame counter of the client. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_COMMAND (Packet &p) |
Send a DoCommand to the Server: uint8_t ID of the company (0..MAX_COMPANIES-1). More... | |
virtual NetworkRecvStatus | Receive_CLIENT_CHAT (Packet &p) |
Sends a chat-packet to the server: uint8_t ID of the action (see NetworkAction). More... | |
virtual NetworkRecvStatus | Receive_CLIENT_SET_NAME (Packet &p) |
Gives the client a new name: string New name of the client. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_QUIT (Packet &p) |
The client is quitting the game. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_ERROR (Packet &p) |
The client made an error and is quitting the game. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_RCON (Packet &p) |
Send an RCon command to the server: string RCon password. More... | |
virtual NetworkRecvStatus | Receive_CLIENT_NEWGRFS_CHECKED (Packet &p) |
Tell the server that we have the required GRFs. More... | |
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 wants to join. More... | |
NetworkRecvStatus | HandlePacket (Packet &p) |
Handle the given packet, i.e. More... | |
NetworkGameSocketHandler (SOCKET s) | |
Create a new socket for the game connection. More... | |
Static Protected Member Functions | |
static NetworkRecvStatus | SendNewGRFsOk () |
Tell the server we got all the NewGRFs. | |
static NetworkRecvStatus | SendGetMap () |
Request the map from the server. | |
static NetworkRecvStatus | SendMapOk () |
Tell the server we received the complete map. | |
static NetworkRecvStatus | SendIdentify () |
Static Protected Attributes | |
static ClientNetworkGameSocketHandler * | my_client = nullptr |
This is us! More... | |
Private Types | |
enum | ServerStatus { STATUS_INACTIVE , STATUS_JOIN , STATUS_AUTH_GAME , STATUS_ENCRYPTED , STATUS_NEWGRFS_CHECK , STATUS_AUTHORIZED , STATUS_MAP_WAIT , STATUS_MAP , STATUS_ACTIVE , STATUS_END } |
Status of the connection with the server. More... | |
Private Attributes | |
std::unique_ptr< class NetworkAuthenticationClientHandler > | authentication_handler |
The handler for the authentication. | |
std::string | connection_string |
Address we are connected to. | |
std::shared_ptr< struct PacketReader > | savegame |
Packet reader for reading the savegame. | |
uint8_t | token |
The token we need to send back to the server to prove we're the right client. | |
ServerStatus | status |
Status of the connection with the server. | |
Friends | |
void | NetworkExecuteLocalCommandQueue () |
Execute all commands on the local command queue that ought to be executed this frame. | |
void | NetworkClose (bool close_admins) |
Close current connections. More... | |
Additional Inherited Members | |
Data Fields inherited from NetworkGameSocketHandler | |
ClientID | client_id |
Client identifier. | |
uint32_t | last_frame |
Last frame we have executed. | |
uint32_t | last_frame_server |
Last frame the server has executed. | |
CommandQueue | incoming_queue |
The command-queue awaiting handling. | |
std::chrono::steady_clock::time_point | last_packet |
Time we received the last frame. | |
Data Fields inherited from NetworkTCPSocketHandler | |
SOCKET | sock |
The socket currently connected to. | |
bool | writable |
Can we write to this socket? | |
Protected Attributes inherited from NetworkSocketHandler | |
std::unique_ptr< class NetworkEncryptionHandler > | receive_encryption_handler |
The handler for decrypting received packets. | |
std::unique_ptr< class NetworkEncryptionHandler > | send_encryption_handler |
The handler for encrypting sent packets. | |
Class for handling the client side of the game connection.
Definition at line 16 of file network_client.h.
|
private |
Status of the connection with the server.
Definition at line 24 of file network_client.h.
ClientNetworkGameSocketHandler::ClientNetworkGameSocketHandler | ( | SOCKET | s, |
const std::string & | connection_string | ||
) |
Create a new socket for the client side of the game connection.
s | The socket to connect with. |
Definition at line 146 of file network_client.cpp.
References my_client.
|
protected |
Check the connection's state, i.e.
is the connection still up?
Definition at line 1202 of file network_client.cpp.
References NetworkGameSocketHandler::CloseConnection(), NetworkGameSocketHandler::last_packet, SetDParam(), ShowErrorMessage(), status, STATUS_AUTHORIZED, and WL_INFO.
Referenced by Send().
void ClientNetworkGameSocketHandler::ClientError | ( | NetworkRecvStatus | res | ) |
Handle an error coming from the client side.
res | The "error" that happened. |
Definition at line 189 of file network_client.cpp.
References _networking, CloseConnection(), CloseWindowById(), NetworkSocketHandler::MarkClosed(), NETWORK_RECV_STATUS_CLOSE_QUERY, NETWORK_RECV_STATUS_DESYNC, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
Referenced by Receive().
|
overridevirtual |
Close the network connection due to the given status.
status | The reason the connection got closed. |
Implements NetworkGameSocketHandler.
Definition at line 161 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, CSleep(), Debug, NetworkSocketHandler::HasClientQuit(), MILLISECONDS_PER_TICK, NETWORK_RECV_STATUS_OKAY, NetworkTCPSocketHandler::SendPackets(), NetworkTCPSocketHandler::sock, and status.
Referenced by ClientError().
|
static |
Actual game loop for the client.
Definition at line 268 of file network_client.cpp.
References _frame_counter, _random, _sync_frame, _sync_seed_1, NetworkExecuteLocalCommandQueue, Randomizer::state, and StateGameLoop().
|
static |
Check whether the client is actually connected (and in the game).
Definition at line 528 of file network_client.cpp.
References my_client, status, and STATUS_ACTIVE.
Referenced by DEF_CONSOLE_HOOK().
|
static |
Check whether we received/can send some data from/to the server and when that's the case handle it appropriately.
Definition at line 243 of file network_client.cpp.
References _networking, NetworkTCPSocketHandler::CanSendReceive(), ClientError(), my_client, NETWORK_RECV_STATUS_OKAY, and NetworkGameSocketHandler::ReceivePackets().
|
overrideprotectedvirtual |
Indication to the client that it needs to authenticate: uint8_t The NetworkAuthenticationMethod
to use.
32 * uint8_t Public key of the server. 24 * uint8_t Nonce for the key exchange.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 718 of file network_client.cpp.
References _settings_client, authentication_handler, NetworkAuthenticationClientHandler::AWAIT_USER_INPUT, NetworkSettings::client_public_key, NetworkSettings::client_secret_key, NetworkAuthenticationClientHandler::Create(), Debug, NetworkAuthenticationClientHandler::INVALID, ClientSettings::network, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, NetworkAuthenticationClientHandler::READY_FOR_RESPONSE, SendAuthResponse(), status, STATUS_AUTH_GAME, and STATUS_JOIN.
|
overrideprotectedvirtual |
Notification that the client trying to join is banned.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 550 of file network_client.cpp.
References Debug, INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_BANNED, ShowErrorMessage(), and WL_CRITICAL.
|
overrideprotectedvirtual |
Sends a chat-packet to the client: uint8_t ID of the action (see NetworkAction).
uint32_t ID of the client (origin of the chat). string Message (max NETWORK_CHAT_LENGTH). uint64_t data (used e.g. for 'give money' actions).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 977 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, Debug, NetworkClientInfo::GetByClientID(), NETWORK_CHAT_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_bool(), Packet::Recv_string(), Packet::Recv_uint32(), Packet::Recv_uint64(), Packet::Recv_uint8(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Sends information about all used GRFs to the client: uint8_t Amount of GRFs (the following data is repeated this many times, i.e.
per GRF data). uint32_t GRF ID 16 * uint8_t MD5 checksum of the GRF
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 673 of file network_client.cpp.
References BSWAP32(), Debug, FGCM_EXACT, FindGRFConfig(), FormatArrayAsHex(), GRFIdentifier::grfid, INVALID_STRING_ID, GRFIdentifier::md5sum, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_NEWGRF_MISMATCH, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint8(), SendNewGRFsOk(), ShowErrorMessage(), status, STATUS_ENCRYPTED, and WL_CRITICAL.
|
overrideprotectedvirtual |
Send information about a client: uint32_t ID of the client (always unique on a server.
1 = server, 0 is invalid). uint8_t ID of the company the client is playing as (255 for spectators). string Name of the client. string Public key of the client.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 563 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, and Packet::Recv_uint32().
|
overrideprotectedvirtual |
Sends a DoCommand to the client: uint8_t ID of the company (0..MAX_COMPANIES-1).
uint32_t ID of the command (see command.h). Command specific buffer with encoded parameters of variable length. The content differs per command and can change without notification. uint8_t ID of the callback. uint32_t Frame of execution.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 956 of file network_client.cpp.
References CC_WARNING, CommandPacket::cmd, Debug, CommandPacket::frame, IConsolePrint(), NetworkGameSocketHandler::incoming_queue, CommandPacket::my_cmd, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, NetworkGameSocketHandler::ReceiveCommand(), Packet::Recv_bool(), Packet::Recv_uint32(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Update the clients knowledge of the max settings: uint8_t Maximum number of companies allowed.
uint8_t Maximum number of spectators allowed.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1185 of file network_client.cpp.
References _network_server_max_companies, _network_server_name, Debug, InvalidateWindowData(), NETWORK_NAME_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint8(), status, STATUS_ACTIVE, and WC_CLIENT_LIST.
|
overrideprotectedvirtual |
Indication to the client that authentication is complete and encryption has to be used from here on forward.
The encryption uses the shared keys generated by the last AUTH_REQUEST key exchange. 24 * uint8_t Nonce for encrypted connection.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 743 of file network_client.cpp.
References authentication_handler, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, NetworkSocketHandler::receive_encryption_handler, NetworkSocketHandler::send_encryption_handler, status, STATUS_AUTH_GAME, and STATUS_ENCRYPTED.
|
overrideprotectedvirtual |
The client made an error: uint8_t Error code caused (see NetworkErrorCode).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 624 of file network_client.cpp.
References lengthof.
|
overrideprotectedvirtual |
Inform all clients that one client made an error and thus has quit/been disconnected: uint32_t ID of the client that caused the error.
uint8_t Code of the error caused (see NetworkErrorCode).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1046 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, Debug, NetworkClientInfo::GetByClientID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Sends a chat-packet for external source to the client: string Name of the source this message came from.
uint16_t TextColour to use for the message. string Name of the user who sent the messsage. string Message (max NETWORK_CHAT_LENGTH).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1028 of file network_client.cpp.
References Debug, IsValidConsoleColour(), NETWORK_CHAT_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_string(), Packet::Recv_uint16(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Sends the current frame counter to the client: uint32_t Frame counter uint32_t Frame counter max (how far may the client walk before the server?) uint32_t General seed 1 (dependent on compile settings, not default).
uint32_t General seed 2 (dependent on compile settings, not default). uint8_t Random token to validate the client is actually listening (only occasionally present).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 906 of file network_client.cpp.
References _frame_counter, _frame_counter_max, _frame_counter_server, _network_first_time, _sync_frame, _sync_seed_1, Packet::CanReadFromPacket(), Ticks::DAY_TICKS, Debug, last_ack_frame, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), Packet::Recv_uint8(), SendAck(), status, STATUS_ACTIVE, and token.
|
overrideprotectedvirtual |
Notification that the server is full.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 540 of file network_client.cpp.
References Debug, INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_FULL, ShowErrorMessage(), and WL_CRITICAL.
|
overrideprotectedvirtual |
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: uint32_t ID of the client that just joined the game.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1087 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, Debug, NetworkClientInfo::GetByClientID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Sends that the server will begin with sending the map to the client: uint32_t Current frame.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 791 of file network_client.cpp.
References _frame_counter, _frame_counter_max, _frame_counter_server, _network_join_bytes, _network_join_bytes_total, _network_join_status, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), savegame, status, and STATUS_MAP.
|
overrideprotectedvirtual |
Sends the data of the map to the client: Contains a part of the map (until max size of packet).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 828 of file network_client.cpp.
References _network_join_bytes, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, savegame, SetWindowDirty(), status, STATUS_MAP, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
overrideprotectedvirtual |
Sends that all data of the map are sent to the client:
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 842 of file network_client.cpp.
References _network_join_status, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, savegame, status, and STATUS_MAP.
|
overrideprotectedvirtual |
Sends the size of the map to the client.
uint32_t Size of the (compressed) map (in bytes).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 815 of file network_client.cpp.
References _network_join_bytes_total, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), savegame, SetWindowDirty(), status, STATUS_MAP, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
overrideprotectedvirtual |
Move a client from one company into another: uint32_t ID of the client.
uint8_t ID of the new company.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1155 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Let the clients know that the server is loading a new map.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1120 of file network_client.cpp.
References _network_own_client_id, _network_reconnect, ClientNetworkEmergencySave(), Debug, INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_ERROR, ShowErrorMessage(), status, STATUS_ACTIVE, STATUS_JOIN, and WL_CRITICAL.
|
overrideprotectedvirtual |
Notification that a client left the game: uint32_t ID of the client.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1065 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, Debug, NetworkClientInfo::GetByClientID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Send the result of an issues RCon command back to the client: uint16_t Colour code.
string Output of the RCon command
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1139 of file network_client.cpp.
References Debug, IConsolePrint(), IsValidConsoleColour(), NETWORK_RCONCOMMAND_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint16(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Let the clients know that the server is closing.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1105 of file network_client.cpp.
References ClientNetworkEmergencySave(), Debug, INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_ERROR, ShowErrorMessage(), status, STATUS_ACTIVE, STATUS_JOIN, and WL_CRITICAL.
|
overrideprotectedvirtual |
Sends a sync-check to the client: uint32_t Frame counter.
uint32_t General seed 1. uint32_t General seed 2 (dependent on compile settings, not default).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 941 of file network_client.cpp.
References _sync_frame, _sync_seed_1, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), status, and STATUS_ACTIVE.
|
overrideprotectedvirtual |
Notification that another client is currently receiving the map: uint8_t Number of clients waiting in front of you.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 775 of file network_client.cpp.
References _network_join_status, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, status, and STATUS_MAP_WAIT.
|
overrideprotectedvirtual |
The client is joined and ready to receive their map: uint32_t Own client ID.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 761 of file network_client.cpp.
References _network_own_client_id, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), SendGetMap(), status, and STATUS_AUTHORIZED.
|
static |
Set the game password as requested.
password | The game password. |
Definition at line 372 of file network_client.cpp.
References authentication_handler, Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_AUTH_RESPONSE, and NetworkTCPSocketHandler::SendPacket().
Referenced by Receive_SERVER_AUTH_REQUEST(), and ClientGamePasswordRequestHandler::SendResponse().
|
static |
Send a command to the server.
cp | The command to send. |
Definition at line 426 of file network_client.cpp.
References CommandPacket::cmd, Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_COMMAND, and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkSendCommand().
|
static |
Ask the server to move us.
company | The company to move to. |
Definition at line 514 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_MOVE, and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkClientRequestMove().
|
static |
Send a console command.
pass | The password for the remote command. |
command | The actual command. |
Definition at line 499 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_RCON, and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkClientSendRcon().
|
static |
Tell the server that we like to change the name of the client.
name | The new name. |
Definition at line 470 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_SET_NAME, and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkUpdateClientName().
|
friend |
Close current connections.
close_admins | Whether the admin connections have to be closed as well. |
Definition at line 594 of file network.cpp.
|
staticprotected |
This is us!
Our client's connection.
Definition at line 42 of file network_client.h.
Referenced by ClientNetworkGameSocketHandler(), IsConnected(), Receive(), Send(), SendAck(), SendAuthResponse(), SendChat(), SendCommand(), SendError(), SendGetMap(), SendJoin(), SendMapOk(), SendMove(), SendNewGRFsOk(), SendQuit(), SendRCon(), SendSetName(), and ~ClientNetworkGameSocketHandler().