From 2592a23c447da61b9a9978317bb9372593d53f12 Mon Sep 17 00:00:00 2001 From: black Date: Thu, 2 Jun 2005 19:00:05 +0000 Subject: [PATCH] -Changed host_abortserver to host_abortframe. -Added a hack to allow the menu crash in Host_Init without it taking down the whole host (please intergrate this into the general design somehow ASAP). -Changed the hostcache code to always add servers at the right position and to eject 'worse' servers from the viewlist. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5379 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 20 ++++++++++++++++---- netconn.c | 23 ++++++++++++----------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/host.c b/host.c index 608f9c2b..abbbff18 100644 --- a/host.c +++ b/host.c @@ -56,7 +56,7 @@ int forcedeveloper; // current client client_t *host_client; -jmp_buf host_abortserver; +jmp_buf host_abortframe; // pretend frames take this amount of time (in seconds), 0 = realtime cvar_t host_framerate = {0, "host_framerate","0"}; @@ -102,7 +102,7 @@ aborts the current host frame and goes on with the next one */ void Host_AbortCurrentFrame(void) { - longjmp (host_abortserver, 1); + longjmp (host_abortframe, 1); } /* @@ -745,7 +745,7 @@ void _Host_Frame (float time) static double time3 = 0; int pass1, pass2, pass3; - if (setjmp(host_abortserver)) + if (setjmp(host_abortframe)) return; // something bad happened, or the server disconnected // decide the simulation time @@ -880,7 +880,6 @@ void Host_StartVideo(void) VID_Start(); CDAudio_Startup(); CL_InitTEnts(); // We must wait after sound startup to load tent sounds - MR_Init(); } } @@ -1057,6 +1056,19 @@ void Host_Init (void) Con_DPrint("========Initialized=========\n"); Host_StartVideo(); + + // FIXME: put this into some neat design, but the menu should be allowed to crash + // without crashing the whole game, so this should just be a short-time solution + + // here comes the not so critical stuff + if (setjmp(host_abortframe)) { + return; + } + + if (vid_opened && cls.state != ca_dedicated) + { + MR_Init(); + } } diff --git a/netconn.c b/netconn.c index ba940894..cf380f89 100755 --- a/netconn.c +++ b/netconn.c @@ -110,14 +110,16 @@ qboolean serverlist_consoleoutput; static void _ServerList_ViewList_Helper_InsertBefore( int index, serverlist_entry_t *entry ) { int i; - if( serverlist_viewcount == SERVERLIST_VIEWLISTSIZE ) - return; + if( serverlist_viewcount < SERVERLIST_VIEWLISTSIZE ) { + i = serverlist_viewcount++; + } else { + i = SERVERLIST_VIEWLISTSIZE - 1; + } - for( i = serverlist_viewcount ; i > index ; i-- ) + for( ; i > index ; i-- ) serverlist_viewlist[ i ] = serverlist_viewlist[ i - 1 ]; serverlist_viewlist[index] = entry; - serverlist_viewcount++; } // we suppose serverlist_viewcount to be valid, ie > 0 @@ -254,9 +256,7 @@ static void ServerList_ViewList_Insert( serverlist_entry_t *entry ) { int start, end, mid; - if( serverlist_viewcount == SERVERLIST_VIEWLISTSIZE ) - return; - + // FIXME: change this to be more readable (...) // now check whether it passes through the masks for( start = 0 ; serverlist_andmasks[start].active && start < SERVERLIST_ANDMASKCOUNT ; start++ ) if( !_ServerList_Entry_Mask( &serverlist_andmasks[start], &entry->info ) ) @@ -271,7 +271,7 @@ static void ServerList_ViewList_Insert( serverlist_entry_t *entry ) if( !serverlist_viewcount ) { _ServerList_ViewList_Helper_InsertBefore( 0, entry ); return; - } + } // ok, insert it, we just need to find out where exactly: // two special cases @@ -335,7 +335,7 @@ static void _ServerList_Test(void) int i; for( i = 0 ; i < 1024 ; i++ ) { memset( &serverlist_cache[serverlist_cachecount], 0, sizeof( serverlist_entry_t ) ); - serverlist_cache[serverlist_cachecount].info.ping = rand() % 450 + 250; + serverlist_cache[serverlist_cachecount].info.ping = 1000 + 1024 - i; dpsnprintf( serverlist_cache[serverlist_cachecount].info.name, 128, "Black's ServerList Test %i", i ); serverlist_cache[serverlist_cachecount].finished = true; sprintf( serverlist_cache[serverlist_cachecount].line1, "%i %s", serverlist_cache[serverlist_cachecount].info.ping, serverlist_cache[serverlist_cachecount].info.name ); @@ -355,9 +355,10 @@ void ServerList_QueryList(void) serverlist_cachecount = 0; serverlist_viewcount = 0; serverlist_consoleoutput = false; - NetConn_QueryMasters(); - + //_ServerList_Test(); + + NetConn_QueryMasters(); } // rest -- 2.39.2