qbsp: move wadlist to map struct

This commit is contained in:
Eric Wasylishen 2022-05-14 15:55:18 -06:00
parent bc90198006
commit c537ad39c1
4 changed files with 8 additions and 13 deletions

View File

@ -118,6 +118,7 @@ struct texdata_t
};
#include <common/imglib.hh>
#include <qbsp/wad.hh>
struct mapdata_t
{
@ -156,6 +157,7 @@ struct mapdata_t
// misc
int start_spots = 0;
bool wadlist_tried_loading = false;
std::list<wad_t> wadlist;
// helpers
const std::string &miptexTextureName(int mt) const { return miptex.at(mt).name; }

View File

@ -66,6 +66,3 @@ void WADList_Init(const char *wadstring);
void WADList_Process();
const texture_t *WADList_GetTexture(const char *name);
// for getting a texture width/height
// FIXME: don't like global state like this :(
extern std::list<wad_t> wadlist;

View File

@ -1101,7 +1101,7 @@ void EnsureTexturesLoaded()
else
WADList_Init(wadstring);
if (!wadlist.size()) {
if (!map.wadlist.size()) {
if (wadstring[0])
logging::print("WARNING: No valid WAD filenames in worldmodel\n");
@ -1111,7 +1111,7 @@ void EnsureTexturesLoaded()
WADList_Init(defaultwad.string().c_str());
if (wadlist.size())
if (map.wadlist.size())
logging::print("Using default WAD: {}\n", defaultwad);
}
}
@ -1158,8 +1158,6 @@ void ProcessFile()
WADList_Process();
BSPX_CreateBrushList();
FinishBSPFile();
wadlist.clear();
}
/*

View File

@ -137,7 +137,7 @@ static void WADList_OpenWad(const fs::path &fpath, bool external)
logging::print("Opened WAD: {}\n", fpath);
if (WAD_LoadInfo(wad, external)) {
wadlist.emplace_front(std::move(wad));
map.wadlist.emplace_front(std::move(wad));
return;
}
@ -181,7 +181,7 @@ void WADList_Init(const char *wadstring)
static const lumpinfo_t *WADList_FindTexture(const std::string &name)
{
for (auto &wad : wadlist) {
for (auto &wad : map.wadlist) {
auto it = wad.lumps.find(name);
if (it == wad.lumps.end()) {
@ -269,7 +269,7 @@ static void WADList_LoadTextures()
if (map.bsp.dtex.textures[i].data[0])
continue;
for (auto &wad : wadlist) {
for (auto &wad : map.wadlist) {
if (WAD_LoadLump(wad, map.miptexTextureName(i).c_str(), map.bsp.dtex.textures[i]))
break;
}
@ -321,7 +321,7 @@ void WADList_Process()
const texture_t *WADList_GetTexture(const char *name)
{
for (auto &wad : wadlist) {
for (auto &wad : map.wadlist) {
auto it = wad.textures.find(name);
if (it == wad.textures.end()) {
@ -333,5 +333,3 @@ const texture_t *WADList_GetTexture(const char *name)
return nullptr;
}
std::list<wad_t> wadlist;