]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/q3map2.h
Merge commit 'ee4b663ef7227a42b5eb051698265bed514ab3c0' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / q3map2.h
index 46fec5eef2bed378f918ff73fe8b8a609ec34ee2..1a7dd34e205e1a30b6679b46c6f24a11cc34cc81 100644 (file)
@@ -41,6 +41,8 @@
 #define Q3MAP_MOTD      "Your map saw the pretty lights from q3map2's BFG"
 
 
+
+
 /* -------------------------------------------------------------------------------
 
    dependencies
    ------------------------------------------------------------------------------- */
 
 /* platform-specific */
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-       #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if GDEF_OS_POSIX
        #include <unistd.h>
        #include <pwd.h>
        #include <limits.h>
 
 
 /* general */
-#include "version.h"            /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
-
 #include "cmdlib.h"
 #include "mathlib.h"
 #include "md5lib.h"
 #include "ddslib.h"
+#ifdef BUILD_CRUNCH
+#include "crn_rgba.h"
+#endif // BUILD_CRUNCH
 
 #include "picomodel.h"
 
 
    ------------------------------------------------------------------------------- */
 
-#define MAC_STATIC_HACK         0
-#if GDEF_OS_MACOS && MAC_STATIC_HACK
-       #define MAC_STATIC          static
-#else
-       #define MAC_STATIC
-#endif
-
-#if 1
        #if GDEF_OS_WINDOWS
                #define Q_stricmp           stricmp
                #define Q_strncasecmp       strnicmp
                #define Q_stricmp           strcasecmp
                #define Q_strncasecmp       strncasecmp
        #endif
+
+// hack to declare and define in the same file
+#ifdef MAIN_C
+       #define Q_EXTERN
+       #define Q_ASSIGN( a )   = a
+#else
+       #define Q_EXTERN extern
+       #define Q_ASSIGN( a )
 #endif
 
 /* macro version */
 /* general */
 #define MAX_QPATH               64
 
-#define MAX_IMAGES              512
+#define MAX_IMAGES              2048
 #define DEFAULT_IMAGE           "*default"
 
-#define MAX_MODELS              512
+#define MAX_MODELS              2048
 
 #define DEF_BACKSPLASH_FRACTION 0.05f   /* 5% backsplash by default */
 #define DEF_BACKSPLASH_DISTANCE 23
 #define C_ANTIPORTAL            0x00004000  /* like hint, but doesn't generate portals */
 #define C_SKIP                  0x00008000  /* like hint, but skips this face (doesn't split bsp) */
 #define C_NOMARKS               0x00010000  /* no decals */
+#define C_OB                    0x00020000  /* skip -noob for this */
 #define C_DETAIL                0x08000000  /* THIS MUST BE THE SAME AS IN RADIANT! */
 
 
+/* new tex surface flags, like Smokin'Guns */
+#define TEX_SURF_METAL             0x00001000
+#define TEX_SURF_WOOD              0x00080000
+#define TEX_SURF_CLOTH             0x00100000
+#define TEX_SURF_DIRT              0x00200000
+#define TEX_SURF_GLASS             0x00400000
+#define TEX_SURF_PLANT             0x00800000
+#define TEX_SURF_SAND              0x01000000
+#define TEX_SURF_SNOW              0x02000000
+#define TEX_SURF_STONE             0x04000000
+#define TEX_SURF_WATER             0x08000000
+#define TEX_SURF_GRASS             0x10000000
+#define TEX_SURF_BREAKABLE         0x20000000
+
+
 /* shadow flags */
 #define WORLDSPAWN_CAST_SHADOWS 1
 #define WORLDSPAWN_RECV_SHADOWS 1
@@ -380,7 +395,7 @@ typedef struct
 bspShader_t;
 
 
-/* planes x^1 is allways the opposite of plane x */
+/* planes x^1 is always the opposite of plane x */
 
 typedef struct
 {
@@ -394,7 +409,7 @@ typedef struct
 {
        int planeNum;
        int children[ 2 ];              /* negative numbers are -(leafs+1), not nodes */
-       int mins[ 3 ];                  /* for frustom culling */
+       int mins[ 3 ];                  /* for frustum culling */
        int maxs[ 3 ];
 }
 bspNode_t;
@@ -545,6 +560,13 @@ typedef enum
 }
 miniMapMode_t;
 
