qbsp: tidying: move pWorldEnt() to mapdata_t

This commit is contained in:
Eric Wasylishen 2022-04-11 00:13:42 -06:00
parent b7fbb48763
commit 9d2f00a1b2
8 changed files with 22 additions and 22 deletions

View File

@ -158,14 +158,14 @@ struct mapdata_t
const std::string &miptexTextureName(int mt) const { return miptex.at(mt).name; }
const std::string &texinfoTextureName(int texinfo) const { return miptexTextureName(mtexinfos.at(texinfo).miptex); }
mapentity_t *world_entity();
};
extern mapdata_t map;
void CalculateWorldExtent(void);
extern mapentity_t *pWorldEnt();
bool ParseEntity(parser_t &parser, mapentity_t *entity);
void EnsureTexturesLoaded();

View File

@ -764,7 +764,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
const mapbrush_t *mapbrush = &src->mapbrush(i);
const contentflags_t contents = Brush_GetContents(mapbrush);
if (contents.is_origin()) {
if (dst == pWorldEnt()) {
if (dst == map.world_entity()) {
logging::print("WARNING: Ignoring origin brush in worldspawn\n");
continue;
}
@ -911,7 +911,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
}
/* entities in some games never use water merging */
if (dst != pWorldEnt() && !options.target_game->allow_contented_bmodels) {
if (dst != map.world_entity() && !options.target_game->allow_contented_bmodels) {
contents = options.target_game->create_solid_contents();
/* Hack to turn bmodels with "_mirrorinside" into func_detail_fence in hull 0.
@ -969,7 +969,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
dst->bounds += brush->bounds;
}
logging::percent(src->nummapbrushes, src->nummapbrushes, src == pWorldEnt());
logging::percent(src->nummapbrushes, src->nummapbrushes, src == map.world_entity());
}
/*
@ -990,7 +990,7 @@ brush_stats_t Brush_LoadEntity(mapentity_t *entity, const int hullnum)
* If this is the world entity, find all func_group and func_detail
* entities and add their brushes with the appropriate contents flag set.
*/
if (entity == pWorldEnt()) {
if (entity == map.world_entity()) {
/*
* We no longer care about the order of adding func_detail and func_group,
* Entity_SortBrushes will sort the brushes

View File

@ -28,7 +28,7 @@
mapdata_t map;
// Useful shortcuts
mapentity_t *pWorldEnt()
mapentity_t *mapdata_t::world_entity()
{
return &map.entities.at(0);
return &entities.at(0);
}

View File

@ -1909,7 +1909,7 @@ void LoadMapFile(void)
logging::print(logging::flag::STAT, "\n");
if (options.expand.value()) {
TestExpandBrushes(pWorldEnt());
TestExpandBrushes(map.world_entity());
}
}

View File

@ -627,7 +627,7 @@ void PortalizeWorld(const mapentity_t *entity, node_t *headnode, const int hulln
MakeHeadnodePortals(entity, headnode);
CutNodePortals_r(headnode, &state);
logging::percent(splitnodes, splitnodes, entity == pWorldEnt());
logging::percent(splitnodes, splitnodes, entity == map.world_entity());
if (hullnum <= 0) {
/* save portal file for vis tracing */

View File

@ -586,7 +586,7 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
/* No map brushes means non-bmodel entity.
We need to handle worldspawn containing no brushes, though. */
if (!entity->nummapbrushes && entity != pWorldEnt())
if (!entity->nummapbrushes && entity != map.world_entity())
return;
/*
@ -602,8 +602,8 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
map.bsp.dmodels.emplace_back();
}
if (entity != pWorldEnt()) {
if (entity == pWorldEnt() + 1)
if (entity != map.world_entity()) {
if (entity == map.world_entity() + 1)
logging::print(logging::flag::PROGRESS, "---- Internal Entities ----\n");
std::string mod = fmt::format("*{}", entity->outputmodelnumber.value());
@ -652,7 +652,7 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
if (hullnum > 0) {
nodes = SolidBSP(entity, true);
if (entity == pWorldEnt() && !options.nofill.value()) {
if (entity == map.world_entity() && !options.nofill.value()) {
// assume non-world bmodels are simple
PortalizeWorld(entity, nodes, hullnum);
if (FillOutside(entity, nodes, hullnum)) {
@ -683,11 +683,11 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
if (options.forcegoodtree.value())
nodes = SolidBSP(entity, false);
else
nodes = SolidBSP(entity, entity == pWorldEnt());
nodes = SolidBSP(entity, entity == map.world_entity());
// build all the portals in the bsp tree
// some portals are solid polygons, and some are paths to other leafs
if (entity == pWorldEnt()) {
if (entity == map.world_entity()) {
// assume non-world bmodels are simple
PortalizeWorld(entity, nodes, hullnum);
@ -730,7 +730,7 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
TJunc(entity, nodes);
}
if (options.objexport.value() && entity == pWorldEnt()) {
if (options.objexport.value() && entity == map.world_entity()) {
ExportObj_Nodes("pre_makefaceedges_plane_faces", nodes);
ExportObj_Marksurfaces("pre_makefaceedges_marksurfaces", nodes);
}
@ -935,7 +935,7 @@ static void BSPX_CreateBrushList(void)
for (entnum = 0; entnum < map.numentities(); entnum++) {
ent = &map.entities.at(entnum);
if (ent == pWorldEnt())
if (ent == map.world_entity())
modelnum = 0;
else {
mod = ValueForKey(ent, "model");
@ -1015,9 +1015,9 @@ void EnsureTexturesLoaded()
wadlist_tried_loading = true;
const char *wadstring = ValueForKey(pWorldEnt(), "_wad");
const char *wadstring = ValueForKey(map.world_entity(), "_wad");
if (!wadstring[0])
wadstring = ValueForKey(pWorldEnt(), "wad");
wadstring = ValueForKey(map.world_entity(), "wad");
if (!wadstring[0])
logging::print("WARNING: No wad or _wad key exists in the worldmodel\n");
else

View File

@ -968,7 +968,7 @@ node_t *SolidBSP(mapentity_t *entity, bool midsplit)
}
PartitionBrushes(std::move(brushcopies), headnode);
//logging::percent(csgmergefaces, csgmergefaces, entity == pWorldEnt());
//logging::percent(csgmergefaces, csgmergefaces, entity == map.pWorldEnt());
logging::print(logging::flag::STAT, " {:8} split nodes\n", splitnodes.load());
logging::print(logging::flag::STAT, " {:8} solid leafs\n", c_solid.load());

View File

@ -463,7 +463,7 @@ int MakeFaceEdges(mapentity_t *entity, node_t *headnode)
firstface = static_cast<int>(map.bsp.dfaces.size());
MakeFaceEdges_r(entity, headnode, 0);
logging::percent(splitnodes, splitnodes, entity == pWorldEnt());
logging::percent(splitnodes, splitnodes, entity == map.world_entity());
pEdgeFaces0.clear();
pEdgeFaces1.clear();