[Download]: Cleanup some stuff (#703)
This commit is contained in:
parent
0fd0cc977b
commit
1bf8601998
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -17,7 +17,7 @@
|
||||
[submodule "deps/mongoose"]
|
||||
path = deps/mongoose
|
||||
url = https://github.com/cesanta/mongoose.git
|
||||
branch = master
|
||||
branch = 7.8
|
||||
[submodule "deps/protobuf"]
|
||||
path = deps/protobuf
|
||||
url = https://github.com/google/protobuf.git
|
||||
|
2
deps/mongoose
vendored
2
deps/mongoose
vendored
@ -1 +1 @@
|
||||
Subproject commit 73813a838386f6ebca447eb54c626803163ee257
|
||||
Subproject commit 0a265e79a67d7bfcdca27f2ccb98ccb474677ec6
|
@ -77,7 +77,7 @@ namespace Assets
|
||||
{
|
||||
Components::FileSystem::File modelFile(std::format("xmodel/{}.iw4xModel", name));
|
||||
|
||||
if (!builder->isPrimaryAsset() && (!Components::ZoneBuilder::PreferDiskAssetsDvar.get<bool>() || !modelFile.exists()))
|
||||
if (!builder->isPrimaryAsset() && (!Components::ZoneBuilder::ZBPreferDiskAssets.get<bool>() || !modelFile.exists()))
|
||||
{
|
||||
header->model = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).model;
|
||||
if (header->model) return;
|
||||
|
@ -455,35 +455,40 @@ namespace Components
|
||||
static std::string ListHandler()
|
||||
{
|
||||
static nlohmann::json jsonList;
|
||||
static auto handled = false;
|
||||
static std::filesystem::path fsGamePre;
|
||||
|
||||
const std::filesystem::path fs_gameDirVar((*Game::fs_gameDirVar)->current.string);
|
||||
const std::filesystem::path fsGame = (*Game::fs_gameDirVar)->current.string;
|
||||
|
||||
if (!fs_gameDirVar.empty() && !handled)
|
||||
if (!fsGame.empty() && (fsGamePre != fsGame))
|
||||
{
|
||||
handled = true;
|
||||
fsGamePre = fsGame;
|
||||
|
||||
std::vector<nlohmann::json> fileList;
|
||||
|
||||
const auto path = (*Game::fs_basepath)->current.string / fs_gameDirVar;
|
||||
auto list = FileSystem::GetSysFileList(path.generic_string(), "iwd", false);
|
||||
const auto path = (*Game::fs_basepath)->current.string / fsGame;
|
||||
auto list = Utils::IO::ListFiles(path, false);
|
||||
list.emplace_back("mod.ff");
|
||||
|
||||
for (const auto& file : list)
|
||||
{
|
||||
auto filename = path / file;
|
||||
if (file.find("_svr_") != std::string::npos)
|
||||
if (filename.extension() != ".iwd"s) // We don't want to serve other files
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.find("_svr_") != std::string::npos) // Files that are 'server only' are skipped
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, nlohmann::json> jsonFileList;
|
||||
auto fileBuffer = Utils::IO::ReadFile(filename.generic_string());
|
||||
if (fileBuffer.empty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, nlohmann::json> jsonFileList;
|
||||
jsonFileList["name"] = file;
|
||||
jsonFileList["size"] = fileBuffer.size();
|
||||
jsonFileList["hash"] = Utils::Cryptography::SHA256::Compute(fileBuffer, true);
|
||||
|
@ -543,17 +543,22 @@ namespace Components
|
||||
}
|
||||
|
||||
std::vector<std::string> fastFiles;
|
||||
|
||||
if (param->get(1) == "all"s)
|
||||
if (std::strcmp(param->get(1), "all") == 0)
|
||||
{
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/english"))
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/english", false))
|
||||
{
|
||||
fastFiles.emplace_back(f.substr(7, f.length() - 10));
|
||||
}
|
||||
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/dlc"))
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/dlc", false))
|
||||
{
|
||||
fastFiles.emplace_back(f.substr(3, f.length() - 6));
|
||||
}
|
||||
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/patch"))
|
||||
for (const auto& f : Utils::IO::ListFiles("zone/patch", false))
|
||||
{
|
||||
fastFiles.emplace_back(f.substr(5, f.length() - 8));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -599,7 +604,7 @@ namespace Components
|
||||
{
|
||||
Utils::IO::CreateDir("userraw/techsets");
|
||||
Utils::Stream buffer(0x1000);
|
||||
Game::MaterialTechniqueSet* dest = buffer.dest<Game::MaterialTechniqueSet>();
|
||||
auto* dest = buffer.dest<Game::MaterialTechniqueSet>();
|
||||
buffer.save(asset.techniqueSet);
|
||||
|
||||
if (asset.techniqueSet->name)
|
||||
|
@ -21,7 +21,7 @@ namespace Components
|
||||
volatile bool ZoneBuilder::CommandThreadTerminate = false;
|
||||
std::thread ZoneBuilder::CommandThread;
|
||||
|
||||
Dvar::Var ZoneBuilder::PreferDiskAssetsDvar;
|
||||
Dvar::Var ZoneBuilder::ZBPreferDiskAssets;
|
||||
|
||||
ZoneBuilder::Zone::Zone(const std::string& name) : indexStart(0), externalSize(0),
|
||||
// Reserve 100MB by default.
|
||||
@ -1101,18 +1101,6 @@ namespace Components
|
||||
Utils::Hook::Set<int*>(0x5BC759, g_copyInfo_new);
|
||||
Utils::Hook::Set<int>(0x5BB9AD, newLimit); // limit check
|
||||
|
||||
// this one lets us keep loading zones and it will ignore assets when the pool is filled
|
||||
/*
|
||||
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader, const std::string&, bool* restrict)
|
||||
{
|
||||
//if (*static_cast<int*>(Game::DB_XAssetPool[type].data) == 0)
|
||||
if (Game::g_poolSize[type] == 0)
|
||||
{
|
||||
*restrict = true;
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// hunk size (was 300 MiB)
|
||||
Utils::Hook::Set<DWORD>(0x64A029, 0x38400000); // 900 MiB
|
||||
Utils::Hook::Set<DWORD>(0x64A057, 0x38400000);
|
||||
@ -1289,7 +1277,8 @@ namespace Components
|
||||
|
||||
std::string csvStr;
|
||||
|
||||
auto fileList = Utils::IO::ListFiles(Utils::String::VA("zone/%s", Game::Win_GetLanguage()));
|
||||
const auto dir = std::format("zone/{}", Game::Win_GetLanguage());
|
||||
auto fileList = Utils::IO::ListFiles(dir, false);
|
||||
for (auto zone : fileList)
|
||||
{
|
||||
Utils::String::Replace(zone, Utils::String::VA("zone/%s/", Game::Win_GetLanguage()), "");
|
||||
@ -1325,7 +1314,7 @@ namespace Components
|
||||
|
||||
while (!Game::Sys_IsDatabaseReady()) std::this_thread::sleep_for(100ms); // wait till its fully loaded
|
||||
|
||||
if (curTechsets_list.size() == 0)
|
||||
if (curTechsets_list.empty())
|
||||
{
|
||||
Logger::Print("Skipping empty zone {}\n", zone);
|
||||
// unload zone
|
||||
@ -1352,7 +1341,7 @@ namespace Components
|
||||
}
|
||||
|
||||
// save csv
|
||||
Utils::IO::WriteFile("zone_source/techsets/" + zone + "_techsets.csv", csvStr.data());
|
||||
Utils::IO::WriteFile("zone_source/techsets/" + zone + "_techsets.csv", csvStr);
|
||||
|
||||
// build the techset zone
|
||||
std::string zoneName = "techsets/" + zone + "_techsets";
|
||||
@ -1382,7 +1371,7 @@ namespace Components
|
||||
Utils::Hook::Set<const char*>(0x649E740, "techsets");
|
||||
|
||||
// load generated techset fastfiles
|
||||
auto list = Utils::IO::ListFiles("zone/techsets");
|
||||
auto list = Utils::IO::ListFiles("zone/techsets", false);
|
||||
int i = 0;
|
||||
int subCount = 0;
|
||||
for (auto it : list)
|
||||
@ -1427,7 +1416,7 @@ namespace Components
|
||||
std::string tempZoneFile = Utils::String::VA("zone_source/techsets/techsets%d.csv", subCount);
|
||||
std::string tempZone = Utils::String::VA("techsets/techsets%d", subCount);
|
||||
|
||||
Utils::IO::WriteFile(tempZoneFile, csvStr.data());
|
||||
Utils::IO::WriteFile(tempZoneFile, csvStr);
|
||||
|
||||
Logger::Print("Building zone '{}'...\n", tempZone);
|
||||
Zone(tempZone).build();
|
||||
@ -1472,7 +1461,7 @@ namespace Components
|
||||
std::string tempZoneFile = Utils::String::VA("zone_source/techsets/techsets%d.csv", subCount);
|
||||
std::string tempZone = Utils::String::VA("techsets/techsets%d", subCount);
|
||||
|
||||
Utils::IO::WriteFile(tempZoneFile, csvStr.data());
|
||||
Utils::IO::WriteFile(tempZoneFile, csvStr);
|
||||
|
||||
Logger::Print("Building zone '{}'...\n", tempZone);
|
||||
Zone(tempZone).build();
|
||||
@ -1511,7 +1500,7 @@ namespace Components
|
||||
csvStr.clear();
|
||||
for (auto tech : curTechsets_list)
|
||||
{
|
||||
std::string mat = ZoneBuilder::FindMaterialByTechnique(tech);
|
||||
auto mat = ZoneBuilder::FindMaterialByTechnique(tech);
|
||||
if (mat.length() == 0)
|
||||
{
|
||||
csvStr.append("techset," + tech + "\n");
|
||||
@ -1522,7 +1511,7 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
Utils::IO::WriteFile("zone_source/techsets/techsets.csv", csvStr.data());
|
||||
Utils::IO::WriteFile("zone_source/techsets/techsets.csv", csvStr);
|
||||
|
||||
// set language back
|
||||
Utils::Hook::Set<const char*>(0x649E740, language);
|
||||
@ -1605,7 +1594,7 @@ namespace Components
|
||||
});
|
||||
|
||||
// True by default, but can be put to zero for backward compatibility if needed
|
||||
ZoneBuilder::PreferDiskAssetsDvar = Dvar::Register<bool>("zb_prefer_disk_assets", true, Game::DVAR_NONE, "Should zonebuilder prefer in-memory assets (requirements) or disk assets, when both are present?");
|
||||
ZoneBuilder::ZBPreferDiskAssets = Dvar::Register<bool>("zb_prefer_disk_assets", true, Game::DVAR_NONE, "Should ZoneBuilder prefer in-memory assets (requirements) or disk assets, when both are present");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace Components
|
||||
static std::vector<std::pair<Game::XAssetType, std::string>> EndAssetTrace();
|
||||
|
||||
static Game::XAssetHeader GetEmptyAssetIfCommon(Game::XAssetType type, const std::string& name, Zone* builder);
|
||||
static Dvar::Var PreferDiskAssetsDvar;
|
||||
static Dvar::Var ZBPreferDiskAssets;
|
||||
|
||||
private:
|
||||
static int StoreTexture(Game::GfxImageLoadDef **loadDef, Game::GfxImage *image);
|
||||
|
@ -97,13 +97,23 @@ namespace Utils::IO
|
||||
return std::filesystem::is_empty(directory);
|
||||
}
|
||||
|
||||
std::vector<std::string> ListFiles(const std::filesystem::path& directory)
|
||||
std::vector<std::string> ListFiles(const std::filesystem::path& directory, const bool recursive)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
|
||||
for (auto& file : std::filesystem::directory_iterator(directory))
|
||||
if (recursive)
|
||||
{
|
||||
files.push_back(file.path().generic_string());
|
||||
for (auto& file : std::filesystem::recursive_directory_iterator(directory))
|
||||
{
|
||||
files.push_back(file.path().generic_string());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& file : std::filesystem::directory_iterator(directory))
|
||||
{
|
||||
files.push_back(file.path().generic_string());
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
|
@ -11,5 +11,5 @@ namespace Utils::IO
|
||||
bool CreateDir(const std::string& dir);
|
||||
bool DirectoryExists(const std::filesystem::path& file);
|
||||
bool DirectoryIsEmpty(const std::filesystem::path& file);
|
||||
std::vector<std::string> ListFiles(const std::filesystem::path& directory);
|
||||
std::vector<std::string> ListFiles(const std::filesystem::path& directory, bool recursive = false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user