]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/map.c
the decompiler now can convert .map files too
[xonotic/netradiant.git] / tools / quake3 / q3map2 / map.c
index f29d7d62e0016c942d65c7a7e70c30080de6553a..448a24fb2398b3e023d9d477e31e93dd29434d0b 100644 (file)
@@ -620,7 +620,7 @@ static void MergeOrigin(entity_t *ent, vec3_t origin)
        SetKeyValue(ent, "origin", string);
 }
 
-brush_t *FinishBrush( void )
+brush_t *FinishBrush( qboolean noCollapseGroups )
 {
        brush_t         *b;
        
@@ -665,7 +665,8 @@ brush_t *FinishBrush( void )
        }
        
        /* add bevel planes */
-       AddBrushBevels();
+       if(!noCollapseGroups)
+               AddBrushBevels();
        
        /* keep it */
        b = CopyBrush( buildBrush );
@@ -837,7 +838,7 @@ static void ParseRawBrush( qboolean onlyLights )
        int                             planenum;
        shaderInfo_t    *si;
        vec_t                   shift[ 2 ];
-       vec_t                   rotate;
+       vec_t                   rotate = 0;
        vec_t                   scale[ 2 ];
        char                    name[ MAX_QPATH ];
        char                    shader[ MAX_QPATH ];
@@ -1034,7 +1035,7 @@ ParseBrush()
 parses a brush out of a map file and sets it up
 */
 
-static void ParseBrush( qboolean onlyLights )
+static void ParseBrush( qboolean onlyLights, qboolean noCollapseGroups )
 {
        brush_t *b;
        
@@ -1081,7 +1082,7 @@ static void ParseBrush( qboolean onlyLights )
        }
        
        /* finish the brush */
-       b = FinishBrush();
+       b = FinishBrush(noCollapseGroups);
 }
 
 
@@ -1418,7 +1419,7 @@ ParseMapEntity()
 parses a single entity out of a map file
 */
 
-static qboolean ParseMapEntity( qboolean onlyLights )
+static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
 {
        epair_t                 *ep;
        const char              *classname, *value;
@@ -1497,7 +1498,7 @@ static qboolean ParseMapEntity( qboolean onlyLights )
                                g_bBrushPrimit = BPRIMIT_NEWBRUSHES;
                                
                                /* parse brush primitive */
-                               ParseBrush( onlyLights );
+                               ParseBrush( onlyLights, noCollapseGroups );
                        }
                        else
                        {
@@ -1507,7 +1508,7 @@ static qboolean ParseMapEntity( qboolean onlyLights )
                                
                                /* parse old brush format */
                                UnGetToken();
-                               ParseBrush( onlyLights );
+                               ParseBrush( onlyLights, noCollapseGroups );
                        }
                        entitySourceBrushes++;
                }
@@ -1585,12 +1586,19 @@ static qboolean ParseMapEntity( qboolean onlyLights )
                value = ValueForKey( &entities[ 0 ], "_celshader" );
        if( value[ 0 ] != '\0' )
        {
-               sprintf( shader, "textures/%s", value );
-               celShader = ShaderInfoForShader( shader );
-               Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
+               if(strcmp(value, "none"))
+               {
+                       sprintf( shader, "textures/%s", value );
+                       celShader = ShaderInfoForShader( shader );
+                       Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
+               }
+               else
+               {
+                       celShader = NULL;
+               }
        }
        else
-               celShader = *globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL;
+               celShader = (*globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL);
 
        /* jal : entity based _shadeangle */
        shadeAngle = 0.0f;
@@ -1657,14 +1665,14 @@ static qboolean ParseMapEntity( qboolean onlyLights )
                AdjustBrushesForOrigin( mapEnt );
 
        /* group_info entities are just for editor grouping (fixme: leak!) */
-       if( !Q_stricmp( "group_info", classname ) )
+       if( !noCollapseGroups && !Q_stricmp( "group_info", classname ) )
        {
                numEntities--;
                return qtrue;
        }
        
        /* group entities are just for editor convenience, toss all brushes into worldspawn */
-       if( funcGroup )
+       if( !noCollapseGroups && funcGroup )
        {
                MoveBrushesToWorld( mapEnt );
                numEntities--;
@@ -1682,11 +1690,11 @@ LoadMapFile()
 loads a map file into a list of entities
 */
 
-void LoadMapFile( char *filename, qboolean onlyLights )
+void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups )
 {              
        FILE            *file;
        brush_t         *b;
-       int                     oldNumEntities, numMapBrushes;
+       int                     oldNumEntities = 0, numMapBrushes;
        
        
        /* note it */
@@ -1715,7 +1723,7 @@ void LoadMapFile( char *filename, qboolean onlyLights )
        buildBrush = AllocBrush( MAX_BUILD_SIDES );
        
        /* parse the map file */
-       while( ParseMapEntity( onlyLights ) );
+       while( ParseMapEntity( onlyLights, noCollapseGroups ) );
        
        /* light loading */
        if( onlyLights )