]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
q3map2: Smokin'Guns 1.2.1 flavour
authorTequila <tequila@smokin-guns.org>
Tue, 22 Jan 2013 10:28:39 +0000 (11:28 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 1 Jun 2019 21:08:17 +0000 (23:08 +0200)
- Imported old q3map2 modifications by spoon from the v0.0.1 q3map2 for WesternQuake3
- Added support for lava content making dynamite explodes and molotov burns
- Added support for "-game smokinguns" option
- Added SMOKINGUNS define in CPPDEFINES so q3map2 builds with Smokin'Guns modifications
- Updated Smokin'Guns map pack to use "-game smokinguns" option with q3map2 tool

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 f410226f9cb731ec1accb8f84163d5cc3b6b5062..0f55316498019126637409ffb2b268ddb0da8a0b 100644 (file)
@@ -2104,6 +2104,23 @@ void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
 
 
 
 
 
 
+#ifdef SMOKINGUNS
+//added by spoon to get back the changed surfaceflags
+void LoadSurfaceFlags(char *filename){
+       int i;
+
+       for(i=0; i<numBSPShaders;i++){
+               shaderInfo_t    *si;
+
+               si = ShaderInfoForShader( bspShaders[i].shader );
+
+               bspShaders[i].surfaceFlags = si->surfaceFlags;
+       }
+}
+#endif
+
+
+
 /*
    LightMain()
    main routine for light processing
 /*
    LightMain()
    main routine for light processing
index 3a82d2cb614ab1d157a00d9896e5e78c7025e603..0eec34429c6bf5b7404a9b7365a7c7d984a29984 100644 (file)
@@ -277,6 +277,9 @@ int main( int argc, char **argv ){
 
        /* ydnar: otherwise create a bsp */
        else{
 
        /* ydnar: otherwise create a bsp */
        else{
+#ifdef SMOKINGUNS
+               compile_map = qtrue;
+#endif
                r = BSPMain( argc, argv );
        }
 
                r = BSPMain( argc, argv );
        }
 
index 0d70d39d296ce981ae20e1794094bd025d83cd74..5593b86aff10b6b5ee59cf4a824f98cd836f9d51 100644 (file)
 #define C_DETAIL                0x08000000  /* THIS MUST BE THE SAME AS IN RADIANT! */
 
 
 #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
+
+
 /* shadow flags */
 #define WORLDSPAWN_CAST_SHADOWS 1
 #define WORLDSPAWN_RECV_SHADOWS 1
 /* shadow flags */
 #define WORLDSPAWN_CAST_SHADOWS 1
 #define WORLDSPAWN_RECV_SHADOWS 1
@@ -1898,6 +1915,13 @@ void                        LoadBSPFile( const char *filename );
 void                        WriteBSPFile( const char *filename );
 void                        PrintBSPFileSizes( void );
 
 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
+
 epair_t                     *ParseEPair( void );
 void                        ParseEntities( void );
 void                        UnparseEntities( void );
 epair_t                     *ParseEPair( void );
 void                        ParseEntities( void );
 void                        UnparseEntities( void );
@@ -1977,6 +2001,10 @@ Q_EXTERN game_t games[]
                                                                #include "game_qfusion.h"   /* qfusion game */
        ,
                                                                #include "game_reaction.h" /* must be after game_quake3.h */
                                                                #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_darkplaces.h"    /* vortex: darkplaces q1 engine */
        ,
        ,
                                                                #include "game_darkplaces.h"    /* vortex: darkplaces q1 engine */
        ,
@@ -2544,6 +2572,11 @@ Q_EXTERN bspFog_t bspFogs[ MAX_MAP_FOGS ];
 Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
 Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
 
 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
+
 #define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
        do \
        { \
 #define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
        do \
        { \
index 584ed68f87a81488be7c2d4540d299472e640b4d..66a46addaf038e58c8c1ce1520505da7a6b4dbc1 100644 (file)
@@ -1181,6 +1181,14 @@ int VisMain( int argc, char **argv ){
        Sys_Printf( "Loading %s\n", source );
        LoadBSPFile( source );
 
        Sys_Printf( "Loading %s\n", source );
        LoadBSPFile( source );
 
+#ifdef SMOKINGUNS
+       StripExtension (source);
+       strcat (source, ".tex");
+       LoadSurfaceFlags(source);
+       StripExtension (source);
+       strcat (source, ".bsp");
+#endif
+
        /* load the portal file */
        if (!portalFilePath[0]) {
                sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
        /* load the portal file */
        if (!portalFilePath[0]) {
                sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
@@ -1223,6 +1231,12 @@ int VisMain( int argc, char **argv ){
                remove( portalFilePath );
        }
 
                remove( portalFilePath );
        }
 
+#ifdef SMOKINGUNS
+       StripExtension (source);
+       WriteTexFile(source);
+       DefaultExtension (source, ".bsp");
+#endif
+
        /* write the bsp file */
        Sys_Printf( "Writing %s\n", source );
        WriteBSPFile( source );
        /* write the bsp file */
        Sys_Printf( "Writing %s\n", source );
        WriteBSPFile( source );
index 4b3e53fe8ce4baaf83cb599da3df60fbcc3511c8..9cfa577baeb8459de4e28c3aae6e6feaf9b6a7ab 100644 (file)
 /* dependencies */
 #include "q3map2.h"
 
 /* dependencies */
 #include "q3map2.h"
 
+#ifdef SMOKINGUNS
+#define NUM_PREFIXINFO 11 //very important
+
+//prefixInfo-stats
+typedef struct {
+       char    *name;
+       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},
+};
+
+//Added by Spoon to recognize surfaceparms by shadernames
+int GetSurfaceParm(const char *tex){
+       char surf[MAX_QPATH], tex2[MAX_QPATH];
+       int     i, j = 0;
+
+       strcpy(tex2, tex);
+
+       //find last dir
+       for(i = 0; i < 64 && tex2[i] != '\0'; i++){
+               if(tex2[i] == '\\' || tex2[i] == '/')
+                       j=i+1;
+       }
+
+       strcpy(surf, tex2+j);
+
+       for(i=0; i<10; i++){
+               if(surf[i] == '_')
+                       break;
+       }
+       surf[i] = '\0';
+
+       //Sys_Printf("%s\n", surf);
+
+       for(i=0; i < NUM_PREFIXINFO; i++){
+               if(!Q_stricmp(surf, prefixInfo[i].name)){
+                       return prefixInfo[i].surfaceFlags;
+               }
+       }
+       return 0;
+}
+#endif
+
 
 
 /*
 
 
 /*
@@ -57,12 +113,14 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
        for ( i = 0; i < numBSPShaders; i++ )
        {
                /* ydnar: handle custom surface/content flags */
        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 ( 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 ) ) {
 
                /* compare name */
                if ( !Q_stricmp( shader, bspShaders[ i ].shader ) ) {
@@ -79,15 +137,20 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
        numBSPShaders++;
        strcpy( bspShaders[ i ].shader, shader );
        bspShaders[ i ].surfaceFlags = si->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 */
        bspShaders[ i ].contentFlags = si->contentFlags;
 
        /* handle custom content/surface flags */
+#ifndef SMOKINGUNS
        if ( surfaceFlags != NULL ) {
                bspShaders[ i ].surfaceFlags = *surfaceFlags;
        }
        if ( contentFlags != NULL ) {
                bspShaders[ i ].contentFlags = *contentFlags;
        }
        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' ) {
 
        /* recursively emit any damage shaders */
        if ( si->damageShader != NULL && si->damageShader[ 0 ] != '\0' ) {
@@ -395,6 +458,63 @@ void BeginBSPFile( void ){
 
 
 
 
 
 
+#ifdef SMOKINGUNS
+//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;
+
+       //first parse the tex-file
+       texfile = fopen(filename, "r");
+       if(texfile){
+               fscanf( texfile, "TEXFILE\n%i\n", &numTexInfos);
+               //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]);
+               }
+       } 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);
+       }
+
+       Sys_Printf("Writing %s ...\n", filename);
+       texfile = fopen (filename, "w");
+
+       fprintf( texfile, "TEXFILE\n");
+
+       fprintf( texfile, "%i\n", numBSPShaders);
+       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;
+       }
+       fclose(texfile);
+}
+#endif
+
+
+
 /*
    EndBSPFile()
    finishes a new bsp and writes to disk
 /*
    EndBSPFile()
    finishes a new bsp and writes to disk
@@ -413,6 +533,11 @@ void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surface
                /* write the surface extra file */
                WriteSurfaceExtraFile( surfaceFilePath );
 
                /* write the surface extra file */
                WriteSurfaceExtraFile( surfaceFilePath );
 
+#ifdef SMOKINGUNS
+               //only create tex file if it is the first compile
+               WriteTexFile (source);
+#endif
+
                /* write the bsp */
                Sys_Printf( "Writing %s\n", BSPFilePath );
                WriteBSPFile( BSPFilePath );
                /* write the bsp */
                Sys_Printf( "Writing %s\n", BSPFilePath );
                WriteBSPFile( BSPFilePath );