OpenTTD
|
Class for handling the client side of the game connection. More...
#include <network_client.h>
Public Member Functions | |
ClientNetworkGameSocketHandler (SOCKET s) | |
Create a new socket for the client side of the game connection. | |
~ClientNetworkGameSocketHandler () | |
Clear whatever we assigned. | |
NetworkRecvStatus | CloseConnection (NetworkRecvStatus status) |
Close the network connection due to the given status. | |
void | ClientError (NetworkRecvStatus res) |
Handle an error coming from the client side. | |
![]() | |
void * | operator new (size_t size) |
Memory allocator for a single class instance. | |
void * | operator new[] (size_t size) |
Memory allocator for an array of class instances. | |
void | operator delete (void *ptr) |
Memory release for a single class instance. | |
void | operator delete[] (void *ptr) |
Memory release for an array of class instances. | |
![]() | |
NetworkRecvStatus | CloseConnection (bool error=true) |
Functions to help ReceivePacket/SendPacket a bit A socket can make errors. | |
void | SetInfo (NetworkClientInfo *info) |
Sets the client info for this socket handler. | |
NetworkClientInfo * | GetInfo () const |
Gets the client info of this socket handler. | |
NetworkRecvStatus | ReceivePackets () |
Do the actual receiving of packets. | |
const char * | ReceiveCommand (Packet *p, CommandPacket *cp) |
Receives a command from the network. | |
void | SendCommand (Packet *p, const CommandPacket *cp) |
Sends a command over the network. | |
![]() | |
bool | IsConnected () const |
Whether this socket is currently bound to a socket. | |
virtual void | SendPacket (Packet *packet) |
This function puts the packet in the send-queue and it is send as soon as possible. | |
SendPacketsState | SendPackets (bool closing_down=false) |
Sends all the buffered packets out for this client. | |
virtual Packet * | ReceivePacket () |
Receives a packet for the given client. | |
bool | CanSendReceive () |
Check whether this socket can send or receive something. | |
bool | HasSendQueue () |
Whether there is something pending in the send queue. | |
NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
Construct a socket handler for a TCP connection. | |
![]() | |
NetworkSocketHandler () | |
Create a new unbound socket. | |
virtual | ~NetworkSocketHandler () |
Close the socket when destructing the socket handler. | |
virtual void | Close () |
Really close the socket. | |
bool | HasClientQuit () const |
Whether the current client connected to the socket has quit. | |
void | Reopen () |
Reopen the socket so we can send/receive stuff again. | |
void | SendGRFIdentifier (Packet *p, const GRFIdentifier *grf) |
Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. | |
void | ReceiveGRFIdentifier (Packet *p, GRFIdentifier *grf) |
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. | |
void | SendCompanyInformation (Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len=NETWORK_COMPANY_NAME_LENGTH) |
Package some generic company information into a packet. |
Static Public Member Functions | |
static NetworkRecvStatus | SendCompanyInformationQuery () |
Query the server for company information. | |
static NetworkRecvStatus | SendJoin () |
Tell the server we would like to join. | |
static NetworkRecvStatus | SendCommand (const CommandPacket *cp) |
Send a command to the server. | |
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 char *password) |
Set the game password as requested. | |
static NetworkRecvStatus | SendCompanyPassword (const char *password) |
Set the company password as requested. | |
static NetworkRecvStatus | SendChat (NetworkAction action, DestType type, int dest, const char *msg, int64 data) |
Send a chat-packet over the network. | |
static NetworkRecvStatus | SendSetPassword (const char *password) |
Tell the server that we like to change the password of the company. | |
static NetworkRecvStatus | SendSetName (const char *name) |
Tell the server that we like to change the name of the client. | |
static NetworkRecvStatus | SendRCon (const char *password, const char *command) |
Send a console command. | |
static NetworkRecvStatus | SendMove (CompanyID company, const char *password) |
Ask the server to move us. | |
static bool | IsConnected () |
Check whether the client is actually connected (and in the game). | |
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. | |
static bool | GameLoop () |
Actual game loop for the client. |
Protected Member Functions | |
virtual NetworkRecvStatus | Receive_SERVER_FULL (Packet *p) |
Notification that the server is full. | |
virtual NetworkRecvStatus | Receive_SERVER_BANNED (Packet *p) |
Notification that the client trying to join is banned. | |
virtual NetworkRecvStatus | Receive_SERVER_ERROR (Packet *p) |
The client made an error: uint8 Error code caused (see NetworkErrorCode). | |
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_INFO (Packet *p) |
Sends information about the companies (one packet per company): uint8 Version of the structure of this packet (NETWORK_COMPANY_INFO_VERSION). | |
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_INFO (Packet *p) |
Send information about a client: uint32 ID of the client (always unique on a server. | |
virtual NetworkRecvStatus | Receive_SERVER_NEED_GAME_PASSWORD (Packet *p) |
Indication to the client that the server needs a game password. | |
virtual NetworkRecvStatus | Receive_SERVER_NEED_COMPANY_PASSWORD (Packet *p) |
Indication to the client that the server needs a company password: uint32 Generation seed. | |
virtual NetworkRecvStatus | Receive_SERVER_WELCOME (Packet *p) |
The client is joined and ready to receive his map: uint32 Own client ID. | |
virtual NetworkRecvStatus | Receive_SERVER_WAIT (Packet *p) |
Notification that another client is currently receiving the map: uint8 Number of clients waiting in front of you. | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_BEGIN (Packet *p) |
Sends that the server will begin with sending the map to the client: uint32 Current frame. | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_SIZE (Packet *p) |
Sends the size of the map to the client. | |
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). | |
virtual NetworkRecvStatus | Receive_SERVER_MAP_DONE (Packet *p) |
Sends that all data of the map are sent to the client: | |
virtual NetworkRecvStatus | Receive_SERVER_JOIN (Packet *p) |
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: uint32 ID of the client that just joined the game. | |
virtual NetworkRecvStatus | Receive_SERVER_FRAME (Packet *p) |
Sends the current frame counter to the client: uint32 Frame counter uint32 Frame counter max (how far may the client walk before the server?) uint32 General seed 1 (dependent on compile settings, not default). | |
virtual NetworkRecvStatus | Receive_SERVER_SYNC (Packet *p) |
Sends a sync-check to the client: uint32 Frame counter. | |
virtual NetworkRecvStatus | Receive_SERVER_COMMAND (Packet *p) |
Sends a DoCommand to the client: uint8 ID of the company (0..MAX_COMPANIES-1). | |
virtual NetworkRecvStatus | Receive_SERVER_CHAT (Packet *p) |
Sends a chat-packet to the client: uint8 ID of the action (see NetworkAction). | |
virtual NetworkRecvStatus | Receive_SERVER_QUIT (Packet *p) |
Notification that a client left the game: uint32 ID of the client. | |
virtual NetworkRecvStatus | Receive_SERVER_ERROR_QUIT (Packet *p) |
Inform all clients that one client made an error and thus has quit/been disconnected: uint32 ID of the client that caused the error. | |
virtual NetworkRecvStatus | Receive_SERVER_SHUTDOWN (Packet *p) |
Let the clients know that the server is closing. | |
virtual NetworkRecvStatus | Receive_SERVER_NEWGAME (Packet *p) |
Let the clients know that the server is loading a new map. | |
virtual NetworkRecvStatus | Receive_SERVER_RCON (Packet *p) |
Send the result of an issues RCon command back to the client: uint16 Colour code. | |
virtual NetworkRecvStatus | Receive_SERVER_CHECK_NEWGRFS (Packet *p) |
Sends information about all used GRFs to the client: uint8 Amount of GRFs (the following data is repeated this many times, i.e. | |
virtual NetworkRecvStatus | Receive_SERVER_MOVE (Packet *p) |
Move a client from one company into another: uint32 ID of the client. | |
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_UPDATE (Packet *p) |
Update the clients knowledge of which company is password protected: uint16 Bitwise representation of each company. | |
virtual NetworkRecvStatus | Receive_SERVER_CONFIG_UPDATE (Packet *p) |
Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed. | |
void | CheckConnection () |
Check the connection's state, i.e. | |
![]() | |
NetworkRecvStatus | ReceiveInvalidPacket (PacketGameType type) |
Helper for logging receiving invalid packets. | |
virtual NetworkRecvStatus | Receive_CLIENT_JOIN (Packet *p) |
Try to join the server: string OpenTTD revision (norev000 if no revision). | |
virtual NetworkRecvStatus | Receive_CLIENT_COMPANY_INFO (Packet *p) |
Request company information (in detail). | |
virtual NetworkRecvStatus | Receive_CLIENT_GAME_PASSWORD (Packet *p) |
Send a password to the server to authorize: uint8 Password type (see NetworkPasswordType). | |
virtual NetworkRecvStatus | Receive_CLIENT_COMPANY_PASSWORD (Packet *p) |
Send a password to the server to authorize uint8 Password type (see NetworkPasswordType). | |
virtual NetworkRecvStatus | Receive_CLIENT_GETMAP (Packet *p) |
Request the map from the server. | |
virtual NetworkRecvStatus | Receive_CLIENT_MAP_OK (Packet *p) |
Tell the server that we are done receiving/loading the map. | |
virtual NetworkRecvStatus | Receive_CLIENT_ACK (Packet *p) |
Tell the server we are done with this frame: uint32 Current frame counter of the client. | |
virtual NetworkRecvStatus | Receive_CLIENT_COMMAND (Packet *p) |
Send a DoCommand to the Server: uint8 ID of the company (0..MAX_COMPANIES-1). | |
virtual NetworkRecvStatus | Receive_CLIENT_CHAT (Packet *p) |
Sends a chat-packet to the server: uint8 ID of the action (see NetworkAction). | |
virtual NetworkRecvStatus | Receive_CLIENT_SET_PASSWORD (Packet *p) |
Set the password for the clients current company: string The password. | |
virtual NetworkRecvStatus | Receive_CLIENT_SET_NAME (Packet *p) |
Gives the client a new name: string New name of the client. | |
virtual NetworkRecvStatus | Receive_CLIENT_QUIT (Packet *p) |
The client is quitting the game. | |
virtual NetworkRecvStatus | Receive_CLIENT_ERROR (Packet *p) |
The client made an error and is quitting the game. | |
virtual NetworkRecvStatus | Receive_CLIENT_RCON (Packet *p) |
Send an RCon command to the server: string RCon password. | |
virtual NetworkRecvStatus | Receive_CLIENT_NEWGRFS_CHECKED (Packet *p) |
Tell the server that we have the required GRFs. | |
virtual NetworkRecvStatus | Receive_CLIENT_MOVE (Packet *p) |
Request the server to move this client into another company: uint8 ID of the company the client wants to join. | |
NetworkRecvStatus | HandlePacket (Packet *p) |
Handle the given packet, i.e. | |
NetworkGameSocketHandler (SOCKET s) | |
Create a new socket for the game connection. |
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 = NULL |
This is us! |
Private Types | |
enum | ServerStatus { STATUS_INACTIVE, STATUS_COMPANY_INFO, 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 | |
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. |
Additional Inherited Members | |
![]() | |
ClientID | client_id |
Client identifier. | |
uint32 | last_frame |
Last frame we have executed. | |
uint32 | last_frame_server |
Last frame the server has executed. | |
CommandQueue | incoming_queue |
The command-queue awaiting handling. | |
uint | last_packet |
Time we received the last frame. |
Class for handling the client side of the game connection.
Definition at line 20 of file network_client.h.
|
private |
Status of the connection with the server.
Definition at line 26 of file network_client.h.
ClientNetworkGameSocketHandler::ClientNetworkGameSocketHandler | ( | SOCKET | s | ) |
Create a new socket for the client side of the game connection.
s | The socket to connect with. |
Definition at line 126 of file network_client.cpp.
References my_client.
ClientNetworkGameSocketHandler::~ClientNetworkGameSocketHandler | ( | ) |
Clear whatever we assigned.
Definition at line 133 of file network_client.cpp.
|
protected |
Check the connection's state, i.e.
is the connection still up?
Definition at line 1137 of file network_client.cpp.
References _realtime_tick, CloseConnection(), INVALID_STRING_ID, NetworkGameSocketHandler::last_packet, SetDParam(), ShowErrorMessage(), status, STATUS_AUTHORIZED, WL_CRITICAL, 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 173 of file network_client.cpp.
References _networking, _switch_mode, CloseConnection(), DeleteWindowById(), NETWORK_RECV_STATUS_CLOSE_QUERY, NETWORK_RECV_STATUS_DESYNC, NETWORK_RECV_STATUS_NEWGRF_MISMATCH, NETWORK_RECV_STATUS_SAVEGAME, NETWORK_RECV_STATUS_SERVER_BANNED, NETWORK_RECV_STATUS_SERVER_ERROR, NETWORK_RECV_STATUS_SERVER_FULL, SendError(), SM_MENU, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
Referenced by GameLoop(), and Receive().
|
virtual |
Close the network connection due to the given status.
status | The reason the connection got closed. |
Implements NetworkGameSocketHandler.
Definition at line 141 of file network_client.cpp.
References NetworkGameSocketHandler::client_id, DEBUG, NetworkGameSocketHandler::GetInfo(), MILLISECONDS_PER_TICK, NETWORK_RECV_STATUS_OKAY, NetworkTCPSocketHandler::SendPackets(), NetworkTCPSocketHandler::sock, and status.
Referenced by CheckConnection(), ClientError(), and NetworkClose().
|
static |
Actual game loop for the client.
Definition at line 238 of file network_client.cpp.
References _date, _date_fract, _frame_counter, _network_first_time, _random, _sync_frame, _sync_seed_1, ClientError(), DEBUG, my_client, NETWORK_RECV_STATUS_DESYNC, NetworkExecuteLocalCommandQueue, SendAck(), Randomizer::state, and StateGameLoop().
|
static |
Check whether the client is actually connected (and in the game).
Definition at line 512 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 213 of file network_client.cpp.
References _networking, NetworkTCPSocketHandler::CanSendReceive(), ClientError(), my_client, NETWORK_RECV_STATUS_OKAY, and NetworkGameSocketHandler::ReceivePackets().
Referenced by NetworkReceive().
|
protectedvirtual |
Notification that the client trying to join is banned.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 534 of file network_client.cpp.
References DeleteWindowById(), INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_BANNED, ShowErrorMessage(), WC_NETWORK_STATUS_WINDOW, WL_CRITICAL, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
protectedvirtual |
Sends a chat-packet to the client: uint8 ID of the action (see NetworkAction).
uint32 ID of the client (origin of the chat). string Message (max NETWORK_CHAT_LENGTH). uint64 data (used e.g. for 'give money' actions).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 940 of file network_client.cpp.
References _network_own_client_id, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_playas, NetworkClientInfo::GetByClientID(), GetDrawStringCompanyColour(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), lastof, NETWORK_CHAT_LENGTH, NETWORK_NAME_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(), seprintf(), SetDParam(), status, and STATUS_ACTIVE.
|
protectedvirtual |
Sends information about all used GRFs to the client: uint8 Amount of GRFs (the following data is repeated this many times, i.e.
per GRF data). uint32 GRF ID 16 * uint8 MD5 checksum of the GRF
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 678 of file network_client.cpp.
References BSWAP32(), DEBUG, FGCM_EXACT, FindGRFConfig(), GRFIdentifier::grfid, INVALID_STRING_ID, lastof, GRFIdentifier::md5sum, md5sumToString(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_NEWGRF_MISMATCH, NETWORK_RECV_STATUS_OKAY, NetworkSocketHandler::ReceiveGRFIdentifier(), Packet::Recv_uint8(), SendNewGRFsOk(), ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.
|
protectedvirtual |
Send information about a client: uint32 ID of the client (always unique on a server.
1 = server, 0 is invalid). uint8 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 587 of file network_client.cpp.
References _network_own_client_id, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_networkclientinfo_pool >::CanAllocateItem(), CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, NetworkClientInfo::client_playas, COMPANY_SPECTATOR, NetworkClientInfo::GetByClientID(), NetworkSocketHandler::HasClientQuit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), lastof, NETWORK_NAME_LENGTH, NETWORK_RECV_STATUS_CONN_LOST, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint32(), Packet::Recv_uint8(), NetworkGameSocketHandler::SetInfo(), SetLocalCompany(), SetWindowDirty(), status, STATUS_AUTHORIZED, strecpy(), and WC_CLIENT_LIST.
|
protectedvirtual |
Sends a DoCommand to the client: uint8 ID of the company (0..MAX_COMPANIES-1).
uint32 ID of the command (see command.h). uint32 P1 (free variable used in DoCommand). uint32 P2. uint32 Tile where this is taking place. string Text. uint8 ID of the callback. uint32 Frame of execution.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 921 of file network_client.cpp.
References CommandQueue::Append(), CC_ERROR, CommandPacket::frame, IConsolePrintF(), 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.
|
protectedvirtual |
Sends information about the companies (one packet per company): uint8 Version of the structure of this packet (NETWORK_COMPANY_INFO_VERSION).
bool Contains data (false marks the end of updates). uint8 ID of the company. string Name of the company. uint32 Year the company was inaugurated. uint64 Value. uint64 Money. uint64 Income. uint16 Performance (last quarter). bool Company is password protected. uint16 Number of trains. uint16 Number of lorries. uint16 Number of busses. uint16 Number of planes. uint16 Number of ships. uint16 Number of train stations. uint16 Number of lorry stations. uint16 Number of bus stops. uint16 Number of airports and heliports. uint16 Number of harbours. bool Company is an AI. string Client names (comma separated list)
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 543 of file network_client.cpp.
References NetworkCompanyStats::ai, NetworkCompanyInfo::clients, NetworkCompanyInfo::company_name, NetworkCompanyInfo::company_value, GetLobbyCompanyInfo(), NetworkSocketHandler::HasClientQuit(), NetworkCompanyInfo::inaugurated_year, NetworkCompanyInfo::income, MAX_COMPANIES, NetworkCompanyInfo::money, NETWORK_COMPANY_INFO_VERSION, NETWORK_RECV_STATUS_CLOSE_QUERY, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, NetworkCompanyStats::num_station, NetworkCompanyStats::num_vehicle, NetworkCompanyInfo::performance, Packet::Recv_bool(), Packet::Recv_string(), Packet::Recv_uint16(), Packet::Recv_uint32(), Packet::Recv_uint64(), Packet::Recv_uint8(), SetWindowDirty(), status, STATUS_COMPANY_INFO, NetworkCompanyInfo::use_password, WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_LOBBY.
|
protectedvirtual |
Update the clients knowledge of which company is password protected: uint16 Bitwise representation of each company.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1124 of file network_client.cpp.
References _network_company_passworded, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint16(), SetWindowClassesDirty(), status, STATUS_ACTIVE, and WC_COMPANY.
|
protectedvirtual |
Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed.
uint8 Maximum number of spectators allowed.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1114 of file network_client.cpp.
References NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint8(), status, and STATUS_ACTIVE.
|
protectedvirtual |
The client made an error: uint8 Error code caused (see NetworkErrorCode).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 640 of file network_client.cpp.
References DeleteWindowById(), error(), INVALID_STRING_ID, lengthof, NETWORK_RECV_STATUS_SERVER_ERROR, Packet::Recv_uint8(), ShowErrorMessage(), WC_NETWORK_STATUS_WINDOW, WL_CRITICAL, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
protectedvirtual |
Inform all clients that one client made an error and thus has quit/been disconnected: uint32 ID of the client that caused the error.
uint8 Code of the error caused (see NetworkErrorCode).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 992 of file network_client.cpp.
References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), GetNetworkErrorMsg(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), Packet::Recv_uint8(), SetWindowDirty(), status, STATUS_AUTHORIZED, and WC_CLIENT_LIST.
|
protectedvirtual |
Sends the current frame counter to the client: uint32 Frame counter uint32 Frame counter max (how far may the client walk before the server?) uint32 General seed 1 (dependent on compile settings, not default).
uint32 General seed 2 (dependent on compile settings, not default). uint8 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 875 of file network_client.cpp.
References _frame_counter, _frame_counter_max, _frame_counter_server, _network_first_time, _sync_frame, _sync_seed_1, DAY_TICKS, DEBUG, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::pos, Packet::Recv_uint32(), Packet::Recv_uint8(), SendAck(), Packet::size, status, STATUS_ACTIVE, and token.
|
protectedvirtual |
Notification that the server is full.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 525 of file network_client.cpp.
References DeleteWindowById(), INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_FULL, ShowErrorMessage(), WC_NETWORK_STATUS_WINDOW, WL_CRITICAL, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
protectedvirtual |
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: uint32 ID of the client that just joined the game.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1029 of file network_client.cpp.
References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), SetWindowDirty(), status, STATUS_AUTHORIZED, and WC_CLIENT_LIST.
|
protectedvirtual |
Sends that the server will begin with sending the map to the client: uint32 Current frame.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 773 of file network_client.cpp.
References _frame_counter, _frame_counter_max, _frame_counter_server, _network_join_bytes, _network_join_bytes_total, _network_join_status, 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.
|
protectedvirtual |
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 804 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.
|
protectedvirtual |
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 818 of file network_client.cpp.
References _local_company, _network_join_status, _realtime_tick, ClearErrorMessages(), CMD_COMPANY_CTRL, COMPANY_NEW_COMPANY, COMPANY_SPECTATOR, DeleteWindowById(), DFT_GAME_FILE, INVALID_STRING_ID, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), NetworkGameSocketHandler::last_packet, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, NETWORK_RECV_STATUS_SAVEGAME, NetworkSendCommand(), NO_DIRECTORY, LoadFilter::Reset(), SafeLoad(), savegame, SendMapOk(), SetLocalCompany(), SetWindowDirty(), ShowErrorMessage(), SLO_LOAD, status, STATUS_MAP, WC_NETWORK_STATUS_WINDOW, WL_CRITICAL, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
protectedvirtual |
Sends the size of the map to the client.
uint32 Size of the (compressed) map (in bytes).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 793 of file network_client.cpp.
References _network_join_bytes_total, 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.
|
protectedvirtual |
Move a client from one company into another: uint32 ID of the client.
uint8 ID of the new company.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1086 of file network_client.cpp.
References _network_own_client_id, NetworkGameSocketHandler::client_id, COMPANY_SPECTATOR, DEBUG, NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), Packet::Recv_uint8(), SetLocalCompany(), status, and STATUS_AUTHORIZED.
|
protectedvirtual |
Indication to the client that the server needs a company password: uint32 Generation seed.
string Network ID of the server.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 726 of file network_client.cpp.
References _network_join_company_password, NetworkSocketHandler::HasClientQuit(), NETWORK_COMPANY_PASSWORD, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint32(), SendCompanyPassword(), status, STATUS_AUTH_COMPANY, and StrEmpty().
|
protectedvirtual |
Indication to the client that the server needs a game password.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 711 of file network_client.cpp.
References _network_join_server_password, NETWORK_GAME_PASSWORD, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, SendGamePassword(), status, STATUS_AUTH_GAME, and StrEmpty().
|
protectedvirtual |
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 1056 of file network_client.cpp.
References _network_own_client_id, _network_reconnect, INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_ERROR, ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.
|
protectedvirtual |
Notification that a client left the game: uint32 ID of the client.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1009 of file network_client.cpp.
References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, DEBUG, NetworkClientInfo::GetByClientID(), NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), SetWindowDirty(), status, STATUS_AUTHORIZED, and WC_CLIENT_LIST.
|
protectedvirtual |
Send the result of an issues RCon command back to the client: uint16 Colour code.
string Output of the RCon command
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1071 of file network_client.cpp.
References IConsolePrint(), IsValidConsoleColour(), NETWORK_RCONCOMMAND_LENGTH, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_string(), Packet::Recv_uint16(), status, and STATUS_AUTHORIZED.
|
protectedvirtual |
Let the clients know that the server is closing.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 1045 of file network_client.cpp.
References INVALID_STRING_ID, NETWORK_RECV_STATUS_SERVER_ERROR, ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.
|
protectedvirtual |
Sends a sync-check to the client: uint32 Frame counter.
uint32 General seed 1. uint32 General seed 2 (dependent on compile settings, not default).
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 908 of file network_client.cpp.
References _sync_frame, _sync_seed_1, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint32(), status, and STATUS_ACTIVE.
|
protectedvirtual |
Notification that another client is currently receiving the map: uint8 Number of clients waiting in front of you.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 760 of file network_client.cpp.
References _network_join_status, _network_join_waiting, NETWORK_RECV_STATUS_MALFORMED_PACKET, NETWORK_RECV_STATUS_OKAY, Packet::Recv_uint8(), SetWindowDirty(), status, STATUS_MAP_WAIT, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
protectedvirtual |
The client is joined and ready to receive his map: uint32 Own client ID.
uint32 Generation seed. string Network ID of the server.
p | The packet that was just received. |
Reimplemented from NetworkGameSocketHandler.
Definition at line 745 of file network_client.cpp.
References _network_own_client_id, NETWORK_RECV_STATUS_MALFORMED_PACKET, Packet::Recv_string(), Packet::Recv_uint32(), SendGetMap(), status, and STATUS_AUTHORIZED.
|
static |
Send the packets of this socket handler.
Definition at line 228 of file network_client.cpp.
References CheckConnection(), my_client, and NetworkTCPSocketHandler::SendPackets().
|
static |
Send an acknowledgement from the server's ticks.
Definition at line 395 of file network_client.cpp.
References _frame_counter, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_ACK, Packet::Send_uint32(), Packet::Send_uint8(), NetworkTCPSocketHandler::SendPacket(), and token.
Referenced by GameLoop(), and Receive_SERVER_FRAME().
|
static |
Send a command to the server.
cp | The command to send. |
Definition at line 409 of file network_client.cpp.
References my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_COMMAND, and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkSendCommand().
|
static |
Query the server for company information.
Definition at line 314 of file network_client.cpp.
References _network_join_status, my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_COMPANY_INFO, NetworkTCPSocketHandler::SendPacket(), SetWindowDirty(), status, STATUS_COMPANY_INFO, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
|
static |
Set the company password as requested.
password | The company password. |
Definition at line 366 of file network_client.cpp.
References GenerateCompanyPasswordHash(), my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_COMPANY_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkJoinStatusWindow::OnQueryTextFinished(), and Receive_SERVER_NEED_COMPANY_PASSWORD().
|
static |
Set the game password as requested.
password | The game password. |
Definition at line 354 of file network_client.cpp.
References my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_GAME_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkJoinStatusWindow::OnQueryTextFinished(), and Receive_SERVER_NEED_GAME_PASSWORD().
|
staticprotected |
Request the map from the server.
Definition at line 375 of file network_client.cpp.
References my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_GETMAP, NetworkTCPSocketHandler::SendPacket(), status, and STATUS_MAP_WAIT.
Referenced by Receive_SERVER_WELCOME().
|
static |
Tell the server we would like to join.
Definition at line 326 of file network_client.cpp.
References _network_join_status, _settings_client, NetworkSettings::client_name, my_client, ClientSettings::network, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_JOIN, Packet::Send_string(), Packet::Send_uint32(), Packet::Send_uint8(), NetworkTCPSocketHandler::SendPacket(), SetWindowDirty(), status, STATUS_JOIN, WC_NETWORK_STATUS_WINDOW, and WN_NETWORK_STATUS_WINDOW_JOIN.
Referenced by NetworkClient_Connected().
|
staticprotected |
Tell the server we received the complete map.
Definition at line 385 of file network_client.cpp.
References my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_MAP_OK, NetworkTCPSocketHandler::SendPacket(), status, and STATUS_ACTIVE.
Referenced by Receive_SERVER_MAP_DONE().
|
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 499 of file network_client.cpp.
References GenerateCompanyPasswordHash(), my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_MOVE, Packet::Send_string(), Packet::Send_uint8(), and NetworkTCPSocketHandler::SendPacket().
Referenced by NetworkClientRequestMove().
|
staticprotected |
Tell the server we got all the NewGRFs.
Definition at line 343 of file network_client.cpp.
References my_client, NETWORK_RECV_STATUS_OKAY, PACKET_CLIENT_NEWGRFS_CHECKED, and NetworkTCPSocketHandler::SendPacket().
Referenced by Receive_SERVER_CHECK_NEWGRFS().
|
static |
Send a console command.
pass | The password for the remote command. |
command | The actual command. |
Definition at line 485 of file network_client.cpp.
References 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 460 of file network_client.cpp.
References 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 447 of file network_client.cpp.
References 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 530 of file network.cpp.
|
staticprotected |
This is us!
Our client's connection.
Definition at line 45 of file network_client.h.
Referenced by ClientNetworkGameSocketHandler(), GameLoop(), IsConnected(), NetworkClose(), NetworkExecuteLocalCommandQueue(), Receive(), Send(), SendAck(), SendChat(), SendCommand(), SendCompanyInformationQuery(), SendCompanyPassword(), SendError(), SendGamePassword(), SendGetMap(), SendJoin(), SendMapOk(), SendMove(), SendNewGRFsOk(), SendQuit(), SendRCon(), SendSetName(), SendSetPassword(), and ~ClientNetworkGameSocketHandler().