diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2021-05-10 12:25:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-10 12:25:39 -0400 |
| commit | 769f5702a422d14bfb0a60a39319da4b4bf9ec1f (patch) | |
| tree | 11e12a20fb2880792722babdee0b5222ea86504f /ZAPD/ZRoom/Commands/SetMinimapChests.cpp | |
| parent | a357277e412b5e8f0f2f0578c7d7d213e8744c8d (diff) | |
ZRoom refactor (#124)
* Remove redundant methods
* first pass os cleaning
* More cleaning
* Fix compilation errors
* Fix dumb crashes
* Fix dumb issues
* Removing most uses of GenerateSourceCodePass1
* more cleanup
* Move segmentOffset to ZRoomCommand
* Half of ParseRawData
* somehow broken...
* fix broken stuff
* This may or may not be broken
* More cleaning
* Remove GenerateSourceCodePass2
* More cleanup and pointer removal
* Use PolygonType2 in SetMesh
* another small cleanup
* Merge PolygonDlist and PolygonDlist2
* More code merging
* GetDeclarationPtrName
* Remove most repeated externs and a bit of redundant code
* Dumb MM fixes
* small fix
(cherry picked from commit 0813fd69538491c5aceb00d79d19bf59fd082ca7)
* Another dumb fix
* Remove GenerateExterns
* Change DeclareReferences signature
* Refactor SetAnimatedTextureList
* const std::vector<uint8_t>&
* another small bunch of changes
* last parserawdata and declarereferences separation probably
* Move parserawdata
* Remove GenerateSourceCodePass1
* Use macros for commands
* Make ZRoomCommand inherit ZResource
* shrink scenes tluts
* ProcessTextureIntersections
* small output improvements
* Small changes
* run format
* SCENE_CMD -> SCENECMD
* fix merge errors
* run format
* fix some warnings
* update macros names
* Add again different commands for each game ni SCENE_CMD_ROOM_BEHAVIOR
* macro update
* More booleans
* Move declaration to its own file
* minor changes
* Update according to latest reviews in oot
* run format
* Yet another cutscene change
* Remove special scene/room segment code
* This is crashing and I don't know why
* remove includeFilePrefix
* fix merge issues
* always pass a parent to zresource
* move path to its own zclass and properly implement parserawdata in commands
* Fix GetDeclarationPtrName uses
* Some ZPath fixes (still broken tho)
* Fix ZPath declarations
* Fix weird problem
* Add `Path` to the docs
* run format
* clean syotes code
* A bunch of changes for MM
* run format
Diffstat (limited to 'ZAPD/ZRoom/Commands/SetMinimapChests.cpp')
| -rw-r--r-- | ZAPD/ZRoom/Commands/SetMinimapChests.cpp | 95 |
1 files changed, 40 insertions, 55 deletions
diff --git a/ZAPD/ZRoom/Commands/SetMinimapChests.cpp b/ZAPD/ZRoom/Commands/SetMinimapChests.cpp index abaff62..bd9c8a0 100644 --- a/ZAPD/ZRoom/Commands/SetMinimapChests.cpp +++ b/ZAPD/ZRoom/Commands/SetMinimapChests.cpp @@ -1,78 +1,57 @@ #include "SetMinimapChests.h" -#include "../../BitConverter.h" -#include "../../Globals.h" -#include "../../StringHelper.h" -#include "../../ZFile.h" -#include "../ZRoom.h" - -SetMinimapChests::SetMinimapChests(ZRoom* nZRoom, std::vector<uint8_t> rawData, - uint32_t rawDataIndex) - : ZRoomCommand(nZRoom, rawData, rawDataIndex) + +#include "BitConverter.h" +#include "Globals.h" +#include "StringHelper.h" +#include "ZFile.h" +#include "ZRoom/ZRoom.h" + +SetMinimapChests::SetMinimapChests(ZFile* nParent) : ZRoomCommand(nParent) +{ +} + +void SetMinimapChests::ParseRawData() { - int32_t numChests = rawData[rawDataIndex + 1]; - segmentOffset = GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 4)); + ZRoomCommand::ParseRawData(); + int numChests = cmdArg1; int32_t currentPtr = segmentOffset; for (int32_t i = 0; i < numChests; i++) { - MinimapChest* chest = new MinimapChest(rawData, currentPtr); + MinimapChest chest(parent->GetRawData(), currentPtr); chests.push_back(chest); currentPtr += 10; } } -SetMinimapChests::~SetMinimapChests() -{ - for (MinimapChest* chest : chests) - delete chest; -} - -std::string SetMinimapChests::GenerateSourceCodePass1(std::string roomName, uint32_t baseAddress) +void SetMinimapChests::DeclareReferences(const std::string& prefix) { - return std::string(); -} + std::string declaration = ""; -std::string SetMinimapChests::GenerateSourceCodePass2(std::string roomName, uint32_t baseAddress) -{ - std::string sourceOutput = ""; + size_t index = 0; + for (const auto& chest : chests) + { + declaration += StringHelper::Sprintf(" { %s },", chest.GetBodySourceCode().c_str()); - sourceOutput += - StringHelper::Sprintf("%s 0x%02X, (u32)%sMinimapChests0x%06X };", - ZRoomCommand::GenerateSourceCodePass1(roomName, baseAddress).c_str(), - chests.size(), roomName.c_str(), segmentOffset); + if (index < chests.size() - 1) + declaration += "\n"; - { - std::string declaration = ""; - - size_t index = 0; - for (MinimapChest* chest : chests) - { - declaration += StringHelper::Sprintf(" { 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X },", - chest->unk0, chest->unk2, chest->unk4, chest->unk6, - chest->unk8); - - if (index < chests.size() - 1) - declaration += "\n"; - - index++; - } - - zRoom->parent->AddDeclarationArray( - segmentOffset, DeclarationAlignment::None, DeclarationPadding::None, chests.size() * 10, - "MinimapChest", - StringHelper::Sprintf("%sMinimapChests0x%06X", roomName.c_str(), segmentOffset), - chests.size(), declaration); + index++; } - return sourceOutput; + parent->AddDeclarationArray( + segmentOffset, DeclarationAlignment::None, chests.size() * 10, "MinimapChest", + StringHelper::Sprintf("%sMinimapChests0x%06X", prefix.c_str(), segmentOffset), + chests.size(), declaration); } -std::string SetMinimapChests::GenerateExterns() const +std::string SetMinimapChests::GetBodySourceCode() const { - return StringHelper::Sprintf("extern MinimapChest %sMinimapChests0x%06X[%i];\n", - zRoom->GetName().c_str(), segmentOffset, chests.size()); + std::string listName = parent->GetDeclarationPtrName(cmdArg2); + return StringHelper::Sprintf("SCENE_CMD_MINIMAP_COMPASS_ICON_INFO(0x%02X, %s)", chests.size(), + listName.c_str()); } std::string SetMinimapChests::GetCommandCName() const @@ -90,11 +69,17 @@ size_t SetMinimapChests::GetRawDataSize() const return ZRoomCommand::GetRawDataSize() + (chests.size() * 10); } -MinimapChest::MinimapChest(std::vector<uint8_t> rawData, uint32_t rawDataIndex) +MinimapChest::MinimapChest(const std::vector<uint8_t>& rawData, uint32_t rawDataIndex) : unk0(BitConverter::ToUInt16BE(rawData, rawDataIndex + 0)), unk2(BitConverter::ToUInt16BE(rawData, rawDataIndex + 2)), unk4(BitConverter::ToUInt16BE(rawData, rawDataIndex + 4)), unk6(BitConverter::ToUInt16BE(rawData, rawDataIndex + 6)), unk8(BitConverter::ToUInt16BE(rawData, rawDataIndex + 8)) { -}
\ No newline at end of file +} + +std::string MinimapChest::GetBodySourceCode() const +{ + return StringHelper::Sprintf("0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X", unk0, unk2, unk4, unk6, + unk8); +} |
