OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef NETWORK_FUNC_H
11 #define NETWORK_FUNC_H
21 #include "../console_type.h"
22 #include "../gfx_type.h"
23 #include "../openttd.h"
24 #include "../company_type.h"
25 #include "../string_type.h"
36 byte NetworkSpectatorCount();
47 void NetworkGameLoop();
50 void NetworkStartDebugLog(
const std::string &connection_string);
55 bool NetworkClientConnectGame(
const std::string &connection_string,
CompanyID default_company,
const std::string &join_server_password =
"",
const std::string &join_company_password =
"");
73 bool NetworkServerStart();
Simple calculated statistics of a company.
DestType
Destination of our chat messages.
void NetworkServerShowStatusToConsole()
Show the status message of all clients on the console.
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
void NetworkDisconnect(bool blocking=false, bool close_admins=true)
We want to disconnect from the host/clients.
Some state information of a company, especially for servers.
NetworkAction
Actions that can be used for NetworkTextMessage.
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
Populate the company stats.
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
void NetworkClientSendRcon(const std::string &password, const std::string &command)
Send a remote console command.
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode)
Handle the pause mode change so we send the right messages to the chat.
Owner
Enum for all companies/owners.
StringList _network_bind_list
The addresses to bind on.
void NetworkServerDailyLoop()
Daily "callback".
void NetworkUpdateServerGameType()
The setting server_game_type was updated; possibly we need to take some action.
bool NetworkIsValidClientName(const std::string_view client_name)
Check whether the given client name is deemed valid for use in network games.
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password)
Change the company password of a given company.
void NetworkClientJoinGame()
Actually perform the joining to the server.
ClientID
'Unique' identifier to be given to clients
void NetworkServerYearlyLoop()
Yearly "callback".
void NetworkPrintClients()
Print all the clients to the console.
std::vector< std::string > StringList
Type for a list of strings.
bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_name)
Change the client name of the given client.
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio)
Tell whether the client has team members who they can chat to.
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, const std::string &reason)
Ban, or kick, everyone joined from the given client's IP.
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::string &message)
Add a text message to the 'chat window' to be shown.
PauseMode
Modes of pausing we've got.
std::string_view ParseFullConnectionString(const std::string &connection_string, uint16 &port, CompanyID *company_id=nullptr)
Converts a string to ip/port/company Format: IP:port::company.
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
StringList _network_host_list
The servers we know.
void NetworkBackgroundLoop()
We have to do some (simple) background stuff that runs normally, even when we are not in multiplayer.
void NetworkUpdateClientName(const std::string &client_name)
Send the server our name as callback from the setting.
void NetworkServerSendConfigUpdate()
Send Config Update.
void NetworkUndrawChatMessage()
Hide the chatbox.
bool NetworkValidateClientName(std::string &client_name)
Trim the given client name in place, i.e.
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password="", const std::string &join_company_password="")
Join a client to the server at with the given connection string.
bool NetworkValidateOurClientName()
Convenience method for NetworkValidateClientName on _settings_client.network.client_name.
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci)
Perform all the server specific administration of a new company.
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string)
Send an rcon reply to the client.
ClientID _network_own_client_id
Our client identifier.
void NetworkClientsToSpectators(CompanyID cid)
Move the clients of a company to the spectators.
void NetworkClientRequestMove(CompanyID company, const std::string &pass="")
Notify the server of this client wanting to be moved to another company.
StringList _network_ban_list
The banned clients.
void NetworkChatMessageLoop()
Check if a message is expired.
void NetworkAfterNewGRFScan()
Rebuild the GRFConfig's of the servers in the game list as we did a rescan and might have found new N...
void NetworkServerKickClient(ClientID client_id, const std::string &reason)
Kick a single client.
ClientID _redirect_console_to_client
If not invalid, redirect the console output to a client.
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data=0)
Send a chat message.
void NetworkServerMonthlyLoop()
Monthly "callback".
void NetworkServerUpdateGameInfo()
Update the server's NetworkServerGameInfo due to changes in settings.
Container for all information known about a client.
bool NetworkValidateServerName(std::string &server_name)
Trim the given server name in place, i.e.
NetworkCompanyState * _network_company_states
Uncomment the following define to enable command replaying.
uint8 _network_reconnect
Reconnect timeout.
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.