OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

network_func.h
Go to the documentation of this file.
1 /* $Id: network_func.h 26788 2014-09-07 14:21:16Z frosch $ */
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 uint32 _network_last_advertise_frame;
38 extern uint8 _network_reconnect;
39 extern StringList _network_bind_list;
40 extern StringList _network_host_list;
41 extern StringList _network_ban_list;
42
43 byte NetworkSpectatorCount();
44 void NetworkUpdateClientName();
45 bool NetworkCompanyHasClients(CompanyID company);
46 const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password);
47 void NetworkReboot();
48 void NetworkDisconnect(bool blocking = false, bool close_admins = true);
49 void NetworkGameLoop();
50 void NetworkBackgroundLoop();
51 void ParseConnectionString(const char **company, const char **port, char *connection_string);
52 void NetworkStartDebugLog(NetworkAddress address);
53 void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
54
55 void NetworkUpdateClientInfo(ClientID client_id);
56 void NetworkClientsToSpectators(CompanyID cid);
57 void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
58 void NetworkClientRequestMove(CompanyID company, const char *pass = "");
59 void NetworkClientSendRcon(const char *password, const char *command);
60 void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
61 bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
62 bool NetworkCompanyIsPassworded(CompanyID company_id);
63 bool NetworkMaxCompaniesReached();
64 bool NetworkMaxSpectatorsReached();
65 void NetworkPrintClients();
66 void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
67
68 /*** Commands ran by the server ***/
69 void NetworkServerDailyLoop();
70 void NetworkServerMonthlyLoop();
71 void NetworkServerYearlyLoop();
72 void NetworkServerSendConfigUpdate();
73 void NetworkServerShowStatusToConsole();
74 bool NetworkServerStart();
75 void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
76 bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
77
78
79 void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
80 void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
81 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
82
83 void NetworkServerKickClient(ClientID client_id);
84 uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
85 uint NetworkServerKickOrBanIP(const char *ip, bool ban);
86
87 void NetworkInitChatMessage();
88 void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
89 void NetworkUndrawChatMessage();
90 void NetworkChatMessageLoop();
91
92 void NetworkAfterNewGRFScan();
93
94 #endif /* ENABLE_NETWORK */
95 #endif /* NETWORK_FUNC_H */