Shipwright/ZAPDTR/ZAPD/ZRoom/Commands/SetPathways.cpp
Nicholas Estelami c80f9fbd57
Added support for multiple game versions (#107)
* WIP Multiversion support

* GC PAL Non-MQ support complete

* Updated OtrGui to handle different game versions

* Added version file

* Added new extract mode to ZAPD and optimized OTR gen time

* Fixed bug causing crash

* Further optimized OTRExporter, saving around ~20 seconds.

* ZAPD is now multi-threaded.

* Fixed merge issue

* Fixed memory leak and fog issue on pause screen.

* Additional fog fixes.

Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
2022-03-31 19:42:44 -04:00

66 lines
1.6 KiB
C++

#include "SetPathways.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
#include "ZFile.h"
#include "ZRoom/ZRoom.h"
SetPathways::SetPathways(ZFile* nParent) : ZRoomCommand(nParent), pathwayList(nParent)
{
}
void SetPathways::DeclareReferences([[maybe_unused]] const std::string& prefix)
{
if (segmentOffset != 0)
{
std::string varName =
StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset);
parent->AddDeclarationPlaceholder(segmentOffset, varName);
}
}
void SetPathways::ParseRawDataLate()
{
if (Globals::Instance->game == ZGame::MM_RETAIL)
{
auto numPaths = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 8;
pathwayList.SetNumPaths(numPaths);
}
if (Globals::Instance->otrMode)
{
auto zPath = (ZPath*)parent->FindResource(segmentOffset);
if (zPath != nullptr)
pathwayList = *zPath;
}
pathwayList.ExtractFromFile(segmentOffset);
}
void SetPathways::DeclareReferencesLate(const std::string& prefix)
{
std::string varName = StringHelper::Sprintf("%sPathway_%06X", prefix.c_str(), segmentOffset);
pathwayList.SetName(varName);
pathwayList.DeclareReferences(prefix);
pathwayList.GetSourceOutputCode(prefix);
}
std::string SetPathways::GetBodySourceCode() const
{
std::string listName;
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "Path", listName, parent->workerID);
return StringHelper::Sprintf("SCENE_CMD_PATH_LIST(%s)", listName.c_str());
}
std::string SetPathways::GetCommandCName() const
{
return "SCmdPathList";
}
RoomCommand SetPathways::GetRoomCommand() const
{
return RoomCommand::SetPathways;
}