Skip to content

Commit

Permalink
* fix RBSP style keys on -exportents and decompilation, so that they …
Browse files Browse the repository at this point in the history
…are alright for -onlyents and compilation
  • Loading branch information
Garux committed Aug 17, 2023
1 parent a5bad3d commit d40538e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/quake3/q3map2/convert_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

/* dependencies */
#include "q3map2.h"
#include "bspfile_rbsp.h"



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

Expand Down
7 changes: 7 additions & 0 deletions tools/quake3/q3map2/exportents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

/* dependencies */
#include "q3map2.h"
#include "bspfile_rbsp.h"



Expand All @@ -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() );
Expand Down
1 change: 1 addition & 0 deletions tools/quake3/q3map2/q3map2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
11 changes: 11 additions & 0 deletions tools/quake3/q3map2/writebsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}



/*
Expand Down

0 comments on commit d40538e

Please sign in to comment.