# network_func.h

Go to the documentation of this file.

    00001 /* $Id: network_func.h 19075 2010-02-10 15:17:27Z smatz $ */
    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
    00015 #include "core/address.h"
    00016 #include "network_type.h"
    00017 #include "../console_type.h"
    00018 #include "../gfx_type.h"
    00019 #include "../openttd.h"
    00020 #include "../company_type.h"
    00021
    00022 #ifdef ENABLE_NETWORK
    00023
    00024 extern NetworkServerGameInfo _network_game_info;
    00025 extern NetworkCompanyState *_network_company_states;
    00026
    00027 extern ClientID _network_own_client_id;
    00028 extern ClientID _redirect_console_to_client;
    00029 extern bool _network_need_advertise;
    00030 extern uint32 _network_last_advertise_frame;
    00031 extern uint8 _network_reconnect;
    00032 extern StringList _network_bind_list;
    00033 extern StringList _network_host_list;
    00034 extern StringList _network_ban_list;
    00035
    00036 byte NetworkSpectatorCount();
    00037 void NetworkUpdateClientName();
    00038 bool NetworkCompanyHasClients(CompanyID company);
    00039 const char *NetworkChangeCompanyPassword(const char *);
    00040 void NetworkReboot();
    00041 void NetworkDisconnect(bool blocking = false);
    00042 void NetworkGameLoop();
    00043 void NetworkUDPGameLoop();
    00044 void NetworkUDPCloseAll();
    00045 void ParseConnectionString(const char **company, const char **port, char *connection_string);
    00046 void NetworkStartDebugLog(NetworkAddress address);
    00047 void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
    00048
    00049 void NetworkUpdateClientInfo(ClientID client_id);
    00050 void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
    00051 void NetworkClientRequestMove(CompanyID company, const char *pass = "");
    00052 void NetworkClientSendRcon(const char *password, const char *command);
    00053 void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
    00054 bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
    00055 bool NetworkCompanyIsPassworded(CompanyID company_id);
    00056 bool NetworkMaxCompaniesReached();
    00057 bool NetworkMaxSpectatorsReached();
    00058 void NetworkPrintClients();
    00059 void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
    00060
    00061 /*** Commands ran by the server ***/
    00062 void NetworkServerMonthlyLoop();
    00063 void NetworkServerYearlyLoop();
    00064 void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
    00065 void NetworkServerSendConfigUpdate();
    00066 void NetworkServerShowStatusToConsole();
    00067 bool NetworkServerStart();
    00068 void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded);
    00069 bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
    00070
    00071 NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index);
    00072 NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);
    00073 NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
    00074 const char *GetClientIP(NetworkClientInfo *ci);
    00075
    00076 void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
    00077 void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string);
    00078 void NetworkServerSendError(ClientID client_id, NetworkErrorCode error);
    00079 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
    00080
    00081 void NetworkServerKickClient(ClientID client_id);
    00082 void NetworkServerBanIP(const char *banip);
    00083
    00084 void NetworkInitChatMessage();
    00085 void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...) WARN_FORMAT(3, 4);
    00086 void NetworkUndrawChatMessage();
    00087 void NetworkChatMessageDailyLoop();
    00088
    00089 void NetworkAfterNewGRFScan();
    00090
    00091 #endif /* ENABLE_NETWORK */
    00092 #endif /* NETWORK_FUNC_H */