]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/q3map2.h
q3map2: drop Q_UNIX definition (rely on GDEF_OS_POSIX instead)
[xonotic/netradiant.git] / tools / quake3 / q3map2 / q3map2.h
index bbb3e76e73518d27b8bc12ef7a42ca46f51b2188..ce37d76c2deabee2311ee478ca0cdc501a34b489 100644 (file)
@@ -32,7 +32,7 @@
 #ifndef Q3MAP2_H
 #define Q3MAP2_H
 
-
+#include "globaldefs.h"
 
 /* version */
 #ifndef Q3MAP_VERSION
@@ -41,8 +41,6 @@
 #define Q3MAP_MOTD      "Your map saw the pretty lights from q3map2's BFG"
 
 
-
-
 /* -------------------------------------------------------------------------------
 
    dependencies
    ------------------------------------------------------------------------------- */
 
 /* platform-specific */
-#if defined( __linux__ ) || defined( __APPLE__ )
-       #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if GDEF_OS_POSIX
        #include <unistd.h>
        #include <pwd.h>
        #include <limits.h>
 #endif
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        #include <windows.h>
 #endif
 
@@ -72,6 +66,9 @@
 #include "mathlib.h"
 #include "md5lib.h"
 #include "ddslib.h"
+#ifdef BUILD_CRUNCH
+#include "crn_rgba.h"
+#endif // BUILD_CRUNCH
 
 #include "picomodel.h"
 
@@ -85,9 +82,6 @@
 #include "md4.h"
 #include <stdlib.h>
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
 
 /* -------------------------------------------------------------------------------
 
 
    ------------------------------------------------------------------------------- */
 
-#define MAC_STATIC_HACK         0
-#if defined( __APPLE__ ) && MAC_STATIC_HACK
-       #define MAC_STATIC          static
-#else
-       #define MAC_STATIC
-#endif
-
 #if 1
-       #ifdef WIN32
+       #if GDEF_OS_WINDOWS
                #define Q_stricmp           stricmp
                #define Q_strncasecmp       strnicmp
        #else
 #define HINT_PRIORITY           1000        /* ydnar: force hint splits first and antiportal/areaportal splits last */
 #define ANTIPORTAL_PRIORITY     -1000
 #define AREAPORTAL_PRIORITY     -1000
-#define DETAIL_PRIORITY     -3000
+#define DETAIL_PRIORITY         -3000
 
 #define PSIDE_FRONT             1
 #define PSIDE_BACK              2
 #define RAD_LUXEL_SIZE          3
 #define SUPER_LUXEL_SIZE        4
 #define SUPER_FLAG_SIZE         4
-#define FLAG_FORCE_SUBSAMPLING 1
+#define FLAG_FORCE_SUBSAMPLING  1
 #define FLAG_ALREADY_SUBSAMPLED 2
 #define SUPER_ORIGIN_SIZE       3
 #define SUPER_NORMAL_SIZE       4
@@ -829,7 +816,7 @@ typedef struct face_s
        struct face_s       *next;
        int planenum;
        int priority;
-       //qboolean                      checked;
+       //qboolean checked;
        int compileFlags;
        winding_t           *w;
 }
@@ -961,8 +948,9 @@ typedef struct parseMesh_s
        shaderInfo_t        *shaderInfo;
        shaderInfo_t        *celShader;             /* :) */
 
+       /* jal : entity based _lightmapsamplesize */
+       int lightmapSampleSize;
        /* ydnar: gs mods */
-       int lightmapSampleSize;                     /* jal : entity based _lightmapsamplesize */
        float lightmapScale;
        vec3_t eMins, eMaxs;
        indexMap_t          *im;
