Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | Private Types | Private Attributes | Friends

ClientNetworkGameSocketHandler Class Reference

Class for handling the client side of the game connection. More...

#include <network_client.h>

Inheritance diagram for ClientNetworkGameSocketHandler:
ZeroedMemoryAllocator NetworkGameSocketHandler NetworkTCPSocketHandler NetworkSocketHandler

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.

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 (dependant 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.

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 PacketReadersavegame
 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.

Detailed Description

Class for handling the client side of the game connection.

Definition at line 20 of file network_client.h.


Member Enumeration Documentation

Status of the connection with the server.

Enumerator:
STATUS_INACTIVE 

The client is not connected nor active.

STATUS_COMPANY_INFO 

We are trying to get company information.

STATUS_JOIN 

We are trying to join a server.

STATUS_NEWGRFS_CHECK 

Last action was checking NewGRFs.

STATUS_AUTH_GAME 

Last action was requesting game (server) password.

STATUS_AUTH_COMPANY 

Last action was requestion company password.

STATUS_AUTHORIZED 

The client is authorized at the server.

STATUS_MAP_WAIT 

The client is waiting as someone else is downloading the map.

STATUS_MAP 

The client is downloading the map.

STATUS_ACTIVE 

The client is active within in the game.

STATUS_END 

Must ALWAYS be on the end of this list!! (period).

Definition at line 26 of file network_client.h.


Constructor & Destructor Documentation

ClientNetworkGameSocketHandler::ClientNetworkGameSocketHandler ( SOCKET  s  ) 

Create a new socket for the client side of the game connection.

Parameters:
s The socket to connect with.

Definition at line 125 of file network_client.cpp.

References my_client.

ClientNetworkGameSocketHandler::~ClientNetworkGameSocketHandler (  ) 

Clear whatever we assigned.

Definition at line 132 of file network_client.cpp.

References my_client, and savegame.


Member Function Documentation

void ClientNetworkGameSocketHandler::CheckConnection (  )  [protected]

Check the connection's state, i.e.

is the connection still up?

Definition at line 1142 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  ) 
NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection ( NetworkRecvStatus  status  )  [virtual]

Close the network connection due to the given status.

Parameters:
status The reason the connection got closed.

Implements NetworkGameSocketHandler.

Definition at line 140 of file network_client.cpp.

References NetworkGameSocketHandler::client_id, DEBUG, NetworkGameSocketHandler::GetInfo(), MILLISECONDS_PER_TICK, NETWORK_RECV_STATUS_OKAY, NetworkTCPSocketHandler::SendPackets(), and NetworkTCPSocketHandler::sock.

Referenced by CheckConnection(), ClientError(), and NetworkClose().

bool ClientNetworkGameSocketHandler::GameLoop (  )  [static]

Actual game loop for the client.

Returns:
Whether everything went okay, or not.

Definition at line 237 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().

bool ClientNetworkGameSocketHandler::IsConnected (  )  [static]

Check whether the client is actually connected (and in the game).

Returns:
True when the client is connected.

Definition at line 517 of file network_client.cpp.

References my_client, and status.

Referenced by DEF_CONSOLE_HOOK().

bool ClientNetworkGameSocketHandler::Receive (  )  [static]

Check whether we received/can send some data from/to the server and when that's the case handle it appropriately.

Returns:
true when everything went okay.

Definition at line 212 of file network_client.cpp.

References _networking, NetworkTCPSocketHandler::CanSendReceive(), ClientError(), my_client, NETWORK_RECV_STATUS_OKAY, and NetworkGameSocketHandler::ReceivePackets().

Referenced by NetworkReceive().

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_BANNED ( Packet p  )  [protected, virtual]

Notification that the client trying to join is banned.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 539 of file network_client.cpp.

References DeleteWindowById(), INVALID_STRING_ID, ShowErrorMessage(), and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT ( Packet p  )  [protected, virtual]

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).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 945 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, Packet::Recv_bool(), Packet::Recv_string(), Packet::Recv_uint32(), Packet::Recv_uint64(), Packet::Recv_uint8(), SetDParam(), status, and STATUS_ACTIVE.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS ( Packet p  )  [protected, virtual]

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

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 683 of file network_client.cpp.

