From a71156e14d3f1144f73e52ca14a2925c2420cfd0 Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Fri, 2 Mar 2001 10:52:15 +0000 Subject: [PATCH] Coordinates are now floats in network protocol (bloats it yes, but the accuracy allows unlimited map size, and smoother movement at very high framerates) prints dump of last 32 svc messages in packet when client encounters unknown svc (corrupt or mis-parsed network stream) some aesthetic cleanup of tempentity parsing rewrite of COM_FileBase default gl_lightmaprgba to 1 (driver speedup (data bloat, but drivers are often more optimized for it), thought I defaulted it to 1 all along, but apparently not) model names no longer use COM_FileBase (thus they are the full name, like "progs/blah.mdl" rather than "blah", "maps/start.bsp" instead of "start", etc) fixed bugs in model colormapping, and added external skin texture support (example: progs/blah.mdl_0_normal.tga and progs/blah.mdl_0_glow.tga, pants and shirts are also supported) support for textures inside HL maps, and the transparent color has been fixed (HL checks for pure blue, not index 255) default r_dynamicparticles to 1 (light smoke/blood) improvement in angled corner sticking situations (still get a little bump as you pass through, but not actually stuck) fixed rotation support in MOVETYPE_FOLLOW, now works perfectly extended description length in hunk headers (50 characters now) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@165 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 56 +++++++++++++++------ cl_tent.c | 130 +++++++++++++------------------------------------ common.c | 56 +++++++++++++++------ common.h | 4 ++ gl_models.c | 22 ++++----- gl_rsurf.c | 4 +- model_alias.c | 27 ++++++++-- model_brush.c | 38 +++++++++++++-- model_shared.c | 3 +- pr_cmds.c | 6 +-- r_part.c | 2 +- sv_main.c | 20 ++++---- sv_phys.c | 27 +++++++--- wad.c | 20 +++----- world.c | 3 +- zone.c | 19 ++++---- 16 files changed, 241 insertions(+), 196 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index 3a4cbe5e..79e49a98 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -char *svc_strings[] = +char *svc_strings[128] = { "svc_bad", "svc_nop", @@ -331,9 +331,9 @@ void CL_ParseServerInfo (void) // parse protocol version number i = MSG_ReadLong (); - if (i != PROTOCOL_VERSION && i != 250) + if (i != PROTOCOL_VERSION && i != DPPROTOCOL_VERSION && i != 250) { - Con_Printf ("Server returned version %i, not %i", i, PROTOCOL_VERSION); + Con_Printf ("Server returned version %i, not %i or %i", i, DPPROTOCOL_VERSION, PROTOCOL_VERSION); return; } Nehahrademcompatibility = false; @@ -765,6 +765,9 @@ void CL_ParseServerMessage (void) { int cmd; int i; + byte cmdlog[32]; + char *cmdlogname[32]; + int cmdindex, cmdcount = 0; // // if recording demos, copy the message out @@ -793,21 +796,49 @@ void CL_ParseServerMessage (void) return; // end of message } - // if the high bit of the command byte is set, it is a fast update + cmdindex = cmdcount & 31; + cmdcount++; + cmdlog[cmdindex] = cmd; + + // if the high bit of the command byte is set, it is a fast update if (cmd & 128) { + cmdlogname[cmdindex] = &("svc_entity"); SHOWNET("fast update"); CL_ParseUpdate (cmd&127); continue; } SHOWNET(svc_strings[cmd]); + cmdlogname[cmdindex] = svc_strings[cmd]; + if (!cmdlogname[cmdindex]) + cmdlogname[cmdindex] = &(""); - // other commands + // other commands switch (cmd) { default: - Host_Error ("CL_ParseServerMessage: Illegible server message\n"); + { + char description[32*64], temp[64]; + int count; + strcpy(description, "packet dump: "); + i = cmdcount - 32; + if (i < 0) + i = 0; + count = cmdcount - i; + i &= 31; + while(count > 0) + { + sprintf(temp, "%3i:%s ", cmdlog[i], cmdlogname[i]); + strcat(description, temp); + count--; + i++; + i &= 31; + } + description[strlen(description)-1] = '\n'; // replace the last space with a newline + Con_Printf(description); + Host_Error ("CL_ParseServerMessage: Illegible server message\n"); + } break; case svc_nop: @@ -919,14 +950,11 @@ void CL_ParseServerMessage (void) break; case svc_setpause: - { - cl.paused = MSG_ReadByte (); - - if (cl.paused) - CDAudio_Pause (); - else - CDAudio_Resume (); - } + cl.paused = MSG_ReadByte (); + if (cl.paused) + CDAudio_Pause (); + else + CDAudio_Resume (); break; case svc_signonnum: diff --git a/cl_tent.c b/cl_tent.c index e03e3aef..518b1ef4 100644 --- a/cl_tent.c +++ b/cl_tent.c @@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" +#define MSG_ReadVector(v) {(v)[0] = MSG_ReadCoord();(v)[1] = MSG_ReadCoord();(v)[2] = MSG_ReadCoord();} + cvar_t r_glowinglightning = {"r_glowinglightning", "1", true}; int num_temp_entities; @@ -65,14 +67,8 @@ void CL_ParseBeam (model_t *m) int i; ent = MSG_ReadShort (); - - start[0] = MSG_ReadCoord (); - start[1] = MSG_ReadCoord (); - start[2] = MSG_ReadCoord (); - - end[0] = MSG_ReadCoord (); - end[1] = MSG_ReadCoord (); - end[2] = MSG_ReadCoord (); + MSG_ReadVector(start); + MSG_ReadVector(end); // override any beam with the same entity for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++) @@ -143,25 +139,19 @@ void CL_ParseTEnt (void) switch (type) { case TE_WIZSPIKE: // spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); R_RunParticleEffect (pos, vec3_origin, 20, 30); S_StartSound (-1, 0, cl_sfx_wizhit, pos, 1, 1); break; case TE_KNIGHTSPIKE: // spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); R_RunParticleEffect (pos, vec3_origin, 226, 20); S_StartSound (-1, 0, cl_sfx_knighthit, pos, 1, 1); break; case TE_SPIKE: // spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // LordHavoc: changed to spark shower R_SparkShower(pos, vec3_origin, 15); //R_RunParticleEffect (pos, vec3_origin, 0, 10); @@ -179,9 +169,7 @@ void CL_ParseTEnt (void) } break; case TE_SPIKEQUAD: // quad spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // LordHavoc: changed to spark shower R_SparkShower(pos, vec3_origin, 15); //R_RunParticleEffect (pos, vec3_origin, 0, 10); @@ -206,9 +194,7 @@ void CL_ParseTEnt (void) } break; case TE_SUPERSPIKE: // super spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // LordHavoc: changed to dust shower R_SparkShower(pos, vec3_origin, 30); //R_RunParticleEffect (pos, vec3_origin, 0, 20); @@ -226,9 +212,7 @@ void CL_ParseTEnt (void) } break; case TE_SUPERSPIKEQUAD: // quad super spike hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // LordHavoc: changed to dust shower R_SparkShower(pos, vec3_origin, 30); //R_RunParticleEffect (pos, vec3_origin, 0, 20); @@ -253,9 +237,7 @@ void CL_ParseTEnt (void) break; // LordHavoc: added for improved blood splatters case TE_BLOOD: // blood puff - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); dir[0] = MSG_ReadChar (); dir[1] = MSG_ReadChar (); dir[2] = MSG_ReadChar (); @@ -263,15 +245,11 @@ void CL_ParseTEnt (void) R_BloodPuff(pos); break; case TE_BLOOD2: // blood puff - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); R_BloodPuff(pos); break; case TE_SPARK: // spark shower - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); dir[0] = MSG_ReadChar (); dir[1] = MSG_ReadChar (); dir[2] = MSG_ReadChar (); @@ -280,26 +258,16 @@ void CL_ParseTEnt (void) break; // LordHavoc: added for improved gore case TE_BLOODSHOWER: // vaporized body - pos[0] = MSG_ReadCoord (); // mins - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - dir[0] = MSG_ReadCoord (); // maxs - dir[1] = MSG_ReadCoord (); - dir[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // mins + MSG_ReadVector(pos2); // maxs velspeed = MSG_ReadCoord (); // speed count = MSG_ReadShort (); // number of particles - R_BloodShower(pos, dir, velspeed, count); + R_BloodShower(pos, pos2, velspeed, count); break; case TE_PARTICLECUBE: // general purpose particle effect - pos[0] = MSG_ReadCoord (); // mins - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - pos2[0] = MSG_ReadCoord (); // maxs - pos2[1] = MSG_ReadCoord (); - pos2[2] = MSG_ReadCoord (); - dir[0] = MSG_ReadCoord (); // dir - dir[1] = MSG_ReadCoord (); - dir[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // mins + MSG_ReadVector(pos2); // maxs + MSG_ReadVector(dir); // dir count = MSG_ReadShort (); // number of particles colorStart = MSG_ReadByte (); // color colorLength = MSG_ReadByte (); // gravity (1 or 0) @@ -308,48 +276,32 @@ void CL_ParseTEnt (void) break; case TE_PARTICLERAIN: // general purpose particle effect - pos[0] = MSG_ReadCoord (); // mins - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - pos2[0] = MSG_ReadCoord (); // maxs - pos2[1] = MSG_ReadCoord (); - pos2[2] = MSG_ReadCoord (); - dir[0] = MSG_ReadCoord (); // dir - dir[1] = MSG_ReadCoord (); - dir[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // mins + MSG_ReadVector(pos2); // maxs + MSG_ReadVector(dir); // dir count = MSG_ReadShort (); // number of particles colorStart = MSG_ReadByte (); // color R_ParticleRain(pos, pos2, dir, count, colorStart, 0); break; case TE_PARTICLESNOW: // general purpose particle effect - pos[0] = MSG_ReadCoord (); // mins - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); - pos2[0] = MSG_ReadCoord (); // maxs - pos2[1] = MSG_ReadCoord (); - pos2[2] = MSG_ReadCoord (); - dir[0] = MSG_ReadCoord (); // dir - dir[1] = MSG_ReadCoord (); - dir[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // mins + MSG_ReadVector(pos2); // maxs + MSG_ReadVector(dir); // dir count = MSG_ReadShort (); // number of particles colorStart = MSG_ReadByte (); // color R_ParticleRain(pos, pos2, dir, count, colorStart, 1); break; case TE_GUNSHOT: // bullet hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); // LordHavoc: changed to dust shower R_SparkShower(pos, vec3_origin, 15); //R_RunParticleEffect (pos, vec3_origin, 0, 20); break; case TE_GUNSHOTQUAD: // quad bullet hitting wall - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); R_SparkShower(pos, vec3_origin, 15); dl = CL_AllocDlight (0); VectorCopy (pos, dl->origin); @@ -360,9 +312,7 @@ void CL_ParseTEnt (void) break; case TE_EXPLOSION: // rocket explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_ParticleExplosion (pos, false); // R_BlastParticles (pos, 120, 120); @@ -376,9 +326,7 @@ void CL_ParseTEnt (void) break; case TE_EXPLOSIONQUAD: // quad rocket explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_ParticleExplosion (pos, false); // R_BlastParticles (pos, 120, 480); @@ -393,9 +341,7 @@ void CL_ParseTEnt (void) /* case TE_SMOKEEXPLOSION: // rocket explosion with a cloud of smoke - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_ParticleExplosion (pos, true); dl = CL_AllocDlight (0); @@ -409,9 +355,7 @@ void CL_ParseTEnt (void) */ case TE_EXPLOSION3: // Nehahra movie colored lighting explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_ParticleExplosion (pos, false); // R_BlastParticles (pos, 120, 120); @@ -425,9 +369,7 @@ void CL_ParseTEnt (void) break; case TE_EXPLOSIONRGB: // colored lighting explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_ParticleExplosion (pos, false); // R_BlastParticles (pos, 120, 120); @@ -441,9 +383,7 @@ void CL_ParseTEnt (void) break; case TE_TAREXPLOSION: // tarbaby explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); R_BlobExplosion (pos); // R_BlastParticles (pos, 120, 120); @@ -496,9 +436,7 @@ void CL_ParseTEnt (void) break; case TE_EXPLOSION2: // color mapped explosion - pos[0] = MSG_ReadCoord (); - pos[1] = MSG_ReadCoord (); - pos[2] = MSG_ReadCoord (); + MSG_ReadVector(pos); FindNonSolidLocation(pos); colorStart = MSG_ReadByte (); colorLength = MSG_ReadByte (); diff --git a/common.c b/common.c index a1e0a2e3..1430e057 100644 --- a/common.c +++ b/common.c @@ -583,6 +583,16 @@ void MSG_WriteString (sizebuf_t *sb, char *s) SZ_Write (sb, s, strlen(s)+1); } +// used by server (always dpprotocol) +// moved to common.h as #define +/* +void MSG_WriteFloatCoord (sizebuf_t *sb, float f) +{ + MSG_WriteFloat(sb, f); +} +*/ + +// used by client void MSG_WriteCoord (sizebuf_t *sb, float f) { if (dpprotocol) @@ -731,6 +741,16 @@ char *MSG_ReadString (void) return string; } +// used by server (always dpprotocol) +// moved to common.h as #define +/* +float MSG_ReadFloatCoord (void) +{ + return MSG_ReadFloat(); +} +*/ + +// used by client float MSG_ReadCoord (void) { if (dpprotocol) @@ -886,25 +906,29 @@ COM_FileBase */ void COM_FileBase (char *in, char *out) { - char *s, *s2; - - s = in + strlen(in) - 1; - - while (s != in && *s != '.') - s--; - - // LordHavoc: EWW bug bug bug bug bug... added previously missing s2 != in (yes, could go hunting through mem for /) - for (s2 = s ; s2 != in && *s2 && *s2 != '/' ; s2--) - ; - - if (s-s2 < 2) + char *slash, *dot; + char *s; + + slash = in; + dot = NULL; + s = in; + while(*s) + { + if (*s == '/') + slash = s + 1; + if (*s == '.') + dot = s; + s++; + } + if (dot == NULL) + dot = s; + if (dot - slash < 2) strcpy (out,"?model?"); else { - // LordHavoc: FIXME: examine this - s--; - strncpy (out,s2+1, s-s2); - out[s-s2] = 0; + while (slash < dot) + *out++ = *slash++; + *out++ = 0; } } diff --git a/common.h b/common.h index da25cafa..a9dad19e 100644 --- a/common.h +++ b/common.h @@ -120,6 +120,8 @@ void MSG_WriteCoord (sizebuf_t *sb, float f); void MSG_WriteAngle (sizebuf_t *sb, float f); void MSG_WritePreciseAngle (sizebuf_t *sb, float f); +#define MSG_WriteFloatCoord MSG_WriteFloat + extern int msg_readcount; extern qboolean msg_badread; // set if a read goes beyond end of message @@ -139,6 +141,8 @@ char *MSG_ReadString (void); float MSG_ReadCoord (void); //float MSG_ReadAngle (void); +#define MSG_ReadFloatCoord MSG_ReadFloat + #define MSG_ReadAngle() (MSG_ReadByte() * (360.0f / 256.0f)) #define MSG_ReadPreciseAngle() (MSG_ReadShort() * (360.0f / 65536.0f)) diff --git a/gl_models.c b/gl_models.c index a496b1b3..42b68fcd 100644 --- a/gl_models.c +++ b/gl_models.c @@ -362,11 +362,9 @@ void R_DrawAliasFrame (maliashdr_t *maliashdr, float alpha, vec3_t color, entity glDepthMask(1); } - if (colormap >= 0) + if (skin[0] || skin[1] || skin[2] || skin[3] || skin[4]) { - if (!skin[0] && !skin[1] && !skin[2] && !skin[3]) - GL_DrawModelMesh(0, NULL, maliashdr); - else + if (colormap >= 0 && (skin[0] || skin[1] || skin[2])) { int c; if (skin[0]) @@ -383,19 +381,21 @@ void R_DrawAliasFrame (maliashdr_t *maliashdr, float alpha, vec3_t color, entity R_TintModel(aliasvertcolor, aliasvertcolor2, maliashdr->numverts, (byte *) (&d_8to24table[c])); GL_DrawModelMesh(skin[2], aliasvertcolor2, maliashdr); } - if (skin[3]) GL_DrawModelMesh(skin[3], NULL, maliashdr); } - } - else - { - if (!skin[3] && !skin[4]) - GL_DrawModelMesh(0, NULL, maliashdr); else { if (skin[4]) GL_DrawModelMesh(skin[4], aliasvertcolor, maliashdr); - if (skin[3]) GL_DrawModelMesh(skin[3], NULL, maliashdr); + else + { + if (skin[0]) GL_DrawModelMesh(skin[0], aliasvertcolor, maliashdr); + if (skin[1]) GL_DrawModelMesh(skin[1], aliasvertcolor, maliashdr); + if (skin[2]) GL_DrawModelMesh(skin[2], aliasvertcolor, maliashdr); + } } + if (skin[3]) GL_DrawModelMesh(skin[3], NULL, maliashdr); } + else + GL_DrawModelMesh(0, NULL, maliashdr); if (fogenabled) { diff --git a/gl_rsurf.c b/gl_rsurf.c index 9084da32..ba5e89d8 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -41,13 +41,12 @@ short lightmapupdate[MAX_LIGHTMAPS][2]; int lightmapalign, lightmapalignmask; // LordHavoc: NVIDIA's broken subimage fix, see BuildLightmaps for notes cvar_t gl_lightmapalign = {"gl_lightmapalign", "4"}; -cvar_t gl_lightmaprgba = {"gl_lightmaprgba", "0"}; +cvar_t gl_lightmaprgba = {"gl_lightmaprgba", "1"}; cvar_t gl_nosubimagefragments = {"gl_nosubimagefragments", "0"}; cvar_t gl_nosubimage = {"gl_nosubimage", "0"}; cvar_t r_ambient = {"r_ambient", "0"}; cvar_t gl_vertex = {"gl_vertex", "0"}; cvar_t gl_texsort = {"gl_texsort", "1"}; -//cvar_t gl_funnywalls = {"gl_funnywalls", "0"}; // LordHavoc: see BuildSurfaceDisplayList cvar_t r_newworldnode = {"r_newworldnode", "0"}; cvar_t r_oldclip = {"r_oldclip", "1"}; cvar_t r_dlightmap = {"r_dlightmap", "1"}; @@ -77,7 +76,6 @@ void GL_Surf_Init() Cvar_RegisterVariable(&gl_nosubimagefragments); Cvar_RegisterVariable(&gl_nosubimage); Cvar_RegisterVariable(&r_ambient); -// Cvar_RegisterVariable(&gl_funnywalls); Cvar_RegisterVariable(&gl_vertex); Cvar_RegisterVariable(&gl_texsort); Cvar_RegisterVariable(&r_newworldnode); diff --git a/model_alias.c b/model_alias.c index de5b65e7..ba66d724 100644 --- a/model_alias.c +++ b/model_alias.c @@ -341,11 +341,28 @@ void Mod_LoadSkin (maliashdr_t *mheader, char *basename, byte *skindata, byte *s } } #else - skintexnum[0] = GL_SkinSplit(skindata, skintemp, width, height, 0x3FBD, va("&%s_normal", basename)); // normal (no special colors) - skintexnum[1] = GL_SkinSplitShirt(skindata, skintemp, width, height, 0x0040, va("&%s_pants", basename)); // pants - skintexnum[2] = GL_SkinSplitShirt(skindata, skintemp, width, height, 0x0002, va("&%s_shirt", basename)); // shirt - skintexnum[3] = GL_SkinSplit(skindata, skintemp, width, height, 0xC000, va("%s_glow", basename)); // glow - skintexnum[4] = GL_SkinSplit(skindata, skintemp, width, height, 0x3FFF, va("%s_body", basename)); // body (normal + pants + shirt, but not glow) + skintexnum[0] = loadtextureimage(va("%s_normal", basename), 0, 0, false, true); + skintexnum[1] = 0; + skintexnum[2] = 0; + skintexnum[3] = loadtextureimage(va("%s_glow" , basename), 0, 0, false, true); + skintexnum[4] = 0; + if (skintexnum[0]) + { + skintexnum[1] = loadtextureimage(va("%s_pants" , basename), 0, 0, false, true); + skintexnum[2] = loadtextureimage(va("%s_shirt" , basename), 0, 0, false, true); + } + else + { + skintexnum[0] = loadtextureimage(basename, 0, 0, false, true); + if (!skintexnum[0]) + { + skintexnum[0] = GL_SkinSplit(skindata, skintemp, width, height, 0x3FBD, va("&%s_normal", basename)); // normal (no special colors) + skintexnum[1] = GL_SkinSplitShirt(skindata, skintemp, width, height, 0x0040, va("&%s_pants", basename)); // pants + skintexnum[2] = GL_SkinSplitShirt(skindata, skintemp, width, height, 0x0002, va("&%s_shirt", basename)); // shirt + skintexnum[3] = GL_SkinSplit(skindata, skintemp, width, height, 0xC000, va("%s_glow", basename)); // glow + skintexnum[4] = GL_SkinSplit(skindata, skintemp, width, height, 0x3FFF, va("%s_body", basename)); // body (normal + pants + shirt, but not glow) + } + } #endif } diff --git a/model_brush.c b/model_brush.c index 0efc4e70..e0bd20f4 100644 --- a/model_brush.c +++ b/model_brush.c @@ -170,17 +170,44 @@ void Mod_LoadTextures (lump_t *l) freeimage = FALSE; transparent = FALSE; bytesperpixel = 1; - if (!hlbsp && mt->offsets[0]) // texture included + if (mt->offsets[0]) // texture included { data = (byte *)((int) mt + mt->offsets[0]); - if (r_fullbrights.value && tx->name[0] != '*') + if (hlbsp) + { + byte *in, *out, *pal; + int palsize, d, p; + bytesperpixel = 4; + freeimage = TRUE; + in = data; + data = out = qmalloc(mt->width * mt->height * 4); + pal = in + (((mt->width * mt->height) * 85) >> 6); + palsize = pal[1] * 0x100 + pal[0]; + if (palsize >= 256) + palsize = 255; + pal += 2; + for (d = 0;d < mt->width * mt->height;d++) + { + p = (*in++) * 3; + out[0] = pal[p]; + out[1] = pal[p+1]; + out[2] = pal[p+2]; + out[3] = 255; + if (out[0] == 255 && out[1] == 0 && out[2] == 0) // HL transparent color (pure blue) + out[0] = out[1] = out[2] = out[3] = 0; + out += 4; + } + } + else if (r_fullbrights.value && tx->name[0] != '*') { for (j = 0;j < tx->width*tx->height;j++) + { if (data[j] >= 224) // fullbright { fullbrights = TRUE; break; } + } } } else // no texture, and no external replacement texture was found @@ -201,24 +228,25 @@ void Mod_LoadTextures (lump_t *l) } else { - tx->transparent = transparent; if (fullbrights) { char name[64]; byte *data2; + tx->transparent = false; data2 = qmalloc(tx->width*tx->height); for (j = 0;j < tx->width*tx->height;j++) data2[j] = data[j] >= 224 ? 0 : data[j]; // no fullbrights - tx->gl_texturenum = GL_LoadTexture (tx->name, tx->width, tx->height, data2, true, transparent, 1); + tx->gl_texturenum = GL_LoadTexture (tx->name, tx->width, tx->height, data2, true, false, 1); strcpy(name, tx->name); strcat(name, "_glow"); for (j = 0;j < tx->width*tx->height;j++) data2[j] = data[j] >= 224 ? data[j] : 0; // only fullbrights - tx->gl_glowtexturenum = GL_LoadTexture (name, tx->width, tx->height, data2, true, transparent, 1); + tx->gl_glowtexturenum = GL_LoadTexture (name, tx->width, tx->height, data2, true, false, 1); qfree(data2); } else { + tx->transparent = transparent; tx->gl_texturenum = GL_LoadTexture (tx->name, tx->width, tx->height, data, true, transparent, bytesperpixel); tx->gl_glowtexturenum = 0; } diff --git a/model_shared.c b/model_shared.c index 65acc092..d9d0efbc 100644 --- a/model_shared.c +++ b/model_shared.c @@ -179,7 +179,8 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash) } // allocate a new model - COM_FileBase (mod->name, loadname); +// COM_FileBase (mod->name, loadname); + strcpy(loadname, mod->name); loadmodel = mod; diff --git a/pr_cmds.c b/pr_cmds.c index 91e435b5..ac18f05b 100644 --- a/pr_cmds.c +++ b/pr_cmds.c @@ -616,7 +616,7 @@ void PF_ambientsound (void) MSG_WriteByte (&sv.signon,svc_spawnstaticsound); for (i=0 ; i<3 ; i++) - MSG_WriteCoord(&sv.signon, pos[i]); + MSG_WriteFloatCoord(&sv.signon, pos[i]); MSG_WriteByte (&sv.signon, soundnum); @@ -1674,7 +1674,7 @@ void PF_WriteAngle (void) void PF_WriteCoord (void) { - MSG_WriteCoord (WriteDest(), G_FLOAT(OFS_PARM1)); + MSG_WriteFloatCoord (WriteDest(), G_FLOAT(OFS_PARM1)); } void PF_WriteString (void) @@ -1708,7 +1708,7 @@ void PF_makestatic (void) MSG_WriteByte (&sv.signon, ent->v.skin); for (i=0 ; i<3 ; i++) { - MSG_WriteCoord(&sv.signon, ent->v.origin[i]); + MSG_WriteFloatCoord(&sv.signon, ent->v.origin[i]); MSG_WriteAngle(&sv.signon, ent->v.angles[i]); } diff --git a/r_part.c b/r_part.c index 1acfbc20..7c4abfa9 100644 --- a/r_part.c +++ b/r_part.c @@ -76,7 +76,7 @@ particle_t **freeparticles; // list used only in compacting particles array cvar_t r_particles = {"r_particles", "1"}; cvar_t r_drawparticles = {"r_drawparticles", "1"}; -cvar_t r_dynamicparticles = {"r_dynamicparticles", "0", TRUE}; +cvar_t r_dynamicparticles = {"r_dynamicparticles", "1", TRUE}; byte shadebubble(float dx, float dy, vec3_t light) { diff --git a/sv_main.c b/sv_main.c index fc1cf115..0d51ed41 100644 --- a/sv_main.c +++ b/sv_main.c @@ -86,9 +86,9 @@ void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count) if (sv.datagram.cursize > MAX_DATAGRAM-16) return; MSG_WriteByte (&sv.datagram, svc_particle); - MSG_WriteCoord (&sv.datagram, org[0]); - MSG_WriteCoord (&sv.datagram, org[1]); - MSG_WriteCoord (&sv.datagram, org[2]); + MSG_WriteFloatCoord (&sv.datagram, org[0]); + MSG_WriteFloatCoord (&sv.datagram, org[1]); + MSG_WriteFloatCoord (&sv.datagram, org[2]); for (i=0 ; i<3 ; i++) { v = dir[i]*16; @@ -169,7 +169,7 @@ void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, MSG_WriteShort (&sv.datagram, channel); MSG_WriteByte (&sv.datagram, sound_num); for (i=0 ; i<3 ; i++) - MSG_WriteCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i])); + MSG_WriteFloatCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i])); } /* @@ -198,7 +198,7 @@ void SV_SendServerinfo (client_t *client) MSG_WriteString (&client->message,message); MSG_WriteByte (&client->message, svc_serverinfo); - MSG_WriteLong (&client->message, PROTOCOL_VERSION); + MSG_WriteLong (&client->message, DPPROTOCOL_VERSION); MSG_WriteByte (&client->message, svs.maxclients); if (!coop.value && deathmatch.value) @@ -682,11 +682,11 @@ void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) if (bits & U_COLORMAP) MSG_WriteByte (msg, ent->v.colormap); if (bits & U_SKIN) MSG_WriteByte (msg, ent->v.skin); if (bits & U_EFFECTS) MSG_WriteByte (msg, ent->v.effects); - if (bits & U_ORIGIN1) MSG_WriteCoord (msg, origin[0]); + if (bits & U_ORIGIN1) MSG_WriteFloatCoord (msg, origin[0]); if (bits & U_ANGLE1) MSG_WriteAngle(msg, angles[0]); - if (bits & U_ORIGIN2) MSG_WriteCoord (msg, origin[1]); + if (bits & U_ORIGIN2) MSG_WriteFloatCoord (msg, origin[1]); if (bits & U_ANGLE2) MSG_WriteAngle(msg, angles[1]); - if (bits & U_ORIGIN3) MSG_WriteCoord (msg, origin[2]); + if (bits & U_ORIGIN3) MSG_WriteFloatCoord (msg, origin[2]); if (bits & U_ANGLE3) MSG_WriteAngle(msg, angles[2]); // LordHavoc: new stuff @@ -743,7 +743,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) MSG_WriteByte (msg, ent->v.dmg_save); MSG_WriteByte (msg, ent->v.dmg_take); for (i=0 ; i<3 ; i++) - MSG_WriteCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i])); + MSG_WriteFloatCoord (msg, other->v.origin[i] + 0.5*(other->v.mins[i] + other->v.maxs[i])); ent->v.dmg_take = 0; ent->v.dmg_save = 0; @@ -1118,7 +1118,7 @@ void SV_CreateBaseline (void) MSG_WriteByte (&sv.signon, svent->baseline.skin); for (i=0 ; i<3 ; i++) { - MSG_WriteCoord(&sv.signon, svent->baseline.origin[i]); + MSG_WriteFloatCoord(&sv.signon, svent->baseline.origin[i]); MSG_WriteAngle(&sv.signon, svent->baseline.angles[i]); } } diff --git a/sv_phys.c b/sv_phys.c index 73b013df..afe020c9 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -234,7 +234,11 @@ Returns the clipflags if the velocity was modified (hit something solid) If steptrace is not NULL, the trace of any vertical wall hit will be stored ============ */ -#define MAX_CLIP_PLANES 5 +// LordHavoc: increased from 5 to 20, to partially fix angled corner sticking +// (example - start.bsp hall to e1m4, leading to the pool there are two +// angled corners, which you could get stuck on, now they are just a one +// frame hiccup) +#define MAX_CLIP_PLANES 20 int SV_FlyMove (edict_t *ent, float time, trace_t *steptrace) { int bumpcount, numbumps; @@ -1165,7 +1169,7 @@ Entities that are "stuck" to another entity */ void SV_Physics_Follow (edict_t *ent) { - vec3_t vf, vr, vu, angles; + vec3_t vf, vr, vu, angles, v; edict_t *e; // regular thinking if (!SV_RunThink (ent)) @@ -1179,13 +1183,20 @@ void SV_Physics_Follow (edict_t *ent) } else { - angles[0] = -(e->v.angles[0] - ent->v.punchangle[0]); - angles[1] = e->v.angles[1] - ent->v.punchangle[1]; - angles[2] = e->v.angles[2] - ent->v.punchangle[2]; + angles[0] = -ent->v.punchangle[0]; + angles[1] = ent->v.punchangle[1]; + angles[2] = ent->v.punchangle[2]; AngleVectors (angles, vf, vr, vu); - ent->v.origin[0] = ent->v.view_ofs[0] * vf[0] + ent->v.view_ofs[1] * vr[0] + ent->v.view_ofs[2] * vu[0] + e->v.origin[0]; - ent->v.origin[1] = ent->v.view_ofs[0] * vf[1] + ent->v.view_ofs[1] * vr[1] + ent->v.view_ofs[2] * vu[1] + e->v.origin[1]; - ent->v.origin[2] = ent->v.view_ofs[0] * vf[2] + ent->v.view_ofs[1] * vr[2] + ent->v.view_ofs[2] * vu[2] + e->v.origin[2]; + v[0] = ent->v.view_ofs[0] * vf[0] + ent->v.view_ofs[1] * vr[0] + ent->v.view_ofs[2] * vu[0]; + v[1] = ent->v.view_ofs[0] * vf[1] + ent->v.view_ofs[1] * vr[1] + ent->v.view_ofs[2] * vu[1]; + v[2] = ent->v.view_ofs[0] * vf[2] + ent->v.view_ofs[1] * vr[2] + ent->v.view_ofs[2] * vu[2]; + angles[0] = -e->v.angles[0]; + angles[1] = e->v.angles[1]; + angles[2] = e->v.angles[2]; + AngleVectors (angles, vf, vr, vu); + ent->v.origin[0] = v[0] * vf[0] + v[1] * vf[1] + v[2] * vf[2] + e->v.origin[0]; + ent->v.origin[1] = v[0] * vr[0] + v[1] * vr[1] + v[2] * vr[2] + e->v.origin[1]; + ent->v.origin[2] = v[0] * vu[0] + v[1] * vu[1] + v[2] * vu[2] + e->v.origin[2]; /* ent->v.origin[0] = ent->v.view_ofs[0] * vf[0] + ent->v.view_ofs[0] * vf[1] + ent->v.view_ofs[0] * vf[2] + e->v.origin[0]; ent->v.origin[1] = ent->v.view_ofs[1] * vr[0] + ent->v.view_ofs[1] * vr[1] + ent->v.view_ofs[1] * vr[2] + e->v.origin[1]; diff --git a/wad.c b/wad.c index 64d35d82..058e07b0 100644 --- a/wad.c +++ b/wad.c @@ -158,7 +158,7 @@ void SwapPic (qpic_t *pic) } // LordHavoc: added alternate WAD2/WAD3 system for HalfLife texture wads -#define TEXWAD_MAXIMAGES 8192 +#define TEXWAD_MAXIMAGES 16384 typedef struct { char name[16]; @@ -354,20 +354,16 @@ byte *W_GetTexture(char *name, int matchwidth, int matchheight) for (i = 0;i < image_width*image_height;i++) { c = *indata++; - if (c == 255) // transparent color - { - *outdata++ = 0; - *outdata++ = 0; - *outdata++ = 0; - *outdata++ = 0; - } + if (pal[c][0] == 255 && pal[c][1] == 0 && pal[c][2] == 0) // HL transparent color (pure blue) + outdata[0] = outdata[1] = outdata[2] = outdata[3] = 0; else { - *outdata++ = pal[c][0]; - *outdata++ = pal[c][1]; - *outdata++ = pal[c][2]; - *outdata++ = 255; + outdata[0] = pal[c][0]; + outdata[1] = pal[c][1]; + outdata[2] = pal[c][2]; + outdata[3] = 255; } + outdata += 4; } return data; } diff --git a/world.c b/world.c index a2cc7e48..eea796c7 100644 --- a/world.c +++ b/world.c @@ -1050,8 +1050,7 @@ loc0: trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end); else trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end); - if (trace.allsolid || trace.startsolid || - trace.fraction < clip->trace.fraction) + if (trace.allsolid || trace.startsolid || trace.fraction < clip->trace.fraction) { trace.ent = touch; if (clip->trace.startsolid) diff --git a/zone.c b/zone.c index a5bb4f0f..e4884467 100644 --- a/zone.c +++ b/zone.c @@ -271,7 +271,7 @@ typedef struct { int sentinal; int size; // including sizeof(hunk_t), -1 = not allocated - char name[24]; + char name[56]; } hunk_t; byte *hunk_base; @@ -316,9 +316,9 @@ void Hunk_Print (qboolean all) hunk_t *h, *next, *endlow, *starthigh, *endhigh; int count, sum, i; int totalblocks; - char name[25]; + char name[51]; - name[24] = 0; + name[50] = 0; count = 0; sum = 0; totalblocks = 0; @@ -367,25 +367,25 @@ void Hunk_Print (qboolean all) // print the single block // // LordHavoc: pad name to full length - for (i = 0;i < 24;i++) + for (i = 0;i < 50;i++) { if (!h->name[i]) break; name[i] = h->name[i]; } - for (;i < 24;i++) + for (;i < 50;i++) name[i] = ' '; - //memcpy (name, h->name, 24); + //memcpy (name, h->name, 51); if (all) Con_Printf ("%8p :%8i %s\n",h, h->size, name); // // print the total // - if (next == endlow || next == endhigh || strncmp(h->name, next->name, 24)) + if (next == endlow || next == endhigh || strncmp(h->name, next->name, 50)) { if (!all) - Con_Printf (" :%8i %s (TOTAL)\n",sum, name); + Con_Printf (" :%8i %s (TOTAL)\n",sum, name); count = 0; sum = 0; } @@ -428,7 +428,8 @@ void *Hunk_AllocName (int size, char *name) h->size = size; h->sentinal = HUNK_SENTINAL; - strncpy (h->name, name, 24); + strncpy (h->name, name, 50); + h->name[50] = 0; return (void *)(h+1); } -- 2.39.2