summaryrefslogtreecommitdiff
path: root/ZAPD/ZRoom/Commands/SetActorList.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-03-20 10:17:39 +0100
committerGitHub <noreply@github.com>2021-03-20 05:17:39 -0400
commit4751db5c9ee0a25a26379ca5b44efad72215d256 (patch)
treece49e6e23e352c93424343f75b2e10601457a9c3 /ZAPD/ZRoom/Commands/SetActorList.cpp
parent963a282dc10036f367a2cb09bb5651aefc73d2a4 (diff)
Add a clang-format config and reformat all source files (#63)
* build: Add genbuildinfo as a dependency for ZAPD object files * Add a clang-format config and reformat all source files The existing code style is mostly preserved; this just makes formatting more consistent and prevents lines from getting too long. * Fix missing includes
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetActorList.cpp')
-rw-r--r--ZAPD/ZRoom/Commands/SetActorList.cpp55
1 files changed, 37 insertions, 18 deletions
diff --git a/ZAPD/ZRoom/Commands/SetActorList.cpp b/ZAPD/ZRoom/Commands/SetActorList.cpp
index 5e291eb..7621051 100644
--- a/ZAPD/ZRoom/Commands/SetActorList.cpp
+++ b/ZAPD/ZRoom/Commands/SetActorList.cpp
@@ -1,14 +1,15 @@
#include "SetActorList.h"
-#include "../../ZFile.h"
-#include "../ZRoom.h"
-#include "../ActorList.h"
#include "../../BitConverter.h"
-#include "../../StringHelper.h"
#include "../../Globals.h"
+#include "../../StringHelper.h"
+#include "../../ZFile.h"
+#include "../ActorList.h"
+#include "../ZRoom.h"
using namespace std;
-SetActorList::SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex) : ZRoomCommand(nZRoom, rawData, rawDataIndex)
+SetActorList::SetActorList(ZRoom* nZRoom, std::vector<uint8_t> rawData, int rawDataIndex)
+ : ZRoomCommand(nZRoom, rawData, rawDataIndex)
{
numActors = rawData[rawDataIndex + 1];
segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4));
@@ -38,7 +39,6 @@ string SetActorList::GenerateSourceCodePass1(string roomName, int baseAddress)
return "";
}
-
string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
{
string sourceOutput = "";
@@ -54,10 +54,14 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
currentPtr += 16;
}
- sourceOutput += StringHelper::Sprintf("%s 0x%02X, (u32)%sActorList0x%06X };", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), numActors, roomName.c_str(), segmentOffset);
+ sourceOutput +=
+ StringHelper::Sprintf("%s 0x%02X, (u32)%sActorList0x%06X };",
+ ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(),
+ numActors, roomName.c_str(), segmentOffset);
- //zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, GetRawDataSize(),
- //"SCmdActorList", ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress), sourceOutput);
+ // zRoom->parent->AddDeclaration(segmentOffset, DeclarationAlignment::None,
+ // DeclarationPadding::None, GetRawDataSize(), "SCmdActorList",
+ //ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress), sourceOutput);
string declaration = "";
@@ -68,18 +72,29 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
// SW97 Actor 0x22 was removed, so we want to not output a working actor.
if (actorNum == 0x22 && Globals::Instance->game == ZGame::OOT_SW97)
- declaration += StringHelper::Sprintf("\t//{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", /*StringHelper::Sprintf("SW_REMOVED_0x%04X", actorNum).c_str()*/ "ACTOR_DUNGEON_KEEP", entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ declaration += StringHelper::Sprintf(
+ "\t//{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X",
+ /*StringHelper::Sprintf("SW_REMOVED_0x%04X", actorNum).c_str()*/
+ "ACTOR_DUNGEON_KEEP", entry->posX, entry->posY, entry->posZ, entry->rotX,
+ entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
else
{
- // SW97 Actor 0x23 and above are shifted up by one because 0x22 was removed between SW97 and retail.
- // We need to shift down by one
+ // SW97 Actor 0x23 and above are shifted up by one because 0x22 was removed between SW97
+ // and retail. We need to shift down by one
if (Globals::Instance->game == ZGame::OOT_SW97 && actorNum >= 0x23)
actorNum--;
if (actorNum < sizeof(ActorList) / sizeof(ActorList[0]))
- declaration += StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", ActorList[actorNum].c_str(), entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ declaration +=
+ StringHelper::Sprintf("\t{ %s, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X",
+ ActorList[actorNum].c_str(), entry->posX, entry->posY,
+ entry->posZ, entry->rotX, entry->rotY, entry->rotZ,
+ (uint16_t)entry->initVar, segmentOffset + (index * 16));
else
- declaration += StringHelper::Sprintf("\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", actorNum, entry->posX, entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ, (uint16_t)entry->initVar, segmentOffset + (index * 16));
+ declaration += StringHelper::Sprintf(
+ "\t{ 0x%04X, %i, %i, %i, %i, %i, %i, 0x%04X }, //0x%06X", actorNum, entry->posX,
+ entry->posY, entry->posZ, entry->rotX, entry->rotY, entry->rotZ,
+ (uint16_t)entry->initVar, segmentOffset + (index * 16));
if (index < actors.size() - 1)
declaration += "\n";
@@ -88,8 +103,10 @@ string SetActorList::GenerateSourceCodePass2(string roomName, int baseAddress)
index++;
}
- zRoom->parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, actors.size() * 16,
- "ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset), GetActorListArraySize(), declaration);
+ zRoom->parent->AddDeclarationArray(
+ segmentOffset, DeclarationAlignment::None, DeclarationPadding::Pad16, actors.size() * 16,
+ "ActorEntry", StringHelper::Sprintf("%sActorList0x%06X", roomName.c_str(), segmentOffset),
+ GetActorListArraySize(), declaration);
return sourceOutput;
}
@@ -104,7 +121,8 @@ size_t SetActorList::GetActorListArraySize()
size_t actorCount = 0;
// Doing an else-if here so we only do the loop when the game is SW97.
- // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count for it.
+ // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count
+ // for it.
if (Globals::Instance->game == ZGame::OOT_SW97)
{
actorCount = 0;
@@ -123,7 +141,8 @@ size_t SetActorList::GetActorListArraySize()
string SetActorList::GenerateExterns()
{
- return StringHelper::Sprintf("extern ActorEntry %sActorList0x%06X[%i];\n", zRoom->GetName().c_str(), segmentOffset, GetActorListArraySize());
+ return StringHelper::Sprintf("extern ActorEntry %sActorList0x%06X[%i];\n",
+ zRoom->GetName().c_str(), segmentOffset, GetActorListArraySize());
}
string SetActorList::GetCommandCName()