Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otrFiles -> archiveFiles #749

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Context::~Context() {

std::shared_ptr<Context> Context::CreateInstance(const std::string name, const std::string shortName,
const std::string configFilePath,
const std::vector<std::string>& otrFiles,
const std::vector<std::string>& archivePaths,
const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings) {
if (mContext.expired()) {
auto shared = std::make_shared<Context>(name, shortName, configFilePath);
mContext = shared;
shared->Init(otrFiles, validHashes, reservedThreadCount, audioSettings);
shared->Init(archivePaths, validHashes, reservedThreadCount, audioSettings);
return shared;
}

Expand All @@ -76,12 +76,12 @@ Context::Context(std::string name, std::string shortName, std::string configFile
: mConfigFilePath(std::move(configFilePath)), mName(std::move(name)), mShortName(std::move(shortName)) {
}

void Context::Init(const std::vector<std::string>& otrFiles, const std::unordered_set<uint32_t>& validHashes,
void Context::Init(const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings) {
InitLogging();
InitConfiguration();
InitConsoleVariables();
InitResourceManager(otrFiles, validHashes, reservedThreadCount);
InitResourceManager(archivePaths, validHashes, reservedThreadCount);
InitControlDeck();
InitCrashHandler();
InitConsole();
Expand Down Expand Up @@ -181,15 +181,15 @@ void Context::InitConsoleVariables() {
mConsoleVariables = std::make_shared<ConsoleVariable>();
}

void Context::InitResourceManager(const std::vector<std::string>& otrFiles,
void Context::InitResourceManager(const std::vector<std::string>& archivePaths,
const std::unordered_set<uint32_t>& validHashes, uint32_t reservedThreadCount) {
if (GetResourceManager() != nullptr) {
return;
}

mMainPath = GetConfig()->GetString("Game.Main Archive", GetAppDirectoryPath());
mPatchesPath = GetConfig()->GetString("Game.Patches Archive", GetAppDirectoryPath() + "/mods");
if (otrFiles.empty()) {
if (archivePaths.empty()) {
std::vector<std::string> paths = std::vector<std::string>();
paths.push_back(mMainPath);
paths.push_back(mPatchesPath);
Expand All @@ -198,7 +198,7 @@ void Context::InitResourceManager(const std::vector<std::string>& otrFiles,
GetResourceManager()->Init(paths, validHashes, reservedThreadCount);
} else {
mResourceManager = std::make_shared<ResourceManager>();
GetResourceManager()->Init(otrFiles, validHashes, reservedThreadCount);
GetResourceManager()->Init(archivePaths, validHashes, reservedThreadCount);
}

if (!GetResourceManager()->DidLoadSuccessfully()) {
Expand Down
6 changes: 3 additions & 3 deletions src/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Context {
static std::shared_ptr<Context> GetInstance();
static std::shared_ptr<Context> CreateInstance(const std::string name, const std::string shortName,
const std::string configFilePath,
const std::vector<std::string>& otrFiles = {},
const std::vector<std::string>& archivePaths = {},
const std::unordered_set<uint32_t>& validHashes = {},
uint32_t reservedThreadCount = 1, AudioSettings audioSettings = {});
static std::shared_ptr<Context> CreateUninitializedInstance(const std::string name, const std::string shortName,
Expand All @@ -37,7 +37,7 @@ class Context {
Context(std::string name, std::string shortName, std::string configFilePath);
~Context();

void Init(const std::vector<std::string>& otrFiles, const std::unordered_set<uint32_t>& validHashes,
void Init(const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
uint32_t reservedThreadCount, AudioSettings audioSettings);

std::shared_ptr<spdlog::logger> GetLogger();
Expand All @@ -58,7 +58,7 @@ class Context {
void InitLogging();
void InitConfiguration();
void InitConsoleVariables();
void InitResourceManager(const std::vector<std::string>& otrFiles = {},
void InitResourceManager(const std::vector<std::string>& archivePaths = {},
const std::unordered_set<uint32_t>& validHashes = {}, uint32_t reservedThreadCount = 1);
void InitControlDeck(std::vector<CONTROLLERBUTTONS_T> additionalBitmasks = {});
void InitCrashHandler();
Expand Down
6 changes: 3 additions & 3 deletions src/resource/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ size_t ResourceIdentifierHash::operator()(const ResourceIdentifier& rcd) const {
ResourceManager::ResourceManager() {
}

void ResourceManager::Init(const std::vector<std::string>& otrFiles, const std::unordered_set<uint32_t>& validHashes,
int32_t reservedThreadCount) {
void ResourceManager::Init(const std::vector<std::string>& archivePaths,
const std::unordered_set<uint32_t>& validHashes, int32_t reservedThreadCount) {
mResourceLoader = std::make_shared<ResourceLoader>();
mArchiveManager = std::make_shared<ArchiveManager>();
GetArchiveManager()->Init(otrFiles, validHashes);
GetArchiveManager()->Init(archivePaths, validHashes);

// the extra `- 1` is because we reserve an extra thread for spdlog
size_t threadCount = std::max(1, (int32_t)(std::thread::hardware_concurrency() - reservedThreadCount - 1));
Expand Down
2 changes: 1 addition & 1 deletion src/resource/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ResourceManager {

public:
ResourceManager();
void Init(const std::vector<std::string>& otrFiles, const std::unordered_set<uint32_t>& validHashes,
void Init(const std::vector<std::string>& archivePaths, const std::unordered_set<uint32_t>& validHashes,
int32_t reservedThreadCount = 1);
~ResourceManager();

Expand Down
Loading