From d87c4ab2893d8acfc6168298bd776a86221e521f Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Sun, 4 Jul 2010 13:57:21 +0000 Subject: [PATCH] Fixes for rev1148: Was too hasty with calling net_udp_close; Fixing typo in WSACleanup() --- CHANGELOG.txt | 1 + main/game.c | 6 +++--- main/net_udp.c | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d8d67c5ab..c89086e4f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ D1X-Rebirth Changelog main/net_udp.c: Fixed Compiler-warning on Windows main/net_ipx.c, main/net_udp.c: Implemented Winsock functions for UDP which I totally forgot about; Now when leaving game in any way, close sockets and Winsock stuff main/gameseq.c, main/multi.c: Since time is not suspended between levels in Multiplayer, call reset_time after level change. Apply this in Singleplayer, too since it should always be safe - and appropriate - to reset timer_value soon as a new level begins +main/net_udp.c: Fixes for rev1148: Was too hasty with calling net_udp_close; Fixing typo in WSACleanup() 20100701 -------- diff --git a/main/game.c b/main/game.c index 3f00ffba1..081a83b80 100644 --- a/main/game.c +++ b/main/game.c @@ -389,7 +389,7 @@ static int time_paused=0; void stop_time() { if (time_paused==0) { - fix time;printf("STOP\n"); + fix time; time = timer_get_fixed_seconds(); last_timer_value = time - last_timer_value; if (last_timer_value < 0) { @@ -404,7 +404,7 @@ void start_time() time_paused--; Assert(time_paused >= 0); if (time_paused==0) { - fix time;printf("START\n"); + fix time; time = timer_get_fixed_seconds(); last_timer_value = time - last_timer_value; } @@ -453,7 +453,7 @@ void FixedStepCalc() } void reset_time() -{printf("RESET\n"); +{ last_timer_value = timer_get_fixed_seconds(); } diff --git a/main/net_udp.c b/main/net_udp.c index 5883cb22f..6c0cdb717 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -453,7 +453,6 @@ static int manual_join_game_handler(newmenu *menu, d_event *event, direct_join * case EVENT_WINDOW_CLOSE: d_free(dj); - net_udp_close(); break; default: @@ -467,7 +466,7 @@ void net_udp_manual_join_game() { direct_join *dj; newmenu_item m[7]; - int nitems = 0; + int nitems = 0, i = 0; MALLOC(dj, direct_join, 1); if (!dj) @@ -501,7 +500,9 @@ void net_udp_manual_join_game() m[nitems].type = NM_TYPE_INPUT; m[nitems].text=UDP_MyPort; m[nitems].text_len=5; nitems++; m[nitems].type = NM_TYPE_TEXT; m[nitems].text=blank; nitems++; // for connecting_txt - newmenu_do1( NULL, "ENTER GAME ADDRESS", nitems, m, (int (*)(newmenu *, d_event *, void *))manual_join_game_handler, dj, 0 ); + i = newmenu_do1( NULL, "ENTER GAME ADDRESS", nitems, m, (int (*)(newmenu *, d_event *, void *))manual_join_game_handler, dj, 0 ); + if (i != -2) + net_udp_close(); } static int NLPage = 0; @@ -770,7 +771,7 @@ void net_udp_init() WORD wVersionRequested; WSADATA wsaData; wVersionRequested = MAKEWORD(2, 0); - WSACleanUp(); + WSACleanup(); if (WSAStartup( wVersionRequested, &wsaData)) nm_messagebox( TXT_ERROR, 1, TXT_OK, "Cannot init Winsock!"); // no break here... game will fail at socket creation anyways... } @@ -805,7 +806,7 @@ void net_udp_init() void net_udp_close() { #ifdef _WIN32 - WSACleanUp(); + WSACleanup(); #endif if( UDP_Socket[0] != -1 )