ksys: Decompile ByamlUtil

And fix some declarations in Byaml.h
This commit is contained in:
Léo Lam
2020-08-21 22:21:26 +02:00
parent bad90bc5d8
commit fc306aa5f0
4 changed files with 49 additions and 5 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ enum class ByamlType {
class ByamlIter {
public:
ByamlIter() = default;
ByamlIter();
explicit ByamlIter(const u8* data);
ByamlIter(const u8* data, const u8* root_node);
ByamlIter(const ByamlIter& other);
+43
View File
@@ -0,0 +1,43 @@
#include "KingSystem/Utils/Byaml.h"
namespace al {
bool tryGetByamlS32(s32* value, const ByamlIter& iter, const char* key) {
return iter.tryGetIntByKey(value, key);
}
bool tryGetByamlU32(u32* value, const ByamlIter& iter, const char* key) {
s32 v{};
bool ret = iter.tryGetIntByKey(&v, key);
if (ret)
*value = v;
return ret;
}
bool tryGetByamlF32(f32* value, const ByamlIter& iter, const char* key) {
f32 v{};
bool ret = iter.tryGetFloatByKey(&v, key);
if (!ret)
return false;
*value = v;
return true;
}
bool tryGetByamlV3f(sead::Vector3f* value, const ByamlIter& iter, const char* key) {
f32 x, y, z;
ByamlIter vec_iter;
if (!iter.tryGetIterByKey(&vec_iter, key))
return false;
x = 0;
bool ok = vec_iter.tryGetFloatByKey(&x, "X");
y = 0;
ok |= vec_iter.tryGetFloatByKey(&y, "Y");
z = 0;
ok |= vec_iter.tryGetFloatByKey(&z, "Z");
*value = {x, y, z};
return ok;
}
} // namespace al