]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.c
newline to keep gcc3 happy
[xonotic/darkplaces.git] / model_brush.c
index 785ef2d0d771e097c579d4507da210ec2fb6e0e5..51538971121534d932ea03e58090d99f046d8903 100644 (file)
@@ -647,7 +647,7 @@ void Mod_LoadLightList(void)
                        if (a != 14)
                        {
                                Mem_Free(lightsstring);
-                               Host_Error("invalid lights file, found %d parameters on line %i, should be 13 parameters (origin[0] origin[1] origin[2] falloff light[0] light[1] light[2] subtract spotdir[0] spotdir[1] spotdir[2] spotcone style)\n", a, n + 1);
+                               Host_Error("invalid lights file, found %d parameters on line %i, should be 14 parameters (origin[0] origin[1] origin[2] falloff light[0] light[1] light[2] subtract spotdir[0] spotdir[1] spotdir[2] spotcone distancebias style)\n", a, n + 1);
                        }
                        s++;
                        n++;
@@ -678,22 +678,20 @@ static void Mod_LoadVisibility (lump_t *l)
 }
 
 // used only for HalfLife maps
-void Mod_ParseWadsFromEntityLump(char *data)
+void Mod_ParseWadsFromEntityLump(const char *data)
 {
        char key[128], value[4096];
        char wadname[128];
        int i, j, k;
        if (!data)
                return;
-       data = COM_Parse(data);
-       if (!data)
+       if (!COM_ParseToken(&data))
                return; // error
        if (com_token[0] != '{')
                return; // error
        while (1)
        {
-               data = COM_Parse(data);
-               if (!data)
+               if (!COM_ParseToken(&data))
                        return; // error
                if (com_token[0] == '}')
                        break; // end of worldspawn
@@ -703,8 +701,7 @@ void Mod_ParseWadsFromEntityLump(char *data)
                        strcpy(key, com_token);
                while (key[strlen(key)-1] == ' ') // remove trailing spaces
                        key[strlen(key)-1] = 0;
-               data = COM_Parse(data);
-               if (!data)
+               if (!COM_ParseToken(&data))
                        return; // error
                strcpy(value, com_token);
                if (!strcmp("wad", key)) // for HalfLife maps
@@ -1287,9 +1284,12 @@ static void Mod_LoadFaces (lump_t *l)
 
        loadmodel->surfaces = out;
        loadmodel->numsurfaces = count;
+       loadmodel->surfacevisframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int));
+       loadmodel->surfacepvsframes = Mem_Alloc(loadmodel->mempool, count * sizeof(int));
 
        for (surfnum = 0;surfnum < count;surfnum++, in++, out++)
        {
+               out->number = surfnum;
                // FIXME: validate edges, texinfo, etc?
                out->firstedge = LittleLong(in->firstedge);
                out->numedges = LittleShort(in->numedges);
@@ -1316,8 +1316,6 @@ static void Mod_LoadFaces (lump_t *l)
 
                // force lightmap upload on first time seeing the surface
                out->cached_dlight = true;
-               out->cached_ambient = -1000;
-               out->cached_lightscalebit = -1000;
 
                CalcSurfaceExtents (out);
 
@@ -1599,21 +1597,21 @@ Mod_LoadMarksurfaces
 */
 static void Mod_LoadMarksurfaces (lump_t *l)
 {
-       int             i, j;
-       short   *in;
+       int i, j;
+       short *in;
 
        in = (void *)(mod_base + l->fileofs);
        if (l->filelen % sizeof(*in))
                Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
        loadmodel->nummarksurfaces = l->filelen / sizeof(*in);
-       loadmodel->marksurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->nummarksurfaces * sizeof(msurface_t *));
+       loadmodel->marksurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->nummarksurfaces * sizeof(int));
 
        for (i = 0;i < loadmodel->nummarksurfaces;i++)
        {
                j = (unsigned) LittleShort(in[i]);
                if (j >= loadmodel->numsurfaces)
                        Host_Error ("Mod_ParseMarksurfaces: bad surface number");
-               loadmodel->marksurfaces[i] = loadmodel->surfaces + j;
+               loadmodel->marksurfaces[i] = j;
        }
 }
 
@@ -2462,6 +2460,8 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
                mod->yawmaxs[2] = mod->normalmaxs[2];
                mod->rotatedmins[0] = mod->rotatedmins[1] = mod->rotatedmins[2] = -modelradius;
                mod->rotatedmaxs[0] = mod->rotatedmaxs[1] = mod->rotatedmaxs[2] = modelradius;
+               mod->radius = modelradius;
+               mod->radius2 = modelradius * modelradius;
                // LordHavoc: check for empty submodels (lacrima.bsp has such a glitch)
                if (mod->normalmins[0] > mod->normalmaxs[0] || mod->normalmins[1] > mod->normalmaxs[1] || mod->normalmins[2] > mod->normalmaxs[2])
                {
@@ -2472,12 +2472,14 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer)
                        VectorClear(mod->yawmaxs);
                        VectorClear(mod->rotatedmins);
                        VectorClear(mod->rotatedmaxs);
+                       mod->radius = 0;
+                       mod->radius2 = 0;
                }
 
                mod->numleafs = bm->visleafs;
 
                mod->Draw = R_DrawBrushModelNormal;
-               mod->DrawShadow = NULL;
+               mod->DrawFakeShadow = NULL;
 
                // LordHavoc: only register submodels if it is the world
                // (prevents bsp models from replacing world submodels)