References BSWAP32(), DEBUG, FGCM_EXACT, FindGRFConfig(), GRFIdentifier::grfid, INVALID_STRING_ID, lastof, GRFIdentifier::md5sum, md5sumToString(), NETWORK_RECV_STATUS_OKAY, NetworkSocketHandler::ReceiveGRFIdentifier(), Packet::Recv_uint8(), SendNewGRFsOk(), ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMMAND ( Packet p  )  [protected, virtual]

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.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 926 of file network_client.cpp.

References CommandQueue::Append(), CC_ERROR, CommandPacket::frame, IConsolePrintF(), NetworkGameSocketHandler::incoming_queue, CommandPacket::my_cmd, NetworkGameSocketHandler::ReceiveCommand(), Packet::Recv_bool(), Packet::Recv_uint32(), status, and STATUS_ACTIVE.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_INFO ( Packet p  )  [protected, virtual]

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)

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 548 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, 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, and NetworkCompanyInfo::use_password.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE ( Packet p  )  [protected, virtual]

Update the clients knowledge of which company is password protected: uint16 Bitwise representation of each company.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1129 of file network_client.cpp.

References _network_company_passworded, Packet::Recv_uint16(), SetWindowClassesDirty(), status, and STATUS_ACTIVE.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE ( Packet p  )  [protected, virtual]

Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed.

uint8 Maximum number of spectators allowed.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1119 of file network_client.cpp.

References Packet::Recv_uint8(), status, and STATUS_ACTIVE.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR ( Packet p  )  [protected, virtual]

The client made an error: uint8 Error code caused (see NetworkErrorCode).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 645 of file network_client.cpp.

References DeleteWindowById(), error(), INVALID_STRING_ID, Packet::Recv_uint8(), ShowErrorMessage(), and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT ( Packet p  )  [protected, virtual]

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).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 997 of file network_client.cpp.

References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), GetNetworkErrorMsg(), Packet::Recv_uint32(), Packet::Recv_uint8(), SetWindowDirty(), status, and STATUS_AUTHORIZED.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME ( Packet p  )  [protected, virtual]

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 (dependant on compile settings, not default).

uint32 General seed 2 (dependant on compile settings, not default). uint8 Random token to validate the client is actually listening (only occasionally present).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 880 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, Packet::pos, Packet::Recv_uint32(), Packet::Recv_uint8(), SendAck(), Packet::size, status, STATUS_ACTIVE, and token.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL ( Packet p  )  [protected, virtual]

Notification that the server is full.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 530 of file network_client.cpp.

References DeleteWindowById(), INVALID_STRING_ID, ShowErrorMessage(), and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_JOIN ( Packet p  )  [protected, virtual]

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.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1034 of file network_client.cpp.

References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), Packet::Recv_uint32(), SetWindowDirty(), status, and STATUS_AUTHORIZED.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_BEGIN ( Packet p  )  [protected, virtual]

Sends that the server will begin with sending the map to the client: uint32 Current frame.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 778 of file network_client.cpp.

References _frame_counter, _frame_counter_max, _frame_counter_server, _network_join_bytes, _network_join_bytes_total, _network_join_status, Packet::Recv_uint32(), savegame, SetWindowDirty(), status, and STATUS_MAP.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA ( Packet p  )  [protected, virtual]

Sends the data of the map to the client: Contains a part of the map (until max size of packet).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 809 of file network_client.cpp.

References _network_join_bytes, PacketReader::AddPacket(), savegame, SetWindowDirty(), status, STATUS_MAP, and PacketReader::written_bytes.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_SIZE ( Packet p  )  [protected, virtual]

Sends the size of the map to the client.

uint32 Size of the (compressed) map (in bytes).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 798 of file network_client.cpp.

References _network_join_bytes_total, Packet::Recv_uint32(), savegame, SetWindowDirty(), status, and STATUS_MAP.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE ( Packet p  )  [protected, virtual]

