mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-12 04:25:12 -05:00
c80f9fbd57
* 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>
93 lines
2.8 KiB
C++
93 lines
2.8 KiB
C++
#include "SetTransitionActorList.h"
|
|
|
|
#include "Globals.h"
|
|
#include "Utils/BitConverter.h"
|
|
#include "Utils/StringHelper.h"
|
|
#include "ZFile.h"
|
|
#include "ZRoom/ZNames.h"
|
|
#include "ZRoom/ZRoom.h"
|
|
|
|
SetTransitionActorList::SetTransitionActorList(ZFile* nParent) : ZRoomCommand(nParent)
|
|
{
|
|
}
|
|
|
|
void SetTransitionActorList::ParseRawData()
|
|
{
|
|
ZRoomCommand::ParseRawData();
|
|
int numActors = cmdArg1;
|
|
uint32_t currentPtr = segmentOffset;
|
|
|
|
for (int32_t i = 0; i < numActors; i++)
|
|
{
|
|
TransitionActorEntry entry(parent->GetRawData(), currentPtr);
|
|
transitionActors.push_back(entry);
|
|
|
|
currentPtr += 16;
|
|
}
|
|
}
|
|
|
|
void SetTransitionActorList::DeclareReferences(const std::string& prefix)
|
|
{
|
|
std::string declaration;
|
|
|
|
size_t index = 0;
|
|
for (const auto& entry : transitionActors)
|
|
{
|
|
declaration += StringHelper::Sprintf(" { %s },", entry.GetBodySourceCode().c_str());
|
|
if (index + 1 < transitionActors.size())
|
|
{
|
|
declaration += "\n";
|
|
}
|
|
|
|
index++;
|
|
}
|
|
|
|
parent->AddDeclarationArray(
|
|
segmentOffset, DeclarationAlignment::Align4, transitionActors.size() * 16,
|
|
"TransitionActorEntry",
|
|
StringHelper::Sprintf("%sTransitionActorList_%06X", prefix.c_str(), segmentOffset),
|
|
transitionActors.size(), declaration);
|
|
}
|
|
|
|
std::string SetTransitionActorList::GetBodySourceCode() const
|
|
{
|
|
std::string listName;
|
|
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "TransitionActorEntry", listName,
|
|
parent->workerID);
|
|
return StringHelper::Sprintf("SCENE_CMD_TRANSITION_ACTOR_LIST(%i, %s)", transitionActors.size(),
|
|
listName.c_str());
|
|
}
|
|
|
|
std::string SetTransitionActorList::GetCommandCName() const
|
|
{
|
|
return "SCmdTransiActorList";
|
|
}
|
|
|
|
RoomCommand SetTransitionActorList::GetRoomCommand() const
|
|
{
|
|
return RoomCommand::SetTransitionActorList;
|
|
}
|
|
|
|
TransitionActorEntry::TransitionActorEntry(const std::vector<uint8_t>& rawData, int rawDataIndex)
|
|
{
|
|
frontObjectRoom = rawData[rawDataIndex + 0];
|
|
frontTransitionReaction = rawData[rawDataIndex + 1];
|
|
backObjectRoom = rawData[rawDataIndex + 2];
|
|
backTransitionReaction = rawData[rawDataIndex + 3];
|
|
actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
|
|
posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
|
|
posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 8);
|
|
posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 10);
|
|
rotY = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
|
|
initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14);
|
|
}
|
|
|
|
std::string TransitionActorEntry::GetBodySourceCode() const
|
|
{
|
|
std::string actorStr = ZNames::GetActorName(actorNum);
|
|
|
|
return StringHelper::Sprintf("%i, %i, %i, %i, %s, %i, %i, %i, %i, 0x%04X", frontObjectRoom,
|
|
frontTransitionReaction, backObjectRoom, backTransitionReaction,
|
|
actorStr.c_str(), posX, posY, posZ, rotY, initVar);
|
|
}
|