+typedef enum
+{
+       MINIMAP_SIDECAR_NONE,
+       MINIMAP_SIDECAR_UNVANQUISHED
+}
+miniMapSidecarFormat_t;
+
 typedef struct game_s
 {
        char                *arg;                           /* -game matches this */
@@ -555,6 +577,7 @@ typedef struct game_s
        int maxLMSurfaceVerts;                              /* default maximum meta surface verts */
        int maxSurfaceVerts;                                /* default maximum surface verts */
        int maxSurfaceIndexes;                              /* default maximum surface indexes (tris * 3) */
+       qboolean texFile;                                   /* enable per shader prefix surface flags and .tex file */
        qboolean emitFlares;                                /* when true, emit flare surfaces */
        char                *flareShader;                   /* default flare shader (MUST BE SET) */
        qboolean wolfLight;                                 /* when true, lights work like wolf q3map  */
@@ -580,6 +603,7 @@ typedef struct game_s
        qboolean miniMapKeepAspect;                         /* minimap keep aspect ratio by letterboxing */
        miniMapMode_t miniMapMode;                          /* minimap mode */
        char                *miniMapNameFormat;             /* minimap name format */
+       miniMapSidecarFormat_t miniMapSidecarFormat;        /* minimap sidecar format */
        char                *bspIdent;                      /* 4-letter bsp file prefix */
        int bspVersion;                                     /* bsp version to use */
        qboolean lumpSwap;                                  /* cod-style len/ofs order */
@@ -786,7 +810,7 @@ typedef struct shaderInfo_s
        sun_t               *sun;                           /* ydnar */
 
        vec3_t color;                                       /* normalized color */
-       vec3_t averageColor;
+       vec4_t averageColor;
        byte lightStyle;
 
        /* vortex: per-surface floodlight */
@@ -1000,7 +1024,7 @@ typedef enum
 }
 surfaceType_t;
 
-char            *surfaceTypes[ NUM_SURFACE_TYPES ]
+Q_EXTERN char *surfaceTypes[ NUM_SURFACE_TYPES ]
 #ifndef MAIN_C
 ;
 #else
@@ -1514,6 +1538,7 @@ 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                         ShiftBSPMain( int argc, char **argv );
 
 /* help.c */
 void                        HelpMain(const char* arg);
@@ -1605,6 +1630,7 @@ void                        MakeNormalVectors( vec3_t forward, vec3_t right, vec
 /* map.c */
 void                        LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups );
 int                         FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points );
+qboolean                                       PlaneEqual( plane_t *p, vec3_t normal, vec_t dist );
 int                         PlaneTypeForNormal( vec3_t normal );
 void                        AddBrushBevels( void );
 brush_t                     *FinishBrush( qboolean noCollapseGroups );
@@ -1690,7 +1716,7 @@ void                        PicoPrintFunc( int level, const char *str );
 void                        PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize );
 picoModel_t                 *FindModel( const char *name, int frame );
 picoModel_t                 *LoadModel( const char *name, int frame );
-void                        InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle );
+void                        InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle, float clipDepth );
 void                        AddTriangleModels( entity_t *e );
 
 
@@ -1812,6 +1838,7 @@ void                        RadFreeLights();
 
 /* light_ydnar.c */
 void                        ColorToBytes( const float *color, byte *colorBytes, float scale );
+void                        ColorToBytesNonZero( const float *color, byte *colorBytes, float scale );
 void                        SmoothNormals( void );
 
 void                        MapRawLightmap( int num );
@@ -1852,7 +1879,7 @@ int                         ImportLightmapsMain( int argc, char **argv );
 
 void                        SetupSurfaceLightmaps( void );
 void                        StitchSurfaceLightmaps( void );
-void                        StoreSurfaceLightmaps( qboolean fastAllocate );
+void                        StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal );
 
 
 /* exportents.c */
@@ -1905,9 +1932,15 @@ int                         CopyLump_Allocate( bspHeader_t *header, int lump, vo
 void                        AddLump( FILE *file, bspHeader_t *header, int lumpNum, const void *data, int length );
 
 void                        LoadBSPFile( const char *filename );
+void                        PartialLoadBSPFile( const char *filename );
 void                        WriteBSPFile( const char *filename );
 void                        PrintBSPFileSizes( void );
 
+void                        WriteTexFile( char *name );
+void                        LoadSurfaceFlags( char *filename );
+int                         GetSurfaceParm( const char *tex );
+void                        RestoreSurfaceFlags( char *filename );
+
 epair_t                     *ParseEPair( void );
 void                        ParseEntities( void );
 void                        UnparseEntities( void );
@@ -1927,6 +1960,8 @@ void InjectCommandLine( char **argv, int beginArgs, int endArgs );
 /* bspfile_ibsp.c */
 void                        LoadIBSPFile( const char *filename );
 void                        WriteIBSPFile( const char *filename );
+void                                           PartialLoadIBSPFile( const char *filename );
+
 
 
 /* bspfile_rbsp.c */
@@ -1941,14 +1976,6 @@ void                        WriteRBSPFile( const char *filename );
 
    ------------------------------------------------------------------------------- */
 
-#ifdef MAIN_C
-       #define Q_EXTERN
-       #define Q_ASSIGN( a )   = a
-#else
-       #define Q_EXTERN extern
-       #define Q_ASSIGN( a )
-#endif
-
 /* game support */
 Q_EXTERN game_t games[]
 #ifndef MAIN_C
@@ -1958,21 +1985,31 @@ 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_nexuiz.h" /* must be after game_quake3.h as they share defines! */
+       ,
+                                                               #include "game_oa.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_q3rally.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_quakelive.h" /* must be after game_quake3.h as they share defines! */
+       ,
+                                                               #include "game_reaction.h" /* must be after game_quake3.h */
+       ,
+                                                               #include "game_smokinguns.h" /* must be after game_quake3.h */
        ,
                                                                #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_wop.h" /* must 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_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"
        ,
@@ -1980,17 +2017,19 @@ 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 */
        ,
-                                                               #include "game_reaction.h" /* must be after game_quake3.h */
+                                                               #include "game_warsow.h" /* must be after game_qfusion.h as they share defines! */
        ,
-                                                               #include "game_darkplaces.h"    /* vortex: darkplaces q1 engine */
+                                                               #include "game_warfork.h" /* must be after game_qfusion.h as they share defines! */
        ,
-                                                               #include "game_dq.h"    /* vortex: deluxe quake game ( darkplaces q1 engine) */
+                                                               #include "game_darkplaces.h" /* darkplaces q1 engine */
+       ,
+                                                               #include "game_dq.h" /* deluxe quake game ( darkplaces q1 engine) */
        ,
                                                                #include "game_prophecy.h"  /* vortex: prophecy game ( darkplaces q1 engine) */
        ,
@@ -2021,9 +2060,11 @@ Q_EXTERN qboolean warnImage Q_ASSIGN( qtrue );
 /* ydnar: sinusoid samples */
 Q_EXTERN float jitters[ MAX_JITTERS ];
 
+/*can't code*/
+Q_EXTERN qboolean doingBSP Q_ASSIGN( qfalse );
 
 /* commandline arguments */
-Q_EXTERN qboolean verbose;
+Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
 Q_EXTERN qboolean verboseEntities Q_ASSIGN( qfalse );
 Q_EXTERN qboolean force Q_ASSIGN( qfalse );
 Q_EXTERN qboolean infoMode Q_ASSIGN( qfalse );
@@ -2061,12 +2102,15 @@ Q_EXTERN qboolean emitFlares Q_ASSIGN( qfalse );
 Q_EXTERN qboolean debugSurfaces Q_ASSIGN( qfalse );
 Q_EXTERN qboolean debugInset Q_ASSIGN( qfalse );
 Q_EXTERN qboolean debugPortals Q_ASSIGN( qfalse );
+Q_EXTERN qboolean debugClip Q_ASSIGN( qfalse );                        /* debug model autoclipping */
+Q_EXTERN float clipDepthGlobal Q_ASSIGN( 2.0f );
 Q_EXTERN qboolean lightmapTriangleCheck Q_ASSIGN( qfalse );
 Q_EXTERN qboolean lightmapExtraVisClusterNudge Q_ASSIGN( qfalse );
 Q_EXTERN qboolean lightmapFill Q_ASSIGN( qfalse );
 Q_EXTERN int metaAdequateScore Q_ASSIGN( -1 );
 Q_EXTERN int metaGoodScore Q_ASSIGN( -1 );
 Q_EXTERN float metaMaxBBoxDistance Q_ASSIGN( -1 );
+Q_EXTERN qboolean noob Q_ASSIGN( qfalse );
 
 #if Q3MAP2_EXPERIMENTAL_SNAP_NORMAL_FIX
 // Increasing the normalEpsilon to compensate for new logic in SnapNormal(), where
@@ -2104,6 +2148,8 @@ Q_EXTERN int blockSize[ 3 ]                                 /* should be the sam
        = { 1024, 1024, 1024 };
 #endif
 
+Q_EXTERN char EnginePath[ 1024 ];
+
 Q_EXTERN char name[ 1024 ];
 Q_EXTERN char source[ 1024 ];
 Q_EXTERN char outbase[ 32 ];
@@ -2196,6 +2242,7 @@ Q_EXTERN char inbase[ MAX_QPATH ];
 Q_EXTERN char globalCelShader[ MAX_QPATH ];
 
 Q_EXTERN float farPlaneDist;                /* rr2do2, rf, mre, ydnar all contributed to this one... */
+Q_EXTERN int farPlaneDistMode;
 
 Q_EXTERN int numportals;
 Q_EXTERN int portalclusters;
@@ -2242,6 +2289,7 @@ Q_EXTERN qboolean keepLights Q_ASSIGN( qfalse );
 Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
 Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
 Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse );
+Q_EXTERN qboolean nolm Q_ASSIGN( qfalse );
 Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse );
 
 Q_EXTERN qboolean noTrace Q_ASSIGN( qfalse );
@@ -2307,6 +2355,8 @@ Q_EXTERN qboolean debugAxis Q_ASSIGN( qfalse );
 Q_EXTERN qboolean debugCluster Q_ASSIGN( qfalse );
 Q_EXTERN qboolean debugOrigin Q_ASSIGN( qfalse );
 Q_EXTERN qboolean lightmapBorder Q_ASSIGN( qfalse );
+//1=warn; 0=warn if lmsize>128
+Q_EXTERN int debugSampleSize Q_ASSIGN( 0 );
 
 /* longest distance across the map */
 Q_EXTERN float maxMapDistance Q_ASSIGN( 0 );
@@ -2317,6 +2367,8 @@ Q_EXTERN float spotScale Q_ASSIGN( 7500.0f );
 Q_EXTERN float areaScale Q_ASSIGN( 0.25f );
 Q_EXTERN float skyScale Q_ASSIGN( 1.0f );
 Q_EXTERN float bounceScale Q_ASSIGN( 0.25f );
+Q_EXTERN float bounceColorRatio Q_ASSIGN( 1.0f );
+Q_EXTERN float vertexglobalscale Q_ASSIGN( 1.0f );
 
 /* jal: alternative angle attenuation curve */
 Q_EXTERN qboolean lightAngleHL Q_ASSIGN( qfalse );
@@ -2335,6 +2387,8 @@ Q_EXTERN float texturesRGB Q_ASSIGN( qfalse );
 Q_EXTERN float colorsRGB Q_ASSIGN( qfalse );
 Q_EXTERN float lightmapExposure Q_ASSIGN( 0.0f );
 Q_EXTERN float lightmapCompensate Q_ASSIGN( 1.0f );
+Q_EXTERN float lightmapBrightness Q_ASSIGN( 1.0f );
+Q_EXTERN float lightmapContrast Q_ASSIGN( 1.0f );
 
 /* ydnar: for runtime tweaking of falloff tolerance */
 Q_EXTERN float falloffTolerance Q_ASSIGN( 1.0f );
@@ -2554,28 +2608,46 @@ Q_EXTERN bspFog_t bspFogs[ MAX_MAP_FOGS ];
 Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
 Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
 
-#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
+// Used for tex file support, Smokin'Guns globals
+Q_EXTERN qboolean compile_map;
+
+#define _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, fillWithZeros ) \
        do \
        { \
+               int prevAllocated = allocated; \
                if ( reqitem >= allocated )     \
                { \
                        if ( allocated == 0 ) { \
-                               allocated = def; } \
+                               allocated = def; \
+                       } \
                        while ( reqitem >= allocated && allocated )     \
+                       { \
                                allocated *= 2; \
+                       } \
                        if ( !allocated || allocated > 2147483647 / (int)sizeof( *ptr ) ) \
                        { \
                                Error( #ptr " over 2 GB" ); \
                        } \
                        ptr = realloc( ptr, sizeof( *ptr ) * allocated ); \
                        if ( !ptr ) { \
-                               Error( #ptr " out of memory" ); } \
+                               Error( #ptr " out of memory" ); \
+                       } \
+                       if ( fillWithZeros ) \
+                       { \
+                               memset( ptr + ( sizeof( *ptr ) * prevAllocated ), 0 , sizeof( *ptr ) * ( allocated - prevAllocated ) ); \
+                       } \
                } \
        } \
        while ( 0 )
 
+#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, qfalse )
+
+#define AUTOEXPAND_BY_REALLOC0( ptr, reqitem, allocated, def ) _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, qtrue )
+
 #define AUTOEXPAND_BY_REALLOC_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC( bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def )
 
+#define AUTOEXPAND_BY_REALLOC0_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC0( 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 )