ksys/gdt: Implement Manager increase functions

This commit is contained in:
Léo Lam 2020-11-11 12:04:58 +01:00
parent e0a8e69d8b
commit 27afd0aa6a
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
7 changed files with 1232 additions and 19 deletions

View File

@ -53563,7 +53563,7 @@
0x00000071008e5da4,getFlag_AutoSaveOnOff,172,_ZN4ksys3gdt21getFlag_AutoSaveOnOffEb
0x00000071008e5e50,getFlag_BalladOfHeroes_Activated,172,_ZN4ksys3gdt32getFlag_BalladOfHeroes_ActivatedEb
0x00000071008e5efc,sub_71008E5EFC,172,_ZN4ksys3gdt40getFlag_BalladOfHeroes_ChainRing_RunningEb
0x00000071008e5fa8,sub_71008E5FA8,172,
0x00000071008e5fa8,sub_71008E5FA8,172,_ZN4ksys3gdt24increaseFlag_CurrentHartEib
0x00000071008e6054,sub_71008E6054,180,_ZN4ksys3gdt40setFlag_BalladOfHeroes_ChainRing_RunningEib
0x00000071008e6108,sub_71008E6108,24,_ZN4ksys3gdt42resetFlag_BalladOfHeroes_ChainRing_RunningEb
0x00000071008e6120,getFlag_BalladOfHeroes_Step02,172,_ZN4ksys3gdt29getFlag_BalladOfHeroes_Step02Eb
@ -53628,23 +53628,23 @@
0x00000071008e8c40,getFlag_CurrentHart,172,_ZN4ksys3gdt19getFlag_CurrentHartEb
0x00000071008e8cec,sub_71008E8CEC,180,_ZN4ksys3gdt19setFlag_CurrentHartEib
0x00000071008e8da0,sub_71008E8DA0,172,_ZN4ksys3gdt19getFlag_CurrentMamoEb
0x00000071008e8e4c,sub_71008E8E4C,172,
0x00000071008e8e4c,sub_71008E8E4C,172,_ZN4ksys3gdt24increaseFlag_CurrentMamoEib
0x00000071008e8ef8,getFlag_CurrentRupee,172,_ZN4ksys3gdt20getFlag_CurrentRupeeEb
0x00000071008e8fa4,sub_71008E8FA4,172,
0x00000071008e8fa4,sub_71008E8FA4,172,_ZN4ksys3gdt24increaseFlag_STErrorCodeEib
0x00000071008e9050,setFlag_CurrentRupee,180,_ZN4ksys3gdt20setFlag_CurrentRupeeEib
0x00000071008e9104,sub_71008E9104,172,_ZN4ksys3gdt38getFlag_CurrentTotalGetRupeeInMiniGameEb
0x00000071008e91b0,sub_71008E91B0,172,
0x00000071008e91b0,sub_71008E91B0,172,_ZN4ksys3gdt25increaseFlag_CurrentRupeeEib
0x00000071008e925c,sub_71008E925C,160,_ZN4ksys3gdt26getFlag_DeadHorse_UserNameEPPKcib
0x00000071008e92fc,sub_71008E92FC,172,_ZN4ksys3gdt39getFlag_Defeated_Priest_Boss_Normal_NumEb
0x00000071008e93a8,sub_71008E93A8,172,
0x00000071008e93a8,sub_71008E93A8,172,_ZN4ksys3gdt25increaseFlag_FamouseValueEib
0x00000071008e9454,sub_71008E9454,172,_ZN4ksys3gdt30getFlag_DefeatedForestGiantNumEb
0x00000071008e9500,sub_71008E9500,172,
0x00000071008e9500,sub_71008E9500,172,_ZN4ksys3gdt25increaseFlag_Item_VelRateEib
0x00000071008e95ac,sub_71008E95AC,180,_ZN4ksys3gdt30setFlag_DefeatedForestGiantNumEib
0x00000071008e9660,sub_71008E9660,172,_ZN4ksys3gdt24getFlag_DefeatedGolemNumEb
0x00000071008e970c,sub_71008E970C,172,
0x00000071008e970c,sub_71008E970C,172,_ZN4ksys3gdt25increaseFlag_KorokNutsNumEib
0x00000071008e97b8,sub_71008E97B8,180,_ZN4ksys3gdt24setFlag_DefeatedGolemNumEib
0x00000071008e986c,sub_71008E986C,172,_ZN4ksys3gdt27getFlag_DefeatedSandwormNumEb
0x00000071008e9918,sub_71008E9918,172,
0x00000071008e9918,sub_71008E9918,172,_ZN4ksys3gdt25increaseFlag_MaxHartValueEib
0x00000071008e99c4,sub_71008E99C4,180,_ZN4ksys3gdt27setFlag_DefeatedSandwormNumEib
0x00000071008e9a78,getFlag_Die_PGanonElectric,172,_ZN4ksys3gdt26getFlag_Die_PGanonElectricEb
0x00000071008e9b24,getFlag_Die_PGanonFire,172,_ZN4ksys3gdt22getFlag_Die_PGanonFireEb
@ -54106,7 +54106,7 @@
0x00000071008fc864,getFlag_WaterSupportReuseTimeInCastle,172,_ZN4ksys3gdt37getFlag_WaterSupportReuseTimeInCastleEb
0x00000071008fc910,setFlag_WaterSupportReuseTimeInCastle,180,_ZN4ksys3gdt37setFlag_WaterSupportReuseTimeInCastleEfb
0x00000071008fc9c4,sub_71008FC9C4,172,_ZN4ksys3gdt27getFlag_WeaponPorchStockNumEb
0x00000071008fca70,sub_71008FCA70,172,
0x00000071008fca70,sub_71008FCA70,172,_ZN4ksys3gdt26increaseFlag_Location_MineEib
0x00000071008fcb1c,sub_71008FCB1C,172,_ZN4ksys3gdt30getFlag_Wind_Relic_BattleStartEb
0x00000071008fcbc8,getFlag_Wind_Relic_Finished,172,_ZN4ksys3gdt27getFlag_Wind_Relic_FinishedEb
0x00000071008fcc74,sub_71008FCC74,172,_ZN4ksys3gdt36getFlag_WindSupportReuseTimeInCastleEb
@ -76011,7 +76011,7 @@
0x0000007100dcf088,Res2Array::dtor,280,_ZN4sead9SafeArrayIN4ksys3res6HandleELi32EED2Ev
0x0000007100dcf1a0,GameDataMgr::dtorDelete,36,_ZN4ksys3gdt7ManagerD0Ev
0x0000007100dcf1c4,GameDataMgr::init,1264,_ZN4ksys3gdt7Manager4initEPN4sead4HeapEPNS2_9FrameworkE?
0x0000007100dcf6b4,sub_7100DCF6B4,704,_ZN4ksys3gdt7Manager15IncrementLoggerC2Ev
0x0000007100dcf6b4,sub_7100DCF6B4,704,_ZN4ksys3gdt7Manager14IncreaseLoggerC2Ev
0x0000007100dcf974,EntryFactoryBgdata::dtor,68,_ZN4ksys3res12EntryFactoryINS0_8GameDataEED2Ev
0x0000007100dcf9b8,GameDataMgr::loadGameDataFromArc,1692,
0x0000007100dd0054,GameDataMgr::loadShopGameDataInfo,600,
@ -76768,7 +76768,7 @@
0x0000007100e02ba8,GameDataFlag::x,68,_ZNK4ksys3gdt8FlagBase10isBoolean_Ev
0x0000007100e02bec,_ZNK4ksys3gdt8FlagBase19setCategoryForBool_EPvj,0x58,_ZNK4ksys3gdt8FlagBase19setCategoryForBool_EPvj
0x0000007100e02c44,GameDataFlag::x_0,80,_ZNK4ksys3gdt8FlagBase19getCategoryForBool_EPKv
0x0000007100e02c94,sub_7100E02C94,248,
0x0000007100e02c94,sub_7100E02C94,248,_ZN4ksys3gdt7Manager14IncreaseLogger9addRecordEiRKN4sead14SafeStringBaseIcEEib
0x0000007100e02d8c,sub_7100E02D8C,952,
0x0000007100e03144,sub_7100E03144,100,
0x0000007100e031a8,sub_7100E031A8,108,

