summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom/Commands/SetPathways.cpp
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2021-04-15 07:49:28 -0400
committerGitHub <noreply@github.com>2021-04-15 07:49:28 -0400
commit179af7d11fd27b046edfb1bbadade865033583d7 (patch)
tree316a55e5c0857e26184d6758a324483e029e8849 /ZAPD/ZRoom/Commands/SetPathways.cpp
parent96ffc1e62720f0f43eb4885e6e7dbaf76a2f6cd2 (diff)
Rename "Prerender" to "Background", properly extract PolygonType1 multi format and change some structs used. (#107)
* Extract BgImage Signed-off-by: angie <angheloalf95@gmail.com> * improve the output a bit Signed-off-by: angie <angheloalf95@gmail.com> * extract backgrounds for multipoly Signed-off-by: angie <angheloalf95@gmail.com> * Extract the dlists of PolygonDlist Signed-off-by: angie <angheloalf95@gmail.com> * commands in the next line Signed-off-by: angie <angheloalf95@gmail.com> * Move a lot of repeated code into a class Signed-off-by: angie <angheloalf95@gmail.com> * Use PolygonDlist instead of MeshEntry0 Signed-off-by: angie <angheloalf95@gmail.com> * Rename prerender to background Signed-off-by: angie <angheloalf95@gmail.com> * format Signed-off-by: angie <angheloalf95@gmail.com> * last cleanup Signed-off-by: angie <angheloalf95@gmail.com> * Handle jpg padding Signed-off-by: angie <angheloalf95@gmail.com> * Add a few checks and warnings for jpeg validity Signed-off-by: Angie <angheloalf95@gmail.com> * typo Signed-off-by: Angie <angheloalf95@gmail.com> * fix merge error Signed-off-by: angie <angheloalf95@gmail.com> * Fix background extraction that somehow was broken Signed-off-by: angie <angheloalf95@gmail.com> * re-add the trailling line feed Signed-off-by: angie <angheloalf95@gmail.com> * add trailing line feed again Signed-off-by: angie <angheloalf95@gmail.com> * fix an already fixed warning Signed-off-by: angie <angheloalf95@gmail.com> * fix crash when no config file is provided * run format
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetPathways.cpp')
-rw-r--r--ZAPD/ZRoom/Commands/SetPathways.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/ZAPD/ZRoom/Commands/SetPathways.cpp b/ZAPD/ZRoom/Commands/SetPathways.cpp
index a58b5b0..7e3d49c 100644
--- a/ZAPD/ZRoom/Commands/SetPathways.cpp
+++ b/ZAPD/ZRoom/Commands/SetPathways.cpp
@@ -1,13 +1,14 @@
#include "SetPathways.h"
#include "../../BitConverter.h"
+#include "../../Globals.h"
#include "../../StringHelper.h"
#include "../../ZFile.h"
-#include "../../Globals.h"
#include "../ZRoom.h"
using namespace std;
-SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, bool isFromHeader)
+SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex,
+ bool isFromHeader)
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
{
_rawData = rawData;
@@ -35,7 +36,9 @@ string SetPathways::GetSourceOutputCode(std::string prefix)
string SetPathways::GenerateSourceCodePass1(string roomName, int baseAddress)
{
- int numPaths = (Globals::Instance->game != ZGame::MM_RETAIL) ? 1 : zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
+ int numPaths = (Globals::Instance->game != ZGame::MM_RETAIL) ?
+ 1 :
+ zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
pathwayList = new PathwayList(zRoom, _rawData, segmentOffset, numPaths);
@@ -48,11 +51,11 @@ string SetPathways::GenerateSourceCodePass2(string roomName, int baseAddress)
sourceOutput +=
StringHelper::Sprintf("%s 0, (u32)%sPathway0x%06X };",
- ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
- roomName.c_str(), segmentOffset);
+ ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
+ roomName.c_str(), segmentOffset);
if (pathwayList != nullptr)
- pathwayList->GetSourceOutputCode(roomName);
+ pathwayList->GetSourceOutputCode(roomName);
return sourceOutput;
}
@@ -61,7 +64,7 @@ int32_t SetPathways::GetRawDataSize()
{
int32_t size = 0;
if (pathwayList != nullptr)
- size += pathwayList->GetRawDataSize();
+ size += pathwayList->GetRawDataSize();
return ZRoomCommand::GetRawDataSize() + size;
}
@@ -69,7 +72,7 @@ int32_t SetPathways::GetRawDataSize()
string SetPathways::GenerateExterns()
{
if (pathwayList != nullptr)
- return pathwayList->GenerateExterns();
+ return pathwayList->GenerateExterns();
return std::string();
}
@@ -84,11 +87,10 @@ RoomCommand SetPathways::GetRoomCommand()
return RoomCommand::SetPathways;
}
-PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, int rawDataIndex) :
- numPoints(rawData[rawDataIndex + 0]),
- unk1(rawData[rawDataIndex + 1]),
- unk2(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
- listSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
+PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, int rawDataIndex)
+ : numPoints(rawData[rawDataIndex + 0]), unk1(rawData[rawDataIndex + 1]),
+ unk2(BitConverter::ToInt16BE(rawData, rawDataIndex + 2)),
+ listSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
{
uint32_t currentPtr = listSegmentOffset;
uint8_t* data = rawData.data();
@@ -104,7 +106,7 @@ PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, int rawDataIndex) :
currentPtr += 6;
}
-
+
if (numPoints == 0) // Hack for SharpOcarina
{
for (int i = 0; i < 3; i++)
@@ -149,11 +151,13 @@ void PathwayList::GetSourceOutputCode(std::string prefix)
for (PathwayEntry* entry : pathways)
{
if (Globals::Instance->game == ZGame::MM_RETAIL)
- declaration += StringHelper::Sprintf(" { %i, %i, %i, (u32)%sPathwayList0x%06X },", entry->numPoints,
- entry->unk1, entry->unk2, prefix.c_str(), entry->listSegmentOffset);
+ declaration += StringHelper::Sprintf(" { %i, %i, %i, (u32)%sPathwayList0x%06X },",
+ entry->numPoints, entry->unk1, entry->unk2,
+ prefix.c_str(), entry->listSegmentOffset);
else
- declaration += StringHelper::Sprintf(" { %i, (u32)%sPathwayList0x%06X },", entry->numPoints,
- prefix.c_str(), entry->listSegmentOffset);
+ declaration +=
+ StringHelper::Sprintf(" { %i, (u32)%sPathwayList0x%06X },", entry->numPoints,
+ prefix.c_str(), entry->listSegmentOffset);
if (index < pathways.size() - 1)
declaration += "\n";
@@ -176,7 +180,7 @@ void PathwayList::GetSourceOutputCode(std::string prefix)
for (Vec3s& point : entry->points)
{
declaration += StringHelper::Sprintf(" { %i, %i, %i }, //0x%06X", point.x, point.y,
- point.z, entry->listSegmentOffset + (index * 6));
+ point.z, entry->listSegmentOffset + (index * 6));
if (index < entry->points.size() - 1)
declaration += "\n";
@@ -209,8 +213,8 @@ string PathwayList::GenerateExterns()
string declaration = "";
for (PathwayEntry* entry : pathways)
{
- declaration += StringHelper::Sprintf("extern Vec3s %sPathwayList0x%06X[];\n", zRoom->GetName().c_str(),
- entry->listSegmentOffset);
+ declaration += StringHelper::Sprintf("extern Vec3s %sPathwayList0x%06X[];\n",
+ zRoom->GetName().c_str(), entry->listSegmentOffset);
}
return declaration;