]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
clarifications about the format of svc_fog
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jan 2001 23:58:32 +0000 (23:58 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jan 2001 23:58:32 +0000 (23:58 +0000)
precache name overflow checks
gl_screen.c - whitespace changes?
sky name overflow checks
"tell" buffer overflow improvement (not really a fix)
edict parsing buffer increase (not really a fix)
increased number of leafs per entity from 64 to 256 (mem hog...  but fixes fall2.bsp  note: quake used 16 and did not have a problem with fall2?) and added warning when it runs out
removed rotating pusher hack and added solid checking
non-working MOVETYPE_FOLLOW rotation support (in-progress)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@130 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
gl_screen.c
gl_warp.c
host_cmd.c
image.h
pr_edict.c
progs.h
protocol.h
sv_phys.c
world.c

index 7810cb5e42794207d5e46b866fd144d46d72347d..3a4cbe5ea5ea445f24ce6c4bb8af73f1f350d294 100644 (file)
@@ -81,7 +81,7 @@ char *svc_strings[] =
        "?", // 48
        "?", // 49
        "svc_farclip", // [coord] size
-       "svc_fog", // [byte] enable <optional past this point, only included if enable is true> [short * 4096] density [byte] red [byte] green [byte] blue
+       "svc_fog", // [byte] enable <optional past this point, only included if enable is true> [short] density*4096 [byte] red [byte] green [byte] blue
        "svc_playerposition" // [float] x [float] y [float] z
 };
 
@@ -384,6 +384,8 @@ void CL_ParseServerInfo (void)
                        Con_Printf ("Server sent too many model precaches\n");
                        return;
                }
+               if (strlen(str) >= MAX_QPATH)
+                       Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
                strcpy (model_precache[nummodels], str);
                Mod_TouchModel (str);
        }
@@ -400,6 +402,8 @@ void CL_ParseServerInfo (void)
                        Con_Printf ("Server sent too many sound precaches\n");
                        return;
                }
+               if (strlen(str) >= MAX_QPATH)
+                       Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
                strcpy (sound_precache[numsounds], str);
                S_TouchSound (str);
        }
index 624a9db635f77317e2b60489417202e3c7b990bc..722dfa60b403d09ed3e941db95be22d0478380c5 100644 (file)
@@ -583,11 +583,11 @@ void SCR_DrawConsole (void)
 ============================================================================== 
 */ 
 
-/* 
+/*
 ================== 
 SCR_ScreenShot_f
 ================== 
-*/  
+*/
 void SCR_ScreenShot_f (void) 
 {
        byte            *buffer;
@@ -621,7 +621,7 @@ void SCR_ScreenShot_f (void)
 
        free (buffer);
        Con_Printf ("Wrote %s\n", filename);
-} 
+}
 
 
 //=============================================================================
