From ca34e8f38f7395b6472090cf01b6b9ccb0646c4f Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 7 Feb 2021 07:34:57 +0300 Subject: [PATCH] enum class EFloodEntities --- tools/quake3/q3map2/bsp.cpp | 13 +++++-------- tools/quake3/q3map2/portals.cpp | 8 ++++---- tools/quake3/q3map2/q3map2.h | 11 +++++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/quake3/q3map2/bsp.cpp b/tools/quake3/q3map2/bsp.cpp index 4fc435e6..c0411e7f 100644 --- a/tools/quake3/q3map2/bsp.cpp +++ b/tools/quake3/q3map2/bsp.cpp @@ -294,7 +294,6 @@ void ProcessWorldModel( void ){ xmlNodePtr polyline, leaknode; char level[ 2 ]; const char *value; - int leakStatus; /* sets integer blockSize from worldspawn "_blocksize" key if it exists */ if( entities[ 0 ].read_keyvalue( value, "_blocksize", "blocksize", "chopsize" ) ) { /* "chopsize" : sof2 */ @@ -333,14 +332,12 @@ void ProcessWorldModel( void ){ FilterStructuralBrushesIntoTree( e, tree ); /* see if the bsp is completely enclosed */ - leakStatus = FloodEntities( tree ); - if ( ignoreLeaks ) { - if ( leakStatus == FLOODENTITIES_LEAKED ) { - leakStatus = FLOODENTITIES_GOOD; - } + EFloodEntities leakStatus = FloodEntities( tree ); + if ( ignoreLeaks && leakStatus == EFloodEntities::Leaked ) { + leakStatus = EFloodEntities::Good; } - const bool leaked = ( leakStatus != FLOODENTITIES_GOOD ); + const bool leaked = ( leakStatus != EFloodEntities::Good ); if( leaked ){ Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" ); Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "******* leaked *******\n" ); @@ -359,7 +356,7 @@ void ProcessWorldModel( void ){ } } - if ( leakStatus != FLOODENTITIES_EMPTY ) { /* if no entities exist, this would accidentally the whole map, and that IS bad */ + if ( leakStatus != EFloodEntities::Empty ) { /* if no entities exist, this would accidentally the whole map, and that IS bad */ /* rebuild a better bsp tree using only the sides that are visible from the inside */ FillOutside( tree->headnode ); diff --git a/tools/quake3/q3map2/portals.cpp b/tools/quake3/q3map2/portals.cpp index 94f3e5b3..b031b7a1 100644 --- a/tools/quake3/q3map2/portals.cpp +++ b/tools/quake3/q3map2/portals.cpp @@ -626,7 +626,7 @@ bool PlaceOccupant( node_t *headnode, vec3_t origin, const entity_t *occupant, b ============= */ -int FloodEntities( tree_t *tree ){ +EFloodEntities FloodEntities( tree_t *tree ){ bool r, inside, skybox; node_t *headnode; const char *value; @@ -706,14 +706,14 @@ int FloodEntities( tree_t *tree ){ if ( !inside ) { Sys_FPrintf( SYS_WRN | SYS_VRBflag, "no entities in open -- no filling\n" ); - return FLOODENTITIES_EMPTY; + return EFloodEntities::Empty; } if ( tree->outside_node.occupied ) { Sys_FPrintf( SYS_WRN | SYS_VRBflag, "entity reached from outside -- leak detected\n" ); - return FLOODENTITIES_LEAKED; + return EFloodEntities::Leaked; } - return FLOODENTITIES_GOOD; + return EFloodEntities::Good; } /* diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index b12ab2c0..3bea7dd5 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1574,10 +1574,13 @@ void SplitNodePortals( node_t *node ); bool PortalPassable( portal_t *p ); -#define FLOODENTITIES_LEAKED 1 -#define FLOODENTITIES_GOOD 0 -#define FLOODENTITIES_EMPTY -1 -int FloodEntities( tree_t *tree ); +enum class EFloodEntities +{ + Leaked, + Good, + Empty +}; +EFloodEntities FloodEntities( tree_t *tree ); void FillOutside( node_t *headnode ); void FloodAreas( tree_t *tree ); face_t *VisibleFaces( entity_t *e, tree_t *tree );