]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/map.c
fix two msvc compile errors
[xonotic/netradiant.git] / tools / quake3 / q3map2 / map.c
index 82d7d2bf3b4cbb4d39c466cc44b5e9542c533953..9b7ba71a55c1f33a472b122302f38d6eefb9fc73 100644 (file)
@@ -44,7 +44,7 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
 #define        USE_HASHING
 #define        PLANE_HASHES    8192
 
-plane_t                                        *planehash[ PLANE_HASHES ];
+int                                            planehash[ PLANE_HASHES ];
 
 int                                            c_boxbevels;
 int                                            c_edgebevels;
@@ -96,7 +96,7 @@ void AddPlaneToHash( plane_t *p )
        hash = (PLANE_HASHES - 1) & (int) fabs( p->dist );
 
        p->hash_chain = planehash[hash];
-       planehash[hash] = p;
+       planehash[hash] = p - mapplanes + 1;
 }
 
 /*
@@ -115,8 +115,7 @@ int CreateNewFloatPlane (vec3_t normal, vec_t dist)
        }
 
        // create a new plane
-       if (nummapplanes+2 > MAX_MAP_PLANES)
-               Error ("MAX_MAP_PLANES");
+       AUTOEXPAND_BY_REALLOC(mapplanes, nummapplanes+1, allocatedmapplanes, 1024);
 
        p = &mapplanes[nummapplanes];
        VectorCopy (normal, p->normal);
@@ -219,6 +218,7 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
 
 {
        int             i, j, hash, h;
+       int pidx;
        plane_t *p;
        vec_t   d;
        vec3_t centerofweight;
@@ -235,8 +235,10 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
        for( i = -1; i <= 1; i++ )
        {
                h = (hash + i) & (PLANE_HASHES - 1);
-               for( p = planehash[ h ]; p != NULL; p = p->hash_chain )
+               for( pidx = planehash[ h ] - 1; pidx != -1; pidx = mapplanes[pidx].hash_chain - 1 )
                {
+                       p = &mapplanes[pidx];
+
                        /* do standard plane compare */
                        if( !PlaneEqual( p, normal, dist ) )
                                continue;
@@ -598,6 +600,7 @@ and links it to the current entity
 static void MergeOrigin(entity_t *ent, vec3_t origin)
 {
        vec3_t adjustment;
+       char string[128];
 
        /* we have not parsed the brush completely yet... */
        GetVectorForKey( ent, "origin", ent->origin );
@@ -606,7 +609,6 @@ static void MergeOrigin(entity_t *ent, vec3_t origin)
        VectorAdd(adjustment, ent->origin, ent->origin);
        VectorCopy(origin, ent->originbrush_origin);
 
-       char string[128];
        sprintf(string, "%f %f %f", ent->origin[0], ent->origin[1], ent->origin[2]);
        SetKeyValue(ent, "origin", string);
 }
@@ -1093,7 +1095,6 @@ void MoveBrushesToWorld( entity_t *ent )
 
        /* we need to undo the common/origin adjustment, and instead shift them by the entity key origin */
        VectorScale(ent->origin, -1, ent->originbrush_origin);
-       Sys_Printf("func_group: adjusting by %f %f %f\n", ent->originbrush_origin[0], ent->originbrush_origin[1], ent->originbrush_origin[2]);
        AdjustBrushesForOrigin(ent);
        VectorClear(ent->originbrush_origin);
        
@@ -1158,8 +1159,6 @@ void AdjustBrushesForOrigin( entity_t *ent )
        brush_t         *b;
        parseMesh_t     *p;
        
-       Sys_Printf("origin: adjusting by %f %f %f\n", ent->originbrush_origin[0], ent->originbrush_origin[1], ent->originbrush_origin[2]);
-
        /* walk brush list */
        for( b = ent->brushes; b != NULL; b = b->next )
        {
@@ -1554,14 +1553,18 @@ static qboolean ParseMapEntity( qboolean onlyLights )
        /* get explicit shadow flags */
        GetEntityShadowFlags( mapEnt, NULL, &castShadows, &recvShadows );
        
+       /* vortex: added _ls key (short name of lightmapscale) */
        /* ydnar: get lightmap scaling value for this entity */
        if( strcmp( "", ValueForKey( mapEnt, "lightmapscale" ) ) ||
-               strcmp( "", ValueForKey( mapEnt, "_lightmapscale" ) ) )
+               strcmp( "", ValueForKey( mapEnt, "_lightmapscale" ) ) || 
+               strcmp( "", ValueForKey( mapEnt, "_ls" ) ) )
        {
                /* get lightmap scale from entity */
                lightmapScale = FloatForKey( mapEnt, "lightmapscale" );
                if( lightmapScale <= 0.0f )
                        lightmapScale = FloatForKey( mapEnt, "_lightmapscale" );
+               if( lightmapScale <= 0.0f )
+                       lightmapScale = FloatForKey( mapEnt, "_ls" );
                if( lightmapScale > 0.0f )
                        Sys_Printf( "Entity %d (%s) has lightmap scale of %.4f\n", mapEnt->mapEntityNum, classname, lightmapScale );
        }
@@ -1579,7 +1582,7 @@ static qboolean ParseMapEntity( qboolean onlyLights )
                Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
        }
        else
-               celShader = NULL;
+               celShader = *globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL;
        
        /* attach stuff to everything in the entity */
        for( brush = mapEnt->brushes; brush != NULL; brush = brush->next )