@@ -1237,6 +1225,7 @@ typedef struct
 {
        int num;
        qboolean hint;                      /* true if this portal was created from a hint splitter */
+       qboolean sky;                       /* true if this portal belongs to a sky leaf */
        qboolean removed;
        visPlane_t plane;                   /* normal pointing into neighbor */
        int leaf;                           /* neighbor */
@@ -1469,7 +1458,7 @@ typedef struct rawLightmap_s
        float                   *bspLuxels[ MAX_LIGHTMAPS ];
        float                   *radLuxels[ MAX_LIGHTMAPS ];
        float                   *superLuxels[ MAX_LIGHTMAPS ];
-       unsigned char               *superFlags;
+       unsigned char           *superFlags;
        float                   *superOrigins;
        float                   *superNormals;
        int                     *superClusters;
@@ -1517,32 +1506,50 @@ vec_t                       Random( void );
 char                        *Q_strncpyz( char *dst, const char *src, size_t len );
 char                        *Q_strcat( char *dst, size_t dlen, const char *src );
 char                        *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
-int                         BSPInfo( int count, char **fileNames );
-int                         ScaleBSPMain( int argc, char **argv );
-int                         ConvertMain( int argc, char **argv );
 
+/* help.c */
+void                        HelpMain(const char* arg);
 
 /* path_init.c */
 game_t                      *GetGame( char *arg );
 void                        InitPaths( int *argc, char **argv );
 
 
+/* fixaas.c */
+int                         FixAASMain( int argc, char **argv );
+
+
 /* bsp.c */
 int                         BSPMain( int argc, char **argv );
 
 
+/* bsp_analyze.c */
+int                         AnalyzeBSPMain( int argc, char **argv );
+
+
+/* bsp_info.c */
+int                         BSPInfoMain( int count, char **fileNames );
+
+/* bsp_scale.c */
+int                         ScaleBSPMain( int argc, char **argv );
+
+/* minimap.c */
+int                         MiniMapBSPMain( int argc, char **argv );
+
+/* convert_bsp.c */
+int                         ConvertBSPMain( int argc, char **argv );
+
+
 /* convert_map.c */
 int                         ConvertBSPToMap( char *bspName );
 int                         ConvertBSPToMap_BP( char *bspName );
 
-
 /* convert_ase.c */
 int                         ConvertBSPToASE( char *bspName );
 
 /* convert_obj.c */
 int                         ConvertBSPToOBJ( char *bspName );
 
-
 /* brush.c */
 sideRef_t                   *AllocSideRef( side_t *side, sideRef_t *next );
 int                         CountBrushList( brush_t *brushes );
@@ -1615,12 +1622,12 @@ void                        MakeTreePortals( tree_t *tree );
 
 
 /* leakfile.c */
-xmlNodePtr                  LeakFile( tree_t *tree );
+xmlNodePtr                  LeakFile( tree_t *tree, const char *lineFilePath );
 
 
 /* prtfile.c */
 void                        NumberClusters( tree_t *tree );
-void                        WritePortalFile( tree_t *tree );
+void                        WritePortalFile( tree_t *tree, const char *portalFilePath );
 
 
 /* writebsp.c */
@@ -1630,7 +1637,7 @@ void                        SetLightStyles( void );
 int                         EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
 
 void                        BeginBSPFile( void );
-void                        EndBSPFile( qboolean do_write );
+void                        EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath );
 void                        EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
 void                        EmitFogs( void );
 
@@ -1742,8 +1749,8 @@ int                         GetSurfaceExtraMinSampleSize( int num );
 float                       GetSurfaceExtraLongestCurve( int num );
 void                        GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
 
-void                        WriteSurfaceExtraFile( const char *path );
-void                        LoadSurfaceExtraFile( const char *path );
+void                        WriteSurfaceExtraFile( const char *surfaceFilePath );
+void                        LoadSurfaceExtraFile( const char *surfaceFilePath );
 
 
 /* decals.c */
@@ -1814,7 +1821,7 @@ void                        FloodLightRawLightmap( int num );
 void                        IlluminateRawLightmap( int num );
 void                        IlluminateVertexes( int num );
 
-void                        SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all );
+void                        SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all );
 void                        SetupBrushes( void );
 void                        SetupClusters( void );
 qboolean                    ClusterVisible( int a, int b );
@@ -1837,7 +1844,12 @@ int                         ImportLightmapsMain( int argc, char **argv );
 
 void                        SetupSurfaceLightmaps( void );
 void                        StitchSurfaceLightmaps( void );
-void                        StoreSurfaceLightmaps( void );
+void                        StoreSurfaceLightmaps( qboolean fastAllocate );
+
+
+/* exportents.c */
+void                        ExportEntities( void );
+int                         ExportEntitiesMain( int argc, char **argv );
 
 
 /* image.c */
@@ -1897,7 +1909,7 @@ qboolean                    KeyExists( const entity_t *ent, const char *key ); /
 const char                  *ValueForKey( const entity_t *ent, const char *key );
 int                         IntForKey( const entity_t *ent, const char *key );
 vec_t                       FloatForKey( const entity_t *ent, const char *key );
-void                        GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
+qboolean                    GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
 entity_t                    *FindTargetEntity( const char *target );
 void                        GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows );
 void InjectCommandLine( char **argv, int beginArgs, int endArgs );
