]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented support for more than 32768 clipnodes (again a case of
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Oct 2007 03:39:40 +0000 (03:39 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 1 Oct 2007 03:39:40 +0000 (03:39 +0000)
arguire qbsp producing files that violate the q1bsp format), this fixes
large monsters falling out of levels in warpspasm

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

model_brush.c
model_brush.h
model_shared.h
todo

index 00df8ca01600c66aa9a8e7205238eb83e6da867b..bbef49b523c6b482f1118a43990c5159e052c3e1 100644 (file)
@@ -629,7 +629,7 @@ static int Mod_Q1BSP_RecursiveHullCheck(RecursiveHullCheckTraceInfo_t *t, int nu
        double t1, t2;
 
        // variables that need to be stored on the stack when recursing
-       dclipnode_t *node;
+       mclipnode_t *node;
        int side;
        double midf, mid[3];
 
@@ -925,7 +925,7 @@ void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cm
 #else
        RecursiveHullCheckTraceInfo_t rhc;
        static hull_t box_hull;
-       static dclipnode_t box_clipnodes[6];
+       static mclipnode_t box_clipnodes[6];
        static mplane_t box_planes[6];
        // fill in a default trace
        memset(&rhc, 0, sizeof(rhc));
@@ -2480,18 +2480,12 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l)
 
                for (j=0 ; j<2 ; j++)
                {
-                       // LordHavoc: this code supports more than 32768 nodes or leafs,
-                       // by simply assuming that there are no more than 65536 combined,
-                       // this makes it compatible with the broken arguire qbsp utility
-                       // which can produce more than 32768 nodes (breaking the format)
-                       // note that arguire light and vis utilities still crash on this
-                       //
-                       // I do not encourage support for this weirdness, this code was
-                       // reworked simply to allow flying around leaky maps that exceed
-                       // the limits, with the assumption that a final compile will be
-                       // valid after the leak is fixed.
+                       // LordHavoc: this code supports broken bsp files produced by
+                       // arguire qbsp which can produce more than 32768 nodes, any value
+                       // below count is assumed to be a node number, any other value is
+                       // assumed to be a leaf number
                        p = (unsigned short)LittleShort(in->children[j]);
-                       if (p < 65536 - loadmodel->brush.num_leafs)
+                       if (p < count)
                        {
                                if (p < loadmodel->brush.num_nodes)
                                        out->children[j] = loadmodel->brush.data_nodes + p;
@@ -2504,6 +2498,7 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l)
                        }
                        else
                        {
+                               // note this uses 65535 intentionally, -1 is leaf 0
                                p = 65535 - p;
                                if (p < loadmodel->brush.num_leafs)
                                        out->children[j] = (mnode_t *)(loadmodel->brush.data_leafs + p);
@@ -2604,7 +2599,8 @@ qboolean Mod_Q1BSP_CheckWaterAlphaSupport(void)
 
 static void Mod_Q1BSP_LoadClipnodes(lump_t *l, hullinfo_t *hullinfo)
 {
-       dclipnode_t *in, *out;
+       dclipnode_t *in;
+       mclipnode_t *out;
        int                     i, count;
        hull_t          *hull;
 
@@ -2612,7 +2608,7 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l, hullinfo_t *hullinfo)
        if (l->filelen % sizeof(*in))
                Host_Error("Mod_Q1BSP_LoadClipnodes: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = (dclipnode_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out));
+       out = (mclipnode_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out));
 
        loadmodel->brushq1.clipnodes = out;
        loadmodel->brushq1.numclipnodes = count;
@@ -2636,12 +2632,15 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l, hullinfo_t *hullinfo)
        for (i=0 ; i<count ; i++, out++, in++)
        {
                out->planenum = LittleLong(in->planenum);
-               out->children[0] = LittleShort(in->children[0]);
-               out->children[1] = LittleShort(in->children[1]);
+               // LordHavoc: this code supports arguire qbsp's broken clipnodes indices (more than 32768 clipnodes), values above count are assumed to be contents values
+               out->children[0] = (unsigned short)LittleShort(in->children[0]);
+               out->children[1] = (unsigned short)LittleShort(in->children[1]);
+               if (out->children[0] >= count)
+                       out->children[0] -= 65536;
+               if (out->children[1] >= count)
+                       out->children[1] -= 65536;
                if (out->planenum < 0 || out->planenum >= loadmodel->brush.num_planes)
                        Host_Error("Corrupt clipping hull(out of range planenum)");
-               if (out->children[0] >= count || out->children[1] >= count)
-                       Host_Error("Corrupt clipping hull(out of range child)");
        }
 }
 
