#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
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 );
#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 */
,
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 \
{ \
/* 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
+
/*
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 ) ) {
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' ) {
+#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
/* 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 );