16 #include "../../stdafx.h" 18 #include "../network.h" 19 #include "../network_internal.h" 20 #include "../../debug.h" 21 #include "../../error.h" 23 #include "table/strings.h" 25 #include "../../safeguards.h" 119 DEBUG(net, 0,
"[tcp/game] received invalid packet type %d from client %d", type, this->
client_id);
121 DEBUG(net, 0,
"[tcp/game] received illegal packet from client %d", this->
client_id);
153 DEBUG(net, 0,
"[tcp/game] received illegal packet type %d from client %d", type, this->
client_id);
Client acknowledges that it has all required NewGRFs.
virtual NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p)
Indication to the client that the server needs a game password.
virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p)
Sends a sync-check to the client: uint32 Frame counter.
Information about a single company.
bool _networking
are we in networking mode?
Server tells everyone that someone is moved to another company.
bool HasClientQuit() const
Whether the current client connected to the socket has quit.
virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p)
Notification that the server is full.
SOCKET sock
The socket currently connected to.
uint32 _realtime_tick
The real time in the game.
Internal entity of a packet.
A client changes its name.
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
A server tells that a client has hit an error and did quit.
Switch to game intro menu.
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...
virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p)
Send a password to the server to authorize: uint8 Password type (see NetworkPasswordType).
The server is full and has no place for you.
virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p)
Sends a chat-packet to the server: uint8 ID of the action (see NetworkAction).
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 repe...
Clients sends the (hashed) game password.
virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p)
Notification that another client is currently receiving the map: uint8 Number of clients waiting in f...
Server distributing the message of a client (or itself).
virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p)
Sends that all data of the map are sent to the client:
virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p)
Indication to the client that the server needs a company password: uint32 Generation seed...
Server tells the client what frame it is in, and thus to where the client may progress.
virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p)
The client made an error and is quitting the game.
The server told us we made an error.
NetworkRecvStatus ReceiveInvalidPacket(PacketGameType type)
Helper for logging receiving invalid packets.
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p)
The client is joined and ready to receive his map: uint32 Own client ID.
The client tells the server which frame it has executed.
virtual Packet * ReceivePacket()
Receives a packet for the given client.
Server tells the client what the random state should be.
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p)
Sends a chat-packet to the client: uint8 ID of the action (see NetworkAction).
Server welcomes you and gives you your ClientID.
Client asks the server to execute some command.
Server tells the client that it is beginning to send the map.
Response of the executed command on the server.
A server tells that a client has quit.
Server distributes a command to (all) the clients.
Critical errors, the MessageBox is shown in all cases.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Server sends NewGRF IDs and MD5 checksums for the client to check.
virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p)
Gives the client a new name: string New name of the client.
A client would like to be moved to another company.
Server sends you information about a client.
NetworkRecvStatus CloseConnection(bool error=true)
Functions to help ReceivePacket/SendPacket a bit A socket can make errors.
Client sends the (hashed) company password.
Server sends bits of the map to the client.
NetworkRecvStatus HandlePacket(Packet *p)
Handle the given packet, i.e.
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_COMPANY_INFO(Packet *p)
Request company information (in detail).
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_SERVER_JOIN(Packet *p)
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO:...
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p)
The client made an error: uint8 Error code caused (see NetworkErrorCode).
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)...
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
A client (re)sets its company's password.
NetworkGameSocketHandler(SOCKET s)
Create a new socket for the game connection.
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_MAP_OK(Packet *p)
Tell the server that we are done receiving/loading the map.
virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p)
Try to join the server: string OpenTTD revision (norev000 if no revision).
virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p)
Tell the server that we have the required GRFs.
uint last_packet
Time we received the last frame.
virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p)
Let the clients know that the server is closing.
Server sending an error message to the client.
A client reports an error to the server.
virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p)
Move a client from one company into another: uint32 ID of the client.
virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p)
Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed...
The connection is 'just' lost.
virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p)
Sends the size of the map to the client.
#define DEBUG(name, level,...)
Output a line of debugging information.
PacketGameType
Enum with all types of TCP packets.
ClientID client_id
Client identifier.
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_CLIENT_RCON(Packet *p)
Send an RCon command to the server: string RCon password.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p)
Notification that a client left the game: uint32 ID of the client.
Tells clients that a new client has joined.
Some network configuration important to the client changed.
Client requests the actual map.
uint32 _frame_counter
The current frame.
virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p)
Let the clients know that the server is loading a new map.
virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p)
Request the map from the server.
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_CLIENT_SET_PASSWORD(Packet *p)
Set the password for the clients current company: string The password.
The server is preparing to start a new game.
virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p)
Sends that the server will begin with sending the map to the client: uint32 Current frame...
Client is not part of anything.
Client executed a command and sends it to the server.
virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p)
Sends information about the companies (one packet per company): uint8 Version of the structure of thi...
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Server tells it has just sent the last bits of the map to the client.
Server tells the client what the (compressed) size of the map is.
The client telling the server it wants to join.
virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p)
Sends the current frame counter to the client: uint32 Frame counter uint32 Frame counter max (how far...
Must ALWAYS be on the end of this list!! (period)
Server tells the client there are some people waiting for the map as well.
SwitchMode _switch_mode
The next mainloop command.
A client tells the server it is going to quit.
bool _network_server
network-server is active
Server requests the (hashed) game password.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
We apparently send a malformed packet.
Server requests the (hashed) company password.
Client said something that should be distributed.
virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p)
Sends a DoCommand to the client: uint8 ID of the company (0..MAX_COMPANIES-1).
The server has banned you.
virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p)
Notification that the client trying to join is banned.
The server is shutting down.
virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p)
The client is quitting the game.
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 th...
Information (password) of a company changed.
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p)
Update the clients knowledge of which company is password protected: uint16 Bitwise representation of...
Request information about all companies.
Client tells the server that it received the whole map.