diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 515e5e7b..3b03e7ad 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -49412,7 +49412,7 @@ 0x00000071007ccd88,setPSavePosForStageGen,104, 0x00000071007ccdf0,setCurrentMapNameFromPlayerPos,76, 0x00000071007cce3c,getIsStageDebug,16, -0x00000071007cce4c,sub_71007CCE4C,124, +0x00000071007cce4c,sub_71007CCE4C,124,_GLOBAL__sub_I_gameStageInfo.cpp 0x00000071007ccec8,nullsub_5409,4, 0x00000071007ccecc,sinitStageSelect,292, 0x00000071007ccff0,uking::StageSelect::ctor,404, @@ -76265,8 +76265,8 @@ 0x0000007100dee554,sub_7100DEE554,796,_ZN4ksys3gdt14copyFlagArraysIN4sead7Vector3IfEEEEvRNS2_8PtrArrayINS5_INS0_8FlagBaseEEEEERKS8_RNS2_8ObjArrayINS0_12TriggerParam14FlagCopyRecordEEERNS2_9SafeArrayIiLi15EEEbbb 0x0000007100dee870,sub_7100DEE870,796,_ZN4ksys3gdt14copyFlagArraysIN4sead7Vector4IfEEEEvRNS2_8PtrArrayINS5_INS0_8FlagBaseEEEEERKS8_RNS2_8ObjArrayINS0_12TriggerParam14FlagCopyRecordEEERNS2_9SafeArrayIiLi15EEEbbb 0x0000007100deeb8c,TriggerParam::resetToInitialValues,2628,_ZN4ksys3gdt12TriggerParam28resetAllFlagsToInitialValuesEv -0x0000007100def5d0,shouldSkipReviveShopItem,868, -0x0000007100def934,TriggerParam::reset,3652, +0x0000007100def5d0,shouldSkipReviveShopItem,868,_ZNK4ksys3gdt12TriggerParam26shouldSkipRevivingShopItemEPbjbRKN4sead6BufferIiEEiiii +0x0000007100def934,TriggerParam::reset,3652,_ZN4ksys3gdt12TriggerParam27resetFlagsAccordingToPolicyEN4sead7BitFlagIjEEi 0x0000007100df0778,TriggerParam::getGameDataFlagBool,32,_ZNK4ksys3gdt12TriggerParam11getBoolFlagEi 0x0000007100df0798,TriggerParam::getBoolFlag,256,_ZNK4ksys3gdt12TriggerParam17getBoolFlagAndIdxEPij 0x0000007100df0898,sub_7100DF0898,32,_ZNK4ksys3gdt12TriggerParam10getS32FlagEi @@ -80013,7 +80013,7 @@ 0x0000007100ed8c8c,getCurrentMapType,12, 0x0000007100ed8c98,setCurrentMapTypeAndName,440, 0x0000007100ed8e50,setCurrentMapNameFromPos_,416, -0x0000007100ed8ff0,sinitCurrentMapStrings,168, +0x0000007100ed8ff0,sinitCurrentMapStrings,168,_GLOBAL__sub_I_StageInfo.cpp 0x0000007100ed9098,sub_7100ED9098,56, 0x0000007100ed90d0,sub_7100ED90D0,92, 0x0000007100ed912c,StagePreActorCache::createInstance,244, @@ -80313,7 +80313,7 @@ 0x0000007100ee22b4,act::findLinkReferenceObj,148, 0x0000007100ee2348,act::acc::findLinkReferenceObj,680, 0x0000007100ee25f0,sub_7100EE25F0,108, -0x0000007100ee265c,getPlayerGridPosition,244, +0x0000007100ee265c,getPlayerGridPosition,244,_ZN4ksys3act22getRevivalGridPositionERKN4sead7Vector3IfEEPiS6_S6_S6_ 0x0000007100ee2750,sub_7100EE2750,56, 0x0000007100ee2788,PlacementObj::getForSaleLink,44, 0x0000007100ee27b4,sub_7100EE27B4,76, diff --git a/lib/sead b/lib/sead index 9ac7ac68..ffa3cd12 160000 --- a/lib/sead +++ b/lib/sead @@ -1 +1 @@ -Subproject commit 9ac7ac68fb0cd1adbb62fb2bfb52d56db3c5cc90 +Subproject commit ffa3cd1219c6d828afbb29222ae8644efdc4a751 diff --git a/src/Game/CMakeLists.txt b/src/Game/CMakeLists.txt index 121a2a9b..834e7d9f 100644 --- a/src/Game/CMakeLists.txt +++ b/src/Game/CMakeLists.txt @@ -7,4 +7,6 @@ add_subdirectory(UI) target_sources(uking PRIVATE gameScene.cpp gameScene.h + gameStageInfo.cpp + gameStageInfo.h ) diff --git a/src/Game/gameStageInfo.cpp b/src/Game/gameStageInfo.cpp new file mode 100644 index 00000000..3ec69a05 --- /dev/null +++ b/src/Game/gameStageInfo.cpp @@ -0,0 +1,10 @@ +#include "Game/gameStageInfo.h" +#include "KingSystem/Utils/InitTimeInfo.h" + +namespace uking { + +static ksys::util::InitConstants sConstants; +sead::FixedSafeString<256> StageInfo::sStr; +StageInfo StageInfo::sInfo; + +} // namespace uking diff --git a/src/Game/gameStageInfo.h b/src/Game/gameStageInfo.h new file mode 100644 index 00000000..d149bffd --- /dev/null +++ b/src/Game/gameStageInfo.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include + +namespace uking { + +// TODO: Incomplete, but all getters should be there +class StageInfo { +public: + static const sead::Vector3f& getPSavePosAngleForStageGen() { + return sInfo.mPSavePosAngleForStageGen; + } + static const sead::Vector3f& getPSavePosForStageGen() { return sInfo.mPSavePosForStageGen; } + static bool isDebugOrDevMap() { return sInfo.mIsDebugOrDevMap; } + static bool isViewerMapType() { return sInfo.mIsViewerMapType; } + static bool isDungeon() { return sInfo.mIsDungeon; } + static bool isCDungeon() { return sInfo.mIsCDungeon; } + static bool isTestDungeon() { return sInfo.mIsTestDungeon; } + static bool isMainFieldDungeon() { return sInfo.mIsMainFieldDungeon; } + static bool isActorViewer() { return sInfo.mIsActorViewer; } + static bool isStageDebug() { return sInfo.mIsStageDebug; } + static bool isRemainsElectric() { return sInfo.mIsRemainsElectric; } + static bool isRemainsFire() { return sInfo.mIsRemainsFire; } + static bool isRemainsWater() { return sInfo.mIsRemainsWater; } + static bool isRemainsWind() { return sInfo.mIsRemainsWind; } + static bool isFinalTrial() { return sInfo.mIsFinalTrial; } + static bool isAocField() { return sInfo.mIsAocField; } + static bool isMainField() { return sInfo.mIsMainField; } + + static sead::FixedSafeString<256> sStr; + +private: + static StageInfo sInfo; + + sead::Vector3f mPSavePosAngleForStageGen; + sead::Vector3f mPSavePosForStageGen; + bool mIsDebugOrDevMap; + bool mIsViewerMapType; + bool mIsDungeon; + bool mIsCDungeon; + bool mIsTestDungeon; + bool mIsMainFieldDungeon; + bool mIsActorViewer; + bool mIsStageDebug; + bool mIsRemainsElectric; + bool mIsRemainsFire; + bool mIsRemainsWater; + bool mIsRemainsWind; + bool mIsFinalTrial; + bool mIsAocField; + bool mIsMainField; +}; + +} // namespace uking diff --git a/src/KingSystem/ActorSystem/actActorSystem.h b/src/KingSystem/ActorSystem/actActorSystem.h index d1ea3c96..2af35cf4 100644 --- a/src/KingSystem/ActorSystem/actActorSystem.h +++ b/src/KingSystem/ActorSystem/actActorSystem.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include namespace ksys::act { @@ -11,6 +13,16 @@ class ActorSystem { public: void onBaseProcMgrCalc(); + + bool getAutoPlacementActorPos(const sead::SafeString& name, sead::Vector3f* pos) const; + + sead::Heap* getEmergencyHeap() const { return mEmergencyHeap; } + const sead::Vector3f& getPlayerPos() const { return mPlayerPos; } + +private: + u8 temp_0x20[0xd0 - 0x20]; + sead::Heap* mEmergencyHeap; + sead::Vector3f mPlayerPos; }; } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorUtil.cpp b/src/KingSystem/ActorSystem/actActorUtil.cpp index 16ab1640..8f24330e 100644 --- a/src/KingSystem/ActorSystem/actActorUtil.cpp +++ b/src/KingSystem/ActorSystem/actActorUtil.cpp @@ -1,5 +1,6 @@ #include "KingSystem/ActorSystem/actActorUtil.h" #include +#include #include "KingSystem/ActorSystem/Profiles/actRopeBase.h" #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorConstDataAccess.h" @@ -525,6 +526,30 @@ bool isAirOctaWoodPlatformDlc(const sead::SafeString& name) { name == "FldObj_DLC_FlyShield_Wood_A_Snow_02"; } +void getRevivalGridPosition(const sead::Vector3f& pos, int* col1, int* row1, int* col2, int* row2) { + const int col = sead::clamp((int(pos.x) + 5000) / 1000, 0, 9); + const int row = sead::clamp((int(pos.z) + 4000) / 1000, 0, 7); + + const auto x = (float(col) + 0.5f) * 1000.0f - 5000.0f; + const auto z = (float(row) + 0.5f) * 1000.0f - 4000.0f; + + if (x < pos.x) { + *col1 = col; + *col2 = col + 1; + } else { + *col1 = col - 1; + *col2 = col; + } + + if (z < pos.z) { + *row1 = row; + *row2 = row + 1; + } else { + *row1 = row - 1; + *row2 = row; + } +} + bool getSameGroupActorName(sead::SafeString* name, BaseProcLink* link) { return getAccessor(link).getSameGroupActorName(name); } diff --git a/src/KingSystem/ActorSystem/actActorUtil.h b/src/KingSystem/ActorSystem/actActorUtil.h index cbc51e5a..b8ec6b79 100644 --- a/src/KingSystem/ActorSystem/actActorUtil.h +++ b/src/KingSystem/ActorSystem/actActorUtil.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace al { @@ -156,6 +157,8 @@ bool isAirOctaWoodPlatformDlc(const sead::SafeString& name); const sead::SafeString& getDefaultDropActor(); +void getRevivalGridPosition(const sead::Vector3f& pos, int* col1, int* row1, int* col2, int* row2); + bool getSameGroupActorName(sead::SafeString* name, BaseProcLink* link); bool getSameGroupActorName(sead::SafeString* name, Actor* actor); bool getSameGroupActorName(sead::SafeString* name, const sead::SafeString& default_value, diff --git a/src/KingSystem/GameData/gdtManager.h b/src/KingSystem/GameData/gdtManager.h index 555f8a01..fa48a737 100644 --- a/src/KingSystem/GameData/gdtManager.h +++ b/src/KingSystem/GameData/gdtManager.h @@ -497,6 +497,9 @@ public: const map::MubinIter& iter); static bool getShopInfoIter(u32 hash, al::ByamlIter* out, const al::ByamlIter& iter, const u32* hashes); + bool getShopSoldOutInfo(u32 hash, al::ByamlIter* out) const { + return getShopInfoIter(hash, out, getShopSoldOutInfoValues(), getShopSoldOutInfoHashes()); + } void resetBoolFlagForRadarMgr(FlagBool& flag); void allocRetryBuffer(sead::Heap* heap); @@ -504,6 +507,11 @@ public: void startSyncOnLoadEnd(); + const al::ByamlIter& getShopAreaInfoValues() const { return mShopAreaInfoValues; } + const u32* getShopAreaInfoHashes() const { return mShopAreaInfoHashes; } + const al::ByamlIter& getShopSoldOutInfoValues() const { return mShopSoldOutInfoValues; } + const u32* getShopSoldOutInfoHashes() const { return mShopSoldOutInfoHashes; } + private: enum class BitFlag { _1 = 0x1, diff --git a/src/KingSystem/GameData/gdtTriggerParam.cpp b/src/KingSystem/GameData/gdtTriggerParam.cpp index 6243c753..077a3ae7 100644 --- a/src/KingSystem/GameData/gdtTriggerParam.cpp +++ b/src/KingSystem/GameData/gdtTriggerParam.cpp @@ -2,9 +2,18 @@ #include #include #include +#include