Can't render this file because it is too large.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -184,4 +184,11 @@ GDT_RESET_FLAG_(resetVec4f)
#undef GDT_SET_FLAG_
inline void increaseS32CommonFlag(s32 value, const sead::SafeString& name, s32 sub_idx,
bool debug) {
auto* mgr = Manager::instance();
if (mgr)
mgr->increaseS32CommonFlag(value, name, sub_idx, debug);
}
} // namespace ksys::gdt

View File

@ -1,6 +1,7 @@
#include "KingSystem/GameData/gdtManager.h"
#include <devenv/seadEnvUtil.h>
#include <framework/seadFramework.h>
#include <mc/seadCoreInfo.h>
#include <thread/seadThreadUtil.h>
#include <time/seadTickTime.h>
#include "KingSystem/GameData/gdtSaveMgr.h"
@ -70,7 +71,7 @@ void Manager::init(sead::Heap* heap, sead::Framework* framework) {
mGameDataHeap = util::DualHeap::create(0xf00000, "GameDataHeap", heap, nullptr, sizeof(void*),
sead::Heap::cHeapDirection_Forward, true);
mIncrementLogger = new (mGameDataHeap) IncrementLogger;
mIncreaseLogger = new (mGameDataHeap) IncreaseLogger;
SaveMgr::createInstance(mGameDataHeap);
SaveMgr::InitArg arg;
@ -136,4 +137,18 @@ void Manager::addReinitCallback(sead::DelegateEvent<ReinitEvent*>::Slot&) {
// Stubbed in release builds.
}
void Manager::IncreaseLogger::addRecord(s32 value, const sead::SafeString& name, s32 sub_idx,
bool debug) {
const u32 name_hash = sead::HashCRC32::calcStringHash(name);
const auto core = sead::CoreInfo::getCurrentCoreId();
const u32 platform_core_id = sead::CoreInfo::getPlatformCoreId(core);
Record record;
record.debug = debug;
record.name_hash = name_hash;
record.sub_idx = sub_idx;
record.value = value;
ring_buffers[0][platform_core_id].pushBack(record);
}
} // namespace ksys::gdt