Move a client from one company into another: uint32 ID of the client.

uint8 ID of the new company.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1091 of file network_client.cpp.

References _network_own_client_id, NetworkGameSocketHandler::client_id, DEBUG, NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Packet::Recv_uint32(), Packet::Recv_uint8(), SetLocalCompany(), status, and STATUS_AUTHORIZED.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEED_COMPANY_PASSWORD ( Packet p  )  [protected, virtual]

Indication to the client that the server needs a company password: uint32 Generation seed.

string Network ID of the server.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 731 of file network_client.cpp.

References NetworkSocketHandler::HasClientQuit(), NETWORK_COMPANY_PASSWORD, Packet::Recv_string(), Packet::Recv_uint32(), SendCompanyPassword(), status, STATUS_AUTH_COMPANY, and StrEmpty().

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEED_GAME_PASSWORD ( Packet p  )  [protected, virtual]

Indication to the client that the server needs a game password.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 716 of file network_client.cpp.

References NETWORK_GAME_PASSWORD, SendGamePassword(), status, STATUS_AUTH_GAME, and StrEmpty().

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_NEWGAME ( Packet p  )  [protected, virtual]

Let the clients know that the server is loading a new map.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1061 of file network_client.cpp.

References _network_own_client_id, _network_reconnect, INVALID_STRING_ID, ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT ( Packet p  )  [protected, virtual]

Notification that a client left the game: uint32 ID of the client.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1014 of file network_client.cpp.

References CC_DEFAULT, NetworkGameSocketHandler::client_id, NetworkClientInfo::client_name, DEBUG, NetworkClientInfo::GetByClientID(), Packet::Recv_uint32(), SetWindowDirty(), status, and STATUS_AUTHORIZED.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_RCON ( Packet p  )  [protected, virtual]

Send the result of an issues RCon command back to the client: uint16 Colour code.

string Output of the RCon command

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1076 of file network_client.cpp.

References IConsolePrint(), IsValidConsoleColour(), NETWORK_RCONCOMMAND_LENGTH, Packet::Recv_string(), Packet::Recv_uint16(), status, and STATUS_AUTHORIZED.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_SHUTDOWN ( Packet p  )  [protected, virtual]

Let the clients know that the server is closing.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 1050 of file network_client.cpp.

References INVALID_STRING_ID, ShowErrorMessage(), status, STATUS_JOIN, and WL_CRITICAL.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_SYNC ( Packet p  )  [protected, virtual]

Sends a sync-check to the client: uint32 Frame counter.

uint32 General seed 1. uint32 General seed 2 (dependant on compile settings, not default).

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 913 of file network_client.cpp.

References _sync_frame, _sync_seed_1, Packet::Recv_uint32(), status, and STATUS_ACTIVE.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WAIT ( Packet p  )  [protected, virtual]

Notification that another client is currently receiving the map: uint8 Number of clients waiting in front of you.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 765 of file network_client.cpp.

References _network_join_status, _network_join_waiting, Packet::Recv_uint8(), SetWindowDirty(), status, and STATUS_MAP_WAIT.

NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_WELCOME ( Packet p  )  [protected, virtual]

The client is joined and ready to receive his map: uint32 Own client ID.

uint32 Generation seed. string Network ID of the server.

Parameters:
p The packet that was just received.

Reimplemented from NetworkGameSocketHandler.

Definition at line 750 of file network_client.cpp.

References _network_own_client_id, Packet::Recv_string(), Packet::Recv_uint32(), SendGetMap(), status, and STATUS_AUTHORIZED.

void ClientNetworkGameSocketHandler::Send (  )  [static]

Send the packets of this socket handler.

Definition at line 227 of file network_client.cpp.

References CheckConnection(), my_client, and NetworkTCPSocketHandler::SendPackets().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendAck (  )  [static]

Send an acknowledgement from the server's ticks.

Definition at line 400 of file network_client.cpp.

