summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>2021-10-11 21:05:36 +0100
committerGitHub <noreply@github.com>2021-10-11 16:05:36 -0400
commit3e9ed72e202b1165152d42f7d160695f9f2f233a (patch)
tree6bee7b0772be9c591f076815850e7f52fc255b4b
parent1c687a69c1f6b84a3fea1bcab8e141f8a26e16dc (diff)
Divide ReadConfigFile into separate functions and move them and the rest of GameConfig to their own file (#168)
* Working as a separate file * Actually use classes * Remove init, use invoke * Change configFilePath to a member of GameConfig * Remove commented stuff, format * Fix invoke, maybe? And lighten up the includes * string_view * Remove unnecessary std::string initialisations * Rest of Leo's review * Format * Merge remote-tracking branch 'upstream/master' into config * Fix merge breakages
-rw-r--r--ZAPD/GameConfig.cpp140
-rw-r--r--ZAPD/GameConfig.h44
-rw-r--r--ZAPD/Globals.cpp127
-rw-r--r--ZAPD/Globals.h28
-rw-r--r--ZAPD/Main.cpp17
-rw-r--r--ZAPD/ZDisplayList.cpp16
-rw-r--r--ZAPD/ZFile.cpp9
-rw-r--r--ZAPD/ZRoom/ZRoom.cpp9
8 files changed, 220 insertions, 170 deletions
diff --git a/ZAPD/GameConfig.cpp b/ZAPD/GameConfig.cpp
new file mode 100644
index 0000000..69ce045
--- /dev/null
+++ b/ZAPD/GameConfig.cpp
@@ -0,0 +1,140 @@
+#include "GameConfig.h"
+
+#include <functional>
+#include <string_view>
+#include "Utils/Directory.h"
+#include "Utils/File.h"
+#include "Utils/Path.h"
+#include "tinyxml2.h"
+
+using ConfigFunc = void (GameConfig::*)(const tinyxml2::XMLElement&);
+
+void GameConfig::ReadTexturePool(const std::string& texturePoolXmlPath)
+{
+ tinyxml2::XMLDocument doc;
+ tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
+
+ if (eResult != tinyxml2::XML_SUCCESS)
+ {
+ fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult);
+ return;
+ }
+
+ tinyxml2::XMLNode* root = doc.FirstChild();
+
+ if (root == nullptr)
+ return;
+
+ for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr;
+ child = child->NextSiblingElement())
+ {
+ if (std::string_view(child->Name()) == "Texture")
+ {
+ std::string crcStr = child->Attribute("CRC");
+ fs::path texPath = child->Attribute("Path");
+ std::string texName;
+
+ uint32_t crc = strtoul(crcStr.c_str(), nullptr, 16);
+
+ texturePool[crc].path = texPath;
+ }
+ }
+}
+
+void GameConfig::GenSymbolMap(const std::string& symbolMapPath)
+{
+ auto symbolLines = File::ReadAllLines(symbolMapPath);
+
+ for (std::string& symbolLine : symbolLines)
+ {
+ auto split = StringHelper::Split(symbolLine, " ");
+ uint32_t addr = strtoul(split[0].c_str(), nullptr, 16);
+ std::string symbolName = split[1];
+
+ symbolMap[addr] = std::move(symbolName);
+ }
+}
+
+void GameConfig::ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element)
+{
+ std::string fileName = element.Attribute("File");
+ GenSymbolMap(Path::GetDirectoryName(configFilePath) + "/" + fileName);
+}
+
+void GameConfig::ConfigFunc_Segment(const tinyxml2::XMLElement& element)
+{
+ std::string fileName = element.Attribute("File");
+ int32_t segNumber = element.IntAttribute("Number");
+ segmentRefs[segNumber] = std::move(fileName);
+}
+
+void GameConfig::ConfigFunc_ActorList(const tinyxml2::XMLElement& element)
+{
+ std::string fileName = element.Attribute("File");
+ std::vector<std::string> lines =
+ File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
+
+ for (auto& line : lines)
+ actorList.emplace_back(std::move(line));
+}
+
+void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element)
+{
+ std::string fileName = element.Attribute("File");
+ std::vector<std::string> lines =
+ File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
+
+ for (auto& line : lines)
+ objectList.emplace_back(std::move(line));
+}
+
+void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element)
+{
+ std::string fileName = element.Attribute("File");
+ ReadTexturePool(Path::GetDirectoryName(configFilePath) + "/" + fileName);
+}
+
+void GameConfig::ConfigFunc_BGConfig(const tinyxml2::XMLElement& element)
+{
+ bgScreenWidth = element.IntAttribute("ScreenWidth", 320);
+ bgScreenHeight = element.IntAttribute("ScreenHeight", 240);
+}
+
+void GameConfig::ReadConfigFile(const std::string& argConfigFilePath)
+{
+ static const std::map<std::string, ConfigFunc> ConfigFuncDictionary = {
+ {"SymbolMap", &GameConfig::ConfigFunc_SymbolMap},
+ {"Segment", &GameConfig::ConfigFunc_Segment},
+ {"ActorList", &GameConfig::ConfigFunc_ActorList},
+ {"ObjectList", &GameConfig::ConfigFunc_ObjectList},
+ {"TexturePool", &GameConfig::ConfigFunc_TexturePool},
+ {"BGConfig", &GameConfig::ConfigFunc_BGConfig},
+ };
+
+ configFilePath = argConfigFilePath;
+ tinyxml2::XMLDocument doc;
+ tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str());
+
+ if (eResult != tinyxml2::XML_SUCCESS)
+ {
+ throw std::runtime_error("Error: Unable to read config file.");
+ }
+
+ tinyxml2::XMLNode* root = doc.FirstChild();
+
+ if (root == nullptr)
+ return;
+
+ for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != nullptr;
+ child = child->NextSiblingElement())
+ {
+ auto it = ConfigFuncDictionary.find(child->Name());
+ if (it == ConfigFuncDictionary.end())
+ {
+ fprintf(stderr, "Unsupported configuration variable: %s\n", child->Name());
+ continue;
+ }
+
+ std::invoke(it->second, *this, *child);
+ }
+}
diff --git a/ZAPD/GameConfig.h b/ZAPD/GameConfig.h
new file mode 100644
index 0000000..a9bbf72
--- /dev/null
+++ b/ZAPD/GameConfig.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <string>
+#include <vector>
+#include "Utils/Directory.h"
+#include "tinyxml2.h"
+
+struct TexturePoolEntry
+{
+ fs::path path = ""; // Path to Shared Texture
+};
+
+class ZFile;
+
+class GameConfig
+{
+public:
+ std::string configFilePath;
+ std::map<int32_t, std::string> segmentRefs;
+ std::map<int32_t, ZFile*> segmentRefFiles;
+ std::map<uint32_t, std::string> symbolMap;
+ std::vector<std::string> actorList;
+ std::vector<std::string> objectList;
+ std::map<uint32_t, TexturePoolEntry> texturePool; // Key = CRC
+
+ // ZBackground
+ uint32_t bgScreenWidth = 320, bgScreenHeight = 240;
+
+ GameConfig() = default;
+
+ void ReadTexturePool(const std::string& texturePoolXmlPath);
+ void GenSymbolMap(const std::string& symbolMapPath);
+
+ void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element);
+ void ConfigFunc_Segment(const tinyxml2::XMLElement& element);
+ void ConfigFunc_ActorList(const tinyxml2::XMLElement& element);
+ void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element);
+ void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element);
+ void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element);
+
+ void ReadConfigFile(const std::string& configFilePath);
+};
diff --git a/ZAPD/Globals.cpp b/ZAPD/Globals.cpp
index f150252..893722b 100644
--- a/ZAPD/Globals.cpp
+++ b/ZAPD/Globals.cpp
@@ -1,6 +1,7 @@
#include "Globals.h"
#include <algorithm>
+#include <string_view>
#include <Utils/File.h>
#include <Utils/Path.h>
@@ -14,9 +15,6 @@ Globals::Globals()
files = std::vector<ZFile*>();
segments = std::vector<int32_t>();
- symbolMap = std::map<uint32_t, std::string>();
- segmentRefs = std::map<int32_t, std::string>();
- segmentRefFiles = std::map<int32_t, ZFile*>();
game = ZGame::OOT_RETAIL;
genSourceFile = true;
testMode = false;
@@ -30,12 +28,12 @@ Globals::Globals()
std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
{
- if (segmentRefs.find(segNumber) != segmentRefs.end())
+ if (cfg.segmentRefs.find(segNumber) != cfg.segmentRefs.end())
{
- if (segmentRefFiles.find(segNumber) == segmentRefFiles.end())
+ if (cfg.segmentRefFiles.find(segNumber) == cfg.segmentRefFiles.end())
{
tinyxml2::XMLDocument doc;
- std::string filePath = segmentRefs[segNumber];
+ std::string filePath = cfg.segmentRefs[segNumber];
tinyxml2::XMLError eResult = doc.LoadFile(filePath.c_str());
if (eResult != tinyxml2::XML_SUCCESS)
@@ -49,136 +47,29 @@ std::string Globals::FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress)
for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
child = child->NextSiblingElement())
{
- if (std::string(child->Name()) == "File")
+ if (std::string_view(child->Name()) == "File")
{
ZFile* file = new ZFile(fileMode, child, "", "", filePath, true);
file->GeneratePlaceholderDeclarations();
- segmentRefFiles[segNumber] = file;
+ cfg.segmentRefFiles[segNumber] = file;
break;
}
}
}
- return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
+ return cfg.segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
}
return "ERROR";
}
-void Globals::ReadConfigFile(const std::string& configFilePath)
-{
- tinyxml2::XMLDocument doc;
- tinyxml2::XMLError eResult = doc.LoadFile(configFilePath.c_str());
-
- if (eResult != tinyxml2::XML_SUCCESS)
- {
- throw std::runtime_error("Error: Unable to read config file.");
- return;
- }
-
- tinyxml2::XMLNode* root = doc.FirstChild();
-
- if (root == nullptr)
- return;
-
- for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
- child = child->NextSiblingElement())
- {
- if (std::string(child->Name()) == "SymbolMap")
- {
- std::string fileName = std::string(child->Attribute("File"));
- GenSymbolMap(Path::GetDirectoryName(configFilePath) + "/" + fileName);
- }
- else if (std::string(child->Name()) == "Segment")
- {
- std::string fileName = std::string(child->Attribute("File"));
- int32_t segNumber = child->IntAttribute("Number");
- segmentRefs[segNumber] = fileName;
- }
- else if (std::string(child->Name()) == "ActorList")
- {
- std::string fileName = std::string(child->Attribute("File"));
- std::vector<std::string> lines =
- File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
-
- for (std::string line : lines)
- cfg.actorList.push_back(StringHelper::Strip(line, "\r"));
- }
- else if (std::string(child->Name()) == "ObjectList")
- {
- std::string fileName = std::string(child->Attribute("File"));
- std::vector<std::string> lines =
- File::ReadAllLines(Path::GetDirectoryName(configFilePath) + "/" + fileName);
-
- for (std::string line : lines)
- cfg.objectList.push_back(StringHelper::Strip(line, "\r"));
- }
- else if (std::string(child->Name()) == "TexturePool")
- {
- std::string fileName = std::string(child->Attribute("File"));
- ReadTexturePool(Path::GetDirectoryName(configFilePath) + "/" + fileName);
- }
- else if (std::string(child->Name()) == "BGConfig")
- {
- cfg.bgScreenWidth = child->IntAttribute("ScreenWidth", 320);
- cfg.bgScreenHeight = child->IntAttribute("ScreenHeight", 240);
- }
- }
-}
-
-void Globals::ReadTexturePool(const std::string& texturePoolXmlPath)
-{
- tinyxml2::XMLDocument doc;
- tinyxml2::XMLError eResult = doc.LoadFile(texturePoolXmlPath.c_str());
-
- if (eResult != tinyxml2::XML_SUCCESS)
- {
- fprintf(stderr, "Warning: Unable to read texture pool XML with error code %i\n", eResult);
- return;
- }
-
- tinyxml2::XMLNode* root = doc.FirstChild();
-
- if (root == nullptr)
- return;
-
- for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
- child = child->NextSiblingElement())
- {
- if (std::string(child->Name()) == "Texture")
- {
- std::string crcStr = std::string(child->Attribute("CRC"));
- fs::path texPath = std::string(child->Attribute("Path"));
- std::string texName;
-
- uint32_t crc = strtoul(crcStr.c_str(), NULL, 16);
-
- cfg.texturePool[crc].path = texPath;
- }
- }
-}
-
-void Globals::GenSymbolMap(const std::string& symbolMapPath)
-{
- auto symbolLines = File::ReadAllLines(symbolMapPath);
-
- for (std::string symbolLine : symbolLines)
- {
- auto split = StringHelper::Split(symbolLine, " ");
- uint32_t addr = strtoul(split[0].c_str(), NULL, 16);
- std::string symbolName = split[1];
-
- symbolMap[addr] = symbolName;
- }
-}
-
void Globals::AddSegment(int32_t segment, ZFile* file)
{
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
segments.push_back(segment);
- segmentRefs[segment] = file->GetXmlFilePath().string();
- segmentRefFiles[segment] = file;
+ cfg.segmentRefs[segment] = file->GetXmlFilePath().string();
+ cfg.segmentRefFiles[segment] = file;
}
bool Globals::HasSegment(int32_t segment)
diff --git a/ZAPD/Globals.h b/ZAPD/Globals.h
index 4811d95..0e6d344 100644
--- a/ZAPD/Globals.h
+++ b/ZAPD/Globals.h
@@ -3,6 +3,7 @@
#include <map>
#include <string>
#include <vector>
+#include "GameConfig.h"
#include "ZFile.h"
class ZRoom;
@@ -14,27 +15,6 @@ enum class VerbosityLevel
VERBOSITY_DEBUG
};
-struct TexturePoolEntry
-{
- fs::path path = ""; // Path to Shared Texture
-};
-
-class GameConfig
-{
-public:
- std::map<int32_t, std::string> segmentRefs;
- std::map<int32_t, ZFile*> segmentRefFiles;
- std::map<uint32_t, std::string> symbolMap;
- std::vector<std::string> actorList;
- std::vector<std::string> objectList;
- std::map<uint32_t, TexturePoolEntry> texturePool; // Key = CRC
-
- // ZBackground
- uint32_t bgScreenWidth = 320, bgScreenHeight = 240;
-
- GameConfig() = default;
-};
-
typedef void (*ExporterSetFunc)(ZFile*);
typedef bool (*ExporterSetFuncBool)(ZFileMode fileMode);
typedef void (*ExporterSetFuncVoid)(int argc, char* argv[], int& i);
@@ -80,10 +60,7 @@ public:
std::vector<ZFile*> files;
std::vector<int32_t> segments;
- std::map<int32_t, std::string> segmentRefs;
- std::map<int32_t, ZFile*> segmentRefFiles;
ZRoom* lastScene;
- std::map<uint32_t, std::string> symbolMap;
std::string currentExporter;
static std::map<std::string, ExporterSet*>* GetExporterMap();
@@ -91,9 +68,6 @@ public:
Globals();
std::string FindSymbolSegRef(int32_t segNumber, uint32_t symbolAddress);
- void ReadConfigFile(const std::string& configFilePath);
- void ReadTexturePool(const std::string& texturePoolXmlPath);
- void GenSymbolMap(const std::string& symbolMapPath);
void AddSegment(int32_t segment, ZFile* file);
bool HasSegment(int32_t segment);
ZResourceExporter* GetExporter(ZResourceType resType);
diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp
index 703de1c..9099cef 100644
--- a/ZAPD/Main.cpp
+++ b/ZAPD/Main.cpp
@@ -20,6 +20,7 @@
#endif
#include <string>
+#include <string_view>
#include "tinyxml2.h"
extern const char gBuildHash[];
@@ -139,30 +140,30 @@ int main(int argc, char* argv[])
}
else if (arg == "-gsf") // Generate source file during extraction
{
- Globals::Instance->genSourceFile = std::string(argv[++i]) == "1";
+ Globals::Instance->genSourceFile = std::string_view(argv[++i]) == "1";
}
else if (arg == "-tm") // Test Mode (enables certain experimental features)
{
- Globals::Instance->testMode = std::string(argv[++i]) == "1";
+ Globals::Instance->testMode = std::string_view(argv[++i]) == "1";
}
else if (arg == "-crc" ||
arg == "--output-crc") // Outputs a CRC file for each extracted texture.
{
- Globals::Instance->testMode = std::string(argv[++i]) == "1";
+ Globals::Instance->testMode = std::string_view(argv[++i]) == "1";
}
else if (arg == "-ulzdl") // Use Legacy ZDisplay List
{
- Globals::Instance->useLegacyZDList = std::string(argv[++i]) == "1";
+ Globals::Instance->useLegacyZDList = std::string_view(argv[++i]) == "1";
}
else if (arg == "-profile") // Enable profiling
{
- Globals::Instance->profile = std::string(argv[++i]) == "1";
+ Globals::Instance->profile = std::string_view(argv[++i]) == "1";
}
else if (arg ==
"-uer") // Split resources into their individual components (enabled by default)
// TODO: We may wish to make this a part of the config file...
{
- Globals::Instance->useExternalResources = std::string(argv[++i]) == "1";
+ Globals::Instance->useExternalResources = std::string_view(argv[++i]) == "1";
}
else if (arg == "-tt") // Set texture type
{
@@ -176,7 +177,7 @@ int main(int argc, char* argv[])
}
else if (arg == "-rconf") // Read Config File
{
- Globals::Instance->ReadConfigFile(argv[++i]);
+ Globals::Instance->cfg.ReadConfigFile(argv[++i]);
}
else if (arg == "-eh") // Enable Error Handler
{
@@ -353,7 +354,7 @@ bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, ZFileMode file
for (tinyxml2::XMLElement* child = root->FirstChildElement(); child != NULL;
child = child->NextSiblingElement())
{
- if (std::string(child->Name()) == "File")
+ if (std::string_view(child->Name()) == "File")
{
ZFile* file = new ZFile(fileMode, child, basePath, "", xmlFilePath, false);
Globals::Instance->files.push_back(file);
diff --git a/ZAPD/ZDisplayList.cpp b/ZAPD/ZDisplayList.cpp
index aca629e..bf5a895 100644
--- a/ZAPD/ZDisplayList.cpp
+++ b/ZAPD/ZDisplayList.cpp
@@ -527,7 +527,7 @@ int32_t ZDisplayList::OptimizationCheck_LoadTextureBlock(int32_t startIndex, std
ZFile* auxParent = parent;
if (parent->segment != segmentNumber && Globals::Instance->HasSegment(segmentNumber))
- auxParent = Globals::Instance->segmentRefFiles.at(segmentNumber);
+ auxParent = Globals::Instance->cfg.segmentRefFiles.at(segmentNumber);
Declaration* decl = auxParent->GetDeclaration(texAddr);
if (Globals::Instance->HasSegment(segmentNumber) && decl != nullptr)
@@ -785,8 +785,8 @@ void ZDisplayList::Opcode_G_MTX(uint64_t data, char* line)
std::string matrixRef;
- if (Globals::Instance->symbolMap.find(mm) != Globals::Instance->symbolMap.end())
- matrixRef = StringHelper::Sprintf("&%s", Globals::Instance->symbolMap[mm].c_str());
+ if (Globals::Instance->cfg.symbolMap.find(mm) != Globals::Instance->cfg.symbolMap.end())
+ matrixRef = StringHelper::Sprintf("&%s", Globals::Instance->cfg.symbolMap[mm].c_str());
else
matrixRef = StringHelper::Sprintf("0x%08X", mm);
@@ -1665,7 +1665,7 @@ static int32_t GfxdCallback_Texture(segptr_t seg, int32_t fmt, int32_t siz, int3
ZFile* auxParent = self->parent;
if (self->parent->segment != texSegNum && Globals::Instance->HasSegment(texSegNum))
- auxParent = Globals::Instance->segmentRefFiles.at(texSegNum);
+ auxParent = Globals::Instance->cfg.segmentRefFiles.at(texSegNum);
Declaration* decl = auxParent->GetDeclaration(texOffset);
if (Globals::Instance->HasSegment(texSegNum) && decl != nullptr)
@@ -1701,7 +1701,7 @@ static int32_t GfxdCallback_Palette(uint32_t seg, [[maybe_unused]] int32_t idx,
ZFile* auxParent = self->parent;
if (self->parent->segment != palSegNum && Globals::Instance->HasSegment(palSegNum))
- auxParent = Globals::Instance->segmentRefFiles.at(palSegNum);
+ auxParent = Globals::Instance->cfg.segmentRefFiles.at(palSegNum);
Declaration* decl = auxParent->GetDeclaration(palOffset);
if (Globals::Instance->HasSegment(palSegNum) && decl != nullptr)
@@ -1734,7 +1734,7 @@ static int32_t GfxdCallback_DisplayList(uint32_t seg)
ZFile* auxParent = self->parent;
if (self->parent->segment != dListSegNum && Globals::Instance->HasSegment(dListSegNum))
- auxParent = Globals::Instance->segmentRefFiles.at(dListSegNum);
+ auxParent = Globals::Instance->cfg.segmentRefFiles.at(dListSegNum);
std::string dListName = auxParent->GetDeclarationPtrName(seg);
@@ -1748,8 +1748,8 @@ static int32_t GfxdCallback_Matrix(uint32_t seg)
std::string mtxName;
ZDisplayList* self = static_cast<ZDisplayList*>(gfxd_udata_get());
- if (Globals::Instance->symbolMap.find(seg) != Globals::Instance->symbolMap.end())
- mtxName = StringHelper::Sprintf("&%s", Globals::Instance->symbolMap[seg].c_str());
+ if (Globals::Instance->cfg.symbolMap.find(seg) != Globals::Instance->cfg.symbolMap.end())
+ mtxName = StringHelper::Sprintf("&%s", Globals::Instance->cfg.symbolMap[seg].c_str());
else if (Globals::Instance->HasSegment(GETSEGNUM(seg)))
{
Declaration* decl =
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp
index 6e02ea4..2245168 100644
--- a/ZAPD/ZFile.cpp
+++ b/ZAPD/ZFile.cpp
@@ -2,6 +2,7 @@
#include <algorithm>
#include <cassert>
+#include <string_view>
#include <unordered_set>
#include <Utils/BinaryWriter.h>
@@ -89,11 +90,11 @@ void ZFile::ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, const std::st
const char* gameStr = reader->Attribute("Game");
if (reader->Attribute("Game") != nullptr)
{
- if (std::string(gameStr) == "MM")
+ if (std::string_view(gameStr) == "MM")
Globals::Instance->game = ZGame::MM_RETAIL;
- else if (std::string(gameStr) == "SW97" || std::string(gameStr) == "OOTSW97")
+ else if (std::string_view(gameStr) == "SW97" || std::string_view(gameStr) == "OOTSW97")
Globals::Instance->game = ZGame::OOT_SW97;
- else if (std::string(gameStr) == "OOT")
+ else if (std::string_view(gameStr) == "OOT")
Globals::Instance->game = ZGame::OOT_RETAIL;
else
throw std::runtime_error(
@@ -213,7 +214,7 @@ void ZFile::ParseXML(ZFileMode mode, tinyxml2::XMLElement* reader, const std::st
rawDataIndex += nRes->GetRawDataSize();
}
- else if (std::string(child->Name()) == "File")
+ else if (std::string_view(child->Name()) == "File")
{
throw std::runtime_error(StringHelper::Sprintf(
"ZFile::ParseXML: Error in '%s'.\n\t Can't declare a File inside a File.\n",
diff --git a/ZAPD/ZRoom/ZRoom.cpp b/ZAPD/ZRoom/ZRoom.cpp
index 4c148ab..af9122f 100644
--- a/ZAPD/ZRoom/ZRoom.cpp
+++ b/ZAPD/ZRoom/ZRoom.cpp
@@ -1,9 +1,8 @@
#include "ZRoom.h"
-
#include <algorithm>
#include <cassert>
#include <chrono>
-
+#include <string_view>
#include "Commands/EndMarker.h"
#include "Commands/SetActorCutsceneList.h"
#include "Commands/SetActorList.h"
@@ -330,9 +329,9 @@ std::string ZRoom::GetDefaultName(const std::string& prefix) const
}
/*
- * There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates back to very
- * early in the game's development. Since this room is a special case, declare automatically the
- * data its contains whitout the need of a header.
+ * There is one room in Ocarina of Time that lacks a header. Room 120, "Syotes", dates
+ * back to very early in the game's development. Since this room is a special case,
+ * declare automatically the data its contains whitout the need of a header.
*/
void ZRoom::SyotesRoomHack()
{