summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2023-05-30 22:07:11 -0400
committerGitHub <noreply@github.com>2023-05-30 22:07:11 -0400
commitbd87285d719e738a8baee8f11d4d6ffce0ab24a0 (patch)
tree1e4956187985e860261c364eca86d9bd0710e19c /ZAPD/ZRoom
parent55bb75eaa6ebf95858931e1557ed90105a150d80 (diff)
Some cleanup and refactoring (#295)
* Cleaned up Main and improved documentation * Moved ZRoom::GetDeclarationSizeFromNeighbor into ZFile * Fixed compile issue
Diffstat (limited to 'ZAPD/ZRoom')
-rw-r--r--ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetEntranceList.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetExitList.cpp2
-rw-r--r--ZAPD/ZRoom/Commands/SetPathways.cpp2
-rw-r--r--ZAPD/ZRoom/ZRoom.cpp18
-rw-r--r--ZAPD/ZRoom/ZRoom.h3
6 files changed, 7 insertions, 22 deletions
diff --git a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
index 1687b54..e64b855 100644
--- a/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
+++ b/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
@@ -21,7 +21,7 @@ void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string&
void SetAlternateHeaders::ParseRawDataLate()
{
- size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
+ size_t numHeaders = zRoom->parent->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
headers.reserve(numHeaders);
for (uint32_t i = 0; i < numHeaders; i++)
diff --git a/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/ZAPD/ZRoom/Commands/SetEntranceList.cpp
index c92f56c..79c87ba 100644
--- a/ZAPD/ZRoom/Commands/SetEntranceList.cpp
+++ b/ZAPD/ZRoom/Commands/SetEntranceList.cpp
@@ -24,7 +24,7 @@ void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& pref
void SetEntranceList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
- uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
+ uint32_t numEntrances = zRoom->parent->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
entrances.reserve(numEntrances);
diff --git a/ZAPD/ZRoom/Commands/SetExitList.cpp b/ZAPD/ZRoom/Commands/SetExitList.cpp
index 80ccc6b..78bbaa8 100644
--- a/ZAPD/ZRoom/Commands/SetExitList.cpp
+++ b/ZAPD/ZRoom/Commands/SetExitList.cpp
@@ -24,7 +24,7 @@ void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
void SetExitList::ParseRawDataLate()
{
// Parse Entrances and Generate Declaration
- uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
+ uint32_t numEntrances = zRoom->parent->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
uint32_t currentPtr = segmentOffset;
exits.reserve(numEntrances);
diff --git a/ZAPD/ZRoom/Commands/SetPathways.cpp b/ZAPD/ZRoom/Commands/SetPathways.cpp
index 52d400a..967d10b 100644
--- a/ZAPD/ZRoom/Commands/SetPathways.cpp
+++ b/ZAPD/ZRoom/Commands/SetPathways.cpp
@@ -24,7 +24,7 @@ void SetPathways::ParseRawDataLate()
{
if (Globals::Instance->game == ZGame::MM_RETAIL)
{
- auto numPaths = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
+ auto numPaths = zRoom->parent->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
pathwayList.SetNumPaths(numPaths);
}
diff --git a/ZAPD/ZRoom/ZRoom.cpp b/ZAPD/ZRoom/ZRoom.cpp
index de9ee61..a28ea7b 100644
--- a/ZAPD/ZRoom/ZRoom.cpp
+++ b/ZAPD/ZRoom/ZRoom.cpp
@@ -64,9 +64,9 @@ ZRoom::~ZRoom()
delete cmd;
}
-void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
+void ZRoom::ExtractWithXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex)
{
- ZResource::ExtractFromXML(reader, nRawDataIndex);
+ ZResource::ExtractWithXML(reader, nRawDataIndex);
if (hackMode == "syotes_room")
SyotesRoomFix();
@@ -356,20 +356,6 @@ ZRoomCommand* ZRoom::FindCommandOfType(RoomCommand cmdType)
return nullptr;
}
-size_t ZRoom::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress)
-{
- auto currentDecl = parent->declarations.find(declarationAddress);
- if (currentDecl == parent->declarations.end())
- return 0;
-
- auto nextDecl = currentDecl;
- std::advance(nextDecl, 1);
- if (nextDecl == parent->declarations.end())
- return parent->GetRawData().size() - currentDecl->first;
-
- return nextDecl->first - currentDecl->first;
-}
-
size_t ZRoom::GetCommandSizeFromNeighbor(ZRoomCommand* cmd)
{
int32_t cmdIndex = -1;
diff --git a/ZAPD/ZRoom/ZRoom.h b/ZAPD/ZRoom/ZRoom.h
index 4e9026f..950dbbb 100644
--- a/ZAPD/ZRoom/ZRoom.h
+++ b/ZAPD/ZRoom/ZRoom.h
@@ -22,7 +22,7 @@ public:
ZRoom(ZFile* nParent);
virtual ~ZRoom();
- void ExtractFromXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override;
+ void ExtractWithXML(tinyxml2::XMLElement* reader, uint32_t nRawDataIndex) override;
void ExtractFromBinary(uint32_t nRawDataIndex, ZResourceType parentType);
void ParseXML(tinyxml2::XMLElement* reader) override;
@@ -37,7 +37,6 @@ public:
void GetSourceOutputCode(const std::string& prefix) override;
std::string GetDefaultName(const std::string& prefix) const override;
- size_t GetDeclarationSizeFromNeighbor(uint32_t declarationAddress);
size_t GetCommandSizeFromNeighbor(ZRoomCommand* cmd);
ZRoomCommand* FindCommandOfType(RoomCommand cmdType);