OpenTTD

network_func.h
Go to the documentation of this file.
1 /* $Id: network_func.h 27400 2015-09-19 16:49:46Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef NETWORK_FUNC_H
13 #define NETWORK_FUNC_H
14
19 // #define DEBUG_DUMP_COMMANDS
20 // #define DEBUG_FAILED_DUMP_COMMANDS
21
22 #include "core/address.h"
23 #include "network_type.h"
24 #include "../console_type.h"
25 #include "../gfx_type.h"
26 #include "../openttd.h"
27 #include "../company_type.h"
28
29 #ifdef ENABLE_NETWORK
30
31 extern NetworkServerGameInfo _network_game_info;
32 extern NetworkCompanyState *_network_company_states;
33
34 extern ClientID _network_own_client_id;
35 extern ClientID _redirect_console_to_client;
36 extern bool _network_need_advertise;
37 extern uint8 _network_reconnect;
38 extern StringList _network_bind_list;
39 extern StringList _network_host_list;
40 extern StringList _network_ban_list;
41
42 byte NetworkSpectatorCount();
43 void NetworkUpdateClientName();
44 bool NetworkCompanyHasClients(CompanyID company);
45 const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password);
46 void NetworkReboot();
47 void NetworkDisconnect(bool blocking = false, bool close_admins = true);
48 void NetworkGameLoop();
49 void NetworkBackgroundLoop();
50 void ParseConnectionString(const char **company, const char **port, char *connection_string);
51 void NetworkStartDebugLog(NetworkAddress address);
52 void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
53
54 void NetworkUpdateClientInfo(ClientID client_id);
55 void NetworkClientsToSpectators(CompanyID cid);
56 void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
57 void NetworkClientRequestMove(CompanyID company, const char *pass = "");
58 void NetworkClientSendRcon(const char *password, const char *command);
59 void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
60 bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
61 bool NetworkCompanyIsPassworded(CompanyID company_id);
62 bool NetworkMaxCompaniesReached();
63 bool NetworkMaxSpectatorsReached();
64 void NetworkPrintClients();
65 void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
66
67 /*** Commands ran by the server ***/
68 void NetworkServerDailyLoop();
69 void NetworkServerMonthlyLoop();
70 void NetworkServerYearlyLoop();
71 void NetworkServerSendConfigUpdate();
72 void NetworkServerShowStatusToConsole();
73 bool NetworkServerStart();
74 void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
75 bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
76
77
78 void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
79 void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
80 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
81
82 void NetworkServerKickClient(ClientID client_id);
83 uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
84 uint NetworkServerKickOrBanIP(const char *ip, bool ban);
85
86 void NetworkInitChatMessage();
87 void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
88 void NetworkUndrawChatMessage();
89 void NetworkChatMessageLoop();
90
91 void NetworkAfterNewGRFScan();
92
93 #endif /* ENABLE_NETWORK */
94 #endif /* NETWORK_FUNC_H */
NetworkServerKickOrBanIP
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban)
Ban, or kick, everyone joined from the given client&#39;s IP.
Definition: network_server.cpp:2085
_network_reconnect
uint8 _network_reconnect
Reconnect timeout.
Definition: network.cpp:66
NetworkInitChatMessage
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
Definition: network_chat_gui.cpp:118
NetworkCompanyIsPassworded
bool NetworkCompanyIsPassworded(CompanyID company_id)
Check if the company we want to join requires a password.
Definition: network.cpp:225
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:27
NetworkServerShowStatusToConsole
void NetworkServerShowStatusToConsole()
Show the status message of all clients on the console.
Definition: network_server.cpp:1962
ParseConnectionString
void ParseConnectionString(const char **company, const char **port, char *connection_string)
Converts a string to ip/port/company Format: IP:port::company.
Definition: network.cpp:474
NetworkServerGameInfo
The game information that is not generated on-the-fly and has to be sent to the clients.
Definition: game.h:28
NetworkCompanyHasClients
bool NetworkCompanyHasClients(CompanyID company)
Check whether a particular company has clients.
Definition: network_server.cpp:2129
NetworkPopulateCompanyStats
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
Populate the company stats.
Definition: network_server.cpp:1564
NetworkDisconnect
void NetworkDisconnect(bool blocking=false, bool close_admins=true)
We want to disconnect from the host/clients.
Definition: network.cpp:798
NetworkUpdateClientInfo
void NetworkUpdateClientInfo(ClientID client_id)
Send updated client info of a particular client.
Definition: network_server.cpp:1603
NetworkAddress
Wrapper for (un)resolved network addresses; there&#39;s no reason to transform a numeric IP to a string a...
Definition: address.h:31
NetworkServerDoMove
void NetworkServerDoMove(ClientID client_id, CompanyID company_id)
Handle the tid-bits of moving a client from one company to another.
Definition: network_server.cpp:2031
NetworkClientRequestMove
void NetworkClientRequestMove(CompanyID company, const char *pass="")
Notify the server of this client wanting to be moved to another company.
Definition: network_client.cpp:1196
_network_bind_list
StringList _network_bind_list
The addresses to bind on.
Definition: network.cpp:67
NetworkHandlePauseChange
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode)
Handle the pause mode change so we send the right messages to the chat.
Definition: network.cpp:348
NetworkServerDailyLoop
void NetworkServerDailyLoop()
Daily "callback".
Definition: network_server.cpp:1946
NetworkChangeCompanyPassword
const char * NetworkChangeCompanyPassword(CompanyID company_id, const char *password)
Change the company password of a given company.
Definition: network.cpp:174
NetworkMaxSpectatorsReached
bool NetworkMaxSpectatorsReached()
Check if max_spectatos has been reached on the server (local check only).
Definition: network_client.cpp:1297
NetworkServerKickClient
void NetworkServerKickClient(ClientID client_id)
Kick a single client.
Definition: network_server.cpp:2074
NetworkServerYearlyLoop
void NetworkServerYearlyLoop()
Yearly "callback".
Definition: network_server.cpp:1931
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:247
NetworkClientPreferTeamChat
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio)
Tell whether the client has team members where he/she can chat to.
Definition: network_client.cpp:1271
NetworkPrintClients
void NetworkPrintClients()
Print all the clients to the console.
Definition: network_server.cpp:2158
address.h
Wrapper for network addresses.
NetworkMaxCompaniesReached
bool NetworkMaxCompaniesReached()
Check if max_companies has been reached on the server (local check only).
Definition: network_client.cpp:1288
NetworkServerSendRcon
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string)
Send an rcon reply to the client.
Definition: network_server.cpp:2065
AutoFreeSmallVector< char *, 4 >
NetworkClientSendRcon
void NetworkClientSendRcon(const char *password, const char *command)
Send a remote console command.
Definition: network_client.cpp:1185
NetworkBackgroundLoop
void NetworkBackgroundLoop()
We have to do some (simple) background stuff that runs normally, even when we are not in multiplayer...
Definition: network.cpp:856
_network_host_list
StringList _network_host_list
The servers we know.
Definition: network.cpp:68
NetworkServerChangeClientName
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
Change the client name of the given client.
Definition: network_server.cpp:1751
Company
Definition: company_base.h:110
NetworkUpdateClientName
void NetworkUpdateClientName()
Send the server our name.
Definition: network_client.cpp:1224
NetworkServerSendChat
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data=0, bool from_admin=false)
Send an actual chat message.
Definition: network_server.cpp:1268
NetworkServerSendConfigUpdate
void NetworkServerSendConfigUpdate()
Send Config Update.
Definition: network_server.cpp:1996
NetworkClientSendChat
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data=0)
Send a chat message.
Definition: network_client.cpp:1252
_network_own_client_id
ClientID _network_own_client_id
Our client identifier.
Definition: network.cpp:63
network_type.h
Types used for networking.
_network_need_advertise
bool _network_need_advertise
Whether we need to advertise.
Definition: network.cpp:65
NetworkServerNewCompany
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci)
Perform all the server specific administration of a new company.
Definition: network_server.cpp:2182
ClientID
ClientID
&#39;Unique&#39; identifier to be given to clients
Definition: network_type.h:43
_network_game_info
NetworkServerGameInfo _network_game_info
Uncomment the following define to enable command replaying.
Definition: network.cpp:61
PauseMode
PauseMode
Modes of pausing we&#39;ve got.
Definition: openttd.h:57
NetworkClientsToSpectators
void NetworkClientsToSpectators(CompanyID cid)
Move the clients of a company to the spectators.
Definition: network_client.cpp:1205
NetworkAddChatMessage
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message,...)
Add a text message to the &#39;chat window&#39; to be shown.
Definition: network_chat_gui.cpp:84
NetworkChatMessageLoop
void NetworkChatMessageLoop()
Check if a message is expired.
Definition: network_chat_gui.cpp:180
_network_ban_list
StringList _network_ban_list
The banned clients.
Definition: network.cpp:69
NetworkCompanyStats
Simple calculated statistics of a company.
Definition: network_type.h:61
NetworkAfterNewGRFScan
void NetworkAfterNewGRFScan()
Rebuild the GRFConfig&#39;s of the servers in the game list as we did a rescan and might have found new N...
Definition: network_gamelist.cpp:173
NetworkUndrawChatMessage
void CDECL void NetworkUndrawChatMessage()
Hide the chatbox.
Definition: network_chat_gui.cpp:134
NetworkServerMonthlyLoop
void NetworkServerMonthlyLoop()
Monthly "callback".
Definition: network_server.cpp:1938
NetworkCompanyState
Some state information of a company, especially for servers.
Definition: network_type.h:68
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
_redirect_console_to_client
ClientID _redirect_console_to_client
If not invalid, redirect the console output to a client.
Definition: network.cpp:64
DestType
DestType
Destination of our chat messages.
Definition: network_type.h:82
_network_company_states
NetworkCompanyState * _network_company_states
Statistics about some companies.
Definition: network.cpp:62
NetworkAction
NetworkAction
Actions that can be used for NetworkTextMessage.
Definition: network_type.h:89