From: Thomas Debesse Date: Wed, 1 May 2019 14:16:52 +0000 (+0200) Subject: q3map2: make Smokin'Guns code not requiring a rebuild X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=38056549ede3da5736686243a1242a2e67a35ec1 q3map2: make Smokin'Guns code not requiring a rebuild Not only Smokin'Guns game can now use .tex sidecar file --- diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt index e0bb8989..7ba643bf 100644 --- a/tools/quake3/CMakeLists.txt +++ b/tools/quake3/CMakeLists.txt @@ -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 diff --git a/tools/quake3/q3map2/game__null.h b/tools/quake3/q3map2/game__null.h index a8bbec9c..a92544b2 100644 --- a/tools/quake3/q3map2/game__null.h +++ b/tools/quake3/q3map2/game__null.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_darkplaces.h b/tools/quake3/q3map2/game_darkplaces.h index 2f998d24..492dd2d2 100644 --- a/tools/quake3/q3map2/game_darkplaces.h +++ b/tools/quake3/q3map2/game_darkplaces.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_dq.h b/tools/quake3/q3map2/game_dq.h index 4d691b46..b4963345 100644 --- a/tools/quake3/q3map2/game_dq.h +++ b/tools/quake3/q3map2/game_dq.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_ef.h b/tools/quake3/q3map2/game_ef.h index 9ef10903..03c9301f 100644 --- a/tools/quake3/q3map2/game_ef.h +++ b/tools/quake3/q3map2/game_ef.h @@ -108,6 +108,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? */ diff --git a/tools/quake3/q3map2/game_etut.h b/tools/quake3/q3map2/game_etut.h index f4303f2e..de7fad75 100644 --- a/tools/quake3/q3map2/game_etut.h +++ b/tools/quake3/q3map2/game_etut.h @@ -143,6 +143,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 */ qfalse, /* wolf lighting model? */ diff --git a/tools/quake3/q3map2/game_ja.h b/tools/quake3/q3map2/game_ja.h index b598a096..cce3260a 100644 --- a/tools/quake3/q3map2/game_ja.h +++ b/tools/quake3/q3map2/game_ja.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_jk2.h b/tools/quake3/q3map2/game_jk2.h index 69c80edb..a667777d 100644 --- a/tools/quake3/q3map2/game_jk2.h +++ b/tools/quake3/q3map2/game_jk2.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_nexuiz.h b/tools/quake3/q3map2/game_nexuiz.h index f299f4d1..b6fee7f9 100644 --- a/tools/quake3/q3map2/game_nexuiz.h +++ b/tools/quake3/q3map2/game_nexuiz.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_prophecy.h b/tools/quake3/q3map2/game_prophecy.h index a5e11cb7..4a156a8f 100644 --- a/tools/quake3/q3map2/game_prophecy.h +++ b/tools/quake3/q3map2/game_prophecy.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_qfusion.h b/tools/quake3/q3map2/game_qfusion.h index 5cd5b038..49506129 100644 --- a/tools/quake3/q3map2/game_qfusion.h +++ b/tools/quake3/q3map2/game_qfusion.h @@ -110,6 +110,7 @@ 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? */ diff --git a/tools/quake3/q3map2/game_quake3.h b/tools/quake3/q3map2/game_quake3.h index 66b40289..2b3302ab 100644 --- a/tools/quake3/q3map2/game_quake3.h +++ b/tools/quake3/q3map2/game_quake3.h @@ -107,6 +107,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? */ diff --git a/tools/quake3/q3map2/game_quakelive.h b/tools/quake3/q3map2/game_quakelive.h index 3f7a29da..b4f876fb 100644 --- a/tools/quake3/q3map2/game_quakelive.h +++ b/tools/quake3/q3map2/game_quakelive.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_reaction.h b/tools/quake3/q3map2/game_reaction.h index 2474274e..6163b391 100644 --- a/tools/quake3/q3map2/game_reaction.h +++ b/tools/quake3/q3map2/game_reaction.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_smokinguns.h b/tools/quake3/q3map2/game_smokinguns.h index 78be8ba7..296803cc 100644 --- a/tools/quake3/q3map2/game_smokinguns.h +++ b/tools/quake3/q3map2/game_smokinguns.h @@ -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." - ------------------------------------------------------------------------------- */ +------------------------------------------------------------------------------- */ @@ -36,16 +36,18 @@ /* ------------------------------------------------------------------------------- -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 diff --git a/tools/quake3/q3map2/game_sof2.h b/tools/quake3/q3map2/game_sof2.h index 2e72270b..fcceb0f9 100644 --- a/tools/quake3/q3map2/game_sof2.h +++ b/tools/quake3/q3map2/game_sof2.h @@ -134,6 +134,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/lens_flare", /* default flare shader */ qfalse, /* wolf lighting model? */ diff --git a/tools/quake3/q3map2/game_tenebrae.h b/tools/quake3/q3map2/game_tenebrae.h index 243f756c..f9ba57ad 100644 --- a/tools/quake3/q3map2/game_tenebrae.h +++ b/tools/quake3/q3map2/game_tenebrae.h @@ -107,6 +107,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 */ qfalse, /* wolf lighting model? */ diff --git a/tools/quake3/q3map2/game_tremulous.h b/tools/quake3/q3map2/game_tremulous.h index 6853e617..a91b4c52 100644 --- a/tools/quake3/q3map2/game_tremulous.h +++ b/tools/quake3/q3map2/game_tremulous.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_unvanquished.h b/tools/quake3/q3map2/game_unvanquished.h index 75d6804e..20c935e6 100644 --- a/tools/quake3/q3map2/game_unvanquished.h +++ b/tools/quake3/q3map2/game_unvanquished.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_wolf.h b/tools/quake3/q3map2/game_wolf.h index fcfd17ec..a29fde2d 100644 --- a/tools/quake3/q3map2/game_wolf.h +++ b/tools/quake3/q3map2/game_wolf.h @@ -124,6 +124,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 */ qtrue, /* wolf lighting model? */ diff --git a/tools/quake3/q3map2/game_wolfet.h b/tools/quake3/q3map2/game_wolfet.h index c783b9a0..46746c37 100644 --- a/tools/quake3/q3map2/game_wolfet.h +++ b/tools/quake3/q3map2/game_wolfet.h @@ -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? */ diff --git a/tools/quake3/q3map2/game_xonotic.h b/tools/quake3/q3map2/game_xonotic.h index b0ac5395..5ffb30fb 100644 --- a/tools/quake3/q3map2/game_xonotic.h +++ b/tools/quake3/q3map2/game_xonotic.h @@ -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? */ diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 0f553164..6b60e737 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -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; isurfaceFlags; + bspShaders[ i ].surfaceFlags = si->surfaceFlags; } } -#endif diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 0eec3442..90fc5d90 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -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 ); } diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 5593b86a..38ee560a 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -167,21 +167,19 @@ #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 \ diff --git a/tools/quake3/q3map2/vis.c b/tools/quake3/q3map2/vis.c index 66a46add..7623590b 100644 --- a/tools/quake3/q3map2/vis.c +++ b/tools/quake3/q3map2/vis.c @@ -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 ); diff --git a/tools/quake3/q3map2/writebsp.c b/tools/quake3/q3map2/writebsp.c index 9cfa577b..3fbed1cc 100644 --- a/tools/quake3/q3map2/writebsp.c +++ b/tools/quake3/q3map2/writebsp.c @@ -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; icolor[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 );