(svn r1240) -Fix: OpenTTD once again compiles if ENABLE_NETWORK is disabled.

-Fix: removed some warnings
-Enabled ENABLE_NETWORK on windows again which I accidentally commented out.
This commit is contained in:
darkvater 2004-12-23 00:24:44 +00:00
parent c4836bbd70
commit 28c1dc3e39
10 changed files with 26 additions and 20 deletions

View File

@ -34,7 +34,7 @@ static void *_dedicated_video_mem;
#ifdef UNIX #ifdef UNIX
/* We want to fork our dedicated server */ /* We want to fork our dedicated server */
void DedicatedFork() void DedicatedFork(void)
{ {
/* Fork the program */ /* Fork the program */
_dedicated_pid = fork(); _dedicated_pid = fork();
@ -242,6 +242,7 @@ static const char *DedicatedVideoStart(char **parm) {
return NULL; return NULL;
} }
void DedicatedFork(void) {}
static void DedicatedVideoStop() { free(_dedicated_video_mem); } static void DedicatedVideoStop() { free(_dedicated_video_mem); }
static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {} static void DedicatedVideoMakeDirty(int left, int top, int width, int height) {}
static bool DedicatedVideoChangeRes(int w, int h) { return false; } static bool DedicatedVideoChangeRes(int w, int h) { return false; }

View File

@ -57,15 +57,14 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) {
case 4: ShowPatchesSelection(); break; case 4: ShowPatchesSelection(); break;
case 5: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break; case 5: DoCommandP(0, InteractiveRandom(), 0, NULL, CMD_CREATE_SCENARIO); break;
case 7: case 7:
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
if (!_network_available) { if (!_network_available) {
ShowErrorMessage(-1,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); ShowErrorMessage(-1, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
} else { } else
ShowNetworkGameWindow(); ShowNetworkGameWindow();
} #else
#else ShowErrorMessage(-1 ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
ShowErrorMessage(-1,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0); #endif /* ENABLE_NETWORK */
#endif /* ENABLE_NETWORK */
break; break;
case 8: ShowGameOptions(); break; case 8: ShowGameOptions(); break;
case 9: ShowGameDifficulty(); break; case 9: ShowGameDifficulty(); break;

View File

@ -2370,7 +2370,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
void ShowSelectGameWindow(); void ShowSelectGameWindow();
extern void ShowJoinStatusWindowAfterJoin(); extern void ShowJoinStatusWindowAfterJoin(void);
void SetupColorsAndInitialWindow() void SetupColorsAndInitialWindow()
{ {

View File

@ -132,8 +132,6 @@ VARDEF NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
VARDEF char _network_player_name[NETWORK_NAME_LENGTH]; VARDEF char _network_player_name[NETWORK_NAME_LENGTH];
VARDEF char _network_default_ip[NETWORK_HOSTNAME_LENGTH]; VARDEF char _network_default_ip[NETWORK_HOSTNAME_LENGTH];
#define MAX_SAVED_SERVERS 10
VARDEF char *_network_host_list[MAX_SAVED_SERVERS];
VARDEF uint16 _network_own_client_index; VARDEF uint16 _network_own_client_index;
VARDEF char _network_unique_id[NETWORK_NAME_LENGTH]; // Our own unique ID VARDEF char _network_unique_id[NETWORK_NAME_LENGTH]; // Our own unique ID
@ -186,9 +184,13 @@ VARDEF bool _network_autoclean_companies;
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X months VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X months
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
// Those variables must always be registered! // Those variables must always be registered!
#define MAX_SAVED_SERVERS 10
VARDEF char *_network_host_list[MAX_SAVED_SERVERS];
VARDEF bool _networking; VARDEF bool _networking;
VARDEF bool _network_available; // is network mode available? VARDEF bool _network_available; // is network mode available?
VARDEF bool _network_server; // network-server is active VARDEF bool _network_server; // network-server is active
@ -199,7 +201,6 @@ void ParseConnectionString(const byte **player, const byte **port, byte *connect
void NetworkUpdateClientInfo(uint16 client_index); void NetworkUpdateClientInfo(uint16 client_index);
void NetworkAddServer(const byte *b); void NetworkAddServer(const byte *b);
void NetworkRebuildHostList(); void NetworkRebuildHostList();
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
void NetworkChangeCompanyPassword(const char *str); void NetworkChangeCompanyPassword(const char *str);
#endif /* NETWORK_H */ #endif /* NETWORK_H */

View File

@ -596,7 +596,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHAT)
{ {
NetworkAction action = NetworkRecv_uint8(p); NetworkAction action = NetworkRecv_uint8(p);
char msg[MAX_TEXT_MSG_LEN]; char msg[MAX_TEXT_MSG_LEN];
NetworkClientInfo *ci, *ci_to; NetworkClientInfo *ci = NULL, *ci_to;
uint16 index; uint16 index;
char name[NETWORK_NAME_LENGTH]; char name[NETWORK_NAME_LENGTH];
bool self_send; bool self_send;

View File

@ -13,7 +13,7 @@
# include <winsock2.h> # include <winsock2.h>
# include <ws2tcpip.h> # include <ws2tcpip.h>
# pragma comment (lib, "ws2_32.lib") # pragma comment (lib, "ws2_32.lib")
//# define ENABLE_NETWORK // On windows, the network is always enabled # define ENABLE_NETWORK // On windows, the network is always enabled
# define GET_LAST_ERROR() WSAGetLastError() # define GET_LAST_ERROR() WSAGetLastError()
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
// Windows has some different names for some types.. // Windows has some different names for some types..

View File

@ -1315,7 +1315,7 @@ void ShowJoinStatusWindow()
AllocateWindowDesc(&_network_join_status_window_desc); AllocateWindowDesc(&_network_join_status_window_desc);
} }
void ShowJoinStatusWindowAfterJoin() void ShowJoinStatusWindowAfterJoin(void)
{ {
/* This is a special instant of ShowJoinStatusWindow, because /* This is a special instant of ShowJoinStatusWindow, because
it is opened after the map is loaded, but the client maybe is not it is opened after the map is loaded, but the client maybe is not
@ -1454,5 +1454,6 @@ void ShowChatWindow(StringID str, StringID caption, int maxlen, int maxwidth, by
WP(w,querystr_d).buf = _edit_str_buf; WP(w,querystr_d).buf = _edit_str_buf;
} }
#else
void ShowJoinStatusWindowAfterJoin(void) {}
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

View File

@ -1,6 +1,8 @@
#ifndef NETWORK_LAN_H #ifndef NETWORK_LAN_H
#define NETWORK_LAN_H #define NETWORK_LAN_H
#ifdef ENABLE_NETWORK
void NetworkUDPInitialize(void); void NetworkUDPInitialize(void);
bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast); bool NetworkUDPListen(SOCKET *udp, uint32 host, uint16 port, bool broadcast);
void NetworkUDPReceive(SOCKET udp); void NetworkUDPReceive(SOCKET udp);
@ -10,4 +12,6 @@ NetworkGameList *NetworkUDPQueryServer(const byte* host, unsigned short port);
void NetworkUDPAdvertise(void); void NetworkUDPAdvertise(void);
void NetworkUDPRemoveAdvertise(void); void NetworkUDPRemoveAdvertise(void);
#endif
#endif /* NETWORK_LAN_H */ #endif /* NETWORK_LAN_H */

View File

@ -952,14 +952,14 @@ static void LoadList(IniFile *ini, const char *grpname, char **list, int len)
static void SaveList(IniFile *ini, const char *grpname, char **list, int len) static void SaveList(IniFile *ini, const char *grpname, char **list, int len)
{ {
IniGroup *group = ini_getgroup(ini, grpname, -1); IniGroup *group = ini_getgroup(ini, grpname, -1);
IniItem *item; IniItem *item = NULL;
int i; int i;
bool first = true; bool first = true;
if (!group) if (!group)
return; return;
for ( i=0; i != len; i++) { for (i = 0; i != len; i++) {
if ( list[i] == '\0' ) continue; if (list[i] == '\0') continue;
if (first) { // add first item to the head of the group if (first) { // add first item to the head of the group
item = ini_item_alloc(group, list[i], strlen(list[i])); item = ini_item_alloc(group, list[i], strlen(list[i]));

2
ttd.c
View File

@ -519,7 +519,7 @@ void LoadIntroGame()
if (_music_driver->is_song_playing()) ResetMusic(); if (_music_driver->is_song_playing()) ResetMusic();
} }
extern void DedicatedFork(); extern void DedicatedFork(void);
int ttd_main(int argc, char* argv[]) int ttd_main(int argc, char* argv[])
{ {