* fix RBSP style keys on -exportents and decompilation, so that they are alright for -onlyents and compilation

This commit is contained in:
Garux 2023-08-18 01:20:58 +06:00
parent a5bad3d471
commit d40538eea0
4 changed files with 23 additions and 0 deletions

View File

@ -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" );

View File

@ -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() );

View File

@ -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 );

View File

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