From: Tequila Date: Tue, 22 Jan 2013 10:28:39 +0000 (+0100) Subject: q3map2: Smokin'Guns 1.2.1 flavour X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3289ca3b9bd1f5563d70f1b48983d2aae66df9d5;p=xonotic%2Fnetradiant.git q3map2: Smokin'Guns 1.2.1 flavour - 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 --- diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index f410226f..0f553164 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -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; isurfaceFlags; + } +} +#endif + + + /* LightMain() main routine for light processing diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 3a82d2cb..0eec3442 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -277,6 +277,9 @@ int main( int argc, char **argv ){ /* ydnar: otherwise create a bsp */ else{ +#ifdef SMOKINGUNS + compile_map = qtrue; +#endif r = BSPMain( argc, argv ); } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 0d70d39d..5593b86a 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -167,6 +167,23 @@ #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 @@ -1898,6 +1915,13 @@ 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 + 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 */ +#ifdef SMOKINGUNS + , + #include "game_smokinguns.h" /* Smokin'Guns */ +#endif , #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 ]; +#ifdef SMOKINGUNS +// Smokin'Guns globals +Q_EXTERN qboolean compile_map; +#endif + #define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \ do \ { \ diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index 584ed68f..66a46add 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -1181,6 +1181,14 @@ 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 + /* 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 ); } +#ifdef SMOKINGUNS + StripExtension (source); + WriteTexFile(source); + DefaultExtension (source, ".bsp"); +#endif + /* write the bsp file */ Sys_Printf( "Writing %s\n", source ); WriteBSPFile( source ); diff --git a/tools/quake3/q3map2/writebsp.c b/tools/quake3/q3map2/writebsp.c index 4b3e53fe..9cfa577b 100644 --- a/tools/quake3/q3map2/writebsp.c +++ b/tools/quake3/q3map2/writebsp.c @@ -36,6 +36,62 @@ /* 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 */ +#ifndef SMOKINGUNS 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 ) ) { @@ -79,15 +137,20 @@ 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 ( contentFlags != NULL ) { bspShaders[ i ].contentFlags = *contentFlags; } +#endif /* 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; icolor[0], se->color[1], se->color[2]); + + + bspShaders[i].surfaceFlags = i; + } + fclose(texfile); +} +#endif + + + /* 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 ); +#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 );