+/*
+ 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;
+
+ /* 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);
+ }
+}
+
+
+
+/*
+ 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" );
+
+ 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 );
+}
+
+
+