14 #include "../stdafx.h" 16 #include "../saveload/saveload.h" 17 #include "../saveload/saveload_filter.h" 18 #include "../command_func.h" 19 #include "../console_func.h" 20 #include "../strings_func.h" 21 #include "../window_func.h" 22 #include "../company_func.h" 23 #include "../company_base.h" 24 #include "../company_gui.h" 25 #include "../core/random_func.hpp" 26 #include "../date_func.h" 27 #include "../gfx_func.h" 33 #include "../core/backup_type.hpp" 35 #include "table/strings.h" 37 #include "../safeguards.h" 44 static const size_t CHUNK = 32 * 1024;
64 assert(this->read_bytes == 0);
66 size_t in_packet = p->
size - p->
pos;
67 size_t to_write =
min((
size_t)(this->bufe - this->buf), in_packet);
70 this->written_bytes += in_packet;
72 memcpy(this->buf, pbuf, to_write);
73 this->buf += to_write;
77 if (to_write == in_packet)
return;
81 to_write = in_packet - to_write;
82 this->buf = *this->blocks.
Append() = CallocT<byte>(
CHUNK);
83 this->bufe = this->buf +
CHUNK;
85 memcpy(this->buf, pbuf, to_write);
86 this->buf += to_write;
89 size_t Read(byte *rbuf,
size_t size)
92 size_t ret_size = size =
min(this->written_bytes - this->read_bytes, size);
93 this->read_bytes += ret_size;
94 const byte *rbufe = rbuf + ret_size;
96 while (rbuf != rbufe) {
97 if (this->buf == this->bufe) {
98 this->buf = *this->block++;
99 this->bufe = this->buf +
CHUNK;
102 size_t to_write =
min(this->bufe - this->buf, rbufe - rbuf);
103 memcpy(rbuf, this->buf, to_write);
105 this->buf += to_write;
113 this->read_bytes = 0;
115 this->block = this->blocks.
Begin();
116 this->buf = *this->block++;
117 this->bufe = this->buf +
CHUNK;
151 if (this->
sock == INVALID_SOCKET)
return status;
193 default: errorno = NETWORK_ERROR_GENERAL;
break;
250 #ifdef NETWORK_SEND_DOUBLE_SEED 255 NetworkError(STR_NETWORK_ERROR_DESYNC);
257 DEBUG(net, 0,
"Sync error detected!");
412 my_client->NetworkGameSocketHandler::SendCommand(p, cp);
566 for (uint i = 0; i < NETWORK_VEH_END; i++) {
569 for (uint i = 0; i < NETWORK_VEH_END; i++) {
642 static const StringID network_error_strings[] = {
643 STR_NETWORK_ERROR_LOSTCONNECTION,
644 STR_NETWORK_ERROR_LOSTCONNECTION,
645 STR_NETWORK_ERROR_LOSTCONNECTION,
646 STR_NETWORK_ERROR_LOSTCONNECTION,
647 STR_NETWORK_ERROR_LOSTCONNECTION,
648 STR_NETWORK_ERROR_LOSTCONNECTION,
649 STR_NETWORK_ERROR_SERVER_ERROR,
650 STR_NETWORK_ERROR_SERVER_ERROR,
651 STR_NETWORK_ERROR_WRONG_REVISION,
652 STR_NETWORK_ERROR_LOSTCONNECTION,
653 STR_NETWORK_ERROR_WRONG_PASSWORD,
654 STR_NETWORK_ERROR_SERVER_ERROR,
655 STR_NETWORK_ERROR_KICKED,
656 STR_NETWORK_ERROR_CHEATER,
657 STR_NETWORK_ERROR_SERVER_FULL,
658 STR_NETWORK_ERROR_TOO_MANY_COMMANDS,
659 STR_NETWORK_ERROR_TIMEOUT_PASSWORD,
660 STR_NETWORK_ERROR_TIMEOUT_COMPUTER,
661 STR_NETWORK_ERROR_TIMEOUT_MAP,
662 STR_NETWORK_ERROR_TIMEOUT_JOIN,
668 StringID err = STR_NETWORK_ERROR_LOSTCONNECTION;
669 if (error < (ptrdiff_t)
lengthof(network_error_strings)) err = network_error_strings[
error];
686 for (; grf_count > 0; grf_count--) {
694 char buf[
sizeof(c.
md5sum) * 2 + 1];
732 p->
Recv_string(_password_server_id,
sizeof(_password_server_id));
754 p->
Recv_string(_password_server_id,
sizeof(_password_server_id));
864 ShowJoinStatusWindow();
881 #ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME 887 #ifdef NETWORK_SEND_DOUBLE_SEED 914 #ifdef NETWORK_SEND_DOUBLE_SEED 959 case NETWORK_ACTION_CHAT_CLIENT:
966 case NETWORK_ACTION_GIVE_MONEY:
970 case NETWORK_ACTION_CHAT_COMPANY: {
974 GetString(name, str,
lastof(name));
1018 NetworkTextMessage(NETWORK_ACTION_LEAVE,
CC_DEFAULT,
false, ci->
client_name, NULL, STR_NETWORK_MESSAGE_CLIENT_LEAVING);
1021 DEBUG(net, 0,
"Unknown client (%d) is leaving the game", client_id);
1095 if (client_id == 0) {
1097 DEBUG(net, 0,
"[move] received invalid client index = 0");
1119 _network_server_max_companies = p->
Recv_uint8();
1120 _network_server_max_spectators = p->
Recv_uint8();
1149 if (lag < 5)
return;
1160 static uint last_lag = 0;
1161 if (last_lag == lag)
return;
1165 ShowErrorMessage(STR_NETWORK_ERROR_CLIENT_GUI_LOST_CONNECTION_CAPTION, STR_NETWORK_ERROR_CLIENT_GUI_LOST_CONNECTION,
WL_INFO);
1228 if (ci == NULL)
return;
Client acknowledges that it has all required NewGRFs.
We are trying to get company information.
used in multiplayer to create a new companies etc.
bool _networking
are we in networking mode?
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
Prepare a DoCommand to be send over the network.
char clients[NETWORK_CLIENTS_LENGTH]
The clients that control this company (Name1, name2, ..)
bool HasClientQuit() const
Whether the current client connected to the socket has quit.
Container for all information known about a client.
SOCKET sock
The socket currently connected to.
virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p)
Notification that another client is currently receiving the map: uint8 Number of clients waiting in f...
uint32 _sync_seed_1
Seed to compare during sync checks.
struct PacketReader * savegame
Packet reader for reading the savegame.
uint32 _realtime_tick
The real time in the game.
Internal entity of a packet.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
TextColour GetDrawStringCompanyColour(CompanyID company)
Get the colour for DrawString-subroutines which matches the colour of the company.
A client changes its name.
static NetworkRecvStatus SendJoin()
Tell the server we would like to join.
size_t written_bytes
The total number of bytes we've written.
static bool Receive()
Check whether we received/can send some data from/to the server and when that's the case handle it ap...
Subdirectory
The different kinds of subdirectories OpenTTD uses.
uint32 Recv_uint32()
Read a 32 bits integer from the packet.
The client is authorized at the server.
virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p)
A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO:...
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
Client list; Window numbers:
PacketSize pos
The current read/write position in the packet.
const char * _network_join_server_password
Login password from -p argument.
virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p)
Let the clients know that the server is closing.
static NetworkRecvStatus SendGamePassword(const char *password)
Set the game password as requested.
Switch to game intro menu.
const char * _network_join_company_password
Company password from -P argument.
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p)
Sends a chat-packet to the client: uint8 ID of the action (see NetworkAction).
bool ai
Is this company an AI.
virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p)
Let the clients know that the server is loading a new map.
static uint8 _network_server_max_spectators
Maximum number of spectators of the currently joined server.
GUIs related to networking.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
void Send_string(const char *data)
Sends a string over the network.
void ClientError(NetworkRecvStatus res)
Handle an error coming from the client side.
static NetworkRecvStatus SendMapOk()
Tell the server we received the complete map.
Something went wrong (down)loading the savegame.
byte ** block
The block we're reading from/writing to.
NetworkErrorCode
The error codes we send around in the protocols.
char company_name[NETWORK_COMPANY_NAME_LENGTH]
Company name.
Clients sends the (hashed) game password.
NetworkJoinStatus _network_join_status
The status of joining.
void Send_uint8(uint8 data)
Package a 8 bits integer in the packet.
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p)
Notification that the server is full.
Client part of the network protocol.
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
static uint8 _network_server_max_companies
Maximum number of companies of the currently joined server.
const T * Begin() const
Get the pointer to the first item (const)
void NetworkClientRequestMove(CompanyID company_id, const char *pass)
Notify the server of this client wanting to be moved to another company.
static NetworkRecvStatus SendNewGRFsOk()
Tell the server we got all the NewGRFs.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p)
Send information about a client: uint32 ID of the client (always unique on a server.
void Send_uint32(uint32 data)
Package a 32 bits integer in the packet.
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data)
Send a chat message.
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
The client wants a new company.
static const TextColour CC_DEFAULT
Default colour of the console.
Money company_value
The company value.
bool IsValidConsoleColour(TextColour c)
Check whether the given TextColour is valid for console usage.
Base core network types and some helper functions to access them.
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
ClientNetworkGameSocketHandler(SOCKET s)
Create a new socket for the client side of the game connection.
static NetworkRecvStatus SendSetPassword(const char *password)
Tell the server that we like to change the password of the company.
void Append(CommandPacket *p)
Append a CommandPacket at the end of the queue.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum, uint32 desired_version)
Find a NewGRF in the scanned list.
void AddPacket(const Packet *p)
Add a packet to this buffer.
virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p)
Notification that a client left the game: uint32 ID of the client.
Class for handling the client side of the game connection.
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...
uint32 _sync_frame
The frame to perform the sync check.
The server told us we made an error.
The client tells the server which frame it has executed.
Basic data to distinguish a GRF.
SendPacketsState SendPackets(bool closing_down=false)
Sends all the buffered packets out for this client.
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p)
The client is joined and ready to receive his map: uint32 Own client ID.
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
Servers always have this ID.
Client asks the server to execute some command.
The password of the company.
T * Append(uint to_add=1)
Append an item and return it.
CommandQueue incoming_queue
The command-queue awaiting handling.
Class to backup a specific variable and restore it later.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p)
The client made an error: uint8 Error code caused (see NetworkErrorCode).
virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p)
Sends a DoCommand to the client: uint8 ID of the company (0..MAX_COMPANIES-1).
static const size_t CHUNK
32 KiB chunks of memory.
uint16 num_vehicle[NETWORK_VEH_END]
How many vehicles are there of this type?
Save game or scenario file.
Done querying the server.
Interface for filtering a savegame till it is loaded.
Year inaugurated_year
What year the company started in.
~ClientNetworkGameSocketHandler()
Clear whatever we assigned.
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.
void StateGameLoop()
State controlling game loop.
static bool IsConnected()
Check whether the client is actually connected (and in the game).
bool prefer_teamchat
choose the chat message target with <ENTER>, true=all clients, false=your team
static NetworkRecvStatus SendAck()
Send an acknowledgement from the server's ticks.
NetworkSettings network
settings related to the network
CompanyID client_playas
As which company is this client playing (CompanyID)
static const uint NETWORK_RCONCOMMAND_LENGTH
The maximum length of a rconsole command, in bytes including '\0'.
void Send_uint64(uint64 data)
Package a 64 bits integer in the packet.
A client would like to be moved to another company.
static NetworkRecvStatus SendCompanyPassword(const char *password)
Set the company password as requested.
DateFract _date_fract
Fractional part of the day.
byte * buffer
The buffer of this packet, of basically variable length up to SEND_MTU.
Information about GRF, used in the game and (part of it) in savegames.
friend void NetworkExecuteLocalCommandQueue()
Execute all commands on the local command queue that ought to be executed this frame.
char client_name[NETWORK_CLIENT_NAME_LENGTH]
Name of the client.
GameMode
Mode which defines the state of the game.
NetworkRecvStatus CloseConnection(bool error=true)
Functions to help ReceivePacket/SendPacket a bit A socket can make errors.
Client sends the (hashed) company password.
uint8 max_spectators
maximum amount of spectators
Company information stored at the client side.
void IConsolePrint(TextColour colour_code, const char *string)
Handle the printing of text entered into the console or redirected there by any other means...
Read some packets, and when do use that data as initial load filter.
AutoFreeSmallVector< byte *, 16 > blocks
Buffer with blocks of allocated memory.
size_t read_bytes
The total number of read bytes.
void CheckConnection()
Check the connection's state, i.e.
ClientID _network_own_client_id
Our client identifier.
ClientSettings _settings_client
The current settings for this game.
static NetworkRecvStatus SendError(NetworkErrorCode errorno)
Send an error-packet over the network.
void CDECL IConsolePrintF(TextColour colour_code, const char *format,...)
Handle the printing of text entered into the console or redirected there by any other means...
A path without any base directory.
The client is waiting as someone else is downloading the map.
void NetworkClientsToSpectators(CompanyID cid)
Move the clients of a company to the spectators.
void SetLocalCompany(CompanyID new_company)
Sets the local company and updates the settings that are set on a per-company basis to reflect the co...
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
virtual void Reset()
Reset this filter to read from the beginning of the file.
void NetworkUpdateClientName()
Send the server our name.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
uint8 _network_reconnect
Reconnect timeout.
static ClientNetworkGameSocketHandler * my_client
This is us!
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
A client (re)sets its company's password.
assert_compile(NETWORK_SERVER_ID_LENGTH==16 *2+1)
Make sure the server ID length is the same as a md5 hash.
#define FOR_ALL_CLIENT_INFOS(var)
Iterate over all the clients.
byte * buf
Buffer we're going to write to/read from.
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p)
Sends information about the companies (one packet per company): uint8 Version of the structure of thi...
We did not have the required NewGRFs.
Basic functions/variables used all over the place.
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p)
Update the clients knowledge of which company is password protected: uint16 Bitwise representation of...
PacketSize size
The size of the whole packet for received packets.
#define lengthof(x)
Return the length of an fixed size array.
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)...
uint last_packet
Time we received the last frame.
static T min(const T a, const T b)
Returns the minimum of two values.
NetworkClientInfo * GetInfo() const
Gets the client info of this socket handler.
uint32 frame
the frame in which this packet is executed
ServerStatus status
Status of the connection with the server.
NetworkRecvStatus CloseConnection(NetworkRecvStatus status)
Close the network connection due to the given status.
static NetworkRecvStatus SendRCon(const char *password, const char *command)
Send a console command.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static NetworkRecvStatus SendMove(CompanyID company, const char *password)
Ask the server to move us.
A client reports an error to the server.
bool Recv_bool()
Read a boolean from the packet.
uint32 _network_join_bytes
The number of bytes we already downloaded.
SaveLoadOperation
Operation performed on the file.
Maximum number of companies.
void Reset()
Reset this filter to read from the beginning of the file.
void NetworkClient_Connected()
Is called after a client is connected to the server.
uint16 performance
What was his performance last month?
uint8 max_companies
maximum amount of companies
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio)
Tell whether the client has team members where he/she can chat to.
virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p)
Indication to the client that the server needs a company password: uint32 Generation seed...
The connection is 'just' lost.
#define DEBUG(name, level,...)
Output a line of debugging information.
virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p)
Notification that the client trying to join is banned.
Network status window; Window numbers:
ClientID client_id
Client identifier.
virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p)
Move a client from one company into another: uint32 ID of the client.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
static NetworkRecvStatus SendCompanyInformationQuery()
Query the server for company information.
The password of the game.
bool NetworkFindName(char *new_name, const char *last)
Check whether a name is unique, and otherwise try to make it unique.
virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p)
Sends a sync-check to the client: uint32 Frame counter.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
bool use_password
Is there a password.
char client_name[NETWORK_CLIENT_NAME_LENGTH]
name of the player (as 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 th...
GUISettings gui
settings related to the GUI
Client requests the actual map.
void SetInfo(NetworkClientInfo *info)
Sets the client info for this socket handler.
uint32 _frame_counter
The current frame.
The server has banned us.
uint64 Recv_uint64()
Read a 64 bits integer from the packet.
void ClearErrorMessages()
Clear all errors from the queue.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
CompanyByte _current_company
Company currently doing an action.
Randomizer _random
Random used in the game state calculations.
static size_t GetNumItems()
Returns number of valid items in the pool.
PacketReader()
Initialise everything.
virtual NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p)
Indication to the client that the server needs a game password.
CompanyID _network_join_as
Who would we like to join as.
CompanyMask _network_company_passworded
Bitmask of the password status of all companies.
void NetworkClientSetCompanyPassword(const char *password)
Set/Reset company password on the client side.
Client executed a command and sends it to the server.
ClientID
'Unique' identifier to be given to clients
virtual NetworkRecvStatus CloseConnection(bool error=true)
Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just ...
void NetworkClientSendRcon(const char *password, const char *command)
Send a remote console command.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
The client telling the server it wants to join.
virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p)
Sends that the server will begin with sending the map to the client: uint32 Current frame...
uint32 _frame_counter_server
The frame_counter of the server, if in network-mode.
uint16 num_station[NETWORK_VEH_END]
How many stations are there of this type?
static const uint NETWORK_SERVER_ID_LENGTH
The maximum length of the network id of the servers, in bytes including '\0'.
Network window; Window numbers:
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
The client is active within in the game.
byte * bufe
End of the buffer we write to/read from.
SwitchMode _switch_mode
The next mainloop command.
const char * GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed)
Hash the given password using server ID and game seed.
const char * ReceiveCommand(Packet *p, CommandPacket *cp)
Receives a command from the network.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() ...
virtual NetworkRecvStatus Receive_SERVER_RCON(Packet *p)
Send the result of an issues RCon command back to the client: uint16 Colour code. ...
static uint32 _password_game_seed
One bit of 'entropy' used to generate a salt for the company passwords.
A client tells the server it is going to quit.
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
bool _network_server
network-server is active
static NetworkRecvStatus SendQuit()
Tell the server we would like to quit.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
static const TextColour CC_ERROR
Colour for error lines.
We are trying to join a server.
Everything we need to know about a command to be able to execute it.
static void Send()
Send the packets of this socket handler.
virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p)
Sends that all data of the map are sent to the client:
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
static NetworkRecvStatus SendSetName(const char *name)
Tell the server that we like to change the name of the client.
uint32 grfid
GRF ID (defined by Action 0x08)
We apparently send a malformed packet.
uint32 _network_join_bytes_total
The total number of bytes to download.
The client is downloading the map.
Client said something that should be distributed.
static const uint NETWORK_NAME_LENGTH
The maximum length of the server name and map name, in bytes including '\0'.
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
virtual void SendPacket(Packet *packet)
This function puts the packet in the send-queue and it is send as soon as possible.
static NetworkRecvStatus SendGetMap()
Request the map from the server.
void Restore()
Restore the variable.
static NetworkRecvStatus SendCommand(const CommandPacket *cp)
Send a command to the server.
Money money
The amount of money the company has.
void ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf)
Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet.
Last action was requesting game (server) password.
uint16 Recv_uint16()
Read a 16 bits integer from the packet.
bool CanSendReceive()
Check whether this socket can send or receive something.
Base socket handler for all TCP sockets.
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Owner
Enum for all companies/owners.
virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p)
Sends the current frame counter to the client: uint32 Frame counter uint32 Frame counter max (how far...
Last action was requesting company password.
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) ...
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
static uint32 last_ack_frame
Last frame we performed an ack.
Only find Grfs matching md5sum.
uint32 state[2]
The state of the randomizer.
static const byte NETWORK_COMPANY_INFO_VERSION
What version of company info is this?
uint8 _network_join_waiting
The number of clients waiting in front of us.
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data)
Send a chat-packet over the network.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
bool my_cmd
did the command originate from "me"
size_t Read(byte *rbuf, size_t size)
Read a given number of bytes from the savegame.
Date _date
Current date in days (day counter)
Company view; Window numbers:
DetailedFileType
Kinds of files in each AbstractFileType.
virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p)
Sends the size of the map to the client.
uint32 _frame_counter_max
To where we may go with our clients.
static bool GameLoop()
Actual game loop for the client.
bool _network_first_time
Whether we have finished joining or not.
byte token
The token we need to send back to the server to prove we're the right client.
DestType
Destination of our chat messages.
Money income
How much did the company earned last year.
static char _password_server_id[NETWORK_SERVER_ID_LENGTH]
The other bit of 'entropy' used to generate a salt for the company passwords.
NetworkAction
Actions that can be used for NetworkTextMessage.
bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf=NULL)
Load the specified savegame but on error do different things.
void Recv_string(char *buffer, size_t size, StringValidationSettings settings=SVS_REPLACE_WITH_QUESTION_MARK)
Reads a string till it finds a '\0' in the stream.
virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p)
Update the clients knowledge of the max settings: uint8 Maximum number of companies allowed...
Request information about all companies.
NetworkCompanyInfo * GetLobbyCompanyInfo(CompanyID company)
Get the company information of a given company to fill for the lobby.
Client tells the server that it received the whole map.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.