From 93f634022a16b9549f00199e8c858b49ca4a3dfa Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 4 May 2022 17:36:23 +0200 Subject: [PATCH] Get all available maps from VPK instead Before we used the stbsp's, but we don't need to copy these for each maps (we could load existing ones to get working texture streaming for maps that don't have this) --- r5dev/gameui/IBrowser.cpp | 30 +++++++++++++++++++++--------- r5dev/gameui/IBrowser.h | 1 - r5dev/squirrel/sqinit.cpp | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index 81ae570e..fdceff51 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -41,16 +41,28 @@ IBrowser::IBrowser(void) { memset(m_chServerConnStringBuffer, 0, sizeof(m_chServerConnStringBuffer)); - std::string path = "stbsp"; - for (const auto& entry : std::filesystem::directory_iterator(path)) - { - std::string filename = entry.path().string(); - int slashPos = filename.rfind("\\", std::string::npos); - filename = filename.substr(static_cast, std::allocator>::size_type>(slashPos) + 1, std::string::npos); - filename = filename.substr(0, filename.size() - 6); + std::regex rgArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" }; + std::smatch smRegexMatches; - m_vszMapsList.push_back(filename); - m_vszMapFileNameList.push_back(filename); + for (const auto& dEntry : std::filesystem::directory_iterator("vpk")) + { + std::string svFileName = dEntry.path().string(); + std::regex_search(svFileName, smRegexMatches, rgArchiveRegex); + + if (smRegexMatches.size() > 0) + { + if (strcmp(smRegexMatches[1].str().c_str(), "frontend") == 0) + { + continue; + } + else if (strcmp(smRegexMatches[1].str().c_str(), "mp_common") == 0) + { + m_vszMapsList.push_back("mp_lobby"); + continue; + } + + m_vszMapsList.push_back(smRegexMatches[1].str()); + } } #ifndef CLIENT_DLL diff --git a/r5dev/gameui/IBrowser.h b/r5dev/gameui/IBrowser.h index 75cceb0c..8447ccda 100644 --- a/r5dev/gameui/IBrowser.h +++ b/r5dev/gameui/IBrowser.h @@ -92,7 +92,6 @@ public: //////////////////// ServerListing m_Server; std::vector m_vszMapsList; - std::vector m_vszMapFileNameList; std::string m_szHostRequestMessage = ""; std::string m_szHostToken = ""; ImVec4 m_iv4HostRequestMessageColor = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); diff --git a/r5dev/squirrel/sqinit.cpp b/r5dev/squirrel/sqinit.cpp index 00c4e15f..007e6e9b 100644 --- a/r5dev/squirrel/sqinit.cpp +++ b/r5dev/squirrel/sqinit.cpp @@ -296,7 +296,7 @@ namespace VSquirrel //----------------------------------------------------------------------------- SQRESULT GetAvailableMaps(HSQUIRRELVM v) { - std::vector vsvMapList = g_pIBrowser->m_vszMapFileNameList; + std::vector vsvMapList = g_pIBrowser->m_vszMapsList; if (vsvMapList.empty()) {