remove global int numMapEntities; int entitySourceBrushes;

This commit is contained in:
Garux 2021-11-06 15:12:21 +03:00
parent 16dddad640
commit 25bb05b0d2
3 changed files with 20 additions and 22 deletions

View File

@ -787,11 +787,11 @@ static void FinishBrush( bool noCollapseGroups, entity_t& mapEnt ){
after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */
if ( buildBrush.compileFlags & C_ORIGIN ) {
Sys_Printf( "Entity %i (%s), Brush %i: origin brush detected\n",
mapEnt.mapEntityNum, mapEnt.classname(), entitySourceBrushes );
mapEnt.mapEntityNum, mapEnt.classname(), buildBrush.brushNum );
if ( entities.size() == 1 ) {
Sys_FPrintf( SYS_WRN, "Entity %i, Brush %i: origin brushes not allowed in world\n",
mapEnt.mapEntityNum, entitySourceBrushes );
mapEnt.mapEntityNum, buildBrush.brushNum );
return;
}
@ -804,7 +804,7 @@ static void FinishBrush( bool noCollapseGroups, entity_t& mapEnt ){
/* determine if the brush is an area portal */
if ( buildBrush.compileFlags & C_AREAPORTAL ) {
if ( entities.size() != 1 ) {
Sys_FPrintf( SYS_WRN, "Entity %i (%s), Brush %i: areaportals only allowed in world\n", mapEnt.mapEntityNum, mapEnt.classname(), entitySourceBrushes );
Sys_FPrintf( SYS_WRN, "Entity %i (%s), Brush %i: areaportals only allowed in world\n", mapEnt.mapEntityNum, mapEnt.classname(), buildBrush.brushNum );
return;
}
}
@ -1159,7 +1159,7 @@ static bool RemoveDuplicateBrushPlanes( brush_t& b ){
parses a brush out of a map file and sets it up
*/
static void ParseBrush( bool onlyLights, bool noCollapseGroups, entity_t& mapEnt ){
static void ParseBrush( bool onlyLights, bool noCollapseGroups, entity_t& mapEnt, int mapPrimitiveNum ){
/* parse the brush out of the map */
ParseRawBrush( onlyLights );
@ -1173,7 +1173,7 @@ static void ParseBrush( bool onlyLights, bool noCollapseGroups, entity_t& mapEnt
buildBrush.portalareas[ 1 ] = -1;
/* set map entity and brush numbering */
buildBrush.entityNum = mapEnt.mapEntityNum;
buildBrush.brushNum = entitySourceBrushes;
buildBrush.brushNum = mapPrimitiveNum;
/* if there are mirrored planes, the entire brush is invalid */
if ( !RemoveDuplicateBrushPlanes( buildBrush ) ) {
@ -1466,7 +1466,7 @@ static void LoadEntityIndexMap( entity_t& e ){
parses a single entity out of a map file
*/
static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntityNum ){
/* eof check */
if ( !GetToken( true ) ) {
return false;
@ -1481,11 +1481,11 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
}
/* setup */
entitySourceBrushes = 0;
entity_t& mapEnt = entities.emplace_back();
int mapPrimitiveNum = 0; /* track .map file numbering of primitives inside an entity */
/* ydnar: true entity numbering */
mapEnt.mapEntityNum = numMapEntities++;
mapEnt.mapEntityNum = mapEntityNum;
/* loop */
while ( 1 )
@ -1510,7 +1510,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
/* check */
if ( strEqual( token, "patchDef2" ) ) {
++c_patches;
ParsePatch( onlyLights, mapEnt );
ParsePatch( onlyLights, mapEnt, mapPrimitiveNum );
}
else if ( strEqual( token, "terrainDef" ) ) {
//% ParseTerrain();
@ -1521,15 +1521,15 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
Sys_FPrintf( SYS_VRB, "detected brushType = BRUSH PRIMITIVES\n" );
g_brushType = EBrushType::Bp;
}
ParseBrush( onlyLights, noCollapseGroups, mapEnt );
ParseBrush( onlyLights, noCollapseGroups, mapEnt, mapPrimitiveNum );
}
else
{
/* AP or 220 */
UnGetToken(); // (
ParseBrush( onlyLights, noCollapseGroups, mapEnt );
ParseBrush( onlyLights, noCollapseGroups, mapEnt, mapPrimitiveNum );
}
entitySourceBrushes++;
++mapPrimitiveNum;
}
else
{
@ -1680,7 +1680,8 @@ void LoadMapFile( const char *filename, bool onlyLights, bool noCollapseGroups )
buildBrush.sides.reserve( MAX_BUILD_SIDES );
/* parse the map file */
while ( ParseMapEntity( onlyLights, noCollapseGroups ) ){};
int mapEntityNum = 0; /* track .map file entities numbering */
while ( ParseMapEntity( onlyLights, noCollapseGroups, mapEntityNum++ ) ){};
/* light loading */
if ( onlyLights ) {

View File

@ -194,7 +194,7 @@ static void ExpandMaxIterations( int *maxIterations, int maxError, const Vector3
creates a mapDrawSurface_t from the patch text
*/
void ParsePatch( bool onlyLights, entity_t& mapEnt ){
void ParsePatch( bool onlyLights, entity_t& mapEnt, int mapPrimitiveNum ){
float info[ 5 ];
mesh_t m;
bspDrawVert_t *verts;
@ -292,7 +292,7 @@ void ParsePatch( bool onlyLights, entity_t& mapEnt ){
/* warn and select degenerate patch */
if ( degenerate ) {
xml_Select( "degenerate patch", mapEnt.mapEntityNum, entitySourceBrushes, false );
xml_Select( "degenerate patch", mapEnt.mapEntityNum, mapPrimitiveNum, false );
free( m.verts );
return;
}
@ -316,7 +316,7 @@ void ParsePatch( bool onlyLights, entity_t& mapEnt ){
/* ydnar: add entity/brush numbering */
pm->entityNum = mapEnt.mapEntityNum;
pm->brushNum = entitySourceBrushes;
pm->brushNum = mapPrimitiveNum;
/* set shader */
pm->shaderInfo = ShaderInfoForShader( shader );

View File

@ -873,7 +873,8 @@ struct entity_t
brushlist_t brushes;
std::vector<brush_t*> colorModBrushes;
parseMesh_t *patches;
int mapEntityNum, firstDrawSurf;
int mapEntityNum; /* .map file entities numbering */
int firstDrawSurf;
int firstBrush, numBrushes; /* only valid during BSP compile */
std::list<epair_t> epairs;
Vector3 originbrush_origin{ 0 };
@ -1498,7 +1499,7 @@ inline node_t *AllocNode(){ return new node_t(); }
/* patch.c */
void ParsePatch( bool onlyLights, entity_t& mapEnt );
void ParsePatch( bool onlyLights, entity_t& mapEnt, int mapPrimitiveNum );
void PatchMapDrawSurfs( entity_t *e );
@ -1788,8 +1789,6 @@ inline double distanceEpsilon = 0.01;
/* bsp */
inline int numMapEntities;
inline int blockSize[ 3 ] = { 1024, 1024, 1024 }; /* should be the same as in radiant */
inline CopiedString g_enginePath;
@ -1802,8 +1801,6 @@ inline int sampleScale; /* vort
inline std::size_t mapEntityNum;
inline int entitySourceBrushes;
inline std::vector<plane_t> mapplanes; /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */ /* nummapplanes will always be even */
inline MinMax g_mapMinmax;