index 9a1f70e7f335ee7de235e70cb82ac67fa1a5b916..d15a34bec6067b793762c8db07466a714ce42033 100644 (file)
--- a/gl_warp.c
+++ b/gl_warp.c
@@ -191,9 +191,14 @@ char       *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
 void R_LoadSkyBox (void)
 {
        int             i;
-       char    name[64];
+       char    name[1024];
        byte*   image_rgba;
 
+       if (strlen(skyname) >= 1000)
+       {
+               Con_Printf ("sky name too long (%i, max is 1000)\n", strlen(skyname));
+               return;
+       }
        for (i=0 ; i<6 ; i++)
        {
                sprintf (name, "env/%s%s", skyname, suf[i]);
index 1e18df996305f07311dc68d1b8c91ac67cb35bd1..44701986a659c7a5fd94e23d82dcf8e345c5ea07 100644 (file)
@@ -795,7 +795,7 @@ void Host_Tell_f(void)
        client_t *save;
        int             j;
        char    *p;
-       char    text[64];
+       char    text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
 
        if (cmd_source == src_command)
        {
diff --git a/image.h b/image.h
index c0d07ee7452acda4b6eb3a23677b2c1ea2cfcf9c..20096ff84427661824a82e1d7b7ae9a7596ab3b7 100644 (file)
--- a/image.h
+++ b/image.h
@@ -9,3 +9,4 @@ extern int loadtextureimagemask (char* filename, int matchwidth, int matchheight
 extern int image_masktexnum;
 extern int loadtextureimagewithmask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap);
 extern void Image_WriteTGARGB (char *filename, int width, int height, byte *data);
+extern void Image_WriteTGARGBA (char *filename, int width, int height, byte *data);
index 93d306b6190db306f1c2080428a2fc8b1df0910f..7f2bcf08d4bcfa420f55c893392d7e94ef503de6 100644 (file)
@@ -759,7 +759,7 @@ ED_ParseGlobals
 */
 void ED_ParseGlobals (char *data)
 {
-       char    keyname[64];
+       char    keyname[1024]; // LordHavoc: good idea? bad idea?  was 64
        ddef_t  *key;
 
        while (1)
diff --git a/progs.h b/progs.h
index d38eb92578b4f127cd0b98545c1dff8d55f7eb6e..2d39385a6e76a55a8f9231478440ed0e0044b366 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -31,8 +31,8 @@ typedef union eval_s
        int                             edict;
 } eval_t;      
 
-// LordHavoc: increased number of leafs per entity limit from 16 to 64
-#define        MAX_ENT_LEAFS   64
+// LordHavoc: increased number of leafs per entity limit from 16 to 256
+#define        MAX_ENT_LEAFS   256
 typedef struct edict_s
 {
        qboolean        free;
index 616f24874d69c6dcbfc46a20e3c551f3767903ba..6de7bcb7f99e330b01dc7524de0c6ab2d0f57284 100644 (file)
@@ -181,7 +181,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define        svc_skybox                      37              // [string] skyname
 
 #define svc_farclip                    50              // [coord] size (default is 6144)
-#define svc_fog                                51              // [byte] enable <optional past this point, only included if enable is true> [float] density [byte] red [byte] green [byte] blue
+#define svc_fog                                51              // [byte] enable <optional past this point, only included if enable is true> [short] density*4096 [byte] red [byte] green [byte] blue
 //#define svc_playerposition   52              // only used in dpprotocol mode
 
 //
index ffe1ce9c2b667086abbede91b1852bc94c4c4ac9..06e1f40ee68b52382bcce35cb07bc97847acee2c 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -598,6 +598,24 @@ void SV_PushRotate (edict_t *pusher, float movetime)
        vec3_t          forward, right, up;
        float           savesolid;
 
+       switch ((int) pusher->v.solid)
+       {
+       // LordHavoc: valid pusher types
+       case SOLID_BSP:
+       case SOLID_BBOX:
+       case SOLID_SLIDEBOX:
+       case SOLID_CORPSE: // LordHavoc: this would be weird...
+               break;
+       // LordHavoc: no collisions
+       case SOLID_NOT:
+       case SOLID_TRIGGER:
+               VectorMA (pusher->v.angles, movetime, pusher->v.avelocity, pusher->v.angles);
+               pusher->v.ltime += movetime;
+               SV_LinkEdict (pusher, false);
+               return;
+       default:
+               Host_Error("SV_PushRotate: unrecognized solid type %f\n", pusher->v.solid);
+       }
        if (!pusher->v.avelocity[0] && !pusher->v.avelocity[1] && !pusher->v.avelocity[2])
        {
                pusher->v.ltime += movetime;
@@ -731,7 +749,6 @@ void SV_Physics_Pusher (edict_t *ent)
 
        oldltime = ent->v.ltime;
        
-       /*
        thinktime = ent->v.nextthink;
        if (thinktime < ent->v.ltime + host_frametime)
        {
@@ -749,23 +766,6 @@ void SV_Physics_Pusher (edict_t *ent)
                else
                        SV_PushMove (ent, movetime);    // advances ent->v.ltime if not blocked
        }
-       */
-       if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2])
-               SV_PushRotate (ent, host_frametime);
-       else
-       {
-               thinktime = ent->v.nextthink;
-               if (thinktime < ent->v.ltime + host_frametime)
-               {
-                       movetime = thinktime - ent->v.ltime;
-                       if (movetime < 0)
-                               movetime = 0;
-               }
-               else
-                       movetime = host_frametime;
-               if (movetime)
-                       SV_PushMove (ent, movetime);    // advances ent->v.ltime if not blocked
-       }
                
        if (thinktime > oldltime && thinktime <= ent->v.ltime)
        {
@@ -1163,19 +1163,33 @@ Entities that are "stuck" to another entity
 */
 void SV_Physics_Follow (edict_t *ent)
 {
-       vec3_t vf, vu, vr, angles;
+       vec3_t vf, vr, vu, angles;
        edict_t *e;
 // regular thinking
-       SV_RunThink (ent);
+       if (!SV_RunThink (ent))
+               return;
        // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects
        e = PROG_TO_EDICT(ent->v.aiment);
-       angles[0] = -e->v.angles[0];
-       angles[1] = e->v.angles[1];
-       angles[2] = e->v.angles[2];
-       AngleVectors (angles, vf, vr, vu);
-       VectorMA (e->v.origin, ent->v.view_ofs[0], vf, ent->v.origin);
-       VectorMA (ent->v.origin, ent->v.view_ofs[1], vr, ent->v.origin);
-       VectorMA (ent->v.origin, ent->v.view_ofs[2], vu, ent->v.origin);
+       if (e->v.angles[0] == ent->v.punchangle[0] && e->v.angles[1] == ent->v.punchangle[1] && e->v.angles[2] == ent->v.punchangle[2])
+       {
+               // quick case for no rotation
+               VectorAdd(e->v.origin, ent->v.view_ofs, ent->v.origin);
+       }
+       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];
+               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];
+               /*
+               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];
+               ent->v.origin[2] = ent->v.view_ofs[2] * vu[0] + ent->v.view_ofs[2] * vu[1] + ent->v.view_ofs[2] * vu[2] + e->v.origin[2];
+               */
+       }
        VectorAdd (e->v.angles, ent->v.v_angle, ent->v.angles);
 //     VectorAdd (PROG_TO_EDICT(ent->v.aiment)->v.origin, ent->v.v_angle, ent->v.origin);
        SV_LinkEdict (ent, true);
diff --git a/world.c b/world.c
index 6be76178b65d810988b4ea2d73050343edc57874..a37612bf146b35f387955b2e87db89833e1c8fc4 100644 (file)
--- a/world.c
+++ b/world.c
@@ -378,7 +378,10 @@ loc0:
        if ( node->contents < 0)
        {
                if (ent->num_leafs == MAX_ENT_LEAFS)
+               {
+                       Con_DPrintf("FindTouchedLeafs overflow\n");
                        return;
+               }
 
                leaf = (mleaf_t *)node;
                leafnum = leaf - sv.worldmodel->leafs - 1;