From d40538eea0b7f80ef79dba74adef25976374d829 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 18 Aug 2023 01:20:58 +0600 Subject: [PATCH] * fix RBSP style keys on -exportents and decompilation, so that they are alright for -onlyents and compilation --- tools/quake3/q3map2/convert_map.cpp | 4 ++++ tools/quake3/q3map2/exportents.cpp | 7 +++++++ tools/quake3/q3map2/q3map2.h | 1 + tools/quake3/q3map2/writebsp.cpp | 11 +++++++++++ 4 files changed, 23 insertions(+) diff --git a/tools/quake3/q3map2/convert_map.cpp b/tools/quake3/q3map2/convert_map.cpp index 2e50ad7d2..7af330d9a 100644 --- a/tools/quake3/q3map2/convert_map.cpp +++ b/tools/quake3/q3map2/convert_map.cpp @@ -30,6 +30,7 @@ /* dependencies */ #include "q3map2.h" +#include "bspfile_rbsp.h" @@ -864,6 +865,9 @@ static int ConvertBSPToMap_Ext( char *bspName, bool brushPrimitives ){ buildBrush.original = &buildBrush; } + if( g_game->load == LoadRBSPFile ) + UnSetLightStyles(); + /* note it */ Sys_Printf( "--- Convert BSP to MAP ---\n" ); diff --git a/tools/quake3/q3map2/exportents.cpp b/tools/quake3/q3map2/exportents.cpp index dd503b159..17ead7cab 100644 --- a/tools/quake3/q3map2/exportents.cpp +++ b/tools/quake3/q3map2/exportents.cpp @@ -30,6 +30,7 @@ /* dependencies */ #include "q3map2.h" +#include "bspfile_rbsp.h" @@ -55,6 +56,12 @@ static void ExportEntities(){ return; } + if( g_game->load == LoadRBSPFile ){ // intent here is to make RBSP specific stuff usable for entity modding with -onlyents + ParseEntities(); + UnSetLightStyles(); + UnparseEntities(); + } + /* write it */ auto filename = StringOutputStream( 256 )( PathExtensionless( source ), ".ent" ); Sys_Printf( "Writing %s\n", filename.c_str() ); diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 66466cc67..62b86e715 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1492,6 +1492,7 @@ void WritePortalFile( const tree_t& tree ); /* writebsp.c */ void SetModelNumbers(); void SetLightStyles(); +void UnSetLightStyles(); int EmitShader( const char *shader, const int *contentFlags, const int *surfaceFlags ); diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index e4acabd91..a37a74b5b 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -301,6 +301,17 @@ void SetLightStyles(){ Sys_FPrintf( SYS_VRB, "%9d light entities stripped\n", numStrippedLights ); } +// reverts SetLightStyles() effect for decompilation purposes +void UnSetLightStyles(){ + for ( entity_t& e : entities ){ + if ( e.classname_prefixed( "light" ) && !strEmpty( e.valueForKey( "targetname" ) ) && !strEmpty( e.valueForKey( "style" ) ) ) { + char value[ 10 ]; + sprintf( value, "%d", e.intForKey( "switch_style" ) ); // value or 0, latter is fine too + e.setKeyValue( "style", value ); + } + } +} + /*