Shipwright/ZAPDTR/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp
louist103 f31a841789
ZAPD Update (#2851)
* git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/

subrepo:
  subdir:   "ZAPDTR"
  merged:   "6aa54a551"
upstream:
  origin:   "C:/ZeldaStuff/ZAPDTR"
  branch:   "rebase2"
  commit:   "6aa54a551"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* git subrepo clone --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/

subrepo:
  subdir:   "ZAPDTR"
  merged:   "88b012240"
upstream:
  origin:   "C:/ZeldaStuff/ZAPDTR"
  branch:   "rebase2"
  commit:   "88b012240"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Update (its broken)

* fix the enum

* git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR

subrepo:
  subdir:   "ZAPDTR"
  merged:   "b7b6e1c82"
upstream:
  origin:   "C:/ZeldaStuff/ZAPDTR/"
  branch:   "rebase2"
  commit:   "b7b6e1c82"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* New names for LUS actions

* git subrepo push --remote=C:/ZeldaStuff/ZAPDTR/ ZAPDTR

subrepo:
  subdir:   "ZAPDTR"
  merged:   "c5cfebeee"
upstream:
  origin:   "C:/ZeldaStuff/ZAPDTR/"
  branch:   "rebase2"
  commit:   "c5cfebeee"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* git subrepo clone (merge) --force --branch=rebase2 C:/ZeldaStuff/ZAPDTR ZAPDTR/

subrepo:
  subdir:   "ZAPDTR"
  merged:   "d5f4769b8"
upstream:
  origin:   "C:/ZeldaStuff/ZAPDTR"
  branch:   "rebase2"
  commit:   "d5f4769b8"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Fix missing commands in the exporter.

* Cleanups.

* git subrepo pull --force --remote=https://github.com/harbourmasters/ZAPDTR --branch=master ZAPDTR

subrepo:
  subdir:   "ZAPDTR"
  merged:   "d4c35b90a"
upstream:
  origin:   "https://github.com/harbourmasters/ZAPDTR"
  branch:   "master"
  commit:   "d4c35b90a"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"

* Add unordered_map include to fix MacOS

* fix string_view

* Update Main.cpp

* fix string view

* So close I can almost taste it

* So close

* Fix missed git marker.

* Fix surface types and

* Update ZFile.cpp

* Delete Jenkinsfile

---------

Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2023-05-07 19:58:50 -04:00

94 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;
transitionActors.reserve(numActors);
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);
}