mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2026-01-30 19:42:51 +03:00
feat(app): add OpenArchives
This commit is contained in:
parent
2a1c75d1e8
commit
1d92f91aee
@ -14,6 +14,7 @@
|
|||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
|
#include "util/Filesystem.hpp"
|
||||||
#include <bc/Debug.hpp>
|
#include <bc/Debug.hpp>
|
||||||
#include <common/Prop.hpp>
|
#include <common/Prop.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
@ -156,6 +157,8 @@ int32_t InitializeGlobal() {
|
|||||||
|
|
||||||
// ClientServices::LoadCDKey();
|
// ClientServices::LoadCDKey();
|
||||||
|
|
||||||
|
OpenArchives();
|
||||||
|
|
||||||
ConsoleInitializeClientCommand();
|
ConsoleInitializeClientCommand();
|
||||||
|
|
||||||
ConsoleInitializeClientCVar("Config.wtf");
|
ConsoleInitializeClientCVar("Config.wtf");
|
||||||
|
|||||||
@ -1,8 +1,19 @@
|
|||||||
#include "util/Filesystem.hpp"
|
#include "util/Filesystem.hpp"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
#include <StormLib.h>
|
#include <StormLib.h>
|
||||||
|
|
||||||
|
static const std::vector<std::string> s_languages = {
|
||||||
|
"enUS", "enGB", "enTW", "zhTW", "esES",
|
||||||
|
"ruRU", "koKR", "ptPT", "esMX", "itIT",
|
||||||
|
"deDE", "frFR", "enCN", "zhCN", "ptBR"
|
||||||
|
};
|
||||||
|
|
||||||
|
void* g_mpqHandle = nullptr;
|
||||||
|
|
||||||
void OsCreateDirectory(const char* pathName, int32_t recursive) {
|
void OsCreateDirectory(const char* pathName, int32_t recursive) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@ -30,7 +41,56 @@ char* OsPathFindExtensionWithDot(char* pathName) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenPatches(const std::string& language, const std::string& fileName) {
|
||||||
|
std::string path("Data/" + language + "/");
|
||||||
|
std::string fullPath;
|
||||||
|
for (int i = 1; i < 20; ++i) {
|
||||||
|
if (i < 2) {
|
||||||
|
fullPath = path + fileName + ".MPQ";
|
||||||
|
} else {
|
||||||
|
fullPath = path + fileName + "-" + std::to_string(i) + ".MPQ";
|
||||||
|
}
|
||||||
|
if (!SFileOpenPatchArchive(g_mpqHandle, fullPath.c_str(), nullptr, 0))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OpenArchives()
|
void OpenArchives()
|
||||||
{
|
{
|
||||||
|
struct stat info = { 0 };
|
||||||
|
|
||||||
|
std::string dataPath("Data/");
|
||||||
|
if (stat(dataPath.c_str(), &info) != 0 || (info.st_mode & S_IFDIR) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!SFileOpenArchive((dataPath + "common.MPQ").c_str(), 0, STREAM_FLAG_READ_ONLY, &g_mpqHandle))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!SFileOpenPatchArchive(g_mpqHandle, (dataPath + "common-2.MPQ").c_str(), nullptr, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!SFileOpenPatchArchive(g_mpqHandle, (dataPath + "expansion.MPQ").c_str(), nullptr, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!SFileOpenPatchArchive(g_mpqHandle, (dataPath + "lichking.MPQ").c_str(), nullptr, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string language;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < s_languages.size(); ++i) {
|
||||||
|
if (stat((dataPath + s_languages[i]).c_str(), &info) == 0 && (info.st_mode & S_IFDIR) != 0) {
|
||||||
|
language = s_languages[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenPatches(language, "locale-" + language);
|
||||||
|
OpenPatches(language, "speech-" + language);
|
||||||
|
OpenPatches(language, "expansion-locale-" + language);
|
||||||
|
OpenPatches(language, "lichking-locale-" + language);
|
||||||
|
OpenPatches(language, "expansion-speech-" + language);
|
||||||
|
OpenPatches(language, "lichking-speech-" + language);
|
||||||
|
OpenPatches(language, "patch-" + language);
|
||||||
|
OpenPatches(language, "patch");
|
||||||
|
OpenPatches(".", "patch");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,4 +12,6 @@ char* OsPathFindExtensionWithDot(char*);
|
|||||||
|
|
||||||
void OpenArchives();
|
void OpenArchives();
|
||||||
|
|
||||||
|
extern void* g_mpqHandle;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user