mirror of https://github.com/OpenTTD/OpenTTD
(svn r6754) -Codechange: Remove some #idef ENABLE_NETWORK specific defines. With networking
disabled hardcode _networking/_network_available to zero and let the compiler handle all optimizations.release/0.5
parent
15bf48acfd
commit
cad526ef36
4
date.c
4
date.c
|
@ -254,9 +254,7 @@ void IncreaseDate(void)
|
|||
TownsMonthlyLoop();
|
||||
IndustryMonthlyLoop();
|
||||
StationMonthlyLoop();
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) NetworkServerMonthlyLoop();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
|
||||
/* check if we entered a new year? */
|
||||
|
@ -269,9 +267,7 @@ void IncreaseDate(void)
|
|||
RoadVehiclesYearlyLoop();
|
||||
AircraftYearlyLoop();
|
||||
ShipsYearlyLoop();
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) NetworkServerYearlyLoop();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/* check if we reached end of the game */
|
||||
if (_cur_year == _patches.ending_year) {
|
||||
|
|
3
gui.h
3
gui.h
|
@ -120,9 +120,6 @@ void SetFiosType(const byte fiostype);
|
|||
/* FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE etc. different colours */
|
||||
extern const byte _fios_colors[];
|
||||
|
||||
/* network gui */
|
||||
void ShowNetworkGameWindow(void);
|
||||
|
||||
/* bridge_gui.c */
|
||||
void ShowBuildBridgeWindow(uint start, uint end, byte type);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "settings.h"
|
||||
#include "heightmap.h"
|
||||
#include "genworld.h"
|
||||
#include "network_gui.h"
|
||||
|
||||
static const Widget _select_game_widgets[] = {
|
||||
{ WWT_CAPTION, RESIZE_NONE, 13, 0, 335, 0, 13, STR_0307_OPENTTD, STR_NULL},
|
||||
|
@ -66,15 +67,11 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
|||
case 5: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
|
||||
case 6: ShowCreateScenario(); break;
|
||||
case 7:
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_network_available) {
|
||||
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
} else {
|
||||
ShowNetworkGameWindow();
|
||||
}
|
||||
#else
|
||||
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
#endif
|
||||
break;
|
||||
case 8: case 9: case 10: case 11:
|
||||
RaiseWindowWidget(w, _opt_newgame.landscape + 8);
|
||||
|
|
15
main_gui.c
15
main_gui.c
|
@ -38,6 +38,7 @@
|
|||
#include "network_data.h"
|
||||
#include "network_client.h"
|
||||
#include "network_server.h"
|
||||
#include "network_gui.h"
|
||||
|
||||
static int _rename_id;
|
||||
static int _rename_what;
|
||||
|
@ -221,23 +222,16 @@ static void MenuClickFinances(int index)
|
|||
ShowPlayerFinances(index);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
extern void ShowClientList(void);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
static void MenuClickCompany(int index)
|
||||
{
|
||||
if (_networking && index == 0) {
|
||||
#ifdef ENABLE_NETWORK
|
||||
ShowClientList();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
} else {
|
||||
if (_networking) index--;
|
||||
ShowPlayerCompany(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void MenuClickGraphs(int index)
|
||||
{
|
||||
switch (index) {
|
||||
|
@ -308,15 +302,12 @@ static void MenuClickBuildAir(int index)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
void ShowNetworkGiveMoneyWindow(byte player)
|
||||
void ShowNetworkGiveMoneyWindow(PlayerID player)
|
||||
{
|
||||
_rename_id = player;
|
||||
_rename_what = 3;
|
||||
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, 180, 1, 0, CS_NUMERAL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
void ShowRenameSignWindow(const Sign *si)
|
||||
|
@ -2320,9 +2311,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
case '1' | WKC_ALT: /* Gimme money */
|
||||
/* Server can not cheat in advertise mode either! */
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (!_networking || !_network_server || !_network_advertise)
|
||||
#endif
|
||||
DoCommandP(0, -10000000, 0, NULL, CMD_MONEY_CHEAT);
|
||||
break;
|
||||
|
||||
|
|
26
network.h
26
network.h
|
@ -197,7 +197,6 @@ VARDEF uint16 _network_udp_broadcast;
|
|||
|
||||
VARDEF byte _network_lan_internet;
|
||||
|
||||
VARDEF bool _network_advertise;
|
||||
VARDEF bool _network_need_advertise;
|
||||
VARDEF uint32 _network_last_advertise_frame;
|
||||
VARDEF uint8 _network_advertise_retries;
|
||||
|
@ -233,13 +232,26 @@ bool NetworkServerStart(void);
|
|||
bool NetworkClientConnectGame(const char* host, unsigned short port);
|
||||
void NetworkReboot(void);
|
||||
void NetworkDisconnect(void);
|
||||
|
||||
VARDEF bool _networking; ///< are we in networking mode?
|
||||
VARDEF bool _network_server; ///< network-server is active
|
||||
VARDEF bool _network_available; ///< is network mode available?
|
||||
|
||||
#else /* ENABLE_NETWORK */
|
||||
/* Network function stubs when networking is disabled */
|
||||
|
||||
static inline void NetworkStartUp(void) {}
|
||||
static inline void NetworkShutDown(void) {}
|
||||
|
||||
#define _networking 0
|
||||
#define _network_server 0
|
||||
#define _network_available 0
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
// Those variables must always be registered!
|
||||
VARDEF bool _networking;
|
||||
VARDEF bool _network_available; // is network mode available?
|
||||
VARDEF bool _network_server; // network-server is active
|
||||
VARDEF bool _network_dedicated; // are we a dedicated server?
|
||||
VARDEF PlayerID _network_playas; // an id to play as..
|
||||
/* These variables must always be registered! */
|
||||
VARDEF bool _network_dedicated; ///< are we a dedicated server?
|
||||
VARDEF bool _network_advertise; ///< is the server advertising to the master server?
|
||||
VARDEF PlayerID _network_playas; ///< an id to play as..
|
||||
|
||||
#endif /* NETWORK_H */
|
||||
|
|
|
@ -1720,6 +1720,4 @@ void ShowNetworkChatQueryWindow(byte desttype, byte dest)
|
|||
UpdateTextBufferSize(&WP(w, querystr_d).text);
|
||||
}
|
||||
|
||||
#else
|
||||
void ShowJoinStatusWindowAfterJoin(void) {}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
|
|
@ -3,6 +3,25 @@
|
|||
#ifndef NETWORK_GUI_H
|
||||
#define NETWORK_GUI_H
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
#include "network_data.h"
|
||||
|
||||
void ShowNetworkNeedPassword(NetworkPasswordType npt);
|
||||
void ShowNetworkGiveMoneyWindow(byte player); // PlayerID
|
||||
void ShowNetworkChatQueryWindow(byte desttype, byte dest);
|
||||
void ShowJoinStatusWindowAfterJoin(void);
|
||||
void ShowNetworkGameWindow(void);
|
||||
void ShowClientList(void);
|
||||
|
||||
#else /* ENABLE_NETWORK */
|
||||
/* Network function stubs when networking is disabled */
|
||||
|
||||
static inline void ShowNetworkChatQueryWindow(byte desttype, byte dest) {}
|
||||
static inline void ShowClientList(void) {}
|
||||
static inline void ShowJoinStatusWindowAfterJoin(void) {}
|
||||
static inline void ShowNetworkGameWindow(void) {}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
#endif /* NETWORK_GUI_H */
|
||||
|
|
|
@ -28,6 +28,12 @@ static inline const char* GetPlayerIP(const NetworkClientInfo* ci)
|
|||
return inet_ntoa(addr);
|
||||
}
|
||||
|
||||
#else /* ENABLE_NETWORK */
|
||||
/* Network function stubs when networking is disabled */
|
||||
|
||||
static inline void NetworkServerMonthlyLoop(void) {}
|
||||
static inline void NetworkServerYearlyLoop(void) {}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
#endif /* NETWORK_SERVER_H */
|
||||
|
|
|
@ -14,6 +14,6 @@ NetworkGameList *NetworkUDPQueryServer(const char* host, unsigned short port);
|
|||
void NetworkUDPAdvertise(void);
|
||||
void NetworkUDPRemoveAdvertise(void);
|
||||
|
||||
#endif
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
#endif /* NETWORK_UDP_H */
|
||||
|
|
15
openttd.c
15
openttd.c
|
@ -453,10 +453,7 @@ int ttd_main(int argc, char *argv[])
|
|||
// restore saved music volume
|
||||
_music_driver->set_volume(msf.music_vol);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
// initialize network-core
|
||||
NetworkStartUp();
|
||||
#endif /* ENABLE_NETWORK */
|
||||
NetworkStartUp(); // initialize network-core
|
||||
|
||||
_opt_ptr = &_opt_newgame;
|
||||
|
||||
|
@ -505,12 +502,7 @@ int ttd_main(int argc, char *argv[])
|
|||
WaitTillSaved();
|
||||
IConsoleFree();
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_available) {
|
||||
// Shut down the network and close any open connections
|
||||
NetworkDisconnect();
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections
|
||||
|
||||
_video_driver->stop();
|
||||
_music_driver->stop();
|
||||
|
@ -986,8 +978,7 @@ void GameLoop(void)
|
|||
|
||||
#ifdef ENABLE_NETWORK
|
||||
// Check for UDP stuff
|
||||
if (_network_available)
|
||||
NetworkUDPGameLoop();
|
||||
if (_network_available) NetworkUDPGameLoop();
|
||||
|
||||
if (_networking && !IsGeneratingWorld()) {
|
||||
// Multiplayer
|
||||
|
|
12
player_gui.c
12
player_gui.c
|
@ -18,15 +18,11 @@
|
|||
#include "train.h"
|
||||
#include "date.h"
|
||||
#include "newgrf.h"
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
#include "network_data.h"
|
||||
#include "network_client.h"
|
||||
#endif
|
||||
|
||||
static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_stickied);
|
||||
|
||||
|
||||
static void DrawPlayerEconomyStats(const Player *p, byte mode)
|
||||
{
|
||||
int x,y,i,j,year;
|
||||
|
@ -811,15 +807,15 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||
DoCommandP(0, w->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
case PCW_WIDGET_COMPANY_PASSWORD:
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (w->window_number == _local_player) {
|
||||
WP(w,def_d).byte_1 = 2;
|
||||
ShowQueryString(BindCString(_network_player_info[_local_player].password),
|
||||
STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w->window_class, w->window_number, CS_ALPHANUMERAL);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -857,12 +853,12 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||
case 1: /* Change company name */
|
||||
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_COMPANY_NAME | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME));
|
||||
break;
|
||||
#ifdef ENABLE_NETWORK
|
||||
case 2: /* Change company password */
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (*b == '\0') *b = '*'; // empty password is a '*' because of console argument
|
||||
NetworkChangeCompanyPassword(1, &b);
|
||||
#endif
|
||||
break;
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue