q3map2: make Smokin'Guns code not requiring a rebuild
authorThomas Debesse <dev@illwieckz.net>
Wed, 1 May 2019 14:16:52 +0000 (16:16 +0200)
committerThomas Debesse <dev@illwieckz.net>
Sat, 1 Jun 2019 21:08:17 +0000 (23:08 +0200)
Not only Smokin'Guns game can now use .tex sidecar file

27 files changed:
tools/quake3/CMakeLists.txt
tools/quake3/q3map2/game__null.h
tools/quake3/q3map2/game_darkplaces.h
tools/quake3/q3map2/game_dq.h
tools/quake3/q3map2/game_ef.h
tools/quake3/q3map2/game_etut.h
tools/quake3/q3map2/game_ja.h
tools/quake3/q3map2/game_jk2.h
tools/quake3/q3map2/game_nexuiz.h
tools/quake3/q3map2/game_prophecy.h
tools/quake3/q3map2/game_qfusion.h
tools/quake3/q3map2/game_quake3.h
tools/quake3/q3map2/game_quakelive.h
tools/quake3/q3map2/game_reaction.h
tools/quake3/q3map2/game_smokinguns.h
tools/quake3/q3map2/game_sof2.h
tools/quake3/q3map2/game_tenebrae.h
tools/quake3/q3map2/game_tremulous.h
tools/quake3/q3map2/game_unvanquished.h
tools/quake3/q3map2/game_wolf.h
tools/quake3/q3map2/game_wolfet.h
tools/quake3/q3map2/game_xonotic.h
tools/quake3/q3map2/light.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/vis.c
tools/quake3/q3map2/writebsp.c

index e0bb898..7ba643b 100644 (file)
@@ -49,6 +49,7 @@ set(q3map2_games
         q3map2/game_quake3.h
         q3map2/game_quakelive.h
         q3map2/game_reaction.h
+        q3map2/game_smokinguns.h
         q3map2/game_sof2.h
         q3map2/game_tenebrae.h
         q3map2/game_tremulous.h
index a8bbec9..a92544b 100644 (file)
@@ -58,6 +58,7 @@
        0,              /* max lightmapped surface verts */
        0,              /* max surface verts */
        0,              /* max surface indexes */
+       qfalse,         /* enable per shader prefix surface flags and .tex file */
        qfalse,         /* flares */
        NULL,           /* default flare shader */
        qfalse,         /* wolf lighting model? */
index 2f998d2..492dd2d 100644 (file)
@@ -49,6 +49,7 @@
        999,                /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 4d691b4..b496334 100644 (file)
@@ -49,6 +49,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 9ef1090..03c9301 100644 (file)
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index f4303f2..de7fad7 100644 (file)
        1024,               /* max lightmapped surface verts */
        1024,               /* max surface verts */
        6144,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index b598a09..cce3260 100644 (file)
@@ -62,6 +62,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qtrue,              /* flares */
        "gfx/misc/flare",   /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 69c80ed..a667777 100644 (file)
@@ -59,6 +59,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qtrue,              /* flares */
        "gfx/misc/flare",   /* default flare shader */
        qfalse,             /* wolf lighting model? */
index f299f4d..b6fee7f 100644 (file)
@@ -58,6 +58,7 @@
        999,                /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index a5e11cb..4a156a8 100644 (file)
@@ -49,6 +49,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 5cd5b03..4950612 100644 (file)
        65535,              /* max lightmapped surface verts */
        65535,              /* max surface verts */
        393210,             /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 66b4028..2b3302a 100644 (file)
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 3f7a29d..b4f876f 100644 (file)
@@ -71,6 +71,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 2474274..6163b39 100644 (file)
@@ -79,6 +79,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 78be8ba..296803c 100644 (file)
@@ -1,30 +1,30 @@
 /* -------------------------------------------------------------------------------
 
-   Copyright (C) 1999-2007 id Software, Inc. and contributors.
-   For a list of contributors, see the accompanying CONTRIBUTORS file.
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-   This file is part of GtkRadiant.
+This file is part of GtkRadiant.
 
-   GtkRadiant is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
+GtkRadiant is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
-   GtkRadiant is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+GtkRadiant is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
-   along with GtkRadiant; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+You should have received a copy of the GNU General Public License
+along with GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-   ----------------------------------------------------------------------------------
+----------------------------------------------------------------------------------
 
-   This code has been altered significantly from its original form, to support
-   several games based on the Quake III Arena engine, in the form of "Q3Map2."
+This code has been altered significantly from its original form, to support
+several games based on the Quake III Arena engine, in the form of "Q3Map2."
 
-   ------------------------------------------------------------------------------- */
+------------------------------------------------------------------------------- */
 
 
 
 
 /* -------------------------------------------------------------------------------
 
-content and surface flags
+content and surface flags - also uses defines from game_quake3.h
 
 ------------------------------------------------------------------------------- */
 
 /* game flags */
 
-// Support content making dynamite explodes and molotov burns
-#define Q_CONT_EXPLOSIVE               2
-#define Q_CONT_FLAMMABLE               4
-#define Q_CONT_BURNING_SOLID   Q_CONT_SOLID|Q_CONT_EXPLOSIVE|Q_CONT_FLAMMABLE
+// support content making dynamite explodes and molotov burns
+#define SG_CONT_EXPLOSIVE              2
+#define SG_CONT_FLAMMABLE              4
+#define SG_CONT_BURNING_SOLID  (Q_CONT_SOLID | SG_CONT_EXPLOSIVE | SG_CONT_FLAMMABLE )
+
+// see q3map2.h for tex surface flags
 
 /* -------------------------------------------------------------------------------
 
@@ -54,25 +56,45 @@ content and surface flags
    ------------------------------------------------------------------------------- */
 
 {
-       "smokinguns",       /* -game x */
-       "smokinguns",       /* default base game data dir */
-       ".smokinguns",      /* unix home sub-dir */
-       "smokinguns",       /* magic path word */
-       "scripts",          /* shader directory */
-       64,                 /* max lightmapped surface verts */
-       999,                /* max surface verts */
-       6000,               /* max surface indexes */
-       qfalse,             /* flares */
-       "flareshader",      /* default flare shader */
-       qfalse,             /* wolf lighting model? */
-       128,                /* lightmap width/height */
-       1.0f,               /* lightmap gamma */
-       1.0f,               /* lightmap compensate */
-       "IBSP",             /* bsp file prefix */
-       46,                 /* bsp file version */
-       qfalse,             /* cod-style lump len/ofs order */
-       LoadIBSPFile,       /* bsp load function */
-       WriteIBSPFile,      /* bsp write function */
+       "smokinguns",           /* -game x */
+       "smokinguns",           /* default base game data dir */
+       ".smokinguns",          /* unix home sub-dir */
+       "smokinguns",           /* magic path word */
+       "scripts",              /* shader directory */
+       1048575,                /* max lightmapped surface verts */
+       1048575,                /* max surface verts */
+       1048575,                /* max surface indexes */
+       qtrue,                  /* enable per shader prefix surface flags and .tex file */
+       qfalse,                 /* flares */
+       "flareshader",          /* default flare shader */
+       qfalse,                 /* wolf lighting model? */
+       128,                    /* lightmap width/height */
+       1.0f,                   /* lightmap gamma */
+       qfalse,                 /* lightmap sRGB */
+       qfalse,                 /* texture sRGB */
+       qfalse,                 /* color sRGB */
+       0.0f,                   /* lightmap exposure */
+       1.0f,                   /* lightmap compensate */
+       1.0f,                   /* lightgrid scale */
+       1.0f,                   /* lightgrid ambient scale */
+       qfalse,                 /* light angle attenuation uses half-lambert curve */
+       qfalse,                 /* disable shader lightstyles hack */
+       qtrue,                  /* keep light entities on bsp */
+       8,                      /* default patchMeta subdivisions tolerance */
+       qfalse,                 /* patch casting enabled */
+       qfalse,                 /* compile deluxemaps */
+       0,                      /* deluxemaps default mode */
+       512,                    /* minimap size */
+       1.0f,                   /* minimap sharpener */
+       0.0f,                   /* minimap border */
+       qtrue,                  /* minimap keep aspect */
+       MINIMAP_MODE_WHITE,     /* minimap mode */
+       "../minimaps/%s.tga",   /* minimap name format */
+       "IBSP",                 /* bsp file prefix */
+       46,                     /* bsp file version */
+       qfalse,                 /* cod-style lump len/ofs order */
+       LoadIBSPFile,           /* bsp load function */
+       WriteIBSPFile,          /* bsp write function */
 
        {
                /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */
@@ -109,7 +131,7 @@ content and surface flags
 
                { "water",          Q_CONT_WATER,               Q_CONT_SOLID,               0,                          0,                          C_LIQUID | C_TRANSLUCENT,   C_SOLID },
                { "slime",          Q_CONT_SLIME,               Q_CONT_SOLID,               0,                          0,                          C_LIQUID | C_TRANSLUCENT,   C_SOLID },
-               { "lava",           Q_CONT_LAVA,                Q_CONT_BURNING_SOLID,       0,                          0,                          C_LIQUID | C_TRANSLUCENT,   C_SOLID },
+               { "lava",           Q_CONT_LAVA,                SG_CONT_BURNING_SOLID,      0,                          0,                          C_LIQUID | C_TRANSLUCENT,   C_SOLID },
 
                { "playerclip",     Q_CONT_PLAYERCLIP,          Q_CONT_SOLID,               0,                          0,                          C_DETAIL | C_TRANSLUCENT,   C_SOLID },
                { "monsterclip",    Q_CONT_MONSTERCLIP,         Q_CONT_SOLID,               0,                          0,                          C_DETAIL | C_TRANSLUCENT,   C_SOLID },
@@ -135,24 +157,22 @@ content and surface flags
                { "dust",           0,                          0,                          Q_SURF_DUST,                0,                          0,                          0 },
 
                /* materials */
-               { "metal",                      0,                                                      0,                                                      Q_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },
-               { "wood",                       0,                                                      0,                                                      Q_SURF_WOOD,                            0,                                                      0,                                                      0 },
-               { "cloth",                      0,                                                      0,                                                      Q_SURF_CLOTH,                           0,                                                      0,                                                      0 },
-               { "dirt",                       0,                                                      0,                                                      Q_SURF_DIRT,                            0,                                                      0,                                                      0 },
-               { "glass",                      0,                                                      0,                                                      Q_SURF_GLASS,                           0,                                                      0,                                                      0 },
-               { "plant",                      0,                                                      0,                                                      Q_SURF_PLANT,                           0,                                                      0,                                                      0 },
-               { "sand",                       0,                                                      0,                                                      Q_SURF_SAND,                            0,                                                      0,                                                      0 },
-               { "snow",                       0,                                                      0,                                                      Q_SURF_SNOW,                            0,                                                      0,                                                      0 },
-               { "stone",                      0,                                                      0,                                                      Q_SURF_STONE,                           0,                                                      0,                                                      0 },
-               { "water",                      0,                                                      0,                                                      Q_SURF_WATER,                           0,                                                      0,                                                      0 },
-               { "grass",                      0,                                                      0,                                                      Q_SURF_GRASS,                           0,                                                      0,                                                      0 }, 
+               { "metal",          0,                          0,                          TEX_SURF_METAL,        0,                          0,                          0 },
+               { "wood",           0,                          0,                          TEX_SURF_WOOD,              0,                          0,                          0 },
+               { "cloth",          0,                          0,                          TEX_SURF_CLOTH,             0,                          0,                          0 },
+               { "dirt",           0,                          0,                          TEX_SURF_DIRT,              0,                          0,                          0 },
+               { "glass",          0,                          0,                          TEX_SURF_GLASS,             0,                          0,                          0 },
+               { "plant",          0,                          0,                          TEX_SURF_PLANT,             0,                          0,                          0 },
+               { "sand",           0,                          0,                          TEX_SURF_SAND,              0,                          0,                          0 },
+               { "snow",           0,                          0,                          TEX_SURF_SNOW,              0,                          0,                          0 },
+               { "stone",          0,                          0,                          TEX_SURF_STONE,             0,                          0,                          0 },
+               { "water",          0,                          0,                          TEX_SURF_WATER,             0,                          0,                          0 },
+               { "grass",          0,                          0,                          TEX_SURF_GRASS,             0,                          0,                          0 }, 
 
                /* null */
                { NULL, 0, 0, 0, 0, 0, 0 }
        }
 }
 
-
-
 /* end marker */
 #endif
index 2e72270..fcceb0f 100644 (file)
        64,                     /* max lightmapped surface verts */
        999,                    /* max surface verts */
        6000,                   /* max surface indexes */
+       qfalse,                 /* enable per shader prefix surface flags and .tex file */
        qtrue,                  /* flares */
        "gfx/misc/lens_flare",  /* default flare shader */
        qfalse,                 /* wolf lighting model? */
index 243f756..f9ba57a 100644 (file)
        1024,               /* max lightmapped surface verts */
        1024,               /* max surface verts */
        6144,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 6853e61..a91b4c5 100644 (file)
@@ -65,6 +65,7 @@
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qfalse,             /* wolf lighting model? */
index 75d6804..20c935e 100644 (file)
@@ -67,6 +67,7 @@ game_t struct
        1048575,                /* max lightmapped surface verts */
        1048575,                /* max surface verts */
        1048575,                /* max surface indexes */
+       qfalse,                 /* enable per shader prefix surface flags and .tex file */
        qfalse,                 /* flares */
        "flareshader",          /* default flare shader */
        qfalse,                 /* wolf lighting model? */
index fcfd17e..a29fde2 100644 (file)
        64,                 /* max lightmapped surface verts */
        999,                /* max surface verts */
        6000,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qtrue,              /* wolf lighting model? */
index c783b9a..46746c3 100644 (file)
@@ -61,6 +61,7 @@
        1024,               /* max lightmapped surface verts */
        1024,               /* max surface verts */
        6144,               /* max surface indexes */
+       qfalse,             /* enable per shader prefix surface flags and .tex file */
        qfalse,             /* flares */
        "flareshader",      /* default flare shader */
        qtrue,              /* wolf lighting model? */
index b0ac539..5ffb30f 100644 (file)
@@ -58,6 +58,7 @@
        1048575, /* max lightmapped surface verts */
        1048575, /* max surface verts */
        1048575, /* max surface indexes */
+       qfalse, /* enable per shader prefix surface flags and .tex file */
        qfalse, /* flares */
        "flareshader", /* default flare shader */
        qfalse, /* wolf lighting model? */
index 0f55316..6b60e73 100644 (file)
@@ -2104,20 +2104,23 @@ void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
 
 
 
-#ifdef SMOKINGUNS
-//added by spoon to get back the changed surfaceflags
-void LoadSurfaceFlags(char *filename){
+/*
+   LoadSurfaceFlags()
+   added by spoon to get back the changed surfaceflags
+   from tex file
+*/
+
+void LoadSurfaceFlags( char *filename ) {
        int i;
 
-       for(i=0; i<numBSPShaders;i++){
-               shaderInfo_t    *si;
+       for( i = 0; i < numBSPShaders; i++ ) {
+               shaderInfo_t *si;
 
                si = ShaderInfoForShader( bspShaders[i].shader );
 
-               bspShaders[i].surfaceFlags = si->surfaceFlags;
+               bspShaders[ i ].surfaceFlags = si->surfaceFlags;
        }
 }
-#endif
 
 
 
index 0eec344..90fc5d9 100644 (file)
@@ -276,10 +276,10 @@ int main( int argc, char **argv ){
        }
 
        /* ydnar: otherwise create a bsp */
-       else{
-#ifdef SMOKINGUNS
+       else {
+               /* used to write Smokin'Guns like tex file */
                compile_map = qtrue;
-#endif
+
                r = BSPMain( argc, argv );
        }
 
index 5593b86..38ee560 100644 (file)
 #define C_DETAIL                0x08000000  /* THIS MUST BE THE SAME AS IN RADIANT! */
 
 
-#ifdef SMOKINGUNS
-// new Smokin'Guns surface flags
-#define        Q_SURF_METAL                    0x00001000
-#define        Q_SURF_WOOD                             0x00080000
-#define        Q_SURF_CLOTH                    0x00100000
-#define Q_SURF_DIRT                            0x00200000
-#define        Q_SURF_GLASS                    0x00400000
-#define        Q_SURF_PLANT                    0x00800000
-#define Q_SURF_SAND                            0x01000000
-#define        Q_SURF_SNOW                             0x02000000
-#define        Q_SURF_STONE                    0x04000000
-#define        Q_SURF_WATER                    0x08000000
-#define        Q_SURF_GRASS                    0x10000000
-#define        Q_SURF_BREAKABLE                0x20000000
-#endif
+/* 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 */
@@ -562,6 +560,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  */
@@ -1915,12 +1914,10 @@ void                        LoadBSPFile( const char *filename );
 void                        WriteBSPFile( const char *filename );
 void                        PrintBSPFileSizes( void );
 
-#ifdef SMOKINGUNS
-void                                           WriteTexFile(char *name);
-void                                           LoadSurfaceFlags(char *filename);
-int                                                    GetSurfaceParm(const char *tex);
-void                                           RestoreSurfaceFlags(char *filename);
-#endif
+void                        WriteTexFile( char *name );
+void                        LoadSurfaceFlags( char *filename );
+int                         GetSurfaceParm( const char *tex );
+void                        RestoreSurfaceFlags( char *filename );
 
 epair_t                     *ParseEPair( void );
 void                        ParseEntities( void );
@@ -2001,10 +1998,8 @@ Q_EXTERN game_t games[]
                                                                #include "game_qfusion.h"   /* qfusion game */
        ,
                                                                #include "game_reaction.h" /* must be after game_quake3.h */
-#ifdef SMOKINGUNS
        ,
-                                                               #include "game_smokinguns.h" /* Smokin'Guns */
-#endif
+                                                               #include "game_smokinguns.h" /* must be after game_quake3.h */
        ,
                                                                #include "game_darkplaces.h"    /* vortex: darkplaces q1 engine */
        ,
@@ -2572,10 +2567,8 @@ Q_EXTERN bspFog_t bspFogs[ MAX_MAP_FOGS ];
 Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
 Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
 
-#ifdef SMOKINGUNS
-// Smokin'Guns globals
-Q_EXTERN qboolean                      compile_map;
-#endif
+// Used for tex file support, Smokin'Guns globals
+Q_EXTERN qboolean compile_map;
 
 #define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
        do \
index 66a46ad..7623590 100644 (file)
@@ -1181,13 +1181,15 @@ int VisMain( int argc, char **argv ){
        Sys_Printf( "Loading %s\n", source );
        LoadBSPFile( source );
 
-#ifdef SMOKINGUNS
-       StripExtension (source);
-       strcat (source, ".tex");
-       LoadSurfaceFlags(source);
-       StripExtension (source);
-       strcat (source, ".bsp");
-#endif
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               strcat( source, ".tex" );
+               LoadSurfaceFlags( source );
+               StripExtension( source );
+               strcat( source, ".bsp" );
+       }
 
        /* load the portal file */
        if (!portalFilePath[0]) {
@@ -1231,11 +1233,13 @@ int VisMain( int argc, char **argv ){
                remove( portalFilePath );
        }
 
-#ifdef SMOKINGUNS
-       StripExtension (source);
-       WriteTexFile(source);
-       DefaultExtension (source, ".bsp");
-#endif
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               WriteTexFile( source );
+               DefaultExtension( source, ".bsp" );
+       }
 
        /* write the bsp file */
        Sys_Printf( "Writing %s\n", source );
index 9cfa577..3fbed1c 100644 (file)
@@ -36,8 +36,7 @@
 /* dependencies */
 #include "q3map2.h"
 
-#ifdef SMOKINGUNS
-#define NUM_PREFIXINFO 11 //very important
+
 
 //prefixInfo-stats
 typedef struct {
@@ -45,21 +44,22 @@ typedef struct {
        int             surfaceFlags;
 } prefixInfo_t;
 
-
 static prefixInfo_t prefixInfo[] = {
-       { "metal",      Q_SURF_METAL},
-       { "wood",       Q_SURF_WOOD},
-       { "cloth",      Q_SURF_CLOTH},
-       { "dirt",       Q_SURF_DIRT},
-       { "glass",      Q_SURF_GLASS},
-       { "plant",      Q_SURF_PLANT},
-       { "sand",       Q_SURF_SAND},
-       { "snow",       Q_SURF_SNOW},
-       { "stone",      Q_SURF_STONE},
-       { "water",      Q_SURF_WATER},
-       { "grass",      Q_SURF_GRASS},
+       { "metal",      TEX_SURF_METAL},
+       { "wood",       TEX_SURF_WOOD},
+       { "cloth",      TEX_SURF_CLOTH},
+       { "dirt",       TEX_SURF_DIRT},
+       { "glass",      TEX_SURF_GLASS},
+       { "plant",      TEX_SURF_PLANT},
+       { "sand",       TEX_SURF_SAND},
+       { "snow",       TEX_SURF_SNOW},
+       { "stone",      TEX_SURF_STONE},
+       { "water",      TEX_SURF_WATER},
+       { "grass",      TEX_SURF_GRASS},
 };
 
+#define NUM_PREFIXINFO 11 /* very important */
+
 //Added by Spoon to recognize surfaceparms by shadernames
 int GetSurfaceParm(const char *tex){
        char surf[MAX_QPATH], tex2[MAX_QPATH];
@@ -67,7 +67,7 @@ int GetSurfaceParm(const char *tex){
 
        strcpy(tex2, tex);
 
-       //find last dir
+       /* find last dir */
        for(i = 0; i < 64 && tex2[i] != '\0'; i++){
                if(tex2[i] == '\\' || tex2[i] == '/')
                        j=i+1;
@@ -81,7 +81,7 @@ int GetSurfaceParm(const char *tex){
        }
        surf[i] = '\0';
 
-       //Sys_Printf("%s\n", surf);
+       /* Sys_Printf("%s\n", surf); */
 
        for(i=0; i < NUM_PREFIXINFO; i++){
                if(!Q_stricmp(surf, prefixInfo[i].name)){
@@ -90,7 +90,6 @@ int GetSurfaceParm(const char *tex){
        }
        return 0;
 }
-#endif
 
 
 
@@ -112,15 +111,17 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
        /* try to find an existing shader */
        for ( i = 0; i < numBSPShaders; i++ )
        {
-               /* ydnar: handle custom surface/content flags */
-#ifndef SMOKINGUNS
-               if ( surfaceFlags != NULL && bspShaders[ i ].surfaceFlags != *surfaceFlags ) {
-                       continue;
-               }
-               if ( contentFlags != NULL && bspShaders[ i ].contentFlags != *contentFlags ) {
-                       continue;
+               /* if not Smokin'Guns like tex file */
+               if ( !game->texFile )
+               {
+                       /* ydnar: handle custom surface/content flags */
+                       if ( surfaceFlags != NULL && bspShaders[ i ].surfaceFlags != *surfaceFlags ) {
+                               continue;
+                       }
+                       if ( contentFlags != NULL && bspShaders[ i ].contentFlags != *contentFlags ) {
+                               continue;
+                       }
                }
-#endif
 
                /* compare name */
                if ( !Q_stricmp( shader, bspShaders[ i ].shader ) ) {
@@ -137,20 +138,26 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
        numBSPShaders++;
        strcpy( bspShaders[ i ].shader, shader );
        bspShaders[ i ].surfaceFlags = si->surfaceFlags;
-#ifdef SMOKINGUNS
-       bspShaders[ i ].surfaceFlags |= GetSurfaceParm(si->shader);
-#endif
-       bspShaders[ i ].contentFlags = si->contentFlags;
 
-       /* handle custom content/surface flags */
-#ifndef SMOKINGUNS
-       if ( surfaceFlags != NULL ) {
-               bspShaders[ i ].surfaceFlags = *surfaceFlags;
+       if ( game->texFile )
+       {
+               /* Smokin'Guns like tex file */
+               bspShaders[ i ].surfaceFlags |= GetSurfaceParm(si->shader);
        }
-       if ( contentFlags != NULL ) {
-               bspShaders[ i ].contentFlags = *contentFlags;
+
+       bspShaders[ i ].contentFlags = si->contentFlags;
+
+       /* if not Smokin'Guns like tex file */
+       if ( !game->texFile )
+       {
+               /* handle custom content/surface flags */
+               if ( surfaceFlags != NULL ) {
+                       bspShaders[ i ].surfaceFlags = *surfaceFlags;
+               }
+               if ( contentFlags != NULL ) {
+                       bspShaders[ i ].contentFlags = *contentFlags;
+               }
        }
-#endif
 
        /* recursively emit any damage shaders */
        if ( si->damageShader != NULL && si->damageShader[ 0 ] != '\0' ) {
@@ -458,60 +465,76 @@ void BeginBSPFile( void ){
 
 
 
-#ifdef SMOKINGUNS
-//added by spoon to get back the changed surfaceflags
-void RestoreSurfaceFlags(char *filename){
+/*
+   RestoreSurfaceFlags()
+   read Smokin'Guns like tex file
+   added by spoon to get back the changed surfaceflags
+ */
+
+void RestoreSurfaceFlags( char *filename ) {
        int i;
-       FILE    *texfile;
-       int             surfaceFlags[MAX_MAP_DRAW_SURFS];
-       int             numTexInfos;
+       FILE *texfile;
+       int surfaceFlags[ MAX_MAP_DRAW_SURFS ];
+       int numTexInfos;
+
+       /* first parse the tex file */
+       texfile = fopen( filename, "r" );
 
-       //first parse the tex-file
-       texfile = fopen(filename, "r");
-       if(texfile){
-               fscanf( texfile, "TEXFILE\n%i\n", &numTexInfos);
-               //Sys_Printf("%i\n", numTexInfos);
+       if ( texfile ) {
+               fscanf( texfile, "TEXFILE\n%i\n", &numTexInfos );
 
-               for(i=0; i<numTexInfos; i++){
+               /* Sys_Printf( "%i\n", numTexInfos ); */
+
+               for ( i = 0; i < numTexInfos; i++ ) {
                        vec3_t color;
-                       fscanf( texfile, "%i %f %f %f\n", &surfaceFlags[i],
-                               &color[0], &color[1], &color[2]);
-                       bspShaders[i].surfaceFlags = surfaceFlags[i];
-                       //Sys_Printf("%i\n", surfaceFlags[i]);
+
+                       fscanf( texfile, "%i %f %f %f\n", &surfaceFlags[ i ],
+                               &color[ 0 ], &color[ 1 ], &color[ 2 ]);
+
+                       bspShaders[ i ].surfaceFlags = surfaceFlags[ i ];
+
+                       /* Sys_Printf( "%i\n", surfaceFlags[ i ] ); */
                }
-       } else
+       } else {
                Sys_Printf("couldn't find %s not tex-file is now writed without surfaceFlags!\n", filename);
+       }
 }
 
-void WriteTexFile( char* name){
-       FILE                    *texfile;
-       char                    filename[1024];
-       int                             i;
 
-       sprintf (filename, "%s.tex", name);
 
-       if(!compile_map){
-               RestoreSurfaceFlags(filename);
+/*
+   WriteTexFile()
+   write Smokin'Guns like tex file
+   added by spoon
+ */
+
+void WriteTexFile( char* filename ) {
+       FILE *texfile;
+       int i;
+
+       if ( !compile_map ) {
+               RestoreSurfaceFlags( filename );
        }
 
-       Sys_Printf("Writing %s ...\n", filename);
-       texfile = fopen (filename, "w");
+       Sys_Printf( "Writing %s ...\n", filename );
 
-       fprintf( texfile, "TEXFILE\n");
+       texfile = fopen ( filename, "w" );
 
-       fprintf( texfile, "%i\n", numBSPShaders);
-       for ( i = 0 ; i < numBSPShaders ; i++ ) {
-               shaderInfo_t    *se = ShaderInfoForShader(bspShaders[i].shader);
+       fprintf( texfile, "TEXFILE\n" );
+
+       fprintf( texfile, "%i\n", numBSPShaders );
 
-               fprintf( texfile, "\n%i %f %f %f", bspShaders[i].surfaceFlags,
-                       se->color[0], se->color[1], se->color[2]);
+       for ( i = 0 ; i < numBSPShaders ; i++ ) {
+               shaderInfo_t *se = ShaderInfoForShader( bspShaders[ i ].shader );
 
+               fprintf( texfile, "\n%i %f %f %f", bspShaders[ i ].surfaceFlags,
+                       se->color[ 0 ], se->color[ 1 ], se->color[ 2 ] );
 
-               bspShaders[i].surfaceFlags = i;
+               bspShaders[ i ].surfaceFlags = i;
        }
-       fclose(texfile);
+
+       fclose( texfile );
 }
-#endif
 
 
 
@@ -533,10 +556,16 @@ void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surface
                /* write the surface extra file */
                WriteSurfaceExtraFile( surfaceFilePath );
 
-#ifdef SMOKINGUNS
-               //only create tex file if it is the first compile
-               WriteTexFile (source);
-#endif
+               if ( game->texFile )
+               {
+                       char basename[ 1024 ];  
+                       char filename[ 1024 ];
+                       strncpy( basename, BSPFilePath, sizeof(basename) );
+                       sprintf( filename, "%s.tex", basename );
+
+                       /* only create tex file if it is the first compile */
+                       WriteTexFile( filename );
+               }
 
                /* write the bsp */
                Sys_Printf( "Writing %s\n", BSPFilePath );