From c537ad39c127620fcb2ac2eb55c03259d5f242b3 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 14 May 2022 15:55:18 -0600 Subject: [PATCH] qbsp: move wadlist to map struct --- include/qbsp/map.hh | 2 ++ include/qbsp/wad.hh | 3 --- qbsp/qbsp.cc | 6 ++---- qbsp/wad.cc | 10 ++++------ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/include/qbsp/map.hh b/include/qbsp/map.hh index 3eb6d158..a94f5e03 100644 --- a/include/qbsp/map.hh +++ b/include/qbsp/map.hh @@ -118,6 +118,7 @@ struct texdata_t }; #include +#include struct mapdata_t { @@ -156,6 +157,7 @@ struct mapdata_t // misc int start_spots = 0; bool wadlist_tried_loading = false; + std::list wadlist; // helpers const std::string &miptexTextureName(int mt) const { return miptex.at(mt).name; } diff --git a/include/qbsp/wad.hh b/include/qbsp/wad.hh index db586353..82744631 100644 --- a/include/qbsp/wad.hh +++ b/include/qbsp/wad.hh @@ -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 wadlist; diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 07542de5..53ed8d5f 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -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(); } /* diff --git a/qbsp/wad.cc b/qbsp/wad.cc index 5c74bd22..714bfc95 100644 --- a/qbsp/wad.cc +++ b/qbsp/wad.cc @@ -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 wadlist; \ No newline at end of file