]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/convert_bsp.c
quake3/help: move away from termcap
[xonotic/netradiant.git] / tools / quake3 / q3map2 / convert_bsp.c
index 5a03df9c067b83eb42023dc0cb48d5d38224d2aa..9a0e05516e239e274470fea2a26fc3a4a67d7e58 100644 (file)
@@ -37,7 +37,7 @@
    PseudoCompileBSP()
    a stripped down ProcessModels
  */
-void PseudoCompileBSP( qboolean need_tree ){
+void PseudoCompileBSP( qboolean need_tree, const char *BSPFilePath, const char *surfaceFilePath ){
        int models;
        char modelValue[10];
        entity_t *entity;
@@ -49,8 +49,7 @@ void PseudoCompileBSP( qboolean need_tree ){
        int i;
 
        SetDrawSurfacesBuffer();
-       mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
-       memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+       mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
        numMapDrawSurfs = 0;
 
        BeginBSPFile();
@@ -125,7 +124,7 @@ void PseudoCompileBSP( qboolean need_tree ){
                EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
                EndModel( entity, node );
        }
-       EndBSPFile( qfalse );
+       EndBSPFile( qfalse, BSPFilePath, surfaceFilePath );
 }
 
 /*
@@ -138,6 +137,8 @@ int ConvertBSPMain( int argc, char **argv ){
        int ( *convertFunc )( char * );
        game_t  *convertGame;
        char ext[1024];
+       char BSPFilePath [ 1024 ];
+       char surfaceFilePath [ 1024 ];
        qboolean map_allowed, force_bsp, force_map;
 
 
@@ -149,7 +150,7 @@ int ConvertBSPMain( int argc, char **argv ){
        force_map = qfalse;
 
        /* arg checking */
-       if ( argc < 1 ) {
+       if ( argc < 2 ) {
                Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-v] <mapname>\n" );
                return 0;
        }
@@ -181,7 +182,7 @@ int ConvertBSPMain( int argc, char **argv ){
                                convertGame = GetGame( argv[ i ] );
                                map_allowed = qfalse;
                                if ( convertGame == NULL ) {
-                                       Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
+                                       Sys_FPrintf( SYS_WRN, "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
                                }
                        }
                }
@@ -232,13 +233,15 @@ int ConvertBSPMain( int argc, char **argv ){
 
        if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
                if ( !map_allowed ) {
-                       Sys_Printf( "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
+                       Sys_FPrintf( SYS_WRN, "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
                }
                StripExtension( source );
                DefaultExtension( source, ".map" );
                Sys_Printf( "Loading %s\n", source );
                LoadMapFile( source, qfalse, convertGame == NULL );
-               PseudoCompileBSP( convertGame != NULL );
+               sprintf( BSPFilePath, "%s.bsp", source );
+               sprintf( surfaceFilePath, "%s.srf", source );
+               PseudoCompileBSP( convertGame != NULL, BSPFilePath, surfaceFilePath );
        }
        else
        {