summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2021-04-13 12:08:54 -0400
committerGitHub <noreply@github.com>2021-04-13 12:08:54 -0400
commit96ffc1e62720f0f43eb4885e6e7dbaf76a2f6cd2 (patch)
treeb35772e0a399a4b19590492fdb9fce556b232c79
parent420508d2d872e8653081d95a43bf2ad8f85d894c (diff)
Fixed pathway bug (#112)
Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
-rw-r--r--ZAPD/ZRoom/Commands/SetPathways.cpp12
-rw-r--r--ZAPD/ZRoom/Commands/SetPathways.h2
-rw-r--r--ZAPD/ZRoom/ZRoom.cpp9
3 files changed, 9 insertions, 14 deletions
diff --git a/ZAPD/ZRoom/Commands/SetPathways.cpp b/ZAPD/ZRoom/Commands/SetPathways.cpp
index d36d15d..a58b5b0 100644
--- a/ZAPD/ZRoom/Commands/SetPathways.cpp
+++ b/ZAPD/ZRoom/Commands/SetPathways.cpp
@@ -7,13 +7,16 @@
using namespace std;
-SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
+SetPathways::SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, bool isFromHeader)
: ZRoomCommand(nZRoom, rawData, rawDataIndex)
{
_rawData = rawData;
_rawDataIndex = rawDataIndex;
- segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
+ if (isFromHeader)
+ segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
+ else
+ segmentOffset = _rawDataIndex;
if (segmentOffset != 0)
zRoom->parent->AddDeclarationPlaceholder(segmentOffset);
@@ -32,7 +35,7 @@ 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);
@@ -88,7 +91,6 @@ PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, int rawDataIndex) :
listSegmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)))
{
uint32_t currentPtr = listSegmentOffset;
-
uint8_t* data = rawData.data();
for (int i = 0; i < numPoints; i++)
@@ -98,7 +100,6 @@ PathwayEntry::PathwayEntry(std::vector<uint8_t> rawData, int rawDataIndex) :
z = BitConverter::ToInt16BE(data, currentPtr + 4);
Vec3s point = Vec3s(x, y, z);
-
points.push_back(point);
currentPtr += 6;
@@ -120,7 +121,6 @@ PathwayList::PathwayList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDat
_rawDataIndex = rawDataIndex;
uint32_t currentPtr = rawDataIndex;
-
uint8_t* data = rawData.data();
for (int pathIndex = 0; pathIndex < length; pathIndex++)
diff --git a/ZAPD/ZRoom/Commands/SetPathways.h b/ZAPD/ZRoom/Commands/SetPathways.h
index c41fdf2..06d0c37 100644
--- a/ZAPD/ZRoom/Commands/SetPathways.h
+++ b/ZAPD/ZRoom/Commands/SetPathways.h
@@ -37,7 +37,7 @@ private:
class SetPathways : public ZRoomCommand
{
public:
- SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex);
+ SetPathways(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex, bool isFromHeader);
~SetPathways();
std::string GetSourceOutputCode(std::string prefix);
diff --git a/ZAPD/ZRoom/ZRoom.cpp b/ZAPD/ZRoom/ZRoom.cpp
index 77d4032..a7325f8 100644
--- a/ZAPD/ZRoom/ZRoom.cpp
+++ b/ZAPD/ZRoom/ZRoom.cpp
@@ -179,8 +179,7 @@ void ZRoom::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8
string addressStr = child->Attribute("Offset");
int address = strtol(StringHelper::Split(addressStr, "0x")[1].c_str(), NULL, 16);
- SetPathways* pathway = new SetPathways(this, rawData, address);
- //pathway->InitList(address);
+ SetPathways* pathway = new SetPathways(this, rawData, address, false);
pathway->GenerateSourceCodePass1(name, 0);
pathway->GenerateSourceCodePass2(name, 0);
@@ -285,7 +284,7 @@ void ZRoom::ParseCommands(std::vector<ZRoomCommand*>& commandList, CommandSet co
cmd = new SetLightList(this, rawData, rawDataIndex);
break; // 0x0C (MM-ONLY)
case RoomCommand::SetPathways:
- cmd = new SetPathways(this, rawData, rawDataIndex);
+ cmd = new SetPathways(this, rawData, rawDataIndex, true);
break; // 0x0D
case RoomCommand::SetTransitionActorList:
cmd = new SetTransitionActorList(this, rawData, rawDataIndex);
@@ -322,13 +321,9 @@ void ZRoom::ParseCommands(std::vector<ZRoomCommand*>& commandList, CommandSet co
break; // 0x18
case RoomCommand::SetCameraSettings:
if (Globals::Instance->game == ZGame::MM_RETAIL)
- {
cmd = new SetWorldMapVisited(this, rawData, rawDataIndex);
- }
else
- {
cmd = new SetCameraSettings(this, rawData, rawDataIndex);
- }
break; // 0x19
case RoomCommand::SetAnimatedTextureList:
cmd = new SetAnimatedTextureList(this, rawData, rawDataIndex);