Shipwright/ZAPDTR/ZAPD/ZRoom/Commands/SetLightList.cpp

101 lines
2.6 KiB
C++
Raw Normal View History

#include "SetLightList.h"
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/StringHelper.h"
SetLightList::SetLightList(ZFile* nParent) : ZRoomCommand(nParent)
{
}
void SetLightList::ParseRawData()
{
ZRoomCommand::ParseRawData();
std::string declarations;
numLights = cmdArg1;
int32_t currentPtr = segmentOffset;
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
lights.reserve(this->numLights);
for (int i = 0; i < this->numLights; i++)
{
LightInfo light(parent->GetRawData(), currentPtr);
currentPtr += light.GetRawDataSize();
lights.push_back(light);
}
}
void SetLightList::DeclareReferences(const std::string& prefix)
{
if (!lights.empty())
{
std::string declarations;
for (size_t i = 0; i < lights.size(); i++)
{
declarations +=
StringHelper::Sprintf("\t{ %s },", lights.at(i).GetBodySourceCode().c_str());
if (i < lights.size() - 1)
declarations += "\n";
}
const auto& light = lights.front();
parent->AddDeclarationArray(
segmentOffset, DeclarationAlignment::Align4, lights.size() * light.GetRawDataSize(),
light.GetSourceTypeName(),
StringHelper::Sprintf("%sLightInfo0x%06X", prefix.c_str(), segmentOffset),
lights.size(), declarations);
}
}
std::string SetLightList::GetBodySourceCode() const
{
std::string listName;
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "LightInfo", listName,
parent->workerID);
return StringHelper::Sprintf("SCENE_CMD_LIGHT_LIST(%i, %s)", numLights, listName.c_str());
}
std::string SetLightList::GetCommandCName() const
{
return "SCmdLightList";
}
RoomCommand SetLightList::GetRoomCommand() const
{
return RoomCommand::SetLightList;
}
LightInfo::LightInfo(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex)
{
type = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0);
x = BitConverter::ToInt16BE(rawData, rawDataIndex + 2);
y = BitConverter::ToInt16BE(rawData, rawDataIndex + 4);
z = BitConverter::ToInt16BE(rawData, rawDataIndex + 6);
r = BitConverter::ToUInt8BE(rawData, rawDataIndex + 8);
g = BitConverter::ToUInt8BE(rawData, rawDataIndex + 9);
b = BitConverter::ToUInt8BE(rawData, rawDataIndex + 10);
drawGlow = BitConverter::ToUInt8BE(rawData, rawDataIndex + 11);
radius = BitConverter::ToInt16BE(rawData, rawDataIndex + 12);
}
std::string LightInfo::GetBodySourceCode() const
{
return StringHelper::Sprintf(
"0x%02X, { %i, %i, %i, { 0x%02X, 0x%02X, 0x%02X }, 0x%02X, 0x%04X }", type, x, y, z, r, g,
b, drawGlow, radius);
}
std::string LightInfo::GetSourceTypeName() const
{
return "LightInfo";
}
size_t LightInfo::GetRawDataSize() const
{
return 0x0E;
}