View File

@ -459,6 +459,15 @@ public:
#undef GDT_RESET_
void increaseS32CommonFlag(s32 value, const sead::SafeString& name, s32 sub_idx, bool debug) {
if (!mIncreaseLogger)
return;
mIncreaseLogger->addRecord(value, name, sub_idx, debug);
if (debug)
onChangedByDebug();
}
void init(sead::Heap* heap, sead::Framework* framework);
void addReinitCallback(ReinitSignal::Slot& slot);
@ -496,17 +505,19 @@ private:
sead::MethodTreeMgr* method_tree_mgr = nullptr;
};
struct IncrementLogger {
struct IncreaseLogger {
struct Record {
u8 _0 = 0;
u32 _4 = 0;
s32 _8 = -1;
u32 _c = 0;
bool debug = false;
u32 name_hash = 0;
s32 sub_idx = -1;
s32 value = 0;
};
KSYS_CHECK_SIZE_NX150(Record, 0x10);
void addRecord(s32 value, const sead::SafeString& name, s32 sub_idx, bool debug);
u64 _0 = 0;
sead::FixedRingBuffer<Record, 64> ring_buffers[6]{};
sead::SafeArray<sead::FixedRingBuffer<Record, 64>, 3> ring_buffers[2];
sead::SafeArray<Record, 0xc0> arrays[2]{};
};
@ -561,7 +572,7 @@ private:
TriggerParamRef mParamBypassPerm{&mFlagBuffer1, &mFlagBuffer, false, false, false};
TriggerParamRef mParam{&mFlagBuffer1, &mFlagBuffer, true, false, false};
IncrementLogger* mIncrementLogger = nullptr;
IncreaseLogger* mIncreaseLogger = nullptr;
TriggerParam* mFlagBuffer1;
TriggerParam* mFlagBuffer;

View File

@ -247,6 +247,9 @@ s32 getFlagGenericS32(FlagHandle handle, bool debug = false);
else:
f.write(
f"void getFlag_{name}({info.arg_type}* value, s32 idx, bool debug = false);\n")
# Increase function
if info.arg_type == "s32":
f.write(f"void increaseFlag_{name}(s32 value, s32 idx, bool debug = false);\n")
# Setter
f.write(f"void setFlag_{name}({info.get_setter_arg_type()} value, s32 idx, bool debug = false);\n")
# Resetter
@ -259,6 +262,9 @@ s32 getFlagGenericS32(FlagHandle handle, bool debug = false);
else:
f.write(
f"void getFlag_{name}({info.arg_type}* value, bool debug = false);\n")
# Increase function
if info.arg_type == "s32":
f.write(f"void increaseFlag_{name}(s32 value, bool debug = false);\n")
# Setter
f.write(f"void setFlag_{name}({info.get_setter_arg_type()} value, bool debug = false);\n")
# Resetter
@ -296,6 +302,10 @@ s32 getFlagGenericS32(FlagHandle handle, bool debug) { return getS32(handle, deb
else:
f.write(
f"void getFlag_{name}({info.arg_type}* value, s32 idx, bool debug) {{ {info.get_getter_fn_name()}(flag_{name}(), value, idx, debug); }}\n")
# Increase function
if info.arg_type == "s32":
f.write(f"void increaseFlag_{name}(s32 value, s32 idx, bool debug) {{ "
f"increaseS32CommonFlag(value, \"{name}\", idx, debug); }}\n")
# Setter
f.write(
f"void setFlag_{name}({info.get_setter_arg_type()} value, s32 idx, bool debug) {{ "
@ -312,6 +322,10 @@ s32 getFlagGenericS32(FlagHandle handle, bool debug) { return getS32(handle, deb
else:
f.write(
f"void getFlag_{name}({info.arg_type}* value, bool debug) {{ {info.get_getter_fn_name()}(flag_{name}(), value, debug); }}\n")
# Increase function
if info.arg_type == "s32":
f.write(f"void increaseFlag_{name}(s32 value, bool debug) {{ "
f"increaseS32CommonFlag(value, \"{name}\", -1, debug); }}\n")
# Setter
f.write(
f"void setFlag_{name}({info.get_setter_arg_type()} value, bool debug) {{ "