diff options
author | darkvater <darkvater@openttd.org> | 2004-09-07 19:34:55 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2004-09-07 19:34:55 +0000 |
commit | 3a241b5ccec2b5f5eb803efbd32f55a5d1de5d97 (patch) | |
tree | fb71b493be30cef91bba060419f951a7a3941f2f | |
parent | bf9c8068be695e95662a541eb76465d60af6c976 (diff) | |
download | openttd-3a241b5ccec2b5f5eb803efbd32f55a5d1de5d97.tar.xz |
(svn r176) -Fix: network_gui const and warnings fixes (Tron)
-rw-r--r-- | functions.h | 2 | ||||
-rw-r--r-- | gui.h | 3 | ||||
-rw-r--r-- | network.c | 12 | ||||
-rw-r--r-- | network_gui.c | 51 |
4 files changed, 32 insertions, 36 deletions
diff --git a/functions.h b/functions.h index faf450e2c..c898e2b7a 100644 --- a/functions.h +++ b/functions.h @@ -137,7 +137,7 @@ void NetworkCoreInit(); void NetworkCoreShutdown(); void NetworkCoreDisconnect(); void NetworkCoreLoop(bool incomming); -bool NetworkCoreConnectGame(byte* b, unsigned short port); +bool NetworkCoreConnectGame(const byte* b, unsigned short port); bool NetworkCoreStartGame(); void NetworkLobbyShutdown(); @@ -1,6 +1,8 @@ #ifndef GUI_H #define GUI_H +#include "window.h" + /* main_gui.c */ void SetupColorsAndInitialWindow(); void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2); @@ -82,6 +84,7 @@ void ShowSmallMap(); void ShowExtraViewPortWindow(); void SetVScrollCount(Window *w, int num); void SetHScrollCount(Window *w, int num); +int HandleEditBoxKey(Window *w, int wid, WindowEvent *we); void ShowCheatWindow(); void AskForNewGameToStart(); @@ -191,7 +191,7 @@ typedef struct FutureSeeds { // remember some future seeds that the server sent to us. static FutureSeeds _future_seed[8]; -static int _num_future_seed; +static uint _num_future_seed; static SOCKET _listensocket; // tcp socket @@ -683,7 +683,7 @@ static bool ReadPackets(ClientState *cs) } } - assert(size>=0 && size < sizeof(cs->buf)); + assert(size < sizeof(cs->buf)); memcpy(cs->buf, network_buffer + pos, size); } @@ -1307,7 +1307,7 @@ void NetworkUDPSend(bool client, struct sockaddr_in recv,struct UDPPacket packet } -bool NetworkUDPSearchGame(byte ** _network_detected_serverip, unsigned short * _network_detected_serverport) { +bool NetworkUDPSearchGame(const byte ** _network_detected_serverip, unsigned short * _network_detected_serverport) { struct UDPPacket packet; int timeout=3000; @@ -1336,7 +1336,7 @@ bool NetworkUDPSearchGame(byte ** _network_detected_serverip, unsigned short * _ } - return (_network_detected_serverport>0); + return (*_network_detected_serverport>0); } @@ -1478,11 +1478,11 @@ DEBUG(misc,3) ("[NET][Core] shutdown()"); /* *************************************************** */ -bool NetworkCoreConnectGame(byte* b, unsigned short port) +bool NetworkCoreConnectGame(const byte* b, unsigned short port) { if (!_network_available) return false; - if (strcmp((char *) b,"auto")==0) { + if (strcmp(b,"auto")==0) { // do autodetect NetworkUDPSearchGame(&b, &port); } diff --git a/network_gui.c b/network_gui.c index a4ad826bd..01de7846d 100644 --- a/network_gui.c +++ b/network_gui.c @@ -10,16 +10,11 @@ #define MAX_QUERYSTR_LEN 64 static byte _edit_str_buf[MAX_QUERYSTR_LEN*2]; static void ShowNetworkStartServerWindow(); +#if 0 static void ShowNetworkLobbyWindow(); - -extern void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask); -extern int HandleEditBoxKey(Window *w, int wid, WindowEvent *we); - -void ShowQueryString(StringID str, StringID caption, int maxlen, int maxwidth, byte window_class, uint16 window_number); - +#endif static byte _selected_field; -char *direct_ip = NULL; static const StringID _connection_types_dropdown[] = { STR_NETWORK_LAN, @@ -65,8 +60,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) NetworkLobbyShutdown(); break; case 3: { /* Find server automaticaly */ - byte *b = "auto"; - NetworkCoreConnectGame(b, _network_server_port); + NetworkCoreConnectGame("auto", _network_server_port); } break; case 4: { /* Connect via direct ip */ StringID str; @@ -103,7 +97,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) break; case WE_KEYPRESS: - if(_selected_field != 6) + if (_selected_field != 6) break; switch (HandleEditBoxKey(w, 6, e)) { @@ -114,7 +108,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - byte *b = e->edittext.str; + const byte *b = e->edittext.str; if (*b == 0) return; NetworkCoreConnectGame(b,_network_server_port); @@ -304,6 +298,7 @@ static void ShowNetworkStartServerWindow() WP(w,querystr_d).buf = _edit_str_buf; } +#if 0 static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) { switch(e->event) { @@ -362,33 +357,32 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) } static const Widget _network_lobby_window_widgets[] = { -{ WWT_PUSHTXTBTN, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, -{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_GAME_LOBBY }, -{ WWT_IMGBTN, BGC, 0, 399, 14, 299, 0x0}, +{ WWT_PUSHTXTBTN, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, +{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_GAME_LOBBY, STR_NULL}, +{ WWT_IMGBTN, BGC, 0, 399, 14, 299, 0x0, STR_NULL}, // chat widget -{ WWT_IMGBTN, BGC, 10, 240, 30, 240, 0x0}, -{ WWT_SCROLLBAR, BGC, 241, 251, 30, 240, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, +{ WWT_IMGBTN, BGC, 10, 240, 30, 240, 0x0, STR_NULL}, +{ WWT_SCROLLBAR, BGC, 241, 251, 30, 240, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // send message prompt -{ WWT_IMGBTN, BGC, 10, 200, 241, 252, 0x0, STR_NETWORK_ENTER_NAME_TIP}, -{ WWT_PUSHTXTBTN, BTC, 201, 251, 241, 252, STR_NETWORK_SEND, STR_NETWORK_SEND_TIP}, +{ WWT_IMGBTN, BGC, 10, 200, 241, 252, 0x0, STR_NETWORK_ENTER_NAME_TIP}, +{ WWT_PUSHTXTBTN, BTC, 201, 251, 241, 252, STR_NETWORK_SEND, STR_NETWORK_SEND_TIP}, // company name -{ WWT_IMGBTN, BGC, 100, 251, 254, 265, 0x0, STR_NETWORK_COMPANY_NAME_TIP}, +{ WWT_IMGBTN, BGC, 100, 251, 254, 265, 0x0, STR_NETWORK_COMPANY_NAME_TIP}, // player information -{ WWT_IMGBTN, BGC, 260, 379, 30, 221, 0x0}, -{ WWT_SCROLLBAR, BGC, 380, 390, 30, 221, 0x1, STR_0190_SCROLL_BAR_SCROLLS_LIST}, +{ WWT_IMGBTN, BGC, 260, 379, 30, 221, 0x0, STR_NULL}, +{ WWT_SCROLLBAR, BGC, 380, 390, 30, 221, 0x1, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // buttons -{ WWT_PUSHTXTBTN, BTC, 260, 390, 233, 244, STR_NETWORK_NEW_COMPANY, STR_NETWORK_NEW_COMPANY_TIP}, -{ WWT_PUSHTXTBTN, BTC, 260, 390, 254, 265, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP}, - -{ WWT_PUSHTXTBTN, BTC, 80, 180, 280, 291, STR_NETWORK_READY, STR_NULL}, -{ WWT_PUSHTXTBTN, BTC, 220, 320, 280, 291, STR_012E_CANCEL, STR_NULL}, +{ WWT_PUSHTXTBTN, BTC, 260, 390, 233, 244, STR_NETWORK_NEW_COMPANY, STR_NETWORK_NEW_COMPANY_TIP}, +{ WWT_PUSHTXTBTN, BTC, 260, 390, 254, 265, STR_NETWORK_SPECTATE_GAME, STR_NETWORK_SPECTATE_GAME_TIP}, -{ WWT_LAST}, +{ WWT_PUSHTXTBTN, BTC, 80, 180, 280, 291, STR_NETWORK_READY, STR_NULL}, +{ WWT_PUSHTXTBTN, BTC, 220, 320, 280, 291, STR_012E_CANCEL, STR_NULL}, +{ WWT_LAST}, }; static const WindowDesc _network_lobby_window_desc = { @@ -414,5 +408,4 @@ static void ShowNetworkLobbyWindow() WP(w,querystr_d).maxwidth = 240; WP(w,querystr_d).buf = _edit_str_buf; } - - +#endif |