network_func.h

Go to the documentation of this file.
00001 /* $Id: network_func.h 26595 2014-05-18 11:21:59Z frosch $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef NETWORK_FUNC_H
00013 #define NETWORK_FUNC_H
00014 
00019 // #define DEBUG_DUMP_COMMANDS
00020 
00021 #include "core/address.h"
00022 #include "network_type.h"
00023 #include "../console_type.h"
00024 #include "../gfx_type.h"
00025 #include "../openttd.h"
00026 #include "../company_type.h"
00027 
00028 #ifdef ENABLE_NETWORK
00029 
00030 extern NetworkServerGameInfo _network_game_info;
00031 extern NetworkCompanyState *_network_company_states;
00032 
00033 extern ClientID _network_own_client_id;
00034 extern ClientID _redirect_console_to_client;
00035 extern bool _network_need_advertise;
00036 extern uint32 _network_last_advertise_frame;
00037 extern uint8 _network_reconnect;
00038 extern StringList _network_bind_list;
00039 extern StringList _network_host_list;
00040 extern StringList _network_ban_list;
00041 
00042 byte NetworkSpectatorCount();
00043 void NetworkUpdateClientName();
00044 bool NetworkCompanyHasClients(CompanyID company);
00045 const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password);
00046 void NetworkReboot();
00047 void NetworkDisconnect(bool blocking = false, bool close_admins = true);
00048 void NetworkGameLoop();
00049 void NetworkBackgroundLoop();
00050 void ParseConnectionString(const char **company, const char **port, char *connection_string);
00051 void NetworkStartDebugLog(NetworkAddress address);
00052 void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
00053 
00054 void NetworkUpdateClientInfo(ClientID client_id);
00055 void NetworkClientsToSpectators(CompanyID cid);
00056 void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
00057 void NetworkClientRequestMove(CompanyID company, const char *pass = "");
00058 void NetworkClientSendRcon(const char *password, const char *command);
00059 void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
00060 bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
00061 bool NetworkCompanyIsPassworded(CompanyID company_id);
00062 bool NetworkMaxCompaniesReached();
00063 bool NetworkMaxSpectatorsReached();
00064 void NetworkPrintClients();
00065 void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
00066 
00067 /*** Commands ran by the server ***/
00068 void NetworkServerDailyLoop();
00069 void NetworkServerMonthlyLoop();
00070 void NetworkServerYearlyLoop();
00071 void NetworkServerSendConfigUpdate();
00072 void NetworkServerShowStatusToConsole();
00073 bool NetworkServerStart();
00074 void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
00075 bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
00076 
00077 
00078 void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
00079 void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
00080 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
00081 
00082 void NetworkServerKickClient(ClientID client_id);
00083 uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
00084 uint NetworkServerKickOrBanIP(const char *ip, bool ban);
00085 
00086 void NetworkInitChatMessage();
00087 void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
00088 void NetworkUndrawChatMessage();
00089 void NetworkChatMessageLoop();
00090 
00091 void NetworkAfterNewGRFScan();
00092 
00093 #endif /* ENABLE_NETWORK */
00094 #endif /* NETWORK_FUNC_H */