mirror of
https://github.com/zeldaret/botw
synced 2026-09-09 11:44:20 -04:00
ksys/gdt: Add some special flag utils
This commit is contained in:
@@ -11,6 +11,8 @@ target_sources(uking PRIVATE
|
||||
gdtManager.h
|
||||
gdtSaveMgr.cpp
|
||||
gdtSaveMgr.h
|
||||
gdtSpecialFlags.cpp
|
||||
gdtSpecialFlags.h
|
||||
gdtTriggerParam.cpp
|
||||
gdtTriggerParam.h
|
||||
)
|
||||
|
||||
@@ -378,6 +378,15 @@ public:
|
||||
return NAME##NoCheckForce(TRAITS::convertValue(value), name); \
|
||||
} \
|
||||
return NAME(TRAITS::convertValue(value), name); \
|
||||
} \
|
||||
inline bool NAME##Special(TRAITS::WrapperArgType value, const sead::SafeString& name, \
|
||||
bool debug, bool force = false) { \
|
||||
if (debug) { \
|
||||
onChangedByDebug(); \
|
||||
auto& ref = debug ? getParamBypassPerm() : getParam(); \
|
||||
return ref.get().NAME(TRAITS::convertValue(value), name, force); \
|
||||
} \
|
||||
return NAME(TRAITS::convertValue(value), name); \
|
||||
} \
|
||||
\
|
||||
bool NAME(TRAITS::WrapperArgType value, FlagHandle handle, bool debug, s32 sub_idx) { \
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
#include "KingSystem/GameData/gdtSpecialFlags.h"
|
||||
#include <prim/seadStringUtil.h>
|
||||
#include "KingSystem/GameData/gdtCommonFlagsUtils.h"
|
||||
#include "KingSystem/GameData/gdtFlagUtils.h"
|
||||
|
||||
namespace ksys::gdt {
|
||||
|
||||
const char* str_Dungeon = "Dungeon";
|
||||
const char* str_Remains = "Remains";
|
||||
const char* sSmallKeyNumFlagSuffix = "_SmallKeyNum";
|
||||
const char* sDungeonClearFlagPrefix = "Clear_";
|
||||
const char* sDungeonEnterFlagPrefix = "Enter_";
|
||||
|
||||
#define GDT_DEFINE_BOOL_GETTER(FLAG) \
|
||||
bool getBool_##FLAG(bool debug = false) { return getBool(flag_##FLAG(), debug); }
|
||||
|
||||
GDT_DEFINE_BOOL_GETTER(SaveProhibition)
|
||||
GDT_DEFINE_BOOL_GETTER(SaveProhibitionArea)
|
||||
GDT_DEFINE_BOOL_GETTER(WarpProhibition)
|
||||
GDT_DEFINE_BOOL_GETTER(WarpProhibitionArea)
|
||||
GDT_DEFINE_BOOL_GETTER(WarpProhibitionArea_Fire_Relic)
|
||||
GDT_DEFINE_BOOL_GETTER(KillTimeProhibition)
|
||||
GDT_DEFINE_BOOL_GETTER(KillTimeProhibitionArea)
|
||||
GDT_DEFINE_BOOL_GETTER(KillTimeProhibitionArea_Fire_Relic)
|
||||
|
||||
#undef GDT_DEFINE_BOOL_GETTER
|
||||
|
||||
s32 getSmallKeyFlag(s32 idx, bool debug = false) {
|
||||
return getS32(flag_SmallKey(), idx, debug);
|
||||
}
|
||||
|
||||
bool isSaveProhibited() {
|
||||
if (getBool_SaveProhibition())
|
||||
return true;
|
||||
if (getBool_SaveProhibitionArea())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isWarpProhibited() {
|
||||
if (getBool_WarpProhibition())
|
||||
return true;
|
||||
if (getBool_WarpProhibitionArea())
|
||||
return true;
|
||||
if (getBool_WarpProhibitionArea_Fire_Relic())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isKillTimeProhibited() {
|
||||
if (getBool_KillTimeProhibition())
|
||||
return true;
|
||||
if (getBool_KillTimeProhibitionArea())
|
||||
return true;
|
||||
if (getBool_KillTimeProhibitionArea_Fire_Relic())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 getSmallKeyNum(const sead::SafeString& map, bool debug) {
|
||||
if (map.startsWith(str_Remains)) {
|
||||
sead::FixedSafeString<32> flag{map};
|
||||
flag.append(sSmallKeyNumFlagSuffix);
|
||||
return getS32ByKey(flag, debug);
|
||||
}
|
||||
|
||||
const s32 dungeon_num = getDungeonNum(map);
|
||||
if (dungeon_num == -1)
|
||||
return 0;
|
||||
|
||||
return getSmallKeyFlag(dungeon_num, debug);
|
||||
}
|
||||
|
||||
s32 getS32ByKey(const sead::SafeString& flag, bool debug) {
|
||||
s32 value{};
|
||||
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getS32(&value, flag);
|
||||
else
|
||||
mgr->getParam().get().getS32(&value, flag);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
s32 getDungeonNum(const sead::SafeString& map) {
|
||||
if (map.startsWith(str_Dungeon)) {
|
||||
const sead::FixedSafeString<32> buffer{str_Dungeon};
|
||||
s32 ret = -1;
|
||||
|
||||
const auto part = map.getPart(buffer.calcLength());
|
||||
if (sead::StringUtil::tryParseS32(&ret, part, sead::StringUtil::CardinalNumber::Base10))
|
||||
return ret;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void incrementSmallKeyNum(const sead::SafeString& map, s32 value, bool debug) {
|
||||
if (map.startsWith(str_Remains)) {
|
||||
sead::FixedSafeString<32> flag{map};
|
||||
flag.append(sSmallKeyNumFlagSuffix);
|
||||
increaseS32CommonFlag(value, flag, -1, debug);
|
||||
} else {
|
||||
const s32 dungeon_number = getDungeonNum(map);
|
||||
if (dungeon_number != -1)
|
||||
increaseS32CommonFlag(value, "SmallKey", dungeon_number, debug);
|
||||
}
|
||||
}
|
||||
|
||||
bool setS32ByKey(s32 value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
return mgr && mgr->setS32Special(value, flag, debug, true);
|
||||
}
|
||||
|
||||
bool setBoolByKey(bool value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
return mgr && mgr->setBoolSpecial(value, flag, debug, true);
|
||||
}
|
||||
|
||||
bool getBoolByKey(const sead::SafeString& flag, bool debug) {
|
||||
bool value{};
|
||||
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getBool(&value, flag);
|
||||
else
|
||||
mgr->getParam().get().getBool(&value, flag);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool isDungeonCleared(const sead::SafeString& map, bool debug) {
|
||||
sead::FixedSafeString<32> flag{sDungeonClearFlagPrefix};
|
||||
flag.append(map, 32 - sizeof("Clear_"));
|
||||
return getBoolByKey(flag, debug);
|
||||
}
|
||||
|
||||
void setDungeonCleared(const sead::SafeString& map, bool cleared, bool debug) {
|
||||
sead::FixedSafeString<32> flag{sDungeonClearFlagPrefix};
|
||||
flag.append(map, 32 - sizeof("Clear_"));
|
||||
setBoolByKey(cleared, flag, debug);
|
||||
}
|
||||
|
||||
bool isDungeonEntered(const sead::SafeString& map, bool debug) {
|
||||
sead::FixedSafeString<32> flag{sDungeonEnterFlagPrefix};
|
||||
flag.append(map, 32 - sizeof("Enter_"));
|
||||
return getBoolByKey(flag, debug);
|
||||
}
|
||||
|
||||
void setDungeonEntered(const sead::SafeString& map, bool cleared, bool debug) {
|
||||
sead::FixedSafeString<32> flag{sDungeonEnterFlagPrefix};
|
||||
flag.append(map, 32 - sizeof("Enter_"));
|
||||
setBoolByKey(cleared, flag, debug);
|
||||
}
|
||||
|
||||
f32 getF32ByKey(const sead::SafeString& flag, bool debug) {
|
||||
f32 value{};
|
||||
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getF32(&value, flag);
|
||||
else
|
||||
mgr->getParam().get().getF32(&value, flag);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void getStr64ByKey(const char** value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getStr64(value, flag);
|
||||
else
|
||||
mgr->getParam().get().getStr64(value, flag);
|
||||
}
|
||||
}
|
||||
|
||||
void getVec3fByKey(sead::Vector3f* value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getVec3f(value, flag);
|
||||
else
|
||||
mgr->getParam().get().getVec3f(value, flag);
|
||||
}
|
||||
}
|
||||
|
||||
s32 getS32ByKey(const sead::SafeString& flag, s32 sub_idx, bool debug) {
|
||||
s32 value{};
|
||||
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getS32(&value, flag, sub_idx);
|
||||
else
|
||||
mgr->getParam().get().getS32(&value, flag, sub_idx);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
f32 getF32ByKey(const sead::SafeString& flag, s32 sub_idx, bool debug) {
|
||||
f32 value{};
|
||||
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getF32(&value, flag, sub_idx);
|
||||
else
|
||||
mgr->getParam().get().getF32(&value, flag, sub_idx);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void getStr64ByKey(const char** value, const sead::SafeString& flag, s32 sub_idx, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
if (mgr) {
|
||||
if (debug)
|
||||
mgr->getParamBypassPerm().get().getStr64(value, flag, sub_idx);
|
||||
else
|
||||
mgr->getParam().get().getStr64(value, flag, sub_idx);
|
||||
}
|
||||
}
|
||||
|
||||
bool setF32ByKey(f32 value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
return mgr && mgr->setF32Special(value, flag, debug, true);
|
||||
}
|
||||
|
||||
bool setStr64ByKey(const sead::SafeString& value, const sead::SafeString& flag, bool debug) {
|
||||
auto* mgr = Manager::instance();
|
||||
return mgr && mgr->setStr64Special(value, flag, debug, true);
|
||||
}
|
||||
|
||||
} // namespace ksys::gdt
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <math/seadVector.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
|
||||
namespace ksys::act {
|
||||
class Actor;
|
||||
}
|
||||
|
||||
namespace ksys::gdt {
|
||||
|
||||
bool isSaveProhibited();
|
||||
bool isWarpProhibited();
|
||||
bool isKillTimeProhibited();
|
||||
|
||||
s32 getSmallKeyNum(const sead::SafeString& map, bool debug = false);
|
||||
s32 getDungeonNum(const sead::SafeString& map);
|
||||
void incrementSmallKeyNum(const sead::SafeString& map, s32 value, bool debug = false);
|
||||
|
||||
s32 getS32ByKey(const sead::SafeString& flag, bool debug = false);
|
||||
bool setS32ByKey(s32 value, const sead::SafeString& flag, bool debug = false);
|
||||
|
||||
bool setBoolByKey(bool value, const sead::SafeString& flag, bool debug = false);
|
||||
bool getBoolByKey(const sead::SafeString& flag, bool debug = false);
|
||||
|
||||
bool isDungeonCleared(const sead::SafeString& map, bool debug = false);
|
||||
void setDungeonCleared(const sead::SafeString& map, bool cleared, bool debug = false);
|
||||
|
||||
bool isDungeonEntered(const sead::SafeString& map, bool debug = false);
|
||||
void setDungeonEntered(const sead::SafeString& map, bool entered, bool debug = false);
|
||||
|
||||
bool isGetItem(const sead::SafeString& actor, bool debug = false);
|
||||
bool isGetItem(act::Actor* actor, bool debug = false);
|
||||
void setIsGetItem(const sead::SafeString& actor, bool value, bool debug = false);
|
||||
// XXX: Same as isGetItem -- why does this exist?
|
||||
bool isGetItem2(const sead::SafeString& actor, bool debug = false);
|
||||
void setIsGetItem2(const sead::SafeString& actor, bool value, bool debug = false);
|
||||
|
||||
f32 getF32ByKey(const sead::SafeString& flag, bool debug = false);
|
||||
void getStr64ByKey(const char** value, const sead::SafeString& flag, bool debug = false);
|
||||
void getVec3fByKey(sead::Vector3f* value, const sead::SafeString& flag, bool debug = false);
|
||||
s32 getS32ByKey(const sead::SafeString& flag, s32 sub_idx, bool debug = false);
|
||||
f32 getF32ByKey(const sead::SafeString& flag, s32 sub_idx, bool debug = false);
|
||||
void getStr64ByKey(const char** value, const sead::SafeString& flag, s32 sub_idx,
|
||||
bool debug = false);
|
||||
bool setF32ByKey(f32 value, const sead::SafeString& flag, bool debug = false);
|
||||
bool setStr64ByKey(const sead::SafeString& value, const sead::SafeString& flag, bool debug = false);
|
||||
|
||||
} // namespace ksys::gdt
|
||||
Reference in New Issue
Block a user