Load new fastfiles (if available!)

This commit is contained in:
momo5502 2016-01-27 10:54:29 +01:00
parent d3a9580f8f
commit 422147207d
3 changed files with 29 additions and 3 deletions

View File

@ -17,12 +17,29 @@ namespace Components
info.name = "dlc2_ui_mp";
data.push_back(info);
// Don't load it for now
//data.push_back({ "weapons_mp", 1, 0 });
// Load custom weapons, if present (force that later on)
if (FastFiles::Exists("weapons_mp"))
{
data.push_back({ "weapons_mp", 1, 0 });
}
Game::DB_LoadXAssets(data.data(), data.size(), sync);
}
// Name is a bit weird, due to FasFileS and ExistS :P
bool FastFiles::Exists(std::string file)
{
std::string path = FastFiles::GetZoneLocation(file.data());
path.append(file);
if (!Utils::EndsWith(path.data(), ".ff"))
{
path.append(".ff");
}
return (GetFileAttributes(path.data()) != INVALID_FILE_ATTRIBUTES);
}
const char* FastFiles::GetZoneLocation(const char* file)
{
const char* dir = Dvar::Var("fs_basepath").Get<const char*>();
@ -32,7 +49,7 @@ namespace Components
std::string absoluteFile = Utils::VA("%s\\%s%s", dir, path.data(), file);
// No ".ff" appended, append it manually
if (!Utils::EndsWith(file, ".ff"))
if (!Utils::EndsWith(absoluteFile.data(), ".ff"))
{
absoluteFile.append(".ff");
}

View File

@ -10,6 +10,8 @@ namespace Components
static void AddZonePath(std::string path);
static std::string Current();
static bool Exists(std::string file);
private:
static std::vector<std::string> ZonePaths;
static const char* GetZoneLocation(const char* file);

View File

@ -40,6 +40,13 @@ namespace Components
data.push_back(info);
}
// Load patch files
std::string patchZone = Utils::VA("patch_%s", zoneInfo->name);
if (FastFiles::Exists(patchZone))
{
data.push_back({ patchZone.data(), zoneInfo->allocFlags, zoneInfo->freeFlags });
}
Game::DB_LoadXAssets(data.data(), data.size(), sync);
}