diff --git a/r5dev/engine/cmodel_bsp.cpp b/r5dev/engine/cmodel_bsp.cpp index b5511af7..7daa8cf5 100644 --- a/r5dev/engine/cmodel_bsp.cpp +++ b/r5dev/engine/cmodel_bsp.cpp @@ -9,6 +9,7 @@ #include "tier0/memstd.h" #include "tier0/jobthread.h" #include "tier1/fmtstr.h" +#include "tier1/keyvalues.h" #include "tier2/fileutils.h" #include "engine/sys_dll2.h" #include "engine/host_cmd.h" @@ -19,7 +20,7 @@ #include "rtech/pak/paktools.h" #include "rtech/pak/pakstream.h" -#include "tier1/keyvalues.h" +#include "vpklib/packedstore.h" #include "datacache/mdlcache.h" #include "filesystem/filesystem.h" #ifndef DEDICATED @@ -29,8 +30,6 @@ CUtlVector g_InstalledMaps; CFmtStrN s_CurrentLevelName; -static std::regex s_ArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" }; - static CustomPakData_t s_customPakData; static KeyValues* s_pLevelSetKV = nullptr; @@ -136,11 +135,11 @@ void Mod_GetAllInstalledMaps() // slash, as the files are loaded from 'vpk/'. Assert(pFileName); - std::regex_search(pFileName, regexMatches, s_ArchiveRegex); + std::regex_search(pFileName, regexMatches, g_VpkDirFileRegex); if (!regexMatches.empty()) { - const std::sub_match& match = regexMatches[1]; + const std::sub_match& match = regexMatches[2]; if (match.compare("frontend") == 0) continue; // Frontend contains no BSP's. @@ -155,6 +154,7 @@ void Mod_GetAllInstalledMaps() else { const string mapName = match.str(); + if (!g_InstalledMaps.HasElement(mapName.c_str())) g_InstalledMaps.AddToTail(mapName.c_str()); } diff --git a/r5dev/vpklib/packedstore.cpp b/r5dev/vpklib/packedstore.cpp index 3acd2162..cbe48e3b 100644 --- a/r5dev/vpklib/packedstore.cpp +++ b/r5dev/vpklib/packedstore.cpp @@ -35,9 +35,6 @@ extern CFileSystem_Stdio* FileSystem(); -static const std::regex s_DirFileRegex{ R"((?:.*\/)?([^_]*)(?:_)(.*)(.bsp.pak000_dir).*)" }; -static const std::regex s_BlockFileRegex{ R"(pak000_([0-9]{3}))" }; - //----------------------------------------------------------------------------- // Purpose: gets the LZHAM compression level // output : lzham_compress_level @@ -98,7 +95,7 @@ CUtlString PackedStore_GetDirBaseName(const CUtlString& dirFileName) const char* baseFileName = V_UnqualifiedFileName(dirFileName.String()); std::cmatch regexMatches; - std::regex_search(baseFileName, regexMatches, s_DirFileRegex); + std::regex_search(baseFileName, regexMatches, g_VpkDirFileRegex); CUtlString result; result.Format("%s_%s", regexMatches[1].str().c_str(), regexMatches[2].str().c_str()); @@ -117,7 +114,7 @@ CUtlString PackedStore_GetDirNameParts(const CUtlString& dirFileName, const int const char* baseFileName = V_UnqualifiedFileName(dirFileName.String()); std::cmatch regexMatches; - std::regex_search(baseFileName, regexMatches, s_DirFileRegex); + std::regex_search(baseFileName, regexMatches, g_VpkDirFileRegex); return regexMatches[nCaptureGroup].str().c_str(); } @@ -846,7 +843,7 @@ VPKDir_t::VPKDir_t(const CUtlString& dirFilePath, bool bSanitizeName) } std::cmatch regexMatches; - std::regex_search(dirFilePath.String(), regexMatches, s_BlockFileRegex); + std::regex_search(dirFilePath.String(), regexMatches, g_VpkPackFileRegex); if (regexMatches.empty()) // Not a block file, or not following the naming scheme. { diff --git a/r5dev/vpklib/packedstore.h b/r5dev/vpklib/packedstore.h index 88e2bcaf..aa79feea 100644 --- a/r5dev/vpklib/packedstore.h +++ b/r5dev/vpklib/packedstore.h @@ -27,6 +27,9 @@ constexpr int PACKFILEINDEX_SEP = 0x0; constexpr int PACKFILEINDEX_END = 0xffff; constexpr const char VPK_IGNORE_FILE[] = ".vpkignore"; +static const std::regex g_VpkDirFileRegex{ R"((?:.*\/)?([^_]*)(?:_)(.*)(.bsp.pak000_dir).*)" }; +static const std::regex g_VpkPackFileRegex{ R"(pak000_([0-9]{3}))" }; + //----------------------------------------------------------------------------- // KeyValues structure for the VPK manifest file. This struct gets populated by // the VPK's corresponding manifest file, which ultimately determines how each