|
OpenTTD Source
14.0-beta1
|
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 (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 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 () |
| Make sure the server ID length is the same as a md5 hash. More... | |
| 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 | SendGamePassword (const std::string &password) |
| Set the game password as requested. More... | |
| static NetworkRecvStatus | SendCompanyPassword (const std::string &password) |
| Set the company 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 | SendSetPassword (const std::string &password) |
| Tell the server that we like to change the password of the company. More... | |
| 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, const std::string &password) |
| 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_NEED_GAME_PASSWORD (Packet *p) override |
| Indication to the client that the server needs a game password. More... | |
| NetworkRecvStatus | Receive_SERVER_NEED_COMPANY_PASSWORD (Packet *p) override |
| Indication to the client that the server needs a company password: uint32_t Generation seed. 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_COMPANY_UPDATE (Packet *p) override |
| Update the clients knowledge of which company is password protected: uint16_t Bitwise representation of each company. 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 (norev000 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_GAME_PASSWORD (Packet *p) |
| Send a password to the server to authorize: uint8_t Password type (see NetworkPasswordType). More... | |
| virtual NetworkRecvStatus | Receive_CLIENT_COMPANY_PASSWORD (Packet *p) |
| Send a password to the server to authorize uint8_t Password type (see NetworkPasswordType). 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_PASSWORD (Packet *p) |
| Set the password for the clients current company: string The password. 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 Protected Attributes | |
| static ClientNetworkGameSocketHandler * | my_client = nullptr |
| This is us! More... | |
Private Types | |
| enum | ServerStatus { STATUS_INACTIVE, STATUS_JOIN, STATUS_NEWGRFS_CHECK, STATUS_AUTH_GAME, STATUS_AUTH_COMPANY, STATUS_AUTHORIZED, STATUS_MAP_WAIT, STATUS_MAP, STATUS_ACTIVE, STATUS_END } |
| Status of the connection with the server. More... | |
Private Attributes | |
| std::string | connection_string |
| Address we are connected to. | |
| struct PacketReader * | savegame |
| Packet reader for reading the savegame. | |
| byte | 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? | |
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 23 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 1228 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 190 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 162 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(), and NetworkClose().
|
static |
Actual game loop for the client.
Definition at line 269 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 559 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 244 of file network_client.cpp.
References _networking, NetworkTCPSocketHandler::CanSendReceive(), ClientError(), my_client, NETWORK_RECV_STATUS_OKAY, and NetworkGameSocketHandler::ReceivePackets().
|
overrideprotectedvirtual |
Notification that the client trying to join is banned.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 582 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 991 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 700 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_JOIN, 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.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 595 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 970 of file network_client.cpp.
References CommandQueue::Append(), 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 which company is password protected: uint16_t Bitwise representation of each company.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1212 of file network_client.cpp.
References _network_company_passworded, NETWORK_RECV_STATUS_MALFORMED_PACKET, 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 1199 of file network_client.cpp.
References _network_server_max_companies, _network_server_name, Debug, NETWORK_NAME_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint8(), SetWindowClassesDirty(), status, STATUS_ACTIVE, and WC_CLIENT_LIST.
|
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 653 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 1060 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 1042 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 920 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 572 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 1101 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 805 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 842 of file network_client.cpp.
References _network_join_bytes, PacketReader::AddPacket(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, savegame, SetWindowDirty(), status, STATUS_MAP, WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN, and PacketReader::written_bytes.
|
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 856 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 829 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 1169 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_uint32(), status, and STATUS_AUTHORIZED.
|
overrideprotectedvirtual |
Indication to the client that the server needs a company password: uint32_t Generation seed.
string Network ID of the server.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 750 of file network_client.cpp.
References _network_join, _password_game_seed, _password_server_id, NetworkJoinInfo::company_password, Debug, NetworkSocketHandler::HasClientQuit(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_SERVER_ID_LENGTH, Packet::Recv_string(), Packet::Recv_uint32(), SendCompanyPassword(), status, and STATUS_AUTH_COMPANY.
|
overrideprotectedvirtual |
Indication to the client that the server needs a game password.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 733 of file network_client.cpp.
References _network_join, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, SendGamePassword(), NetworkJoinInfo::server_password, status, and STATUS_AUTH_GAME.
|
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 1134 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 1079 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 1153 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 1119 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 955 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 789 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.
uint32_t Generation seed. string Network ID of the server.
| p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 771 of file network_client.cpp.
References _network_own_client_id, _password_game_seed, _password_server_id, Debug, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_SERVER_ID_LENGTH, Packet::Recv_string(), Packet::Recv_uint32(), SendGetMap(), status, and STATUS_AUTHORIZED.
|
static |
Send a command to the server.
| cp | The command to send. |
Definition at line 440 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 |
Set the company password as requested.
| password | The company password. |
Definition at line 387 of file network_client.cpp.
References _password_game_seed, _password_server_id, Debug, GenerateCompanyPasswordHash(), my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_COMPANY_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by Receive_SERVER_NEED_COMPANY_PASSWORD().
|
static |
Set the game password as requested.
| password | The game password. |
Definition at line 373 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_GAME_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by Receive_SERVER_NEED_GAME_PASSWORD().
|
static |
Make sure the server ID length is the same as a md5 hash.
Tell the server we would like to join.
Definition at line 339 of file network_client.cpp.
References _network_join_status, Debug, my_client, status, and STATUS_JOIN.
Referenced by NetworkClient_Connected().
|
static |
Ask the server to move us.
| company | The company to move to. |
| password | The password of the company to move to. |
Definition at line 544 of file network_client.cpp.
References _password_game_seed, _password_server_id, Debug, GenerateCompanyPasswordHash(), my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_MOVE, Packet::Send_string(), Packet::Send_uint8(), 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 528 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_RCON, Packet::Send_string(), 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 499 of file network_client.cpp.
References Debug, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_SET_NAME, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkUpdateClientName().
|
static |
Tell the server that we like to change the password of the company.
| password | The new password. |
Definition at line 484 of file network_client.cpp.
References _password_game_seed, _password_server_id, Debug, GenerateCompanyPasswordHash(), my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_SET_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkClientSetCompanyPassword().
|
friend |
Close current connections.
| close_admins | Whether the admin connections have to be closed as well. |
Definition at line 575 of file network.cpp.
|
staticprotected |
This is us!
Our client's connection.
Definition at line 41 of file network_client.h.
Referenced by ClientNetworkGameSocketHandler(), IsConnected(), NetworkClose(), NetworkExecuteLocalCommandQueue(), Receive(), Send(), SendAck(), SendChat(), SendCommand(), SendCompanyPassword(), SendError(), SendGamePassword(), SendGetMap(), SendJoin(), SendMapOk(), SendMove(), SendNewGRFsOk(), SendQuit(), SendRCon(), SendSetName(), SendSetPassword(), and ~ClientNetworkGameSocketHandler().