mirror of
https://github.com/zeldaret/oot.git
synced 2025-02-02 17:44:25 +00:00
20c1f4e648
* First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
129 lines
3 KiB
C++
129 lines
3 KiB
C++
#include "Globals.h"
|
|
#include "File.h"
|
|
#include "tinyxml2.h"
|
|
#include <algorithm>
|
|
|
|
using namespace tinyxml2;
|
|
using namespace std;
|
|
|
|
Globals* Globals::Instance;
|
|
|
|
Globals::Globals()
|
|
{
|
|
Instance = this;
|
|
|
|
files = std::vector<ZFile*>();
|
|
segments = std::vector<int>();
|
|
symbolMap = std::map <uint32_t, std::string>();
|
|
segmentRefs = map<int, string>();
|
|
segmentRefFiles = map<int, ZFile*>();
|
|
game = ZGame::OOT_RETAIL;
|
|
genSourceFile = true;
|
|
testMode = false;
|
|
profile = false;
|
|
includeFilePrefix = false;
|
|
useExternalResources = true;
|
|
lastScene = nullptr;
|
|
verbosity = VERBOSITY_SILENT;
|
|
}
|
|
|
|
string Globals::FindSymbolSegRef(int segNumber, uint32_t symbolAddress)
|
|
{
|
|
if (segmentRefs.find(segNumber) != segmentRefs.end())
|
|
{
|
|
if (segmentRefFiles.find(segNumber) == segmentRefFiles.end())
|
|
{
|
|
XMLDocument doc;
|
|
string filePath = segmentRefs[segNumber];
|
|
XMLError eResult = doc.LoadFile(filePath.c_str());
|
|
|
|
if (eResult != tinyxml2::XML_SUCCESS)
|
|
return "ERROR";
|
|
|
|
XMLNode* root = doc.FirstChild();
|
|
|
|
if (root == nullptr)
|
|
return "ERROR";
|
|
|
|
//vector<ZFile*> files = vector<ZFile*>();
|
|
|
|
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
|
{
|
|
if (string(child->Name()) == "File")
|
|
{
|
|
ZFile* file = new ZFile(fileMode, child, "", "", "", true);
|
|
file->GeneratePlaceholderDeclarations();
|
|
segmentRefFiles[segNumber] = file;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return segmentRefFiles[segNumber]->GetDeclarationName(symbolAddress, "ERROR");
|
|
}
|
|
|
|
return "ERROR";
|
|
}
|
|
|
|
void Globals::ReadConfigFile(const std::string& configFilePath)
|
|
{
|
|
XMLDocument doc;
|
|
XMLError eResult = doc.LoadFile(configFilePath.c_str());
|
|
|
|
if (eResult != tinyxml2::XML_SUCCESS)
|
|
return;
|
|
|
|
XMLNode* root = doc.FirstChild();
|
|
|
|
if (root == nullptr)
|
|
return;
|
|
|
|
for (XMLElement* child = root->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
|
|
{
|
|
if (string(child->Name()) == "SymbolMap")
|
|
{
|
|
string fileName = string(child->Attribute("File"));
|
|
GenSymbolMap(fileName);
|
|
}
|
|
else if (string(child->Name()) == "Segment")
|
|
{
|
|
string fileName = string(child->Attribute("File"));
|
|
int segNumber = child->IntAttribute("Number");
|
|
segmentRefs[segNumber] = fileName;
|
|
}
|
|
}
|
|
}
|
|
|
|
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(int segment)
|
|
{
|
|
if (std::find(segments.begin(), segments.end(), segment) == segments.end())
|
|
segments.push_back(segment);
|
|
}
|
|
|
|
bool Globals::HasSegment(int segment)
|
|
{
|
|
return std::find(segments.begin(), segments.end(), segment) != segments.end();
|
|
}
|
|
|
|
GameConfig::GameConfig()
|
|
{
|
|
segmentRefs = map<int, string>();
|
|
segmentRefFiles = map<int, ZFile*>();
|
|
symbolMap = std::map<uint32_t, std::string>();
|
|
actorList = std::vector<std::string>();
|
|
objectList = std::vector<std::string>();
|
|
}
|