@@ -1938,19 +1950,21 @@ Q_EXTERN game_t games[]
        {
                                                                #include "game_quake3.h"
        ,
-                                                               #include "game_quakelive.h" /* most be after game_quake3.h as they share defines! */
+                                                               #include "game_quakelive.h" /* must be after game_quake3.h as they share defines! */
        ,
-                                                               #include "game_nexuiz.h" /* most be after game_quake3.h as they share defines! */
+                                                               #include "game_nexuiz.h" /* must be after game_quake3.h as they share defines! */
        ,
-                                                               #include "game_xonotic.h" /* most be after game_quake3.h as they share defines! */
+                                                               #include "game_xonotic.h" /* must be after game_quake3.h as they share defines! */
        ,
                                                                #include "game_tremulous.h" /*LinuxManMikeC: must be after game_quake3.h, depends on #define's set in it */
+       ,
+                                                               #include "game_unvanquished.h" /* must be after game_tremulous.h as they share defines! */
        ,
                                                                #include "game_tenebrae.h"
        ,
                                                                #include "game_wolf.h"
        ,
-                                                               #include "game_wolfet.h" /* most be after game_wolf.h as they share defines! */
+                                                               #include "game_wolfet.h" /* must be after game_wolf.h as they share defines! */
        ,
                                                                #include "game_etut.h"
        ,
@@ -1958,9 +1972,9 @@ Q_EXTERN game_t games[]
        ,
                                                                #include "game_sof2.h"
        ,
-                                                               #include "game_jk2.h"   /* most be after game_sof2.h as they share defines! */
+                                                               #include "game_jk2.h"   /* must be after game_sof2.h as they share defines! */
        ,
-                                                               #include "game_ja.h"    /* most be after game_jk2.h as they share defines! */
+                                                               #include "game_ja.h"    /* must be after game_jk2.h as they share defines! */
        ,
                                                                #include "game_qfusion.h"   /* qfusion game */
        ,
@@ -2020,8 +2034,8 @@ Q_EXTERN qboolean nofog Q_ASSIGN( qfalse );
 Q_EXTERN qboolean noHint Q_ASSIGN( qfalse );                        /* ydnar */
 Q_EXTERN qboolean renameModelShaders Q_ASSIGN( qfalse );            /* ydnar */
 Q_EXTERN qboolean skyFixHack Q_ASSIGN( qfalse );                    /* ydnar */
-Q_EXTERN qboolean bspAlternateSplitWeights Q_ASSIGN( qfalse );                      /* 27 */
-Q_EXTERN qboolean deepBSP Q_ASSIGN( qfalse );                   /* div0 */
+Q_EXTERN qboolean bspAlternateSplitWeights Q_ASSIGN( qfalse );      /* 27 */
+Q_EXTERN qboolean deepBSP Q_ASSIGN( qfalse );                       /* div0 */
 Q_EXTERN qboolean maxAreaFaceSurface Q_ASSIGN( qfalse );                    /* divVerent */
 
 Q_EXTERN int patchSubdivisions Q_ASSIGN( 8 );                       /* ydnar: -patchmeta subdivisions */
@@ -2505,7 +2519,7 @@ Q_EXTERN int allocatedBSPBrushSides Q_ASSIGN( 0 );
 Q_EXTERN bspBrushSide_t*    bspBrushSides Q_ASSIGN( NULL );
 
 Q_EXTERN int numBSPLightBytes Q_ASSIGN( 0 );
-Q_EXTERN byte               *bspLightBytes Q_ASSIGN( NULL );
+Q_EXTERN byte *bspLightBytes Q_ASSIGN( NULL );
 
 //%    Q_EXTERN int                            numBSPGridPoints Q_ASSIGN( 0 );
 //%    Q_EXTERN byte                           *bspGridPoints Q_ASSIGN( NULL );
@@ -2517,11 +2531,11 @@ Q_EXTERN int numBSPVisBytes Q_ASSIGN( 0 );
 Q_EXTERN byte bspVisBytes[ MAX_MAP_VISIBILITY ];
 
 Q_EXTERN int numBSPDrawVerts Q_ASSIGN( 0 );
-Q_EXTERN bspDrawVert_t          *bspDrawVerts Q_ASSIGN( NULL );
+Q_EXTERN bspDrawVert_t *bspDrawVerts Q_ASSIGN( NULL );
 
 Q_EXTERN int numBSPDrawIndexes Q_ASSIGN( 0 );
 Q_EXTERN int allocatedBSPDrawIndexes Q_ASSIGN( 0 );
-Q_EXTERN int                *bspDrawIndexes Q_ASSIGN( NULL );
+Q_EXTERN int *bspDrawIndexes Q_ASSIGN( NULL );
 
 Q_EXTERN int numBSPDrawSurfaces Q_ASSIGN( 0 );
 Q_EXTERN bspDrawSurface_t   *bspDrawSurfaces Q_ASSIGN( NULL );
@@ -2543,16 +2557,16 @@ Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
                                allocated *= 2; \
                        if ( !allocated || allocated > 2147483647 / (int)sizeof( *ptr ) ) \
                        { \
-                               Error( # ptr " over 2 GB" ); \
+                               Error( #ptr " over 2 GB" ); \
                        } \
                        ptr = realloc( ptr, sizeof( *ptr ) * allocated ); \
                        if ( !ptr ) { \
-                               Error( # ptr " out of memory" ); } \
+                               Error( #ptr " out of memory" ); } \
                } \
        } \
        while ( 0 )
 
-#define AUTOEXPAND_BY_REALLOC_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC( bsp ## suffix, numBSP ## suffix, allocatedBSP ## suffix, def )
+#define AUTOEXPAND_BY_REALLOC_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC( bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def )
 
 #define Image_LinearFloatFromsRGBFloat( c ) ( ( ( c ) <= 0.04045f ) ? ( c ) * ( 1.0f / 12.92f ) : (float)pow( ( ( c ) + 0.055f ) * ( 1.0f / 1.055f ), 2.4f ) )
 #define Image_sRGBFloatFromLinearFloat( c ) ( ( ( c ) < 0.0031308f ) ? ( c ) * 12.92f : 1.055f * (float)pow( ( c ), 1.0f / 2.4f ) - 0.055f )