mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -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
81
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
81
ZAPDTR/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "SetAlternateHeaders.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include "Utils/BitConverter.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
SetAlternateHeaders::SetAlternateHeaders(ZFile* nParent) : ZRoomCommand(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
if (cmdArg2 != 0)
|
||||
{
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationPlaceholder(segmentOffset, varName);
|
||||
}
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::ParseRawDataLate()
|
||||
{
|
||||
int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4;
|
||||
|
||||
for (int32_t i = 0; i < numHeaders; i++)
|
||||
{
|
||||
int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4));
|
||||
headers.push_back(address);
|
||||
|
||||
if (address != 0 && parent->GetDeclaration(GETSEGOFFSET(address)) == nullptr)
|
||||
{
|
||||
ZRoom* altheader = new ZRoom(parent);
|
||||
altheader->ExtractFromBinary(GETSEGOFFSET(address), zRoom->GetResourceType());
|
||||
altheader->DeclareReferences(parent->GetName());
|
||||
|
||||
parent->resources.push_back(altheader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetAlternateHeaders::DeclareReferencesLate(const std::string& prefix)
|
||||
{
|
||||
if (!headers.empty())
|
||||
{
|
||||
std::string declaration;
|
||||
|
||||
for (size_t i = 0; i < headers.size(); i++)
|
||||
{
|
||||
std::string altHeaderName;
|
||||
Globals::Instance->GetSegmentedPtrName(headers.at(i), parent, "", altHeaderName);
|
||||
|
||||
declaration += StringHelper::Sprintf("\t%s,", altHeaderName.c_str());
|
||||
|
||||
if (i + 1 < headers.size())
|
||||
declaration += "\n";
|
||||
}
|
||||
|
||||
std::string varName =
|
||||
StringHelper::Sprintf("%sAlternateHeaders0x%06X", prefix.c_str(), segmentOffset);
|
||||
parent->AddDeclarationArray(segmentOffset, GetDeclarationAlignment(), headers.size() * 4,
|
||||
"SceneCmd*", varName, headers.size(), declaration);
|
||||
}
|
||||
}
|
||||
|
||||
std::string SetAlternateHeaders::GetBodySourceCode() const
|
||||
{
|
||||
std::string listName;
|
||||
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "SceneCmd*", listName);
|
||||
return StringHelper::Sprintf("SCENE_CMD_ALTERNATE_HEADER_LIST(%s)", listName.c_str());
|
||||
}
|
||||
|
||||
std::string SetAlternateHeaders::GetCommandCName() const
|
||||
{
|
||||
return "SCmdAltHeaders";
|
||||
}
|
||||
|
||||
RoomCommand SetAlternateHeaders::GetRoomCommand() const
|
||||
{
|
||||
return RoomCommand::SetAlternateHeaders;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue