summaryrefslogtreecommitdiff
path: root/src/KingSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-11-22 12:27:07 +0100
committerLéo Lam <leo@leolam.fr>2020-11-22 15:36:18 +0100
commit622104fbd219117455c7a6776aea1658e36cd888 (patch)
treeebeaf572bed218de3c05717bb29cac6a1570081d /src/KingSystem
parente99f0f8949978ed0c1ee2a3ad1255666a3639262 (diff)
ksys/act: Add more InfoData functions
Diffstat (limited to 'src/KingSystem')
-rw-r--r--src/KingSystem/ActorSystem/actActorCreator.h2
-rw-r--r--src/KingSystem/ActorSystem/actDebug.h12
-rw-r--r--src/KingSystem/ActorSystem/actInfoData.cpp112
-rw-r--r--src/KingSystem/ActorSystem/actInfoData.h5
-rw-r--r--src/KingSystem/ActorSystem/actTag.h4
-rw-r--r--src/KingSystem/Event/CMakeLists.txt2
-rw-r--r--src/KingSystem/Event/evtEvent.cpp1
-rw-r--r--src/KingSystem/Event/evtEvent.h26
8 files changed, 163 insertions, 1 deletions
diff --git a/src/KingSystem/ActorSystem/actActorCreator.h b/src/KingSystem/ActorSystem/actActorCreator.h
index 65a3494b..ef6c229a 100644
--- a/src/KingSystem/ActorSystem/actActorCreator.h
+++ b/src/KingSystem/ActorSystem/actActorCreator.h
@@ -19,6 +19,8 @@ class ActorCreator {
public:
void setActorFactory(ActorFactory* factory) { mActorFactory = factory; }
+ bool get5a() const { return _5a; }
+
private:
sead::Heap* forBaseProcDualHeap;
sead::Heap* placementMgrHeap;
diff --git a/src/KingSystem/ActorSystem/actDebug.h b/src/KingSystem/ActorSystem/actDebug.h
index 5342d341..29495c25 100644
--- a/src/KingSystem/ActorSystem/actDebug.h
+++ b/src/KingSystem/ActorSystem/actDebug.h
@@ -1,21 +1,31 @@
#pragma once
#include <heap/seadDisposer.h>
+#include <prim/seadTypedBitFlag.h>
#include "KingSystem/Utils/Types.h"
namespace ksys::act {
class ActorDebug {
SEAD_SINGLETON_DISPOSER(ActorDebug)
+ virtual ~ActorDebug();
+
public:
+ enum class Flag {
+ _10000000 = 0x10000000,
+ };
+
struct HashUnused {
u32 hash = 0;
u32 b;
};
const char* getNullStr(HashUnused* u);
+ bool hasFlag(Flag flag) const { return mFlags.isOn(flag); }
- u8 TEMP1[0x2F0];
+ void* _28;
+ sead::TypedBitFlag<Flag> mFlags;
+ u8 TEMP1[0x2DC];
f32 mDispDistanceMultiplier;
u8 TEMP2[0x114];
};
diff --git a/src/KingSystem/ActorSystem/actInfoData.cpp b/src/KingSystem/ActorSystem/actInfoData.cpp
index af03b8a3..9d6427cb 100644
--- a/src/KingSystem/ActorSystem/actInfoData.cpp
+++ b/src/KingSystem/ActorSystem/actInfoData.cpp
@@ -2,6 +2,9 @@
#include <KingSystem/Resource/resModelResourceDivide.h>
#include <codec/seadHashCRC32.h>
#include <math/seadMathNumbers.h>
+#include "KingSystem/ActorSystem/actActorCreator.h"
+#include "KingSystem/ActorSystem/actDebug.h"
+#include "KingSystem/Event/evtEvent.h"
#include "KingSystem/Event/evtManager.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
#include "KingSystem/Utils/Byaml/ByamlArrayIter.h"
@@ -144,6 +147,35 @@ bool InfoData::getActorIter(al::ByamlIter* iter, const char* actor, bool x) cons
return false;
}
+bool InfoData::logFailure(const sead::SafeString& actor_name) const {
+#ifdef MATCHING_HACK_NX_CLANG
+ // This is required to prevent LLVM from detecting that 'this' is unused
+ // and optimizing out the passing of 'this' in callers.
+ __builtin_assume(mActorsBytes);
+#endif
+
+ auto* event = evt::Manager::instance()->getActiveEvent();
+ if (event && event->hasFlag(evt::Event::Flag::_80000000000))
+ return false;
+
+ if (!ActorCreator::instance()->get5a())
+ return false;
+
+ if (ActorDebug::instance() && ActorDebug::instance()->hasFlag(ActorDebug::Flag::_10000000))
+ return false;
+
+ if (actor_name.startsWith("MergedGrudge"))
+ return false;
+
+ if (actor_name.startsWith("Armor_50"))
+ return false;
+
+ if (actor_name == "Weapon_Sword_DemoCheck")
+ return false;
+
+ return true;
+}
+
void InfoData::getRecipeInfo(const char* actor, InfoData::RecipeInfo& info) const {
al::ByamlIter iter;
if (getActorIter(&iter, actor)) {
@@ -614,4 +646,84 @@ bool InfoData::hasDropEntry(const char* actor, const char* key) const {
return iter.isExistKey(key);
}
+s32 InfoData::getInstSize(const char* actor) const {
+ return getInt(actor, "instSize", 0, false);
+}
+
+u32 InfoData::getBugMask(const char* actor) const {
+ return getInt(actor, "bugMask");
+}
+
+u32 InfoData::getModelFlags(const char* actor) const {
+ u32 flags = 0x4000;
+ if (!actor)
+ return flags;
+
+ bool is_map_const = false;
+
+ {
+ const char* profile;
+ if (getActorProfile(&profile, actor)) {
+ const sead::SafeString profile_ = profile;
+ if (profile_ == "MapConstPassive" || profile_ == "MapConstActive")
+ is_map_const = true;
+ }
+ }
+
+ {
+ al::ByamlIter iter;
+ if (getActorIter(&iter, actor)) {
+ if (!hasTag(iter, tags::Tree))
+ flags |= 0x1000;
+ } else {
+ flags |= 0x1000;
+ }
+ }
+
+ s32 type = -1;
+ {
+ al::ByamlIter iter;
+ if (getActorIter(&iter, actor)) {
+ if (hasTag(iter, tags::Unk_0x4F4E1426))
+ type = 0;
+ else if (hasTag(iter, tags::PasteGrudgeSlime))
+ type = 1;
+ }
+ }
+
+ if (is_map_const)
+ flags &= ~0x1000;
+
+ if (type == 0 || (type != 1 && !is_map_const))
+ flags |= 0x2000;
+
+ if (is_map_const && type == 1)
+ flags |= 0x1000;
+
+ return flags;
+}
+
+bool InfoData::getVariationMatAnim(const char* actor, const char** anim, f32* frame) const {
+ al::ByamlIter iter;
+ if (!getActorIter(&iter, actor))
+ return false;
+
+ *anim = getStringByKey(iter, "variationMatAnim", sead::SafeString::cEmptyString);
+ *frame = getIntByKey(iter, "variationMatAnimFrame");
+ return (*anim)[0] != 0;
+}
+
+bool InfoData::getName(al::ByamlIter* iter, const char** name, s32 idx) const {
+ if (idx < 0 || idx >= mNumActors)
+ return false;
+
+ *iter = {mActorsBytes, mActorsBytes + mActorOffsets[idx]};
+ al::ByamlHashIter hash_iter{iter->getRootNode()};
+ al::ByamlData data;
+ if (!hash_iter.getDataByKey(&data, mNameIdx))
+ return false;
+
+ return iter->tryConvertString(name, &data);
+}
+
} // namespace ksys::act
diff --git a/src/KingSystem/ActorSystem/actInfoData.h b/src/KingSystem/ActorSystem/actInfoData.h
index a576bc74..1827d0f1 100644
--- a/src/KingSystem/ActorSystem/actInfoData.h
+++ b/src/KingSystem/ActorSystem/actInfoData.h
@@ -121,6 +121,11 @@ public:
f32 getAabbNormHalf(const char* actor) const;
bool isHasFar(const char* actor) const;
bool hasDropEntry(const char* actor, const char* key) const;
+ s32 getInstSize(const char* actor) const;
+ u32 getBugMask(const char* actor) const;
+ u32 getModelFlags(const char* actor) const;
+ bool getVariationMatAnim(const char* actor, const char** anim, f32* frame) const;
+ bool getName(al::ByamlIter* iter, const char** name, s32 idx) const;
const char* getString(const char* actor, const char* key, const sead::SafeString& default_,
bool x = true) const;
diff --git a/src/KingSystem/ActorSystem/actTag.h b/src/KingSystem/ActorSystem/actTag.h
index 7581ecaf..db63c04a 100644
--- a/src/KingSystem/ActorSystem/actTag.h
+++ b/src/KingSystem/ActorSystem/actTag.h
@@ -28,6 +28,7 @@ private:
};
#define KSYS_ACT_DEFINE_TAG(NAME) inline constexpr Tag NAME(#NAME)
+#define KSYS_ACT_DEFINE_TAG_UNK(HASH) inline constexpr Tag Unk_##HASH(HASH)
namespace tags {
@@ -396,8 +397,11 @@ KSYS_ACT_DEFINE_TAG(ZukanOther);
KSYS_ACT_DEFINE_TAG(ZukanSozai);
KSYS_ACT_DEFINE_TAG(ZukanWeapon);
+KSYS_ACT_DEFINE_TAG_UNK(0x4F4E1426);
+
} // namespace tags
#undef KSYS_ACT_DEFINE_TAG
+#undef KSYS_ACT_DEFINE_TAG_UNK
} // namespace ksys::act
diff --git a/src/KingSystem/Event/CMakeLists.txt b/src/KingSystem/Event/CMakeLists.txt
index 3be2d282..cd1f47d5 100644
--- a/src/KingSystem/Event/CMakeLists.txt
+++ b/src/KingSystem/Event/CMakeLists.txt
@@ -1,4 +1,6 @@
target_sources(uking PRIVATE
+ evtEvent.cpp
+ evtEvent.h
evtManager.cpp
evtManager.h
)
diff --git a/src/KingSystem/Event/evtEvent.cpp b/src/KingSystem/Event/evtEvent.cpp
new file mode 100644
index 00000000..9577e6a3
--- /dev/null
+++ b/src/KingSystem/Event/evtEvent.cpp
@@ -0,0 +1 @@
+#include "KingSystem/Event/evtEvent.h"
diff --git a/src/KingSystem/Event/evtEvent.h b/src/KingSystem/Event/evtEvent.h
new file mode 100644
index 00000000..ac6a8a94
--- /dev/null
+++ b/src/KingSystem/Event/evtEvent.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <basis/seadTypes.h>
+#include <prim/seadTypedBitFlag.h>
+
+namespace ksys::evt {
+
+// TODO
+class Event {
+public:
+ Event();
+ virtual ~Event();
+
+ enum class Flag : u64 {
+ _80000000000 = 0x80000000000,
+ };
+
+ bool hasFlag(Flag flag) const { return mFlags.isOn(flag); }
+
+private:
+ u8 TEMP_0[0x338];
+ sead::TypedBitFlag<Flag> mFlags;
+};
+// sizeof() = 0x620
+
+} // namespace ksys::evt