References _frame_counter, my_client, PACKET_CLIENT_ACK, Packet::Send_uint32(), Packet::Send_uint8(), NetworkTCPSocketHandler::SendPacket(), and token.

Referenced by GameLoop(), and Receive_SERVER_FRAME().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand ( const CommandPacket cp  )  [static]

Send a command to the server.

Parameters:
cp The command to send.

Definition at line 414 of file network_client.cpp.

References my_client, PACKET_CLIENT_COMMAND, and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkSendCommand().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyInformationQuery (  )  [static]

Query the server for company information.

Definition at line 313 of file network_client.cpp.

References _network_join_status, my_client, PACKET_CLIENT_COMPANY_INFO, NetworkTCPSocketHandler::SendPacket(), SetWindowDirty(), and status.

Referenced by TCPQueryConnecter::OnConnect().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendCompanyPassword ( const char *  password  )  [static]

Set the company password as requested.

Parameters:
password The company password.

Definition at line 364 of file network_client.cpp.

References GenerateCompanyPasswordHash(), my_client, PACKET_CLIENT_COMPANY_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkJoinStatusWindow::OnQueryTextFinished(), and Receive_SERVER_NEED_COMPANY_PASSWORD().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendGamePassword ( const char *  password  )  [static]

Set the game password as requested.

Parameters:
password The game password.

Definition at line 352 of file network_client.cpp.

References my_client, PACKET_CLIENT_GAME_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkJoinStatusWindow::OnQueryTextFinished(), and Receive_SERVER_NEED_GAME_PASSWORD().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap (  )  [static, protected]

Request the map from the server.

Definition at line 373 of file network_client.cpp.

References my_client, PACKET_CLIENT_GETMAP, Packet::Send_uint32(), NetworkTCPSocketHandler::SendPacket(), and status.

Referenced by Receive_SERVER_WELCOME().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendMapOk (  )  [static, protected]

Tell the server we received the complete map.

Definition at line 390 of file network_client.cpp.

References my_client, PACKET_CLIENT_MAP_OK, NetworkTCPSocketHandler::SendPacket(), and status.

Referenced by Receive_SERVER_MAP_DONE().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendMove ( CompanyID  company,
const char *  password 
) [static]

Ask the server to move us.

Parameters:
company The company to move to.
password The password of the company to move to.

Definition at line 504 of file network_client.cpp.

References GenerateCompanyPasswordHash(), my_client, PACKET_CLIENT_MOVE, Packet::Send_string(), Packet::Send_uint8(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkClientRequestMove().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendNewGRFsOk (  )  [static, protected]

Tell the server we got all the NewGRFs.

Definition at line 341 of file network_client.cpp.

References my_client, PACKET_CLIENT_NEWGRFS_CHECKED, and NetworkTCPSocketHandler::SendPacket().

Referenced by Receive_SERVER_CHECK_NEWGRFS().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon ( const char *  pass,
const char *  command 
) [static]

Send a console command.

Parameters:
pass The password for the remote command.
command The actual command.

Definition at line 490 of file network_client.cpp.

References my_client, PACKET_CLIENT_RCON, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkClientSendRcon().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetName ( const char *  name  )  [static]

Tell the server that we like to change the name of the client.

Parameters:
name The new name.

Definition at line 465 of file network_client.cpp.

References my_client, PACKET_CLIENT_SET_NAME, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkUpdateClientName().

NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetPassword ( const char *  password  )  [static]

Tell the server that we like to change the password of the company.

Parameters:
password The new password.

Definition at line 452 of file network_client.cpp.

References GenerateCompanyPasswordHash(), my_client, PACKET_CLIENT_SET_PASSWORD, Packet::Send_string(), and NetworkTCPSocketHandler::SendPacket().

Referenced by NetworkClientSetCompanyPassword().


Friends And Related Function Documentation

void NetworkClose ( bool  close_admins  )  [friend]

Close current connections.

Parameters:
close_admins Whether the admin connections have to be closed as well.

Definition at line 510 of file network.cpp.


Field Documentation


The documentation for this class was generated from the following files: