]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.c
improved TraceLine in chase.c to be more generally useful (should move it to another...
[xonotic/darkplaces.git] / model_brush.c
index d86b498e54e333940007fc42b9ac791e529acfb0..0efc4e70c62b2d9476a2bd25df8f43d5e506d839 100644 (file)
@@ -124,7 +124,7 @@ void Mod_LoadTextures (lump_t *l)
        m->nummiptex = LittleLong (m->nummiptex);
        
        loadmodel->numtextures = m->nummiptex;
-       loadmodel->textures = Hunk_AllocName (m->nummiptex * sizeof(*loadmodel->textures) , loadname);
+       loadmodel->textures = Hunk_AllocName (m->nummiptex * sizeof(*loadmodel->textures), va("%s texture headers", loadname));
 
        // just to work around bounds checking when debugging with it (array index out of bounds error thing)
        dofs = m->dataofs;
@@ -142,7 +142,7 @@ void Mod_LoadTextures (lump_t *l)
                if ( (mt->width & 15) || (mt->height & 15) )
                        Host_Error ("Texture %s is not 16 aligned", mt->name);
                // LordHavoc: rewriting the map texture loader for GLQuake
-               tx = Hunk_AllocName (sizeof(texture_t), loadname );
+               tx = Hunk_AllocName (sizeof(texture_t), va("%s textures", loadname));
                loadmodel->textures[i] = tx;
 
                // LordHavoc: force all names to lowercase and make sure they are terminated while copying
@@ -206,7 +206,7 @@ void Mod_LoadTextures (lump_t *l)
                        {
                                char name[64];
                                byte *data2;
-                               data2 = malloc(tx->width*tx->height);
+                               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);
@@ -215,7 +215,7 @@ void Mod_LoadTextures (lump_t *l)
                                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);
-                               free(data2);
+                               qfree(data2);
                        }
                        else
                        {
@@ -224,7 +224,7 @@ void Mod_LoadTextures (lump_t *l)
                        }
                }
                if (freeimage)
-                       free(data);
+                       qfree(data);
        }
 
 //
@@ -335,7 +335,7 @@ void Mod_LoadLighting (lump_t *l)
        loadmodel->lightdata = NULL;
        if (hlbsp) // LordHavoc: load the colored lighting data straight
        {
-               loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname);
+               loadmodel->lightdata = Hunk_AllocName ( l->filelen, va("%s lightmaps", loadname));
                memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
        }
        else // LordHavoc: bsp version 29 (normal white lighting)
@@ -365,7 +365,7 @@ void Mod_LoadLighting (lump_t *l)
                // LordHavoc: oh well, expand the white lighting data
                if (!l->filelen)
                        return;
-               loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename);
+               loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, va("%s lightmaps", loadname));
                in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write
                out = loadmodel->lightdata;
                memcpy (in, mod_base + l->fileofs, l->filelen);
@@ -392,7 +392,7 @@ void Mod_LoadVisibility (lump_t *l)
                loadmodel->visdata = NULL;
                return;
        }
-       loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname);    
+       loadmodel->visdata = Hunk_AllocName ( l->filelen, va("%s visdata", loadname));
        memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
 }
 
@@ -412,7 +412,7 @@ void Mod_LoadEntities (lump_t *l)
                loadmodel->entities = NULL;
                return;
        }
-       loadmodel->entities = Hunk_AllocName ( l->filelen, loadname);   
+       loadmodel->entities = Hunk_AllocName ( l->filelen, va("%s entities", loadname));
        memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen);
 
        if (isworldmodel)
@@ -435,7 +435,7 @@ void Mod_LoadVertexes (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s vertices", loadname));
 
        loadmodel->vertexes = out;
        loadmodel->numvertexes = count;
@@ -463,7 +463,7 @@ void Mod_LoadSubmodels (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s submodels", loadname));
 
        loadmodel->submodels = out;
        loadmodel->numsubmodels = count;
@@ -499,7 +499,7 @@ void Mod_LoadEdges (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( (count + 1) * sizeof(*out), loadname);   
+       out = Hunk_AllocName ( (count + 1) * sizeof(*out), va("%s edges", loadname));
 
        loadmodel->edges = out;
        loadmodel->numedges = count;
@@ -520,7 +520,7 @@ void Mod_LoadTexinfo (lump_t *l)
 {
        texinfo_t *in;
        mtexinfo_t *out;
-       int     i, j, count;
+       int     i, j, k, count;
        int             miptex;
        float   len1, len2;
 
@@ -528,15 +528,16 @@ void Mod_LoadTexinfo (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s texinfo", loadname));
 
        loadmodel->texinfo = out;
        loadmodel->numtexinfo = count;
 
        for ( i=0 ; i<count ; i++, in++, out++)
        {
-               for (j=0 ; j<8 ; j++)
-                       out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
+               for (k=0 ; k<2 ; k++)
+                       for (j=0 ; j<4 ; j++)
+                               out->vecs[k][j] = LittleFloat (in->vecs[k][j]);
                len1 = Length (out->vecs[0]);
                len2 = Length (out->vecs[1]);
                len1 = (len1 + len2)/2;
@@ -652,7 +653,7 @@ void Mod_LoadFaces (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s faces", loadname));
 
        loadmodel->surfaces = out;
        loadmodel->numsurfaces = count;
@@ -751,7 +752,7 @@ void Mod_LoadNodes (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s nodes", loadname));
 
        loadmodel->nodes = out;
        loadmodel->numnodes = count;
@@ -798,7 +799,7 @@ void Mod_LoadLeafs (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s leafs", loadname));
 
        loadmodel->leafs = out;
        loadmodel->numleafs = count;
@@ -855,7 +856,7 @@ void Mod_LoadClipnodes (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s clipnodes", loadname));
 
        loadmodel->clipnodes = out;
        loadmodel->numclipnodes = count;
@@ -953,7 +954,7 @@ void Mod_MakeHull0 (void)
        
        in = loadmodel->nodes;
        count = loadmodel->numnodes;
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s hull0", loadname));
 
        hull->clipnodes = out;
        hull->firstclipnode = 0;
@@ -989,7 +990,7 @@ void Mod_LoadMarksurfaces (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s marksurfaces", loadname));
 
        loadmodel->marksurfaces = out;
        loadmodel->nummarksurfaces = count;
@@ -1017,7 +1018,7 @@ void Mod_LoadSurfedges (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*sizeof(*out), loadname);   
+       out = Hunk_AllocName ( count*sizeof(*out), va("%s surfedges", loadname));
 
        loadmodel->surfedges = out;
        loadmodel->numsurfedges = count;
@@ -1044,7 +1045,7 @@ void Mod_LoadPlanes (lump_t *l)
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        count = l->filelen / sizeof(*in);
-       out = Hunk_AllocName ( count*2*sizeof(*out), loadname); 
+       out = Hunk_AllocName ( count*2*sizeof(*out), va("%s planes", loadname));
 
        loadmodel->planes = out;
        loadmodel->numplanes = count;