From 154e848d327b982e1e909876ca36691ff7f8b71e Mon Sep 17 00:00:00 2001 From: Shpoike Date: Tue, 5 Oct 2021 06:13:27 +0100 Subject: [PATCH] Try to fix some connectivity issues. --- Quake/cl_parse.c | 24 +++++++++++++++--------- Quake/gl_rmain.c | 8 ++++++++ Quake/glquake.h | 1 + Quake/net_dgrm.c | 2 ++ Quake/pr_cmds.c | 4 ++-- Quake/r_brush.c | 3 --- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Quake/cl_parse.c b/Quake/cl_parse.c index 5690e295..1433cf3b 100644 --- a/Quake/cl_parse.c +++ b/Quake/cl_parse.c @@ -2073,12 +2073,15 @@ static void CL_ParsePrecache(void) case 0: //models if (index < MAX_MODELS) { - cl.model_precache[index] = Mod_ForName (name, false); - //FIXME: if its a bsp model, generate lightmaps. - //FIXME: update static entities with that modelindex - - if (cl.model_precache[index]) - GL_BuildModel(cl.model_precache[index]); + q_strlcpy (cl.model_name[index], name, MAX_QPATH); + Mod_TouchModel (name); + if (!cl.sendprespawn) + { + cl.model_precache[index] = Mod_ForName (name, (index==1)?true:false); + //FIXME: update static entities with that modelindex + if (cl.model_precache[index] && cl.model_precache[index]->type == mod_brush) + lightmaps_latecached=true; + } } break; #ifdef PSET_SCRIPT @@ -2241,14 +2244,12 @@ static void CL_ParseStatString(int stat, const char *str) //proquake has its own extension coding thing. static void CL_ParseStuffText(const char *msg) { - const char *str; + char *str; q_strlcat(cl.stuffcmdbuf, msg, sizeof(cl.stuffcmdbuf)); for (; (str = strchr(cl.stuffcmdbuf, '\n')); memmove(cl.stuffcmdbuf, str, Q_strlen(str)+1)) { qboolean handled = false; - str++;//skip past the \n - if (*cl.stuffcmdbuf == 0x01 && cl.protocol == PROTOCOL_NETQUAKE) //proquake message, just strip this and try again (doesn't necessarily have a trailing \n straight away) { for (str = cl.stuffcmdbuf+1; *str >= 0x01 && *str <= 0x1f; str++) @@ -2256,6 +2257,8 @@ static void CL_ParseStuffText(const char *msg) continue; } + *str++ = 0;//skip past the \n + //handle special commands if (cl.stuffcmdbuf[0] == '/' && cl.stuffcmdbuf[1] == '/') { @@ -2282,7 +2285,10 @@ static void CL_ParseStuffText(const char *msg) //let the server exec general user commands (massive security hole) if (!handled) + { Cbuf_AddTextLen(cl.stuffcmdbuf, str-cl.stuffcmdbuf); + Cbuf_AddTextLen("\n", 1); + } } } diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index c1e38ca2..351897f7 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -1159,6 +1159,14 @@ void R_RenderView (void) else if (gl_finish.value) glFinish (); + if (lightmaps_latecached) + { + GL_BuildLightmaps (); + GL_BuildBModelVertexBuffer (); + lightmaps_latecached=false; + } + + //Spike -- quickly draw the world from the skyroom camera's point of view. skyroom_drawn = false; if (r_refdef.drawworld && skyroom_enabled && skyroom_visible) diff --git a/Quake/glquake.h b/Quake/glquake.h index 824d6846..f9733151 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -326,6 +326,7 @@ extern overflowtimes_t dev_overflows; //this stores the last time overflow messa //johnfitz -- moved here from r_brush.c extern int gl_lightmap_format, lightmap_bytes; +extern qboolean lightmaps_latecached; //we need to rebuild lightmaps and model vbos before rendering. #define LMBLOCK_WIDTH 256 //FIXME: make dynamic. if we have a decent card there's no real reason not to use 4k or 16k (assuming there's no lightstyles/dynamics that need uploading...) #define LMBLOCK_HEIGHT 256 //Alternatively, use texture arrays, which would avoid the need to switch textures as often. diff --git a/Quake/net_dgrm.c b/Quake/net_dgrm.c index a7e97b20..f24dd890 100644 --- a/Quake/net_dgrm.c +++ b/Quake/net_dgrm.c @@ -571,6 +571,8 @@ int Datagram_GetMessage (qsocket_t *sock) } length = BigLong(packetBuffer.length); + if (length == 0xffffffff) + continue; //some kind of lingering QW or DP response? flags = length & (~NETFLAG_LENGTH_MASK); length &= NETFLAG_LENGTH_MASK; diff --git a/Quake/pr_cmds.c b/Quake/pr_cmds.c index 1c38aa84..516d0321 100644 --- a/Quake/pr_cmds.c +++ b/Quake/pr_cmds.c @@ -1998,8 +1998,8 @@ int CL_Precache_Model(const char *name) { strcpy(cl.model_name_csqc[i], name); cl.model_precache_csqc[i] = Mod_ForName (name, false); - if (cl.model_precache_csqc[i]) - GL_BuildModel(cl.model_precache_csqc[i]); + if (cl.model_precache_csqc[i] && cl.model_precache_csqc[i]->type == mod_brush) + lightmaps_latecached=true; return -i; } diff --git a/Quake/r_brush.c b/Quake/r_brush.c index 6ecc23bb..022f7830 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -900,9 +900,6 @@ void GL_BuildModel (qmodel_t *m) //johnfitz } - if (m->type == mod_brush) - lightmaps_latecached=true; - // GL_BuildBModelVertexBuffer(); }