Files
@ r23483:3733e6b8ff17
Branch filter:
Location: cpp/openttd-patchpack/source/src/network/network_func.h - annotation
r23483:3733e6b8ff17
3.8 KiB
text/x-c
Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.
Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.
A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.
With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.
All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.
Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.
A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.
With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.
All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
r9428:6800206a6c0d r9428:6800206a6c0d r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10238:f2215d7dd22b r9428:6800206a6c0d r9428:6800206a6c0d r9428:6800206a6c0d r9428:6800206a6c0d r21282:5b76c1614957 r21282:5b76c1614957 r21282:5b76c1614957 r21282:5b76c1614957 r21282:5b76c1614957 r21656:d57ae4494337 r21282:5b76c1614957 r10828:d8d68d002525 r9428:6800206a6c0d r9428:6800206a6c0d r11082:09fb79759019 r13521:8a785d107381 r14248:a9050881acd7 r9428:6800206a6c0d r9451:01b0b6cc547f r10459:3e3b1f14f8df r9428:6800206a6c0d r10454:ba5e39738ffa r10454:ba5e39738ffa r9428:6800206a6c0d r9428:6800206a6c0d r11629:97018c71b598 r11560:52827dc8eb76 r11560:52827dc8eb76 r9428:6800206a6c0d r9428:6800206a6c0d r10207:a1fc2f2a33db r10207:a1fc2f2a33db r17923:55051a786f80 r9428:6800206a6c0d r16255:08842c21f00b r9428:6800206a6c0d r18892:ba984148392c r10207:a1fc2f2a33db r10822:adfba97cb1d1 r10457:8667446e8fd4 r9428:6800206a6c0d r10454:ba5e39738ffa r15025:2d23afc43d78 r12134:0a6111a3288d r10907:3616576a3216 r9428:6800206a6c0d r10507:b7c7868bab20 r10460:5fba179e6ffa r10907:3616576a3216 r10907:3616576a3216 r10907:3616576a3216 r10461:3494bf73458c r13521:8a785d107381 r9428:6800206a6c0d r9428:6800206a6c0d r16256:b1e0699fee93 r9428:6800206a6c0d r9428:6800206a6c0d r10907:3616576a3216 r9428:6800206a6c0d r9428:6800206a6c0d r21467:8b87202cc00f r10865:2be2c584bcb6 r9428:6800206a6c0d r9428:6800206a6c0d r10907:3616576a3216 r16955:558d50c26a94 r16262:95a75f09ea09 r9428:6800206a6c0d r11274:6d4814f2e94b r17591:c2a7b2b05a8a r15179:de4f52bbb07f r11274:6d4814f2e94b r9898:bbef3303e005 r16769:c5dcfeb0d0a2 r9898:bbef3303e005 r16769:c5dcfeb0d0a2 r9898:bbef3303e005 r13054:319ef5c8a6c7 r13054:319ef5c8a6c7 r9428:6800206a6c0d | /* $Id$ */
/*
* 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/>.
*/
/** @file network_func.h Network functions used by other parts of OpenTTD. */
#ifndef NETWORK_FUNC_H
#define NETWORK_FUNC_H
/**
* Uncomment the following define to enable command replaying.
* See docs/desync.txt for details.
*/
// #define DEBUG_DUMP_COMMANDS
// #define DEBUG_FAILED_DUMP_COMMANDS
#include "core/address.h"
#include "network_type.h"
#include "../console_type.h"
#include "../gfx_type.h"
#include "../openttd.h"
#include "../company_type.h"
extern NetworkServerGameInfo _network_game_info;
extern NetworkCompanyState *_network_company_states;
extern ClientID _network_own_client_id;
extern ClientID _redirect_console_to_client;
extern bool _network_need_advertise;
extern uint8 _network_reconnect;
extern StringList _network_bind_list;
extern StringList _network_host_list;
extern StringList _network_ban_list;
byte NetworkSpectatorCount();
void NetworkUpdateClientName();
bool NetworkCompanyHasClients(CompanyID company);
const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *password);
void NetworkReboot();
void NetworkDisconnect(bool blocking = false, bool close_admins = true);
void NetworkGameLoop();
void NetworkBackgroundLoop();
void ParseConnectionString(const char **company, const char **port, char *connection_string);
void NetworkStartDebugLog(NetworkAddress address);
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
void NetworkUpdateClientInfo(ClientID client_id);
void NetworkClientsToSpectators(CompanyID cid);
void NetworkClientConnectGame(NetworkAddress address, CompanyID join_as, const char *join_server_password = NULL, const char *join_company_password = NULL);
void NetworkClientRequestMove(CompanyID company, const char *pass = "");
void NetworkClientSendRcon(const char *password, const char *command);
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg, int64 data = 0);
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
bool NetworkCompanyIsPassworded(CompanyID company_id);
bool NetworkMaxCompaniesReached();
bool NetworkMaxSpectatorsReached();
void NetworkPrintClients();
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
/*** Commands ran by the server ***/
void NetworkServerDailyLoop();
void NetworkServerMonthlyLoop();
void NetworkServerYearlyLoop();
void NetworkServerSendConfigUpdate();
void NetworkServerShowStatusToConsole();
bool NetworkServerStart();
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, ClientID from_id, int64 data = 0, bool from_admin = false);
void NetworkServerKickClient(ClientID client_id);
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban);
uint NetworkServerKickOrBanIP(const char *ip, bool ban);
void NetworkInitChatMessage();
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *message, ...) WARN_FORMAT(3, 4);
void NetworkUndrawChatMessage();
void NetworkChatMessageLoop();
void NetworkAfterNewGRFScan();
#endif /* NETWORK_FUNC_H */
|