From 422147207d9355bf9cb92e6dc0b96d4986684f19 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 27 Jan 2016 10:54:29 +0100 Subject: [PATCH] Load new fastfiles (if available!) --- src/Components/Modules/FastFiles.cpp | 23 ++++++++++++++++++++--- src/Components/Modules/FastFiles.hpp | 2 ++ src/Components/Modules/Maps.cpp | 7 +++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index e0ba995e..1f275f3e 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -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(); @@ -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"); } diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index 4cca26ab..6000ce63 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -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 ZonePaths; static const char* GetZoneLocation(const char* file); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 036b9a86..78795fbe 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -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); }