Fix gamedata library search order in some cases. (#1914)
This commit is contained in:
parent
d57d7e7401
commit
30a2160839
@ -1083,15 +1083,7 @@ bool CGameConfig::GetMemSig(const char *key, void **addr)
|
||||
return m_Sigs.retrieve(key, addr);
|
||||
}
|
||||
|
||||
GameConfigManager::GameConfigManager()
|
||||
{
|
||||
}
|
||||
|
||||
GameConfigManager::~GameConfigManager()
|
||||
{
|
||||
}
|
||||
|
||||
void GameConfigManager::OnSourceModStartup(bool late)
|
||||
void GameBinPathManager::Init()
|
||||
{
|
||||
char search_path[PLATFORM_MAX_PATH * 8];
|
||||
bridge->filesystem->GetSearchPath("GAMEBIN", false, search_path, sizeof(search_path));
|
||||
@ -1104,19 +1096,41 @@ void GameConfigManager::OnSourceModStartup(bool late)
|
||||
{
|
||||
if (path.length() > 0
|
||||
&& path.find(addons_folder) == std::string::npos
|
||||
&& m_gameBinDirectories.find(path.c_str()) == m_gameBinDirectories.cend()
|
||||
&& m_lookup.find(path) == m_lookup.cend()
|
||||
)
|
||||
m_gameBinDirectories.insert(path);
|
||||
{
|
||||
m_lookup.insert(path);
|
||||
m_ordered.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
iss.clear();
|
||||
|
||||
bridge->filesystem->GetSearchPath("EXECUTABLE_PATH", false, search_path, sizeof(search_path));
|
||||
std::istringstream iss2(search_path);
|
||||
for (std::string path; std::getline(iss2, path, ';');)
|
||||
iss.str(search_path);
|
||||
|
||||
for (std::string path; std::getline(iss, path, ';');)
|
||||
{
|
||||
if (m_gameBinDirectories.find(path.c_str()) == m_gameBinDirectories.cend())
|
||||
m_gameBinDirectories.insert(path);
|
||||
if (m_lookup.find(path) == m_lookup.cend())
|
||||
{
|
||||
m_lookup.insert(path);
|
||||
m_ordered.push_back(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameConfigManager::GameConfigManager()
|
||||
{
|
||||
}
|
||||
|
||||
GameConfigManager::~GameConfigManager()
|
||||
{
|
||||
}
|
||||
|
||||
void GameConfigManager::OnSourceModStartup(bool late)
|
||||
{
|
||||
m_gameBinPathManager.Init();
|
||||
|
||||
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
|
||||
|
||||
strncopy(g_Game, g_pSM->GetGameFolderName(), sizeof(g_Game));
|
||||
@ -1249,7 +1263,7 @@ void GameConfigManager::CacheGameBinaryInfo(const char* pszName)
|
||||
|
||||
bool binary_found = false;
|
||||
char binary_path[PLATFORM_MAX_PATH];
|
||||
for (auto it = m_gameBinDirectories.begin(); it != m_gameBinDirectories.end(); ++it)
|
||||
for (auto it = m_gameBinPathManager.Paths().begin(); it != m_gameBinPathManager.Paths().end(); ++it)
|
||||
{
|
||||
ke::SafeSprintf(binary_path, sizeof(binary_path), "%s%s%s", it->c_str(), it->back() == PLATFORM_SEP_CHAR ? "" : PLATFORM_SEP, name);
|
||||
#if defined PLATFORM_WINDOWS
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <am-refcounting.h>
|
||||
#include <sm_stringhashmap.h>
|
||||
#include <sm_namehashset.h>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@ -136,6 +136,23 @@ struct GameBinaryInfo
|
||||
bool m_crcOK = false;
|
||||
};
|
||||
|
||||
class GameBinPathManager
|
||||
{
|
||||
public:
|
||||
GameBinPathManager() {}
|
||||
~GameBinPathManager() {}
|
||||
public:
|
||||
void Init();
|
||||
|
||||
inline const std::vector<std::string>& Paths() const
|
||||
{
|
||||
return m_ordered;
|
||||
}
|
||||
private:
|
||||
std::unordered_set<std::string> m_lookup;
|
||||
std::vector<std::string> m_ordered;
|
||||
};
|
||||
|
||||
class GameConfigManager :
|
||||
public IGameConfigManager,
|
||||
public SMGlobalClass
|
||||
@ -165,9 +182,9 @@ private:
|
||||
private:
|
||||
NameHashSet<CGameConfig *> m_Lookup;
|
||||
StringHashMap<GameBinaryInfo> m_gameBinInfos;
|
||||
std::set<std::string> m_gameBinDirectories;
|
||||
public:
|
||||
StringHashMap<ITextListener_SMC *> m_customHandlers;
|
||||
GameBinPathManager m_gameBinPathManager;
|
||||
};
|
||||
|
||||
extern GameConfigManager g_GameConfigs;
|
||||
|
Loading…
Reference in New Issue
Block a user