# network_func.h

Go to the documentation of this file.

    00001 /* $Id: network_func.h 18809 2010-01-15 16:41:15Z rubidium $ */
    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 bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
    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 void NetworkClientSetPassword(const char *password);
    00055 bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
    00056 bool NetworkCompanyIsPassworded(CompanyID company_id);
    00057 bool NetworkMaxCompaniesReached();
    00058 bool NetworkMaxSpectatorsReached();
    00059 void NetworkPrintClients();
    00060 void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
    00061
    00062 /*** Commands ran by the server ***/
    00063 void NetworkServerMonthlyLoop();
    00064 void NetworkServerYearlyLoop();
    00065 void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
    00066 void NetworkServerSendConfigUpdate();
    00067 void NetworkServerShowStatusToConsole();
    00068 bool NetworkServerStart();
    00069 void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded);
    00070 bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
    00071
    00072 NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index);
    00073 NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);
    00074 NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
    00075 const char *GetClientIP(NetworkClientInfo *ci);
    00076
    00077 void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
    00078 void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string);
    00079 void NetworkServerSendError(ClientID client_id, NetworkErrorCode error);
    00080 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0);
    00081
    00082 void NetworkServerKickClient(ClientID client_id);
    00083 void NetworkServerBanIP(const char *banip);
    00084
    00085 void NetworkInitChatMessage();
    00086 void CDECL NetworkAddChatMessage(TextColour colour, uint8 duration, const char *message, ...) WARN_FORMAT(3, 4);
    00087 void NetworkUndrawChatMessage();
    00088 void NetworkChatMessageDailyLoop();
    00089
    00090 void NetworkAfterNewGRFScan();
    00091
    00092 #endif /* ENABLE_NETWORK */
    00093 #endif /* NETWORK_FUNC_H */