2008-05-30 18:20:26 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-10-14 19:27:08 +00:00
|
|
|
/** @file network_func.h Network functions used by other parts of OpenTTD. */
|
2008-05-30 18:20:26 +00:00
|
|
|
|
|
|
|
#ifndef NETWORK_FUNC_H
|
|
|
|
#define NETWORK_FUNC_H
|
|
|
|
|
2009-01-20 11:28:18 +00:00
|
|
|
#include "core/address.h"
|
2008-05-30 18:20:26 +00:00
|
|
|
#include "network_type.h"
|
|
|
|
#include "../console_type.h"
|
2009-02-09 02:09:47 +00:00
|
|
|
#include "../gfx_type.h"
|
2009-11-12 20:33:30 +00:00
|
|
|
#include "../openttd.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "../company_type.h"
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2009-10-04 20:00:56 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
2008-06-03 08:04:35 +00:00
|
|
|
extern NetworkServerGameInfo _network_game_info;
|
2008-12-22 20:42:02 +00:00
|
|
|
extern NetworkCompanyState *_network_company_states;
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2008-12-22 12:59:31 +00:00
|
|
|
extern ClientID _network_own_client_id;
|
|
|
|
extern ClientID _redirect_console_to_client;
|
2008-05-30 18:20:26 +00:00
|
|
|
extern bool _network_need_advertise;
|
|
|
|
extern uint32 _network_last_advertise_frame;
|
|
|
|
extern uint8 _network_reconnect;
|
2009-04-10 12:56:55 +00:00
|
|
|
extern StringList _network_bind_list;
|
2009-04-03 12:49:58 +00:00
|
|
|
extern StringList _network_host_list;
|
|
|
|
extern StringList _network_ban_list;
|
2008-05-30 18:20:26 +00:00
|
|
|
|
|
|
|
byte NetworkSpectatorCount();
|
2008-09-30 20:39:50 +00:00
|
|
|
void NetworkUpdateClientName();
|
|
|
|
bool NetworkCompanyHasClients(CompanyID company);
|
2011-01-19 16:47:40 +00:00
|
|
|
const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password, bool already_hashed = true);
|
2008-05-30 18:20:26 +00:00
|
|
|
void NetworkReboot();
|
2010-10-17 17:35:42 +00:00
|
|
|
void NetworkDisconnect(bool blocking = false, bool close_admins = true);
|
2008-05-30 18:20:26 +00:00
|
|
|
void NetworkGameLoop();
|
|
|
|
void NetworkUDPGameLoop();
|
2008-09-30 20:39:50 +00:00
|
|
|
void ParseConnectionString(const char **company, const char **port, char *connection_string);
|
2009-01-20 01:32:06 +00:00
|
|
|
void NetworkStartDebugLog(NetworkAddress address);
|
2008-12-22 18:40:57 +00:00
|
|
|
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2008-12-22 12:59:31 +00:00
|
|
|
void NetworkUpdateClientInfo(ClientID client_id);
|
2010-04-17 11:39:46 +00:00
|
|
|
void NetworkClientsToSpectators(CompanyID cid);
|
2009-06-10 19:00:34 +00:00
|
|
|
void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
|
2009-01-23 22:18:06 +00:00
|
|
|
void NetworkClientRequestMove(CompanyID company, const char *pass = "");
|
2008-05-30 18:20:26 +00:00
|
|
|
void NetworkClientSendRcon(const char *password, const char *command);
|
2008-12-29 10:37:53 +00:00
|
|
|
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
|
2008-12-22 21:15:02 +00:00
|
|
|
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
2009-01-23 22:18:06 +00:00
|
|
|
bool NetworkCompanyIsPassworded(CompanyID company_id);
|
|
|
|
bool NetworkMaxCompaniesReached();
|
|
|
|
bool NetworkMaxSpectatorsReached();
|
2008-12-22 21:26:26 +00:00
|
|
|
void NetworkPrintClients();
|
2009-11-12 20:33:30 +00:00
|
|
|
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
|
2008-05-30 18:20:26 +00:00
|
|
|
|
|
|
|
/*** Commands ran by the server ***/
|
2010-10-17 17:36:23 +00:00
|
|
|
void NetworkServerDailyLoop();
|
2008-05-30 18:20:26 +00:00
|
|
|
void NetworkServerMonthlyLoop();
|
|
|
|
void NetworkServerYearlyLoop();
|
2009-01-23 22:18:06 +00:00
|
|
|
void NetworkServerSendConfigUpdate();
|
2008-05-30 18:20:26 +00:00
|
|
|
void NetworkServerShowStatusToConsole();
|
|
|
|
bool NetworkServerStart();
|
2009-01-23 22:18:06 +00:00
|
|
|
void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded);
|
2009-01-21 23:07:11 +00:00
|
|
|
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2009-04-04 00:48:48 +00:00
|
|
|
const char *GetClientIP(NetworkClientInfo *ci);
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2009-01-23 22:18:06 +00:00
|
|
|
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
|
2011-01-03 12:01:41 +00:00
|
|
|
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
|
2010-10-17 17:40:18 +00:00
|
|
|
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
|
2008-05-30 18:20:26 +00:00
|
|
|
|
2009-03-06 12:42:01 +00:00
|
|
|
void NetworkServerKickClient(ClientID client_id);
|
2011-04-22 15:59:32 +00:00
|
|
|
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
|
2010-05-13 16:00:50 +00:00
|
|
|
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
|
2009-03-06 12:42:01 +00:00
|
|
|
|
2008-08-11 22:45:11 +00:00
|
|
|
void NetworkInitChatMessage();
|
2010-12-14 14:57:51 +00:00
|
|
|
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
|
2008-08-11 22:45:11 +00:00
|
|
|
void NetworkUndrawChatMessage();
|
2010-12-14 14:57:51 +00:00
|
|
|
void NetworkChatMessageLoop();
|
2008-08-11 22:45:11 +00:00
|
|
|
|
2009-09-17 21:14:16 +00:00
|
|
|
void NetworkAfterNewGRFScan();
|
|
|
|
|
2008-05-30 18:20:26 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
#endif /* NETWORK_FUNC_H */
|