mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07:00
git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
f52a2a6406
commit
5dda5762ba
217 changed files with 47152 additions and 0 deletions
73
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
73
ZAPDTR/ZAPD/ZRoom/Commands/SetExitList.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "SetExitList.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
#include "ZRoom/ZRoom.h"
|
||||
|
||||
SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (segmentOffset != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetExitList::ParseRawDataLate()
|
||||
{
|
||||
// Parse Entrances and Generate Declaration
|
||||
int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2;
|
||||
uint32_t currentPtr = segmentOffset;
|
||||
|
||||
for (int32_t i = 0; i < numEntrances; i++)
|
||||
{
|
||||
uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr);
|
||||
exits.push_back(exit);
|
||||
|
||||
currentPtr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (!exits.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < exits.size(); i++)
|
||||
{
|
||||
declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i));
|
||||
if (i + 1 < exits.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sExitList_%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, exits.size() * 2,
|
||||
"u16", varName, exits.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetExitList::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "u16", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_EXIT_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetExitList::GetCommandCName() const
|
||||
{
|
||||
return "SCmdExitList";
|
||||
}
|
||||
|
||||
RoomCommand SetExitList::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetExitList;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue