Skip to content

Commit

Permalink
Added VBSP features for Propper
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfestridershooter committed Nov 3, 2023
1 parent 7094105 commit ba1c1d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
31 changes: 29 additions & 2 deletions sp/src/utils/vbsp/staticprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,35 @@ void EmitStaticProps()
for ( i = 0; i < num_entities; ++i)
{
char* pEntity = ValueForKey(&entities[i], "classname");
if (!strcmp(pEntity, "static_prop") || !strcmp(pEntity, "prop_static"))
const int iInsertAsStatic = IntForKey( &entities[i], "insertasstaticprop" ); // If the key is absent, IntForKey will return 0.
bool bInsertAsStatic = g_bPropperInsertAllAsStatic;

// 1 = No, 2 = Yes; Any other number will just use what g_bPropperInsertAllAsStatic is set as.
if ( iInsertAsStatic == 1 ) { bInsertAsStatic = false; }
else if ( iInsertAsStatic == 2 ) { bInsertAsStatic = true; }

if ( !strcmp( pEntity, "static_prop" ) || !strcmp( pEntity, "prop_static" ) || ( !strcmp( pEntity, "propper_model" ) && bInsertAsStatic ) )
{
StaticPropBuild_t build;

GetVectorForKey( &entities[i], "origin", build.m_Origin );
GetAnglesForKey( &entities[i], "angles", build.m_Angles );
build.m_pModelName = ValueForKey( &entities[i], "model" );
if ( !strcmp( pEntity, "propper_model" ) )
{
char* pModelName = ValueForKey( &entities[i], "modelname" );

// The modelname keyvalue lacks 'models/' at the start and '.mdl' at the end, so we have to add them.
char modelpath[MAX_VALUE];
sprintf( modelpath, "models/%s.mdl", pModelName );

Msg( "Inserting propper_model (%.0f %.0f %.0f) as prop_static: %s\n", build.m_Origin[0], build.m_Origin[1], build.m_Origin[2], modelpath );

build.m_pModelName = modelpath;
}
else // Otherwise we just assume it's a normal prop_static
{
build.m_pModelName = ValueForKey( &entities[i], "model" );
}
build.m_Solid = IntForKey( &entities[i], "solid" );
build.m_Skin = IntForKey( &entities[i], "skin" );
build.m_FadeMaxDist = FloatForKey( &entities[i], "fademaxdist" );
Expand Down Expand Up @@ -649,6 +671,11 @@ void EmitStaticProps()
// strip this ent from the .bsp file
entities[i].epairs = 0;
}
else if ( g_bPropperStripEntities && !strncmp( pEntity, "propper_", 8 ) ) // Strip out any entities with 'propper_' in their classname, as they don't actually exist in-game.
{
Warning( "Not including %s in BSP compile due to it being a propper entity that isn't used in-game.\n", pEntity );
entities[i].epairs = 0;
}
}

// Strip out lighting origins; has to be done here because they are used when
Expand Down
15 changes: 15 additions & 0 deletions sp/src/utils/vbsp/vbsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ bool g_DisableWaterLighting = false;
bool g_bAllowDetailCracks = false;
bool g_bAllowDynamicPropsAsStatic = false;
bool g_bNoVirtualMesh = false;
bool g_bPropperInsertAllAsStatic = false;
bool g_bPropperStripEntities = false;

float g_defaultLuxelSize = DEFAULT_LUXEL_SIZE;
float g_luxelScale = 1.0f;
Expand Down Expand Up @@ -1145,6 +1147,14 @@ int RunVBSP( int argc, char **argv )
{
EnableFullMinidumps( true );
}
else if ( !Q_stricmp( argv[i], "-defaultproppermodelsstatic" ) )
{
g_bPropperInsertAllAsStatic = true;
}
else if ( !Q_stricmp( argv[i], "-strippropperentities" ) )
{
g_bPropperStripEntities = true;
}
else if (argv[i][0] == '-')
{
Warning("VBSP: Unknown option \"%s\"\n\n", argv[i]);
Expand Down Expand Up @@ -1232,6 +1242,11 @@ int RunVBSP( int argc, char **argv )
" -nox360 : Disable generation Xbox360 version of vsp (default)\n"
" -replacematerials : Substitute materials according to materialsub.txt in content\\maps\n"
" -FullMinidumps : Write large minidumps on crash.\n"
" -defaultproppermodelsstatic: All propper_models will be inserted into the BSP\n"
" as static props by default, unless InsertAsStaticProp equals 1.\n"
" -strippropperentities: Removes all entities with propper_ in their classname.\n"
" This is to avoid a bunch of Propper entities attempting\n"
" to spawn in-game despite them being internal entities.\n"
);
}

Expand Down
2 changes: 2 additions & 0 deletions sp/src/utils/vbsp/vbsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ extern bool g_DisableWaterLighting;
extern bool g_bAllowDetailCracks;
extern bool g_bAllowDynamicPropsAsStatic;
extern bool g_bNoVirtualMesh;
extern bool g_bPropperInsertAllAsStatic;
extern bool g_bPropperStripEntities;
extern char outbase[32];

extern char source[1024];
Expand Down

0 comments on commit ba1c1d5

Please sign in to comment.