SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
DotCamParams.cpp
1#include "Game/Camera/DotCamParams.hpp"
2#include <cstdio>
3#include <cstring>
4
5DotCamReader::~DotCamReader() {
6
7}
8
9DotCamReaderInBin::DotCamReaderInBin(const void *pData) :
10 mVersion(0), _8(nullptr), mMapInfo() {
11 mMapIter.mInfo = nullptr;
12 mMapIter._4 = -1;
13 init(pData);
14}
15
16DotCamReaderInBin::~DotCamReaderInBin() {
17 if (_8 != nullptr) {
18 delete[] _8;
19 }
20}
21
22u32 DotCamReaderInBin::getVersion() const {
23 return mVersion;
24}
25
26#ifdef NON_MATCHING
27// Stack issues
28bool DotCamReaderInBin::hasMoreChunk() const {
29 bool hasMore = false;
30
31 if (mMapIter.isValid()) {
32 const JMapData *mapData = mMapInfo.mData;
33 s32 iVar2 = mapData != nullptr ? mapData->_0 : 0;
34
35 bool bVar1 = false;
36
37 const JMapInfo &mapInfo = mMapInfo;
38
39 if (mMapIter._4 == iVar2 && mMapIter.mInfo != nullptr && mapInfo.mData != nullptr) {
40 if (mMapIter.mInfo->mData == mapInfo.mData) {
41 bVar1 = true;
42 }
43 }
44
45 if (!bVar1) {
46 hasMore = true;
47 }
48 }
49
50 return hasMore;
51}
52#endif
53
54void DotCamReaderInBin::nextToChunk() {
55 if (mMapIter.isValid()) {
56 mMapIter._4++;
57 }
58}
59
60bool DotCamReaderInBin::getValueInt(const char *pName, long *pOut) {
61 return mMapIter.getValue<long>(pName, pOut);
62}
63
64bool DotCamReaderInBin::getValueFloat(const char *pName, float *pOut) {
65 return mMapIter.getValue<float>(pName, pOut);
66}
67
68bool DotCamReaderInBin::getValueVec(const char *pName, TVec3f *pOut) {
69 char buffer[0x100];
70 char *pBuffer = &buffer[0];
71
72 f32 z;
73 f32 y;
74 f32 x;
75
76 snprintf(pBuffer, sizeof(buffer), "%s.X", pName);
77 bool success = mMapIter.getValue<float>(pBuffer, &x) & 1;
78
79 snprintf(pBuffer, sizeof(buffer), "%s.Y", pName);
80 success &= mMapIter.getValue<float>(pBuffer, &y);
81
82 snprintf(pBuffer, sizeof(buffer), "%s.Z", pName);
83 success &= mMapIter.getValue<float>(pBuffer, &z);
84
85 if (success) {
86 pOut->x = x;
87 pOut->y = y;
88 pOut->z = z;
89 }
90
91 return success;
92}
93
94bool DotCamReaderInBin::getValueString(const char *pName, const char **pOut) {
95 s32 iVar3 = mMapIter._4;
96 JMapInfo *info = mMapIter.mInfo;
97 s32 index = info->searchItemInfo(pName);
98
99 if (index < 0) {
100 return false;
101 }
102
103 return info->getValueFast(iVar3, index, pOut);
104}
105
106#ifdef NON_MATCHING
107// Stack issues
108void DotCamReaderInBin::init(const void *pData) {
109 mMapInfo.attach(pData);
110 s32 index = mMapInfo.searchItemInfo("version");
111
112 bool valid = index >= 0;
113
114 if (valid) {
115 mMapInfo.getValueFast(0, index, &mVersion);
116 }
117
118 mMapIter.mInfo = &mMapInfo;
119 mMapIter._4 = 0;
120}
121#endif