From 23d0fe1eb08f5ec334d59336954c6a8d7d3947bd Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 7 Oct 2023 15:17:06 +0200 Subject: [PATCH] Always load/unload project specific zones --- src/Linker/Linker.cpp | 39 ++++++++++++++++++++------------- src/Utils/Utils/StringUtils.cpp | 12 ++++++++++ src/Utils/Utils/StringUtils.h | 3 +++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/Linker/Linker.cpp b/src/Linker/Linker.cpp index 738173a3..d94d39d8 100644 --- a/src/Linker/Linker.cpp +++ b/src/Linker/Linker.cpp @@ -25,6 +25,7 @@ #include "Game/T6/ZoneCreatorT6.h" #include "Utils/ObjFileStream.h" +#include "Utils/StringUtils.h" #include "Zone/AssetList/AssetList.h" #include "Zone/AssetList/AssetListStream.h" #include "Zone/Definition/ZoneDefinitionStream.h" @@ -403,28 +404,21 @@ class LinkerImpl final : public Linker return true; } - bool BuildFastFile(const std::string& projectName, ZoneDefinition& zoneDefinition, SearchPaths& sourceSearchPaths) + bool BuildFastFile(const std::string& projectName, ZoneDefinition& zoneDefinition, SearchPaths& assetSearchPaths, SearchPaths& gdtSearchPaths, SearchPaths& sourceSearchPaths) const { - std::string gameName; - if (!GetGameNameFromZoneDefinition(gameName, projectName, zoneDefinition)) - return false; - - for (auto& c : gameName) - c = static_cast(std::tolower(c)); - - auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName); - auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName); - const auto zone = CreateZoneForDefinition(projectName, zoneDefinition, &assetSearchPaths, &gdtSearchPaths, &sourceSearchPaths); auto result = zone != nullptr; if (zone) result = WriteZoneToFile(projectName, zone.get()); - m_search_paths.UnloadProjectSpecificSearchPaths(); - return result; } + bool BuildIPak(const std::string& projectName, ZoneDefinition& zoneDefinition, SearchPaths& assetSearchPaths, SearchPaths& sourceSearchPaths) + { + return false; + } + bool BuildProject(const std::string& projectName) { auto sourceSearchPaths = m_search_paths.GetSourceSearchPathsForProject(projectName); @@ -437,18 +431,33 @@ class LinkerImpl final : public Linker if (!GetProjectTypeFromZoneDefinition(projectType, projectName, *zoneDefinition)) return false; + std::string gameName; + if (!GetGameNameFromZoneDefinition(gameName, projectName, *zoneDefinition)) + return false; + utils::MakeStringLowerCase(gameName); + + auto assetSearchPaths = m_search_paths.GetAssetSearchPathsForProject(gameName, projectName); + auto gdtSearchPaths = m_search_paths.GetGdtSearchPathsForProject(gameName, projectName); + + auto result = false; switch (projectType) { case ProjectType::FASTFILE: - return BuildFastFile(projectName, *zoneDefinition, sourceSearchPaths); + result = BuildFastFile(projectName, *zoneDefinition, assetSearchPaths, gdtSearchPaths, sourceSearchPaths); + break; case ProjectType::IPAK: + result = BuildIPak(projectName, *zoneDefinition, assetSearchPaths, sourceSearchPaths); + break; + default: assert(false); break; } - return false; + m_search_paths.UnloadProjectSpecificSearchPaths(); + + return result; } bool LoadZones() diff --git a/src/Utils/Utils/StringUtils.cpp b/src/Utils/Utils/StringUtils.cpp index e7f84d9a..3edf0c59 100644 --- a/src/Utils/Utils/StringUtils.cpp +++ b/src/Utils/Utils/StringUtils.cpp @@ -88,4 +88,16 @@ namespace utils inEscape = true; } } + + void MakeStringLowerCase(std::string& str) + { + for (auto& c : str) + c = static_cast(tolower(c)); + } + + void MakeStringUpperCase(std::string& str) + { + for (auto& c : str) + c = static_cast(toupper(c)); + } } diff --git a/src/Utils/Utils/StringUtils.h b/src/Utils/Utils/StringUtils.h index 860f8dbb..d49de6b9 100644 --- a/src/Utils/Utils/StringUtils.h +++ b/src/Utils/Utils/StringUtils.h @@ -11,4 +11,7 @@ namespace utils void EscapeStringForQuotationMarks(std::ostream& stream, const std::string_view& str); std::string UnescapeStringFromQuotationMarks(const std::string_view& str); void UnescapeStringFromQuotationMarks(std::ostream& stream, const std::string_view& str); + + void MakeStringLowerCase(std::string& str); + void MakeStringUpperCase(std::string& str); }