@@ -2649,14 +2648,14 @@ static void Mod_Q1BSP_LoadClipnodes(lump_t *l, hullinfo_t *hullinfo)
 static void Mod_Q1BSP_MakeHull0(void)
 {
        mnode_t         *in;
-       dclipnode_t *out;
+       mclipnode_t *out;
        int                     i;
        hull_t          *hull;
 
        hull = &loadmodel->brushq1.hulls[0];
 
        in = loadmodel->brush.data_nodes;
-       out = (dclipnode_t *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_nodes * sizeof(dclipnode_t));
+       out = (mclipnode_t *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_nodes * sizeof(*out));
 
        hull->clipnodes = out;
        hull->firstclipnode = 0;
index 5646631977195e0c95c403f568bfb39c4c5c7b25..b4cce7b7030fe37e7908205aba2ad4bad8e770da 100644 (file)
@@ -163,9 +163,15 @@ typedef struct mleaf_s
 }
 mleaf_t;
 
+typedef struct mclipnode_s
+{
+       int                     planenum;
+       int                     children[2];    // negative numbers are contents
+} mclipnode_t;
+
 typedef struct hull_s
 {
-       dclipnode_t *clipnodes;
+       mclipnode_t *clipnodes;
        mplane_t *planes;
        int firstclipnode;
        int lastclipnode;
index ea5e58770a921f689e0770013ab498f23580c3d5..2c4be3756414f5400fa4008142079ea4855f5b81 100644 (file)
@@ -666,7 +666,7 @@ typedef struct model_brushq1_s
        int                             *surfedges;
 
        int                             numclipnodes;
-       dclipnode_t             *clipnodes;
+       mclipnode_t             *clipnodes;
 
        hull_t                  hulls[MAX_MAP_HULLS];
 
diff --git a/todo b/todo
index 7a016f33cc57f2968ba9282b08b9715e835711fb..9b417894338dd81af572db2c6c6ef21a1f017f58 100644 (file)
--- a/todo
+++ b/todo
@@ -1,6 +1,4 @@
 - todo: difficulty ratings are: 0 = trivial, 1 = easy, 2 = easy-moderate, 3 = moderate, 4 = moderate-hard, 5 = hard, 6 = hard++, 7 = nightmare, d = done, -d = done but have not notified the people who asked for it, f = failed, -f = failed but have not notified the people who asked for it
--d (Amish, Fuh) feature darkplaces client: add qw protocol support (making darkplaces work as a qwcl client) (Amish, Fuh)
--d (Stribbs, Jimmy Freestone) feature darkplaces renderer: add HalfLife2 style water rendering (Mitchell, Stribbs, Jimmy Freestone)
 0 bug darkplaces client qw: add .mvd demo support
 0 bug darkplaces client qw: add .qwd demo support
 0 bug darkplaces client qw: add spectator cvar (Plague Monkey Rat)
@@ -1215,6 +1213,7 @@ d feature darkplaces client: add .loc file support and say macros
 d feature darkplaces client: add BX_WAL_SUPPORT to extensions and document it, the feature has been in for a long time, also update wiki.quakesrc.org accordingly
 d feature darkplaces client: add a dot crosshair texture (HellToupee)
 d feature darkplaces client: add a sv_fixedframeratesingleplayer cvar (default off), to allow fixed framerate singleplayer mods, mainly useful for physics (Urre)
+d feature darkplaces client: add qw protocol support (making darkplaces work as a qwcl client) (Amish, Fuh)
 d feature darkplaces client: add showbrand cvar which would show gfx/brand.tga in the left/right top/bottom corner (depending on value of scr_showbrand) all the time, this would be useful for screenshots (Spirit_of_85)
 d feature darkplaces client: cl_capture_video avi support would be nice, the Intel(r) 4:2:0 codec seems to be standard on Windows XP so this should be easy
 d feature darkplaces client: make tab completion able to complete map names when using a map or changelevel command (Zenex, Eksess)
@@ -1252,6 +1251,7 @@ d feature darkplaces protocol: add PRYDON_CLIENTCURSOR extension - clientside mo
 d feature darkplaces protocol: add back colormod extension (FrikaC, Uffe, Gilgamesh, Wazat)
 d feature darkplaces protocol: add buttons 9-16 (yummyluv)
 d feature darkplaces protocol: allow sending of additional precaches during game, this needs to send a reliable message to all connected clients stating the new filename to load, and also to be sent to new connections (VorteX, Vermeulen)
+d feature darkplaces renderer: add HalfLife2 style water rendering (Mitchell, Stribbs, Jimmy Freestone)
 d feature darkplaces renderer: add a nearclip cvar (Tomaz)
 d feature darkplaces renderer: add q3bsp water rendering, both scrolling and watershader (Zombie)
 d feature darkplaces renderer: add r_shadow_visiblelighting cvar which draws redish orange polygons similar to visiblevolumes for measuring number of light passes per pixel (Harbish)