From 463596ca521f4ead7397a3035cb3f717849ffe4e Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 12 Jul 2003 16:49:09 +0000 Subject: [PATCH] now sends nops to server as unreliable, to avoid trashing the reliable packet system, this fixed connecting through NAT (!) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3260 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 64 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index 77a8a183..6375d290 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -195,12 +195,17 @@ void CL_KeepaliveMessage (void) if (cls.netcon && NetConn_CanSendMessage(cls.netcon) && (time = Sys_DoubleTime()) - lastmsg >= 5) { + sizebuf_t msg; + qbyte buf[4]; lastmsg = time; // write out a nop + // LordHavoc: must use unreliable because reliable could kill the sigon message! Con_Printf("--> client to server keepalive\n"); - MSG_WriteByte(&cls.message, clc_nop); - NetConn_SendReliableMessage(cls.netcon, &cls.message); - SZ_Clear(&cls.message); + msg.data = buf; + msg.maxsize = sizeof(buf); + msg.cursize = 0; + MSG_WriteChar(&msg, svc_nop); + NetConn_SendUnreliableMessage(cls.netcon, &msg); // try not to utterly crush the computer with work, that's just rude Sys_Sleep(); } @@ -369,41 +374,48 @@ void CL_ParseServerInfo (void) // disable until we get textures for it R_ResetSkyBox(); - memset (cl.model_precache, 0, sizeof(cl.model_precache)); - memset (cl.sound_precache, 0, sizeof(cl.sound_precache)); + memset(cl.model_precache, 0, sizeof(cl.model_precache)); + memset(cl.sound_precache, 0, sizeof(cl.sound_precache)); - // touch all of the precached models that are still loaded so we can free - // anything that isn't needed - Mod_ClearUsed(); + // parse model precache list for (nummodels=1 ; ; nummodels++) { - CL_KeepaliveMessage (); - str = MSG_ReadString (); + str = MSG_ReadString(); if (!str[0]) break; if (nummodels==MAX_MODELS) Host_Error ("Server sent too many model precaches\n"); if (strlen(str) >= MAX_QPATH) Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); - strcpy (parse_model_precache[nummodels], str); - Mod_TouchModel (str); + strcpy(parse_model_precache[nummodels], str); } - - // do the same for sounds + // parse sound precache list for (numsounds=1 ; ; numsounds++) { - CL_KeepaliveMessage (); - str = MSG_ReadString (); + str = MSG_ReadString(); if (!str[0]) break; if (numsounds==MAX_SOUNDS) - Host_Error ("Server sent too many sound precaches\n"); + Host_Error("Server sent too many sound precaches\n"); if (strlen(str) >= MAX_QPATH) - Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); - strcpy (parse_sound_precache[numsounds], str); - S_TouchSound (str); + Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1); + strcpy(parse_sound_precache[numsounds], str); } + // touch all of the precached models that are still loaded so we can free + // anything that isn't needed + Mod_ClearUsed(); + for (i = 1;i < nummodels;i++) + { + CL_KeepaliveMessage(); + Mod_TouchModel(parse_model_precache[i]); + } + // do the same for sounds + for (i = 1;i < numsounds;i++) + { + CL_KeepaliveMessage(); + S_TouchSound(parse_sound_precache[i]); + } // purge anything that was not touched Mod_PurgeUnused(); @@ -411,15 +423,15 @@ void CL_ParseServerInfo (void) // world model CL_KeepaliveMessage (); - cl.model_precache[1] = Mod_ForName (parse_model_precache[1], false, false, true); + cl.model_precache[1] = Mod_ForName(parse_model_precache[1], false, false, true); if (cl.model_precache[1] == NULL) Con_Printf("Map %s not found\n", parse_model_precache[1]); // normal models for (i=2 ; i