From 42807160cfb33af9f3cf2fa6b0ba98f232208cdb Mon Sep 17 00:00:00 2001 From: AlexApps99 Date: Mon, 26 Jul 2021 21:58:51 +1200 Subject: [PATCH] Add #ifdef declarations for NON_MATCHING code --- CMakeLists.txt | 1 + Contributing.md | 2 +- src/Game/AI/Query/queryHasSetItem.cpp | 4 ++- src/Game/Actor/actWeapon.cpp | 16 ++++++++--- src/Game/DLC/aocManager.cpp | 4 ++- src/Game/Damage/dmgDamageManagerBase.cpp | 4 ++- src/Game/UI/uiPauseMenuDataMgr.cpp | 28 ++++++++++++++----- .../ActorSystem/LOD/actLodState.cpp | 8 ++++-- src/KingSystem/ActorSystem/actASSetting.cpp | 4 ++- .../ActorSystem/actActorCreator.cpp | 4 ++- .../ActorSystem/actActorParamMgr.cpp | 8 ++++-- src/KingSystem/ActorSystem/actActorUtil.cpp | 12 ++++++-- src/KingSystem/ActorSystem/actAiClassDef.cpp | 8 ++++-- src/KingSystem/ActorSystem/actBaseProc.cpp | 8 ++++-- .../ActorSystem/actBaseProcJobQue.cpp | 4 ++- src/KingSystem/ActorSystem/actBaseProcMgr.cpp | 16 ++++++++--- .../ActorSystem/actInstParamPack.cpp | 11 ++++++-- src/KingSystem/Ecosystem/ecoSystem.cpp | 8 ++++-- src/KingSystem/Event/evtResourceTimeline.cpp | 4 ++- src/KingSystem/GameData/gdtManager.cpp | 8 ++++-- src/KingSystem/GameData/gdtTriggerParam.cpp | 4 ++- src/KingSystem/Map/mapObject.cpp | 16 +++++++---- src/KingSystem/Map/mapObjectLink.cpp | 3 +- src/KingSystem/Map/mapPlacementMgr.cpp | 6 ++-- src/KingSystem/Physics/System/physDefines.cpp | 4 ++- src/KingSystem/Quest/qstIndicator.cpp | 4 ++- src/KingSystem/Quest/qstManager.cpp | 12 ++++++-- src/KingSystem/Quest/qstQuest.cpp | 3 +- src/KingSystem/Quest/qstStep.cpp | 4 ++- .../Resource/Actor/resResourceAIProgram.cpp | 8 ++++-- .../Resource/Actor/resResourceAS.cpp | 4 ++- .../Resource/Actor/resResourceASResource.cpp | 4 ++- .../Resource/Actor/resResourceActorLink.cpp | 9 ++++-- .../Resource/Actor/resResourceBoneControl.cpp | 4 ++- .../Actor/resResourceLifeCondition.cpp | 4 ++- .../Resource/Actor/resResourceModelList.cpp | 8 ++++-- .../Resource/Actor/resResourceRecipe.cpp | 4 ++- src/KingSystem/Resource/resHandle.cpp | 4 ++- src/KingSystem/Resource/resInfoContainer.cpp | 8 ++++-- .../Resource/resResourceGameData.cpp | 3 +- .../Resource/resResourceGameSaveData.cpp | 4 ++- .../Resource/resResourceMgrTask.cpp | 8 ++++-- src/KingSystem/Resource/resUnit.cpp | 8 ++++-- src/KingSystem/System/OverlayArena.cpp | 8 ++++-- src/KingSystem/System/OverlayArenaSystem.cpp | 4 ++- src/KingSystem/System/VFRValue.cpp | 4 ++- src/KingSystem/Utils/ParamIO.cpp | 4 ++- src/KingSystem/Utils/Thread/ManagedTask.cpp | 4 ++- .../Utils/Thread/MessageDispatcher.cpp | 8 ++++-- src/KingSystem/Utils/Thread/Task.cpp | 8 ++++-- src/KingSystem/Utils/Thread/TaskMgr.cpp | 8 ++++-- src/KingSystem/Utils/Thread/TaskQueueBase.cpp | 8 ++++-- src/KingSystem/Utils/Thread/TaskThread.cpp | 4 ++- src/KingSystem/World/worldManager.cpp | 8 ++++-- src/KingSystem/World/worldShootingStarMgr.cpp | 3 +- 55 files changed, 274 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35455146..3d166a6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) add_executable(uking) target_include_directories(uking PRIVATE src) +target_compile_definitions(uking PRIVATE NON_MATCHING) target_compile_options(uking PRIVATE -fno-rtti -fno-exceptions) target_compile_options(uking PRIVATE -Wall -Wextra -Wdeprecated) target_compile_options(uking PRIVATE -Wno-unused-parameter -Wno-unused-private-field) diff --git a/Contributing.md b/Contributing.md index 0573f617..e70ded27 100644 --- a/Contributing.md +++ b/Contributing.md @@ -165,7 +165,7 @@ public: 9. **Update the list of decompiled functions**. * If you have a function that matches perfectly, great! - * If there are still minor differences left, add a `// NON_MATCHING: ` comment to explain what is wrong and add a `?` at the end of the mangled function name in the CSV. + * If there are still minor differences left, wrap the function in an `#ifdef NON_MATCHING`, add a comment to explain what is wrong, and add a `?` at the end of the mangled function name in the CSV. * For major differences (lots of entirely red/green/blue lines in the diff), add a `!` at the end of the function name. 10. Before opening a PR, reformat the code with clang-format and run `tools/check.py`. diff --git a/src/Game/AI/Query/queryHasSetItem.cpp b/src/Game/AI/Query/queryHasSetItem.cpp index 7b8ccd7d..82055adc 100644 --- a/src/Game/AI/Query/queryHasSetItem.cpp +++ b/src/Game/AI/Query/queryHasSetItem.cpp @@ -8,7 +8,8 @@ HasSetItem::HasSetItem(const InitArg& arg) : ksys::act::ai::Query(arg) {} HasSetItem::~HasSetItem() = default; -// NON_MATCHING: temp duplication +// temp duplication +#ifdef NON_MATCHING int HasSetItem::doQuery() { auto* gdm = ksys::gdt::Manager::instance(); if (gdm == nullptr) @@ -27,6 +28,7 @@ int HasSetItem::doQuery() { } return 0; } +#endif void HasSetItem::loadParams(const evfl::QueryArg& arg) { loadInt(arg.param_accessor, "Count"); diff --git a/src/Game/Actor/actWeapon.cpp b/src/Game/Actor/actWeapon.cpp index 7ea6c2dc..7cee1bbe 100644 --- a/src/Game/Actor/actWeapon.cpp +++ b/src/Game/Actor/actWeapon.cpp @@ -309,7 +309,8 @@ bool WeaponModifierInfo::pickRandomYellowModifierAmiibo(const sead::SafeString& return pickRandomModifierAmiibo(ranges); } -// NON_MATCHING: isConfigValid() somehow does not match when inlined (but matches the Wii U version) +// isConfigValid() somehow does not match when inlined (but matches the Wii U version) +#ifdef NON_MATCHING bool WeaponModifierInfo::pickRandomBlueModifierTbox(const sead::SafeString& actor) { auto* info = ksys::act::InfoData::instance(); if (!info) @@ -328,6 +329,7 @@ bool WeaponModifierInfo::pickRandomBlueModifierTbox(const sead::SafeString& acto return pickRandomModifier(ranges); } +#endif bool WeaponModifierInfo::pickRandomModifier(const WeaponModifierRanges& ranges) { const auto modifier = ranges.getRandomModifier(); @@ -408,7 +410,8 @@ bool WeaponModifierRanges::loadTierBlue(const ksys::res::GParamList& gparamlist) return true; } -// NON_MATCHING: isConfigValid() somehow does not match when inlined (but matches the Wii U version) +// isConfigValid() somehow does not match when inlined (but matches the Wii U version) +#ifdef NON_MATCHING bool WeaponModifierInfo::pickRandomBlueModifierActor(const ksys::act::ActorConstDataAccess& acc) { WeaponModifierRanges ranges; const auto& gparamlist = *acc.getGParamList(); @@ -419,8 +422,10 @@ bool WeaponModifierInfo::pickRandomBlueModifierActor(const ksys::act::ActorConst } return false; } +#endif -// NON_MATCHING: isConfigValid() somehow does not match when inlined (but matches the Wii U version) +// isConfigValid() somehow does not match when inlined (but matches the Wii U version) +#ifdef NON_MATCHING bool WeaponModifierInfo::pickRandomYellowModifierTbox(const sead::SafeString& actor) { auto* info = ksys::act::InfoData::instance(); if (!info) @@ -439,6 +444,7 @@ bool WeaponModifierInfo::pickRandomYellowModifierTbox(const sead::SafeString& ac return pickRandomModifier(ranges); } +#endif bool WeaponModifierRanges::loadTierYellow(const ksys::res::GParamList& gparamlist) { const auto* param = gparamlist.getWeaponCommon(); @@ -459,7 +465,8 @@ bool WeaponModifierRanges::loadTierYellow(const ksys::res::GParamList& gparamlis return true; } -// NON_MATCHING: isConfigValid() somehow does not match when inlined (but matches the Wii U version) +// isConfigValid() somehow does not match when inlined (but matches the Wii U version) +#ifdef NON_MATCHING bool WeaponModifierInfo::pickRandomYellowModifierActor(const ksys::act::ActorConstDataAccess& acc) { WeaponModifierRanges ranges; const auto& gparamlist = *acc.getGParamList(); @@ -470,5 +477,6 @@ bool WeaponModifierInfo::pickRandomYellowModifierActor(const ksys::act::ActorCon } return false; } +#endif } // namespace uking::act diff --git a/src/Game/DLC/aocManager.cpp b/src/Game/DLC/aocManager.cpp index 46e66553..ff8dce15 100644 --- a/src/Game/DLC/aocManager.cpp +++ b/src/Game/DLC/aocManager.cpp @@ -450,7 +450,8 @@ bool Manager::parseVersion() { return true; } -// NON_MATCHING: stack and duplicated branch -- volatile variables are painful +// stack and duplicated branch -- volatile variables are painful +#ifdef NON_MATCHING void Manager::checkVersion() { if (mVersion == 0) return; @@ -469,6 +470,7 @@ void Manager::checkVersion() { mVersionFlags.isOnBit(VersionError(VersionError::TooOld)); mVersionFlags.isOnBit(VersionError(VersionError::TooNew)); } +#endif bool Manager::VersionFile::readVersion() { if (!file_handle.requestedLoad()) diff --git a/src/Game/Damage/dmgDamageManagerBase.cpp b/src/Game/Damage/dmgDamageManagerBase.cpp index ce029d3e..2a798100 100644 --- a/src/Game/Damage/dmgDamageManagerBase.cpp +++ b/src/Game/Damage/dmgDamageManagerBase.cpp @@ -18,9 +18,11 @@ DamageManagerBase_UnknownBase1::DamageManagerBase_UnknownBase1(ksys::act::Actor* // when writing the vtable and Actor. // The original Compiler writes (0x8, 0x10) in one 'stp', and writes 0x0 and 0x18 individually with // 'str'. The rest seems to fall out of sync due to that, but it's otherwise functionally the same. -// NON_MATCHING: Incorrect order. +// Incorrect order. +#ifdef NON_MATCHING DamageManagerBase::DamageManagerBase(ksys::act::Actor* actor) : DamageManagerBase_UnknownBase1(actor) {} +#endif u32 DamageManagerBase::getDamage() { u32 result; diff --git a/src/Game/UI/uiPauseMenuDataMgr.cpp b/src/Game/UI/uiPauseMenuDataMgr.cpp index 678e5484..b3997c5e 100644 --- a/src/Game/UI/uiPauseMenuDataMgr.cpp +++ b/src/Game/UI/uiPauseMenuDataMgr.cpp @@ -1052,7 +1052,8 @@ void PauseMenuDataMgr::autoEquipLastAddedItem() { } } -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item, const sead::OffsetList& list) { const auto type = item->getType(); @@ -1083,8 +1084,10 @@ const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item, saveToGameData(list); return sead::SafeString::cEmptyString; } +#endif -// NON_MATCHING: harmless reordering +// harmless reordering +#ifdef NON_MATCHING void PauseMenuDataMgr::unequipAll(PouchItemType type) { const auto lock = sead::makeScopedLock(mCritSection); @@ -1108,6 +1111,7 @@ void PauseMenuDataMgr::unequipAll(PouchItemType type) { } } } +#endif KSYS_ALWAYS_INLINE inline void PauseMenuDataMgr::deleteItem_(const sead::OffsetList& list, PouchItem* item, @@ -1192,7 +1196,8 @@ void PauseMenuDataMgr::removeArrow(const sead::SafeString& arrow_name, int count ksys::gdt::setFlag_PorchItem_Value1(num, idx); } -// NON_MATCHING: branch merging -- but this is pretty clearly equivalent +// branch merging -- but this is pretty clearly equivalent +#ifdef NON_MATCHING int PauseMenuDataMgr::getItemCount(const sead::SafeString& name, bool count_equipped) const { const auto type = getType(name); if (isPouchItemInvalid(type)) @@ -1259,6 +1264,7 @@ int PauseMenuDataMgr::getItemCount(const sead::SafeString& name, bool count_equi } return count; } +#endif void PauseMenuDataMgr::setEquippedWeaponItemValue(s32 value, PouchItemType type) { if (isPouchItemNotWeapon(type)) @@ -1336,7 +1342,8 @@ void PauseMenuDataMgr::removeGrabbedItems() { saveToGameData(items); } -// NON_MATCHING: mostly branching (which leads to other differences), but visibly equivalent +// mostly branching (which leads to other differences), but visibly equivalent +#ifdef NON_MATCHING bool PauseMenuDataMgr::addGrabbedItem(ksys::act::BaseProcLink* link) { if (!link || !link->hasProc()) return false; @@ -1376,6 +1383,7 @@ bool PauseMenuDataMgr::addGrabbedItem(ksys::act::BaseProcLink* link) { mGrabbedItems[4] = {}; return found; } +#endif bool PauseMenuDataMgr::getEquippedArrowType(sead::BufferedSafeString* name, int* count) const { const auto lock = sead::makeScopedLock(mCritSection); @@ -1646,7 +1654,8 @@ PouchCategory PauseMenuDataMgr::getCategoryForType(PouchItemType type) const { } } -// NON_MATCHING: two harmless reorderings +// two harmless reorderings +#ifdef NON_MATCHING void PauseMenuDataMgr::removeCookResult(const sead::SafeString& name, s32 effect_type, bool check_effect) { auto* info = ksys::act::InfoData::instance(); @@ -1705,6 +1714,7 @@ void PauseMenuDataMgr::removeCookResult(const sead::SafeString& name, s32 effect updateInventoryInfo(items); updateListHeads(); } +#endif bool PauseMenuDataMgr::switchEquipment(const sead::SafeString& name, int* value, act::WeaponModifierInfo* modifier) { @@ -2191,7 +2201,8 @@ int pouchItemSortPredicateForArrow(const PouchItem* lhs, const PouchItem* rhs) { return (*fn)(lhs, rhs, info_data); } -// NON_MATCHING: branching, but this is so trivial it isn't worth spending time on matching this +// branching, but this is so trivial it isn't worth spending time on matching this +#ifdef NON_MATCHING const sead::SafeString* PauseMenuDataMgr::getEquippedItemName(PouchItemType type) const { const auto lock = sead::makeScopedLock(mCritSection); const auto& items = getItems(); @@ -2206,6 +2217,7 @@ const sead::SafeString* PauseMenuDataMgr::getEquippedItemName(PouchItemType type } return nullptr; } +#endif const PouchItem* PauseMenuDataMgr::getEquippedItem(PouchItemType type) const { const auto lock = sead::makeScopedLock(mCritSection); @@ -2542,7 +2554,8 @@ bool PauseMenuDataMgr::isOverCategoryLimit(PouchItemType type) const { return true; } -// NON_MATCHING: branching (really weird issue...) +// branching (really weird issue...) +#ifdef NON_MATCHING int PauseMenuDataMgr::countArmors(const sead::SafeString& lowest_rank_armor_name) const { if (!isPouchItemArmor(getType(lowest_rank_armor_name))) return 0; @@ -2569,6 +2582,7 @@ int PauseMenuDataMgr::countArmors(const sead::SafeString& lowest_rank_armor_name } return count; } +#endif void PauseMenuDataMgr::addNonDefaultItem(const sead::SafeString& name, int value, const act::WeaponModifierInfo* modifier) { diff --git a/src/KingSystem/ActorSystem/LOD/actLodState.cpp b/src/KingSystem/ActorSystem/LOD/actLodState.cpp index 99bdfbca..3dff3e29 100644 --- a/src/KingSystem/ActorSystem/LOD/actLodState.cpp +++ b/src/KingSystem/ActorSystem/LOD/actLodState.cpp @@ -9,7 +9,8 @@ namespace ksys::act { -// NON_MATCHING: reorders at the beginning because of initFlags -- should be equivalent +// reorders at the beginning because of initFlags -- should be equivalent +#ifdef NON_MATCHING LodState::LodState(sead::Heap* heap, sead::BitFlag32 flags, Actor* actor, int disable_calc_skip_frame, float x) : mFlags14(flags), mActor(actor), _44(x), mDisableCalcSkipFrame(disable_calc_skip_frame) { @@ -300,13 +301,15 @@ LodState::LodState(sead::Heap* heap, sead::BitFlag32 flags, Actor* actor, _50 = 3.0f; } } +#endif LodState::~LodState() { if (mOcclusionQueryCylinder) delete mOcclusionQueryCylinder; } -// NON_MATCHING: ????? reordering +// ????? reordering +#ifdef NON_MATCHING void LodState::initFlags() { _28 = 1.0; _40 = 0.0; @@ -327,5 +330,6 @@ void LodState::initFlags() { _60 = 0xFFFF; _64 = -3; } +#endif } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actASSetting.cpp b/src/KingSystem/ActorSystem/actASSetting.cpp index 2b020cfe..164d9e67 100644 --- a/src/KingSystem/ActorSystem/actASSetting.cpp +++ b/src/KingSystem/ActorSystem/actASSetting.cpp @@ -15,7 +15,8 @@ void ASSetting::init(const sead::SafeString& config_path, sead::Heap* heap) { mHandle.load(config_path, &req); } -// NON_MATCHING: sead::DirectResource to res::ASSetting cast nullptr check; branching for the return +// sead::DirectResource to res::ASSetting cast nullptr check; branching for the return +#ifdef NON_MATCHING res::ASParamParser* ASSetting::getBoneParams(const sead::SafeString& key) const { auto* res = sead::DynamicCast(mHandle.getResource()); if (!res) @@ -27,5 +28,6 @@ res::ASParamParser* ASSetting::getBoneParams(const sead::SafeString& key) const } return nullptr; } +#endif } // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actActorCreator.cpp b/src/KingSystem/ActorSystem/actActorCreator.cpp index e3203b5e..fc5a54c0 100644 --- a/src/KingSystem/ActorSystem/actActorCreator.cpp +++ b/src/KingSystem/ActorSystem/actActorCreator.cpp @@ -166,7 +166,8 @@ bool ActorCreator::requestCreateActor(const char* name, sead::Heap* heap, BasePr return requestCreateActor_(actor_class, name, heap, map_object, handle, task_lane_id, params); } -// NON_MATCHING: OffsetList iteration +// OffsetList iteration +#ifdef NON_MATCHING void ActorCreator::enableDistanceUnloadChecks() { const auto lock = sead::makeScopedLock(mActorListCS); for (auto it = mActorList.robustBegin(); it != mActorList.robustEnd(); ++it) { @@ -176,6 +177,7 @@ void ActorCreator::enableDistanceUnloadChecks() { } mEnableDistanceChecks = true; } +#endif void ActorCreator::eraseActor(Actor* actor) { const auto lock = sead::makeScopedLock(mActorListCS); diff --git a/src/KingSystem/ActorSystem/actActorParamMgr.cpp b/src/KingSystem/ActorSystem/actActorParamMgr.cpp index e2ace0d4..3e8d4317 100644 --- a/src/KingSystem/ActorSystem/actActorParamMgr.cpp +++ b/src/KingSystem/ActorSystem/actActorParamMgr.cpp @@ -175,7 +175,8 @@ ActorParam* ActorParamMgr::allocParam(const char* actor_name, bool* allocated_ne return param; } -// NON_MATCHING: addressing mode +// addressing mode +#ifdef NON_MATCHING ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_free_param) const { auto lock = sead::makeScopedLock(mCS); for (s32 i = 0; i < NumParams; ++i) { @@ -189,6 +190,7 @@ ActorParam* ActorParamMgr::getParam(const char* actor_name, ActorParam** out_fre } return nullptr; } +#endif ActorParam* ActorParamMgr::loadParam(const char* actor_name, res::Handle* pack_handle, void* x, u32 load_req_c) { @@ -291,7 +293,8 @@ bool ActorParamMgr::loadFileAsync(ActorParam* param, ActorParam::ResourceType ty return true; } -// NON_MATCHING: different address calculation for static_cast(res)->getPath() +// different address calculation for static_cast(res)->getPath() +#ifdef NON_MATCHING template T* ActorParamMgr::handleAsyncFileLoad(ActorParam* param, s32* idx, ActorParam::ResourceType type, void*) { @@ -329,6 +332,7 @@ T* ActorParamMgr::handleAsyncFileLoad(ActorParam* param, s32* idx, ActorParam::R return res; } +#endif bool ActorParamMgr::finishLoadingActorLink(ActorParam* param, void* x) { s32 idx = 0; diff --git a/src/KingSystem/ActorSystem/actActorUtil.cpp b/src/KingSystem/ActorSystem/actActorUtil.cpp index 24fb1011..443e4046 100644 --- a/src/KingSystem/ActorSystem/actActorUtil.cpp +++ b/src/KingSystem/ActorSystem/actActorUtil.cpp @@ -113,7 +113,8 @@ bool hasOneTagAtLeast(const ActorConstDataAccess& accessor, const sead::SafeStri return false; } -// NON_MATCHING: this version doesn't have unnecessary register moves. +// this version doesn't have unnecessary register moves. +#ifdef NON_MATCHING bool shouldSkipSpawnWhenRaining(map::Object* obj) { if (obj->getFlags().isOff(map::Object::Flag::CreateNotRain)) return false; @@ -124,6 +125,7 @@ bool shouldSkipSpawnWhenRaining(map::Object* obj) { const auto pos = obj->getTranslate(); return !world::Manager::instance()->isRaining(pos); } +#endif bool shouldSkipSpawnIfGodForestOff(map::Object* obj) { bool value = false; @@ -177,7 +179,8 @@ auto initSpawnConditionGameDataFlags_dummy() { return sIsGetStopTimerLv2Handle; } -// NON_MATCHING: redundant branches in the original code. +// redundant branches in the original code. +#ifdef NON_MATCHING bool hasAnyRevivalTag(const sead::SafeString& actor) { auto* info = InfoData::instance(); al::ByamlIter iter; @@ -198,6 +201,7 @@ bool hasAnyRevivalTag(const sead::SafeString& actor) { } return false; } +#endif bool hasStopTimerMiddleTag(Actor* actor) { return hasTag(actor, tags::StopTimerMiddle); @@ -207,10 +211,12 @@ bool hasStopTimerShortTag(Actor* actor) { return hasTag(actor, tags::StopTimerShort); } -// NON_MATCHING: ??? +// ??? +#ifdef NON_MATCHING const char* arrowTypeToString(ArrowType idx) { return sArrowTypes[u32(idx)]; } +#endif ArrowType arrowTypeFromString(const sead::SafeString& name) { for (s32 i = 0; i < sArrowTypes.size(); ++i) { diff --git a/src/KingSystem/ActorSystem/actAiClassDef.cpp b/src/KingSystem/ActorSystem/actAiClassDef.cpp index 378d2248..064aa883 100644 --- a/src/KingSystem/ActorSystem/actAiClassDef.cpp +++ b/src/KingSystem/ActorSystem/actAiClassDef.cpp @@ -42,7 +42,8 @@ void AIClassDef::init(const sead::SafeString& aidef_file_name, sead::Heap* heap) mData->load(heap); } -// NON_MATCHING: not trying to match the heap sort. The rest should be equivalent +// not trying to match the heap sort. The rest should be equivalent +#ifdef NON_MATCHING bool AIClassDef::Data::load(sead::Heap* heap) { root_iter.tryGetIterByKey(&iters[s32(AIDefType::AI)], str_AIs); root_iter.tryGetIterByKey(&iters[s32(AIDefType::Action)], str_Actions); @@ -82,6 +83,7 @@ bool AIClassDef::Data::load(sead::Heap* heap) { return true; } +#endif s32 AIClassDef::getRawDefIdx(const sead::SafeString& def_name, AIDefType type) const { const auto hash = sead::HashCRC32::calcStringHash(def_name); @@ -137,7 +139,8 @@ void AIClassDef::getDef(const sead::SafeString& class_name, AIDefSet* set, data->inst_params_key_idx[s32(AIDefInstParamKind::AITree)]); } -// NON_MATCHING: CalcTiming ifs are reordered +// CalcTiming ifs are reordered +#ifdef NON_MATCHING void AIClassDef::doGetDef(AIDef* def, const al::ByamlIter& iter, AIDefInstParamKind param_kind, AIDefType class_type, s32 key_idx) const { def->no_stop = false; @@ -259,6 +262,7 @@ void AIClassDef::doGetDef(AIDef* def, const al::ByamlIter& iter, AIDefInstParamK ++def->num_params; } } +#endif void AIClassDef::getDef(AIDef* def, const sead::SafeString& class_name, AIDefInstParamKind param_kind, AIDefType class_type) const { diff --git a/src/KingSystem/ActorSystem/actBaseProc.cpp b/src/KingSystem/ActorSystem/actBaseProc.cpp index 528766d3..545618a2 100644 --- a/src/KingSystem/ActorSystem/actBaseProc.cpp +++ b/src/KingSystem/ActorSystem/actBaseProc.cpp @@ -155,7 +155,8 @@ BaseProc::PreDeletePrepareResult BaseProc::prepareForPreDelete_() { return PreDeletePrepareResult::Done; } -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING bool BaseProc::startPreparingForPreDelete_() { if (mUpdateStateListNode.isLinked()) return false; @@ -163,6 +164,7 @@ bool BaseProc::startPreparingForPreDelete_() { return !mBaseProcLinkData || mBaseProcLinkData->refCount() <= 0 || BaseProcMgr::instance()->getUnk3() || tera::checkTeraSystemStatus(); } +#endif void BaseProc::destruct_(int should_destruct) { if (should_destruct == 1) { @@ -346,7 +348,8 @@ void BaseProc::jobInvoked(JobType type) { } } -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING bool BaseProc::processStateUpdate(u8 counter) { const bool delete_requested = mStateFlags.isOn(StateFlags::RequestDelete); const bool initialized = mFlags.isOn(Flags::Initialized); @@ -444,6 +447,7 @@ bool BaseProc::processStateUpdate(u8 counter) { mStateFlags = new_flags; return ret; } +#endif void BaseProc::processPreDelete() { if (!mFlags.isOn(Flags::Initialized)) diff --git a/src/KingSystem/ActorSystem/actBaseProcJobQue.cpp b/src/KingSystem/ActorSystem/actBaseProcJobQue.cpp index efa623a1..6803f6bd 100644 --- a/src/KingSystem/ActorSystem/actBaseProcJobQue.cpp +++ b/src/KingSystem/ActorSystem/actBaseProcJobQue.cpp @@ -80,7 +80,8 @@ bool BaseProcJobQue::pushJobs(sead::FixedSizeJQ* queue, BaseProcJobLists* lists, return true; } -// NON_MATCHING: sxtw + madd -> smaddl +// sxtw + madd -> smaddl +#ifdef NON_MATCHING bool BaseProcJobQue::pushExtraJobs(sead::FixedSizeJQ* queue, BaseProcJobLists* lists, int priority, JobType type) { const auto& list = lists->getList(priority); @@ -104,6 +105,7 @@ bool BaseProcJobQue::pushExtraJobs(sead::FixedSizeJQ* queue, BaseProcJobLists* l return true; } +#endif bool BaseProcJobQue::pushExtraJobs(sead::FixedSizeJQ* queue, const agl::utl::AtomicPtrArray& links) { diff --git a/src/KingSystem/ActorSystem/actBaseProcMgr.cpp b/src/KingSystem/ActorSystem/actBaseProcMgr.cpp index a3ca8407..d3e84e17 100644 --- a/src/KingSystem/ActorSystem/actBaseProcMgr.cpp +++ b/src/KingSystem/ActorSystem/actBaseProcMgr.cpp @@ -40,7 +40,8 @@ BaseProcMgr::~BaseProcMgr() { BaseProcHeapMgr::deleteInstance(); } -// NON_MATCHING: mJobLists.allocBufferAssert - BaseProcJobLists ctor +// mJobLists.allocBufferAssert - BaseProcJobLists ctor +#ifdef NON_MATCHING void BaseProcMgr::init(sead::Heap* heap, s32 num_job_types, u32 main_thread_id, u32 havok_thread_id1, u32 havok_thread_id2, const BaseProcInitializerArgs& initializer_args) { @@ -66,6 +67,7 @@ void BaseProcMgr::init(sead::Heap* heap, s32 num_job_types, u32 main_thread_id, BaseProcHeapMgr::createInstance(heap); BaseProcLinkDataMgr::createInstance(heap); } +#endif void BaseProcMgr::generateProcId(u32* id) { *id = mCreatedProcCounter.increment(); @@ -529,7 +531,8 @@ BaseProc* BaseProcMgr::getProc(const u32& id, BaseProcMgr::ProcFilters filters) return proc; } -// NON_MATCHING: stack +// stack +#ifdef NON_MATCHING void BaseProcMgr::forEachProc(sead::IDelegate1& callback, ProcFilters filters) { const auto lock = sead::makeScopedLock(mProcMapCS); @@ -542,6 +545,7 @@ void BaseProcMgr::forEachProc(sead::IDelegate1& callback, ProcFilters mProcMap.forEach(sead::Delegate1( &context, &ProcForEachContext::forEach)); } +#endif void BaseProcMgr::forEachProc(const sead::SafeString& proc_name, sead::IDelegate1& callback, @@ -633,12 +637,15 @@ void BaseProcMgr::decrementUnk3() { --mUnk3; } -// NON_MATCHING: reorderings +// reorderings +#ifdef NON_MATCHING void BaseProcMgr::queueExtraJobPush(BaseProcJobLink* job_link) { getExtraJobs().pushBack(job_link); } +#endif -// NON_MATCHING: ??? +// ??? +#ifdef NON_MATCHING void BaseProcMgr::moveExtraJobsToOtherBuffer(JobType type) { const auto old_idx = mCurrentExtraJobArrayIdx; swapExtraJobArray(); @@ -647,6 +654,7 @@ void BaseProcMgr::moveExtraJobsToOtherBuffer(JobType type) { link.getProc()->queueExtraJobPush_(type, mCurrentExtraJobArrayIdx); } } +#endif bool BaseProcMgr::hasExtraJobLink(BaseProcJobLink* job_link, s32 idx) { for (auto& ptr : mExtraJobLinkArrays.ref()[idx]) { diff --git a/src/KingSystem/ActorSystem/actInstParamPack.cpp b/src/KingSystem/ActorSystem/actInstParamPack.cpp index a943cd06..1bf45cac 100644 --- a/src/KingSystem/ActorSystem/actInstParamPack.cpp +++ b/src/KingSystem/ActorSystem/actInstParamPack.cpp @@ -9,7 +9,8 @@ void InstParamPack::Buffer::clear() { mData.fill(0); } -// NON_MATCHING: write() +// write() +#ifdef NON_MATCHING void InstParamPack::Buffer::add(const void* data, const sead::SafeString& name, s32 byte_size, InstParamPack::EntryType type) { if (byte_size + mPosition + u32(sizeof(const char*)) + 1 > mData.getByteSize()) { @@ -22,13 +23,16 @@ void InstParamPack::Buffer::add(const void* data, const sead::SafeString& name, writeBytes(data, byte_size); ++mNumItems; } +#endif -// NON_MATCHING: write() +// write() +#ifdef NON_MATCHING void InstParamPack::Buffer::add(ActorCallback* callback, const sead::SafeString& name) { add(callback, name, sizeof(callback), EntryType::UInt64); } +#endif -// NON_MATCHING +#ifdef NON_MATCHING bool InstParamPack::Buffer::pop(s32* position, InstParamPack::Entry* out_entry) { if (!read(out_entry->key, position)) return false; @@ -67,6 +71,7 @@ bool InstParamPack::Buffer::pop(s32* position, InstParamPack::Entry* out_entry) return false; } } +#endif InstParamPack::Buffer& InstParamPack::Buffer::operator=(const InstParamPack::Buffer& other) { size_t pos = other.mPosition; diff --git a/src/KingSystem/Ecosystem/ecoSystem.cpp b/src/KingSystem/Ecosystem/ecoSystem.cpp index 42da40ac..6f8252bf 100644 --- a/src/KingSystem/Ecosystem/ecoSystem.cpp +++ b/src/KingSystem/Ecosystem/ecoSystem.cpp @@ -29,7 +29,8 @@ SEAD_SINGLETON_DISPOSER_IMPL(Ecosystem) void Ecosystem::calc() {} -// NON_MATCHING: FP instructions rearranged. +// FP instructions rearranged. +#ifdef NON_MATCHING s32 Ecosystem::getMapArea(const EcoMapInfo& info, f32 posX, f32 posZ) const { posX = sead::clamp(posX, -5000.0F, 4999.0F); posZ = sead::clamp(posZ, -4000.0F, 4000.0F); @@ -62,6 +63,7 @@ s32 Ecosystem::getMapArea(const EcoMapInfo& info, f32 posX, f32 posZ) const { return -1; } } +#endif void Ecosystem::getAreaNameByNum(s32 areaNum, const char** out) const { *out = nullptr; @@ -75,7 +77,8 @@ void Ecosystem::getAreaNameByNum(s32 areaNum, const char** out) const { iter.tryGetStringByKey(out, "Area"); } -// NON_MATCHING: Equivalent, minor conditional differences and register usage +// Equivalent, minor conditional differences and register usage +#ifdef NON_MATCHING void Ecosystem::getStatusEffectInfo(StatusEffect statusEffectIdx, s32 idx, eco::StatusEffectInfo* out) const { al::ByamlIter listIter; @@ -135,6 +138,7 @@ void Ecosystem::getStatusEffectInfo(StatusEffect statusEffectIdx, s32 idx, out->val._f32 = val2; } } +#endif void Ecosystem::getClimateNameByNum(s32 areaNum, const char** out) const { *out = nullptr; diff --git a/src/KingSystem/Event/evtResourceTimeline.cpp b/src/KingSystem/Event/evtResourceTimeline.cpp index a7156334..28ea3261 100644 --- a/src/KingSystem/Event/evtResourceTimeline.cpp +++ b/src/KingSystem/Event/evtResourceTimeline.cpp @@ -118,7 +118,8 @@ long bindActorActions(evfl::TimelineObj& obj, res::EventFlowActionBinder binder) return int(ok) | (int(failed) << 8); } -// NON_MATCHING: minor reordering for the buildTimeline loop +// minor reordering for the buildTimeline loop +#ifdef NON_MATCHING bool ResourceTimeline::setUpBindings(ActorBindings* bindings, sead::Heap* heap) { sead::Buffer timeline_objs; timeline_objs.allocBufferAssert(mTimelines.size(), heap); @@ -162,6 +163,7 @@ bool ResourceTimeline::setUpBindings(ActorBindings* bindings, sead::Heap* heap) timeline_objs.freeBuffer(); return true; } +#endif bool ResourceTimeline::buildTimeline(evfl::TimelineObj* obj, int idx, sead::Heap* heap) { auto& timeline = mTimelines[idx]; diff --git a/src/KingSystem/GameData/gdtManager.cpp b/src/KingSystem/GameData/gdtManager.cpp index 2e392908..b0b5972c 100644 --- a/src/KingSystem/GameData/gdtManager.cpp +++ b/src/KingSystem/GameData/gdtManager.cpp @@ -76,7 +76,8 @@ Manager::~Manager() { } } -// NON_MATCHING: address differences for the static bgdata_factory that causes different regalloc +// address differences for the static bgdata_factory that causes different regalloc +#ifdef NON_MATCHING void Manager::init(sead::Heap* heap, sead::Framework* framework) { sead::TickTime a; sead::TickTime b; @@ -137,6 +138,7 @@ void Manager::init(sead::Heap* heap, sead::Framework* framework) { mBitFlags.set(BitFlag::_1000); mNumFlagsToReset = 0; } +#endif void Manager::loadShopGameDataInfo(const sead::SafeString& path) { res::LoadRequest req; @@ -795,7 +797,8 @@ void Manager::syncStart() { util::safeDeleteArray(buffer); } -// NON_MATCHING: recordFlagChange calls not being merged, or merged in the wrong way +// recordFlagChange calls not being merged, or merged in the wrong way +#ifdef NON_MATCHING void Manager::syncUpdate(const char* data) { const sead::SafeString cmd = data; auto it = cmd.tokenBegin("|"); @@ -1032,6 +1035,7 @@ void Manager::syncUpdate(const char* data) { return; } } +#endif void Manager::recordFlagChange(u32 platform_core_id, TriggerParam* tparam, u8 type, const s32& idx, const s32& sub_idx) { diff --git a/src/KingSystem/GameData/gdtTriggerParam.cpp b/src/KingSystem/GameData/gdtTriggerParam.cpp index 077a3ae7..ff8089cc 100644 --- a/src/KingSystem/GameData/gdtTriggerParam.cpp +++ b/src/KingSystem/GameData/gdtTriggerParam.cpp @@ -2462,7 +2462,8 @@ bool shouldLogFlagChange(const sead::SafeString& flag_name, FlagType type) { return sConfig.shouldLog(flag_name, event_type); } -// NON_MATCHING: reorderings (which result in other small differences) +// reorderings (which result in other small differences) +#ifdef NON_MATCHING sead::Color4f getFlagColor(FlagType type) { if (s32(type) == FlagType::Bool || s32(type) == FlagType::BoolArray) return sead::Color4f::cRed; @@ -2480,5 +2481,6 @@ sead::Color4f getFlagColor(FlagType type) { return sead::Color4f::cBlue; } +#endif } // namespace ksys::gdt diff --git a/src/KingSystem/Map/mapObject.cpp b/src/KingSystem/Map/mapObject.cpp index d0671bdf..0b793c9f 100644 --- a/src/KingSystem/Map/mapObject.cpp +++ b/src/KingSystem/Map/mapObject.cpp @@ -11,7 +11,7 @@ namespace ksys::map { -// NON_MATCHING +#ifdef NON_MATCHING Object::Object() { mHardModeFlags.makeAllZero(); _b = 0xFF; @@ -20,6 +20,7 @@ Object::Object() { mProc = nullptr; mLinkData = nullptr; } +#endif Object::~Object() { if (mLinkData != nullptr) { @@ -49,7 +50,7 @@ void Object::free() { mLinkData->field_57 = 0; } -// NON_MATCHING +#ifdef NON_MATCHING void Object::initData(MubinIter* iter, u8 idx, u32 actor_data_idx, ActorData* data) { mActorDataIdx = 0xFFFF; mFlags0.makeAllZero(); @@ -100,6 +101,7 @@ void Object::initData(MubinIter* iter, u8 idx, u32 actor_data_idx, ActorData* da } initRevivalGameDataFlagAndMiscFlags(data, false); } +#endif act::BaseProc* Object::tryGetProc(bool force) { auto* bpm = act::BaseProcMgr::instance(); @@ -403,7 +405,7 @@ void Object::setRevivalFlagValue(bool value) { gdt::Manager::instance()->setBool(value, mRevivalGameDataFlagHash); } -// NON_MATCHING +#ifdef NON_MATCHING bool Object::x_18() const { act::InfoData::InvalidLifeConditions info; const char* s; @@ -419,6 +421,7 @@ bool Object::x_18() const { sead::Vector3f temp = mTranslate; return !id->sub_7100D30DF8(info, temp); } +#endif bool Object::setupTargetLinks(Object* src, ObjectLink* link, sead::Heap* heap) { if (mNumLinksPointingToMe == 0) @@ -454,7 +457,7 @@ bool Object::checkTraverseFlags() const { return mFlags0.isOn(Flag0::_500400); } -// NON_MATCHING +#ifdef NON_MATCHING bool Object::x_20() const { if (getActorData().mFlags.isOffBit(ActorData::Flag::RevivalEnable)) return false; @@ -467,6 +470,7 @@ bool Object::x_20() const { } return false; } +#endif void Object::onBaseProcCreated(act::BaseProc* actor) { if (actor != nullptr) { @@ -543,7 +547,8 @@ sead::Vector3f Object::getRotate() const { return result; } -// NON_MATCHING: Vec3f copy incorrect +// Vec3f copy incorrect +#ifdef NON_MATCHING void Object::getTraversePosAndLoadDistance(sead::Vector3f* traverse_pos, f32* load_dist) const { if (mFlags.isOn(Flag::HasTraversePos)) mMubinIter.tryGetFloatArrayByKey(&traverse_pos->x, "TraversePos"); @@ -551,6 +556,7 @@ void Object::getTraversePosAndLoadDistance(sead::Vector3f* traverse_pos, f32* lo *traverse_pos = mTranslate; *load_dist = getLoadDistance(false); } +#endif void Object::getUniqueName(const char** out) const { if (mFlags.isOff(Flag::HasUniqueName) || !mMubinIter.tryGetParamStringByKey(out, "UniqueName")) diff --git a/src/KingSystem/Map/mapObjectLink.cpp b/src/KingSystem/Map/mapObjectLink.cpp index 700ab069..aff66c1c 100644 --- a/src/KingSystem/Map/mapObjectLink.cpp +++ b/src/KingSystem/Map/mapObjectLink.cpp @@ -185,7 +185,7 @@ void ObjectLinkData::setGenGroup(GenGroup* group) { mGenGroup = group; } -// NON_MATCHING +#ifdef NON_MATCHING bool ObjectLinkArray::checkLink(MapLinkDefType t, bool b) { bool x_exists; ObjectLink* link = nullptr; @@ -216,6 +216,7 @@ done: acc.acquire(nullptr); return acc.checkLinkTagActivated(b, x_exists); } +#endif ObjectLink* ObjectLinkArray::findLinkWithType(MapLinkDefType type) { return findLinkWithType_0(type); diff --git a/src/KingSystem/Map/mapPlacementMgr.cpp b/src/KingSystem/Map/mapPlacementMgr.cpp index 931e6531..3ca5b27c 100644 --- a/src/KingSystem/Map/mapPlacementMgr.cpp +++ b/src/KingSystem/Map/mapPlacementMgr.cpp @@ -28,7 +28,7 @@ void PlacementMgr::releaseTree() { mPlacementTree = nullptr; } -// NON_MATCHING +#ifdef NON_MATCHING void PlacementMgr::x_3() { auto ac = act::ActorCreator::instance(); const auto loc = sead::makeScopedLock(ac->getCS()); @@ -41,12 +41,13 @@ void PlacementMgr::x_3() { } } } +#endif void PlacementMgr::reset7F0() { _7f0 = 0; } -// NON_MATCHING +#ifdef NON_MATCHING void PlacementMgr::initClusteredRenderer() { if (mThread != nullptr && mClusteredRenderer == nullptr) return; @@ -68,6 +69,7 @@ void PlacementMgr::initClusteredRenderer() { mClusteredRenderer->startThread(); } } +#endif void PlacementMgr::auto0() { if (mThread == nullptr) diff --git a/src/KingSystem/Physics/System/physDefines.cpp b/src/KingSystem/Physics/System/physDefines.cpp index f6333608..16cb9503 100644 --- a/src/KingSystem/Physics/System/physDefines.cpp +++ b/src/KingSystem/Physics/System/physDefines.cpp @@ -72,7 +72,8 @@ WallCode wallCodeFromText(const sead::SafeString& text) { return 0; } -// NON_MATCHING: duplicated branches? +// duplicated branches? +#ifdef NON_MATCHING MotionType motionTypeFromText(const sead::SafeString& text) { if (text == "Dynamic") return MotionType::Dynamic; @@ -82,5 +83,6 @@ MotionType motionTypeFromText(const sead::SafeString& text) { return MotionType::Keyframed; return MotionType::Unknown; } +#endif } // namespace ksys::phys diff --git a/src/KingSystem/Quest/qstIndicator.cpp b/src/KingSystem/Quest/qstIndicator.cpp index eff0585b..6bfb20a4 100644 --- a/src/KingSystem/Quest/qstIndicator.cpp +++ b/src/KingSystem/Quest/qstIndicator.cpp @@ -12,7 +12,8 @@ Indicator::~Indicator() { finalize(); } -// NON_MATCHING: Confusing control flow +// Confusing control flow +#ifdef NON_MATCHING bool Indicator::init(al::ByamlIter* iter, sead::BufferedSafeString* out_message) { if (!iter->isValid()) { // Step (%s) is invalid data. @@ -142,6 +143,7 @@ bool Indicator::init(al::ByamlIter* iter, sead::BufferedSafeString* out_message) acquireActors(); return true; } +#endif void Indicator::finalize() { actors.freeBuffer(); diff --git a/src/KingSystem/Quest/qstManager.cpp b/src/KingSystem/Quest/qstManager.cpp index a5929790..59b094c7 100644 --- a/src/KingSystem/Quest/qstManager.cpp +++ b/src/KingSystem/Quest/qstManager.cpp @@ -44,7 +44,8 @@ bool Manager::isQuestActor(act::Actor* actor) const { return false; } -// NON_MATCHING: leftovers from a stripped debug function +// leftovers from a stripped debug function +#ifdef NON_MATCHING void Manager::auto0(act::Actor* actor) { if (actor == nullptr) return; @@ -55,6 +56,7 @@ void Manager::auto0(act::Actor* actor) { quest->x_9(actor); } } +#endif bool Manager::auto4(act::Actor* actor) const { auto end = mQuests.end(); @@ -65,7 +67,8 @@ bool Manager::auto4(act::Actor* actor) const { return true; } -// NON_MATCHING: loops are nonmatching +// loops are nonmatching +#ifdef NON_MATCHING bool Manager::sub_7100FD78F8() { s32 size = mQuests.size(); u32 data_count = 0; @@ -90,6 +93,7 @@ bool Manager::sub_7100FD78F8() { } return true; } +#endif bool Manager::sub_7100FD7B30(const sead::SafeString& quest_name, const sead::SafeString& step_name, bool setAocVersionFlag1) { @@ -102,7 +106,8 @@ bool Manager::setQuestStepFromEvent(const sead::SafeString& quest_name, return setQuestStep(quest_name, step_name, true, force_run_telop, setAocVersionFlag1); } -// NON_MATCHING: quest is dereferenced several times +// quest is dereferenced several times +#ifdef NON_MATCHING bool Manager::setQuestStep(const sead::SafeString& quest_name, const sead::SafeString& step_name, bool copy_name, bool force_run_telop, bool setAocVersionFlag1) { u32 hash = sead::HashCRC32::calcStringHash(quest_name.cstr()); @@ -135,5 +140,6 @@ bool Manager::setQuestStep(const sead::SafeString& quest_name, const sead::SafeS quest->mAocVersionFlags |= 1; return true; } +#endif } // namespace ksys::qst diff --git a/src/KingSystem/Quest/qstQuest.cpp b/src/KingSystem/Quest/qstQuest.cpp index 96e48ed4..7f19bdf1 100644 --- a/src/KingSystem/Quest/qstQuest.cpp +++ b/src/KingSystem/Quest/qstQuest.cpp @@ -8,7 +8,7 @@ Quest::~Quest() { mSteps.freeBuffer(); } -// NON_MATCHING +#ifdef NON_MATCHING Quest::Quest(const sead::SafeString& name, sead::Heap* heap) : mName(name), mHeap(heap) { _8 = 0; _c = 0; @@ -16,6 +16,7 @@ Quest::Quest(const sead::SafeString& name, sead::Heap* heap) : mName(name), mHea mNameHash = agl::utl::ParameterBase::calcHash(mName); mAocVersionFlags = 0; } +#endif void Quest::initFlags(gdt::Manager* gdm) { if (gdm == nullptr) diff --git a/src/KingSystem/Quest/qstStep.cpp b/src/KingSystem/Quest/qstStep.cpp index 4eeada65..b20e32f9 100644 --- a/src/KingSystem/Quest/qstStep.cpp +++ b/src/KingSystem/Quest/qstStep.cpp @@ -5,12 +5,14 @@ namespace ksys::qst { -// NON_MATCHING: regalloc +// regalloc +#ifdef NON_MATCHING Step::Step(const u8** iter_data, sead::Heap* heap) : heap(heap) { if (*iter_data != nullptr) { iter = new (heap, std::nothrow_t()) al::ByamlIter(*iter_data); } } +#endif bool Step::sub_7100FDB89C(act::Actor* actor) const { for (int i = 0; i < links.size(); ++i) { diff --git a/src/KingSystem/Resource/Actor/resResourceAIProgram.cpp b/src/KingSystem/Resource/Actor/resResourceAIProgram.cpp index 4900aa20..01dee2ab 100644 --- a/src/KingSystem/Resource/Actor/resResourceAIProgram.cpp +++ b/src/KingSystem/Resource/Actor/resResourceAIProgram.cpp @@ -68,7 +68,8 @@ static bool parseBehaviorIdx(agl::utl::ResParameterObj obj, sead::Buffer& bu return true; } -// NON_MATCHING: the parameter iteration loops in parseAIActionIdx and parseBehaviorIdx +// the parameter iteration loops in parseAIActionIdx and parseBehaviorIdx +#ifdef NON_MATCHING bool AIProgram::parse_(u8* data, size_t, sead::Heap* parent_heap) { if (data) { auto* heap = util::tryCreateDualHeap(parent_heap); @@ -106,8 +107,10 @@ bool AIProgram::parse_(u8* data, size_t, sead::Heap* parent_heap) { mHeap->adjust(); return true; } +#endif -// NON_MATCHING: the parameter iteration loops in parseAIActionIdx and parseBehaviorIdx +// the parameter iteration loops in parseAIActionIdx and parseBehaviorIdx +#ifdef NON_MATCHING bool AIProgram::parseAIActions(sead::Buffer& defs, sead::Heap* heap, agl::utl::ParameterList& target_list, const agl::utl::ResParameterList& root, const char* type_name) { @@ -170,6 +173,7 @@ bool AIProgram::parseAIActions(sead::Buffer& defs, sead::Heap* heap addList(&target_list, type_name); return true; } +#endif bool AIProgram::parseBehaviors(sead::Heap* heap, const agl::utl::ResParameterList& root) { const auto list = agl::utl::getResParameterList(root, "Behavior"); diff --git a/src/KingSystem/Resource/Actor/resResourceAS.cpp b/src/KingSystem/Resource/Actor/resResourceAS.cpp index 2453d491..924915d6 100644 --- a/src/KingSystem/Resource/Actor/resResourceAS.cpp +++ b/src/KingSystem/Resource/Actor/resResourceAS.cpp @@ -18,7 +18,8 @@ AS::~AS() = default; void AS::doCreate_(u8*, u32, sead::Heap*) {} -// NON_MATCHING: SafeString vtable load is reordered +// SafeString vtable load is reordered +#ifdef NON_MATCHING bool AS::parse_(u8* data, size_t size, sead::Heap* parent_heap) { mHeap = util::tryCreateDualHeap(parent_heap); if (!mHeap) @@ -143,6 +144,7 @@ bool AS::parse_(u8* data, size_t size, sead::Heap* parent_heap) { mHeap->adjust(); return true; } +#endif ASResource* AS::getFirstResource() const { if (mElementResources.size() == 0) diff --git a/src/KingSystem/Resource/Actor/resResourceASResource.cpp b/src/KingSystem/Resource/Actor/resResourceASResource.cpp index e6b2be31..8805110c 100644 --- a/src/KingSystem/Resource/Actor/resResourceASResource.cpp +++ b/src/KingSystem/Resource/Actor/resResourceASResource.cpp @@ -216,7 +216,8 @@ ASResourceWithChildren::~ASResourceWithChildren() { mChildren.freeBuffer(); } -// NON_MATCHING: getParameterData (redundant uxtw which leads to localised regalloc diffs) +// getParameterData (redundant uxtw which leads to localised regalloc diffs) +#ifdef NON_MATCHING bool ASResourceWithChildren::doParse(const ASResource::ParseArgs& args) { const auto Children = agl::utl::getResParameterObj(args.list, "Children"); if (!Children) @@ -238,6 +239,7 @@ bool ASResourceWithChildren::doParse(const ASResource::ParseArgs& args) { return true; } +#endif int ASResourceWithChildren::callOnChildren_(MemberFunction fn) { int ret = 0; diff --git a/src/KingSystem/Resource/Actor/resResourceActorLink.cpp b/src/KingSystem/Resource/Actor/resResourceActorLink.cpp index d941d417..7fdef88a 100644 --- a/src/KingSystem/Resource/Actor/resResourceActorLink.cpp +++ b/src/KingSystem/Resource/Actor/resResourceActorLink.cpp @@ -42,6 +42,8 @@ ActorLink::ActorLink() : ParamIO("xml", 0) { addObj(&mUsers.obj, "LinkTarget"); } +// getResParameter (redundant uxtw; i and res increment order) +#ifdef NON_MATCHING bool ActorLink::parse_(u8* data, size_t, sead::Heap* heap) { if (!data) return true; @@ -50,7 +52,7 @@ bool ActorLink::parse_(u8* data, size_t, sead::Heap* heap) { const auto root = archive.getRootList(); const s32 tags_idx = root.searchObjIndex(agl::utl::ParameterBase::calcHash("Tags")); - // NON_MATCHING: getResParameter (redundant uxtw; i and res increment order) + const auto parse_tags = [&] { if (tags_idx == -1) return; @@ -79,6 +81,7 @@ bool ActorLink::parse_(u8* data, size_t, sead::Heap* heap) { applyResParameterArchive(agl::utl::ResParameterArchive{data}); return true; } +#endif void ActorLink::finalize_() { if (!mTags.isBufferReady()) @@ -91,10 +94,12 @@ void ActorLink::finalize_() { mTags.freeBuffer(); } -// NON_MATCHING: operands are swapped for an equality comparison in binarySearch +// operands are swapped for an equality comparison in binarySearch +#ifdef NON_MATCHING bool ActorLink::hasTag(const char* tag_name) const { return mTags.size() >= 1 && mTags.binarySearch(sead::HashCRC32::calcStringHash(tag_name)) != -1; } +#endif bool ActorLink::hasTag(u32 tag) const { return mTags.size() >= 1 && mTags.binarySearch(tag) != -1; diff --git a/src/KingSystem/Resource/Actor/resResourceBoneControl.cpp b/src/KingSystem/Resource/Actor/resResourceBoneControl.cpp index 1c4fe869..f9d7356b 100644 --- a/src/KingSystem/Resource/Actor/resResourceBoneControl.cpp +++ b/src/KingSystem/Resource/Actor/resResourceBoneControl.cpp @@ -16,7 +16,8 @@ BoneControl::~BoneControl() { void BoneControl::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {} -// NON_MATCHING: mFootIkController.isInvalidFt (???) +// mFootIkController.isInvalidFt (???) +#ifdef NON_MATCHING bool BoneControl::parse_(u8* data, size_t size, sead::Heap* heap) { if (!data) return true; @@ -225,6 +226,7 @@ bool BoneControl::parse_(u8* data, size_t size, sead::Heap* heap) { applyResParameterArchive(agl::utl::ResParameterArchive{data}); return true; } +#endif const BoneControl::BoneGroup* BoneControl::getBoneGroup(const sead::SafeString& name) const { const auto idx = mBoneGroups.binarySearch( diff --git a/src/KingSystem/Resource/Actor/resResourceLifeCondition.cpp b/src/KingSystem/Resource/Actor/resResourceLifeCondition.cpp index 84edd261..21f4675c 100644 --- a/src/KingSystem/Resource/Actor/resResourceLifeCondition.cpp +++ b/src/KingSystem/Resource/Actor/resResourceLifeCondition.cpp @@ -2,7 +2,8 @@ namespace ksys::res { -// NON_MATCHING: two instructions swapped +// two instructions swapped +#ifdef NON_MATCHING bool LifeCondition::parse_(u8* data, size_t, sead::Heap* heap) { if (!data) return true; @@ -55,6 +56,7 @@ bool LifeCondition::parse_(u8* data, size_t, sead::Heap* heap) { return true; } +#endif void LifeCondition::parseArray(const agl::utl::ResParameterObj* data, agl::utl::IParameterObj* obj, sead::Buffer>* buffer, diff --git a/src/KingSystem/Resource/Actor/resResourceModelList.cpp b/src/KingSystem/Resource/Actor/resResourceModelList.cpp index 18b9c0e8..a76c9931 100644 --- a/src/KingSystem/Resource/Actor/resResourceModelList.cpp +++ b/src/KingSystem/Resource/Actor/resResourceModelList.cpp @@ -36,7 +36,8 @@ ModelList::~ModelList() { void ModelList::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {} -// NON_MATCHING: reorderings +// reorderings +#ifdef NON_MATCHING bool ModelList::parse_(u8* data, size_t size, sead::Heap* heap) { agl::utl::ResParameterArchive archive{data}; const auto root = archive.getRootList(); @@ -103,6 +104,7 @@ bool ModelList::parse_(u8* data, size_t size, sead::Heap* heap) { return true; } +#endif bool ModelList::parseModelData(const agl::utl::ResParameterList& res, sead::Heap* heap) { if (!mModelData.tryAllocBuffer(res.getResParameterListNum() != 0, heap)) @@ -310,7 +312,8 @@ act::InfoData::Locator::Type ModelList::getLocatorTypeFromStr(const sead::SafeSt return act::InfoData::Locator::Type::Invalid; } -// NON_MATCHING: weird unrolling and Vector3f store (str should be a stp) +// weird unrolling and Vector3f store (str should be a stp) +#ifdef NON_MATCHING bool ModelList::getLocatorInfo(act::InfoData::Locator* info, act::InfoData::Locator::Type type) const { agl::utl::ResParameterArchive archive{mRawData}; @@ -335,6 +338,7 @@ bool ModelList::getLocatorInfo(act::InfoData::Locator* info, return false; } +#endif bool ModelList::isParticalEnable(int anm_target_idx) const { return mAnmTargets[anm_target_idx].is_partical_enable.ref(); diff --git a/src/KingSystem/Resource/Actor/resResourceRecipe.cpp b/src/KingSystem/Resource/Actor/resResourceRecipe.cpp index c2921e62..edebe53b 100644 --- a/src/KingSystem/Resource/Actor/resResourceRecipe.cpp +++ b/src/KingSystem/Resource/Actor/resResourceRecipe.cpp @@ -2,7 +2,8 @@ namespace ksys::res { -// NON_MATCHING: first line (see also Drop::parse_) +// first line (see also Drop::parse_) +#ifdef NON_MATCHING bool Recipe::parse_(u8* data, size_t, sead::Heap* heap) { mTableNum.init(0, "TableNum", "テーブルの数", &mObj); addObj(&mObj, "Header"); @@ -50,6 +51,7 @@ bool Recipe::parse_(u8* data, size_t, sead::Heap* heap) { applyResParameterArchive(agl::utl::ResParameterArchive{data}); return true; } +#endif void Recipe::parseTable_(const s32& table_idx) { const s32 num = mTables[table_idx].column_num.ref(); diff --git a/src/KingSystem/Resource/resHandle.cpp b/src/KingSystem/Resource/resHandle.cpp index e47cb65e..1d101119 100644 --- a/src/KingSystem/Resource/resHandle.cpp +++ b/src/KingSystem/Resource/resHandle.cpp @@ -275,7 +275,8 @@ bool Handle::hasParsedResource() const { return mFlags.isOn(Flag::Parsed); } -// NON_MATCHING: switch +// switch +#ifdef NON_MATCHING void Handle::updateResourceMgrFlag_() { sead::FixedSafeString<128> path("***"); if (mUnit) @@ -322,6 +323,7 @@ void Handle::updateResourceMgrFlag_() { (heap->getName().startsWith("Sound") || heap->getName().startsWith("Audio")) ? 0 : 1; res::ResourceMgrTask::instance()->setFlag2000Or5000(type); } +#endif void Handle::updateStatusAndUnload_() { auto* unit = mUnit; diff --git a/src/KingSystem/Resource/resInfoContainer.cpp b/src/KingSystem/Resource/resInfoContainer.cpp index 14795e56..492a59cd 100644 --- a/src/KingSystem/Resource/resInfoContainer.cpp +++ b/src/KingSystem/Resource/resInfoContainer.cpp @@ -11,7 +11,8 @@ ResourceInfoContainer::ResourceInfoContainer() = default; ResourceInfoContainer::~ResourceInfoContainer() = default; -// NON_MATCHING: LoadRequest field write order +// LoadRequest field write order +#ifdef NON_MATCHING bool ResourceInfoContainer::loadResourceSizeTable() { const auto load_res = [&] { LoadRequest req; @@ -78,8 +79,10 @@ bool ResourceInfoContainer::loadResourceSizeTable() { stubbedLogFunction(); return true; } +#endif -// NON_MATCHING: missing mStringEntries(string_entry_idx).res_size > 0 check +// missing mStringEntries(string_entry_idx).res_size > 0 check +#ifdef NON_MATCHING u32 ResourceInfoContainer::getResourceSize(const sead::SafeString& name) const { const u32 name_hash = sead::HashCRC32::calcStringHash(name); @@ -94,6 +97,7 @@ u32 ResourceInfoContainer::getResourceSize(const sead::SafeString& name) const { return 0; } +#endif namespace { [[gnu::noinline]] bool stringLessThan(const sead::SafeString& a, const sead::SafeString& b) { diff --git a/src/KingSystem/Resource/resResourceGameData.cpp b/src/KingSystem/Resource/resResourceGameData.cpp index cc315128..f080df8a 100644 --- a/src/KingSystem/Resource/resResourceGameData.cpp +++ b/src/KingSystem/Resource/resResourceGameData.cpp @@ -163,7 +163,7 @@ KSYS_ALWAYS_INLINE inline bool tryGetVector(const al::ByamlIter& value_iter, T* } } // namespace -// NON_MATCHING: +#ifdef NON_MATCHING // * stack layout and reordering (possibly caused by the stack differences). // * In init_string_array_flag_config, some calls to memcpy (for string copies) are replaced // with memset and calcLength() is optimized out. @@ -404,6 +404,7 @@ void GameData::doCreate_(u8* data, u32, sead::Heap*) { gdt::FlagType::Vector4fArray, init_vector_array_flag_config, init_vector_array_child_flag_config); } +#endif void GameData::loadDebugData(gdt::FlagDebugData* data, const al::ByamlIter& iter) { if (!data) diff --git a/src/KingSystem/Resource/resResourceGameSaveData.cpp b/src/KingSystem/Resource/resResourceGameSaveData.cpp index b832fb27..6ab46249 100644 --- a/src/KingSystem/Resource/resResourceGameSaveData.cpp +++ b/src/KingSystem/Resource/resResourceGameSaveData.cpp @@ -44,8 +44,9 @@ s32 GameSaveData::File::findFlagIndex(u32 flag_name_hash) const { return -1; } -// NON_MATCHING: cNullChar is loaded too late (which throws off a lot of things) and Clang is +// cNullChar is loaded too late (which throws off a lot of things) and Clang is // using a different register to access file->info +#ifdef NON_MATCHING void GameSaveData::doCreate_(u8* buffer, u32, sead::Heap*) { auto* heap = gdt::Manager::instance()->getSaveAreaHeap(); al::ByamlIter root_iter{buffer}; @@ -113,6 +114,7 @@ void GameSaveData::doCreate_(u8* buffer, u32, sead::Heap*) { mFiles.pushBack(file); } +#endif void GameSaveData::finalize() { if (mSaveInfo) diff --git a/src/KingSystem/Resource/resResourceMgrTask.cpp b/src/KingSystem/Resource/resResourceMgrTask.cpp index e9d0e75e..4497d4f4 100644 --- a/src/KingSystem/Resource/resResourceMgrTask.cpp +++ b/src/KingSystem/Resource/resResourceMgrTask.cpp @@ -478,7 +478,8 @@ void ResourceMgrTask::updateResourceArenasFlag8() { mArenaForResourceL.updateFlag8(false); } -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING sead::Heap* ResourceMgrTask::makeHeapForUnit(const MakeHeapArg& arg) { const auto heap_size = arg.heap_size; const auto path = arg.path; @@ -507,6 +508,7 @@ sead::Heap* ResourceMgrTask::makeHeapForUnit(const MakeHeapArg& arg) { *arg.out_arena2 = arena; return heap; } +#endif ResourceUnit* ResourceMgrTask::clearCachesAndGetUnit(const GetUnitArg& arg) { auto* unit = mUnitPool.tryAlloc(); @@ -627,7 +629,8 @@ bool ResourceMgrTask::getUncompressedSize(u32* size, const sead::SafeString& pat return true; } -// NON_MATCHING: reordering +// reordering +#ifdef NON_MATCHING void ResourceMgrTask::setCompactionStopped(bool stopped) { u32 old_counter; if (stopped) @@ -639,6 +642,7 @@ void ResourceMgrTask::setCompactionStopped(bool stopped) { if (mCompactionCounter == 0 || old_counter == 0) stubbedLogFunction(); } +#endif bool ResourceMgrTask::isCompactionStopped() const { return mCompactionCounter == 0; diff --git a/src/KingSystem/Resource/resUnit.cpp b/src/KingSystem/Resource/resUnit.cpp index ee252d84..ff458e36 100644 --- a/src/KingSystem/Resource/resUnit.cpp +++ b/src/KingSystem/Resource/resUnit.cpp @@ -146,12 +146,14 @@ static const ResourceUnit::Status sUnitStatusTransitionTable[] = { ResourceUnit::Status::_14, ResourceUnit::Status::_14, }; -// NON_MATCHING: ldr + sxtw -> ldrsw +// ldr + sxtw -> ldrsw +#ifdef NON_MATCHING void ResourceUnit::updateStatus() { const s32 idx = mStatus; if (Status::_2 <= idx && idx <= Status::_6) mStatus = sUnitStatusTransitionTable[idx]; } +#endif bool ResourceUnit::isTask1NotQueued() const { return mTask1.getStatus() == util::Task::Status::RemovedFromQueue; @@ -184,7 +186,8 @@ bool ResourceUnit::isStatus9_12_15() const { return mStatus == Status::_9 || mStatus == Status::_12 || mStatus == Status::_15; } -// NON_MATCHING: branching for the second if +// branching for the second if +#ifdef NON_MATCHING bool ResourceUnit::isParseOk() const { auto* ksys_res = sead::DynamicCast(mResource); @@ -201,6 +204,7 @@ bool ResourceUnit::isParseOk() const { return false; } +#endif bool ResourceUnit::isStatusFlag8000Set() const { return mStatusFlags.isOn(StatusFlag::NeedToIncrementRefCount); diff --git a/src/KingSystem/System/OverlayArena.cpp b/src/KingSystem/System/OverlayArena.cpp index 62ae8a8c..26a999ea 100644 --- a/src/KingSystem/System/OverlayArena.cpp +++ b/src/KingSystem/System/OverlayArena.cpp @@ -16,7 +16,8 @@ OverlayArena::~OverlayArena() { destroy(); } -// NON_MATCHING: branching at the end (csel instead of a branch) +// branching at the end (csel instead of a branch) +#ifdef NON_MATCHING bool OverlayArena::init(const OverlayArena::InitArg& arg) { if (!arg.heap) { res::stubbedLogFunction(); @@ -59,6 +60,7 @@ bool OverlayArena::init(const OverlayArena::InitArg& arg) { return true; } +#endif void OverlayArena::stubbed() {} @@ -126,7 +128,8 @@ bool OverlayArena::checkIsOom() const { // FIXME: figure out what sead function this is bool seadCheckPointer(void* ptr); -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING util::DualHeap* OverlayArena::makeDualHeap(u32 size, const sead::SafeString& name, sead::Heap::HeapDirection direction, res::ResourceUnit* unit, bool) { @@ -157,6 +160,7 @@ util::DualHeap* OverlayArena::makeDualHeap(u32 size, const sead::SafeString& nam mFlags.set(Flag::_4); return heap; } +#endif void OverlayArena::addSize(s32 size) { mSize += size; diff --git a/src/KingSystem/System/OverlayArenaSystem.cpp b/src/KingSystem/System/OverlayArenaSystem.cpp index 1731b491..2dede4a9 100644 --- a/src/KingSystem/System/OverlayArenaSystem.cpp +++ b/src/KingSystem/System/OverlayArenaSystem.cpp @@ -63,7 +63,8 @@ void OverlayArenaSystem::destroyHeaps() { mFlags.set(Flag::_2); } -// NON_MATCHING: reordering for TaskThread::InitArg +// reordering for TaskThread::InitArg +#ifdef NON_MATCHING bool OverlayArenaSystem::init(const InitArg& arg, sead::Heap* heap) { mSystemPauseMgr = arg.system_pause_mgr; @@ -125,6 +126,7 @@ bool OverlayArenaSystem::init(const InitArg& arg, sead::Heap* heap) { return true; } +#endif void OverlayArenaSystem::getSzsDecompressor(sead::SZSDecompressor** decompressor) const { if (decompressor) diff --git a/src/KingSystem/System/VFRValue.cpp b/src/KingSystem/System/VFRValue.cpp index 471f18a2..68601898 100644 --- a/src/KingSystem/System/VFRValue.cpp +++ b/src/KingSystem/System/VFRValue.cpp @@ -57,10 +57,12 @@ VFRVec3f::VFRVec3f() : value{0, 0, 0}, prev_value{0, 0, 0}, mean{0, 0, 0} {} VFRVec3f::VFRVec3f(const sead::Vector3f& value) : value{value}, prev_value{value}, mean{value} {} -// NON_MATCHING: float regalloc +// float regalloc +#ifdef NON_MATCHING void VFRVec3f::updateStats() { updateStatsImpl(value, &prev_value, &mean); } +#endif void VFRVec3f::operator*=(f32 scalar) { VFR::multiply(&value, scalar); diff --git a/src/KingSystem/Utils/ParamIO.cpp b/src/KingSystem/Utils/ParamIO.cpp index 1fd9da6e..a5a75fa5 100644 --- a/src/KingSystem/Utils/ParamIO.cpp +++ b/src/KingSystem/Utils/ParamIO.cpp @@ -69,11 +69,13 @@ const char* ParamIO::getString(const agl::utl::ResParameterObj& obj, const char* return param.getData(); } -// NON_MATCHING: how the default_value Vec3f is stored on the stack +// how the default_value Vec3f is stored on the stack +#ifdef NON_MATCHING sead::Vector3f ParamIO::getVec3(const agl::utl::ResParameterObj& obj, const char* key, sead::Vector3f default_value, void*) const { const auto param = agl::utl::getResParameter(obj, key); return param.ptr() ? *param.getData() : default_value; } +#endif } // namespace ksys diff --git a/src/KingSystem/Utils/Thread/ManagedTask.cpp b/src/KingSystem/Utils/Thread/ManagedTask.cpp index 8a0f3dfd..7018ed37 100644 --- a/src/KingSystem/Utils/Thread/ManagedTask.cpp +++ b/src/KingSystem/Utils/Thread/ManagedTask.cpp @@ -83,7 +83,8 @@ void ManagedTask::attachHandle(ManagedTaskHandle* handle, TaskQueueBase* queue) mHandle = handle; } -// NON_MATCHING: switch +// switch +#ifdef NON_MATCHING void ManagedTask::detachHandle() { TaskQueueLock lock; lock.lock(mQueue); @@ -102,5 +103,6 @@ void ManagedTask::detachHandle() { } } } +#endif } // namespace ksys::util diff --git a/src/KingSystem/Utils/Thread/MessageDispatcher.cpp b/src/KingSystem/Utils/Thread/MessageDispatcher.cpp index c6c2baad..236fdd2e 100644 --- a/src/KingSystem/Utils/Thread/MessageDispatcher.cpp +++ b/src/KingSystem/Utils/Thread/MessageDispatcher.cpp @@ -239,7 +239,8 @@ bool MessageDispatcher::Queues::sendMessageOnProcessingThread(const MesTransceiv return mMainQueue.addMessage(message); } -// NON_MATCHING: branching: deduplicated Message destructor call +// branching: deduplicated Message destructor call +#ifdef NON_MATCHING bool MessageDispatcher::sendMessageOnProcessingThread(const MesTransceiverId& src, const MesTransceiverId& dest, const MessageType& type, void* user_data, @@ -248,6 +249,7 @@ bool MessageDispatcher::sendMessageOnProcessingThread(const MesTransceiverId& sr return false; return mQueues->sendMessageOnProcessingThread(src, dest, type, user_data, ack); } +#endif struct AddMessageContext : IMessageBrokerRegister::IForEachContext { AddMessageContext(MessageQueue* queue, Message* message) : queue(queue), message(message) {} @@ -331,7 +333,8 @@ void MessageDispatcher::Queues::process() { mIsProcessing = false; } -// NON_MATCHING: regalloc +// regalloc +#ifdef NON_MATCHING void MessageDispatcher::update() { mUpdateEndEvent.resetSignal(); mProcessingThread = sead::ThreadMgr::instance()->getCurrentThread(); @@ -342,5 +345,6 @@ void MessageDispatcher::update() { mProcessingThread = nullptr; mUpdateEndEvent.setSignal(); } +#endif } // namespace ksys diff --git a/src/KingSystem/Utils/Thread/Task.cpp b/src/KingSystem/Utils/Thread/Task.cpp index e2ba464f..71cf18f5 100644 --- a/src/KingSystem/Utils/Thread/Task.cpp +++ b/src/KingSystem/Utils/Thread/Task.cpp @@ -34,7 +34,8 @@ void Task::deleteDelegate_() { } } -// NON_MATCHING: mDelegate2 = nullptr store +// mDelegate2 = nullptr store +#ifdef NON_MATCHING void Task::finalize_() { if (mStatus == Status::Finalized) return; @@ -47,6 +48,7 @@ void Task::finalize_() { mRemoveCallback = nullptr; mStatus = Status::Finalized; } +#endif bool Task::setDelegate(const TaskDelegateSetter& setter) { mDelegate = setter.getDelegate(); @@ -56,7 +58,8 @@ bool Task::setDelegate(const TaskDelegateSetter& setter) { return onSetDelegate_(setter); } -// NON_MATCHING: branching +// branching +#ifdef NON_MATCHING bool Task::submitRequest(TaskRequest& request) { // Processing this request is impossible if there is no thread *and* no queue! if (request.mThread == nullptr && request.mQueue == nullptr) @@ -114,6 +117,7 @@ bool Task::submitRequest(TaskRequest& request) { } return push_ok || b; } +#endif bool Task::canSubmitRequest() const { const bool run_finished_on_current_thread = diff --git a/src/KingSystem/Utils/Thread/TaskMgr.cpp b/src/KingSystem/Utils/Thread/TaskMgr.cpp index b5eec563..f8aa6f2c 100644 --- a/src/KingSystem/Utils/Thread/TaskMgr.cpp +++ b/src/KingSystem/Utils/Thread/TaskMgr.cpp @@ -80,7 +80,8 @@ void TaskMgr::submitRequest(TaskMgrRequest& request) { request.task = nullptr; } -// NON_MATCHING: reorderings +// reorderings +#ifdef NON_MATCHING bool TaskMgr::fetchIdleTaskForRequest_(TaskMgrRequest& request, bool retry_until_success) { if (!hasTasks()) return false; @@ -108,6 +109,7 @@ bool TaskMgr::fetchIdleTaskForRequest_(TaskMgrRequest& request, bool retry_until request.task = task; return true; } +#endif void TaskMgr::freeTask(ManagedTask* task) { auto lock = sead::makeScopedLock(mCS2); @@ -155,7 +157,8 @@ bool TaskMgr::trySubmitRequest(TaskMgrRequest& request) { return ok; } -// NON_MATCHING: the factory invoke function pointer is loaded earlier in the original code +// the factory invoke function pointer is loaded earlier in the original code +#ifdef NON_MATCHING void TaskMgr::init(s32 num_tasks, sead::Heap* heap, ManagedTaskFactory& factory) { if (!heap->isFreeable()) mFlags.reset(Flag::HeapIsFreeable); @@ -177,6 +180,7 @@ void TaskMgr::init(s32 num_tasks, sead::Heap* heap, ManagedTaskFactory& factory) factory(&mTask); } +#endif bool TaskMgr::hasTasks() const { return mTasks.size() > 0; diff --git a/src/KingSystem/Utils/Thread/TaskQueueBase.cpp b/src/KingSystem/Utils/Thread/TaskQueueBase.cpp index 49e91f24..8c220ebb 100644 --- a/src/KingSystem/Utils/Thread/TaskQueueBase.cpp +++ b/src/KingSystem/Utils/Thread/TaskQueueBase.cpp @@ -234,7 +234,8 @@ void TaskQueueBase::blockTasks(u8 id) { mLanes[id].blocked = true; } -// NON_MATCHING: the while (!areAllThreadsPaused()) loop generates weird code in the original +// the while (!areAllThreadsPaused()) loop generates weird code in the original +#ifdef NON_MATCHING void TaskQueueBase::blockTasksAndReloadThreads(u8 id) { blockTasks(id); @@ -257,6 +258,7 @@ void TaskQueueBase::blockTasksAndReloadThreads(u8 id) { thread.resume(); } } +#endif void TaskQueueBase::unblockTasks(u8 id) { if (mLanes[id].blocked) { @@ -407,7 +409,8 @@ void TaskQueueBase::removeTask(Task* task, bool b) { unlock(); } -// NON_MATCHING: regalloc inside the task lambda + reorderings for the loop counters. +// regalloc inside the task lambda + reorderings for the loop counters. +#ifdef NON_MATCHING void TaskQueueBase::fetchTask(Task** out_task) { lock(); @@ -481,5 +484,6 @@ void TaskQueueBase::fetchTask(Task** out_task) { unlock(); } +#endif } // namespace ksys::util diff --git a/src/KingSystem/Utils/Thread/TaskThread.cpp b/src/KingSystem/Utils/Thread/TaskThread.cpp index 27dcd4e9..be24952b 100644 --- a/src/KingSystem/Utils/Thread/TaskThread.cpp +++ b/src/KingSystem/Utils/Thread/TaskThread.cpp @@ -136,8 +136,9 @@ bool TaskThread::isLookingForTask() const { return mFlags.isOn(Flag::IsLookingForTask); } -// NON_MATCHING: branching for `if (mTaskQueue->getNumActiveTasks() == 0)`: +// branching for `if (mTaskQueue->getNumActiveTasks() == 0)`: // Clang got rid of the branch and merged the two mFlags writes +#ifdef NON_MATCHING void TaskThread::calc_(sead::MessageQueue::Element msg) { if (mFlags.isOn(Flag::Paused)) { if (msg != cMessage_Resume) @@ -239,6 +240,7 @@ void TaskThread::calc_(sead::MessageQueue::Element msg) { mFlags.reset(Flag::IsActive); mFlags.reset(Flag::IsLookingForTask); } +#endif bool TaskThread::receivedPauseMsg() const { return mMessageQueue.peek(sead::MessageQueue::BlockType::NonBlocking) == cMessage_Pause; diff --git a/src/KingSystem/World/worldManager.cpp b/src/KingSystem/World/worldManager.cpp index 1f798fc2..0dc18cef 100644 --- a/src/KingSystem/World/worldManager.cpp +++ b/src/KingSystem/World/worldManager.cpp @@ -321,8 +321,10 @@ void Manager::unload() { getWeatherMgr()->onUnload(); } -// NON_MATCHING: stores in a different order (handwritten assignments?) but should be equivalent +// stores in a different order (handwritten assignments?) but should be equivalent +#ifdef NON_MATCHING Manager::Manager() = default; +#endif static Job* makeJob(JobType type, sead::Heap* heap) { switch (type) { @@ -877,7 +879,8 @@ void Manager::setTemperatureNight(float temp) { mTempDirectNightTimer = 4; } -// NON_MATCHING: mPlayerPos.y gets loaded into s8 instead of w20 +// mPlayerPos.y gets loaded into s8 instead of w20 +#ifdef NON_MATCHING void Manager::setIgnitedLevel(int level, float radius, sead::Vector3f center) { mIgnitedTimer = 4; mIgnitedRadius = radius; @@ -890,5 +893,6 @@ void Manager::setIgnitedLevel(int level, float radius, sead::Vector3f center) { mIgnitedRadius = 7.0; } } +#endif } // namespace ksys::world diff --git a/src/KingSystem/World/worldShootingStarMgr.cpp b/src/KingSystem/World/worldShootingStarMgr.cpp index b1d0066c..277d2687 100644 --- a/src/KingSystem/World/worldShootingStarMgr.cpp +++ b/src/KingSystem/World/worldShootingStarMgr.cpp @@ -30,7 +30,7 @@ void ShootingStarMgr::init_(sead::Heap* heap) { initSchedule(); } -// NON_MATCHING +#ifdef NON_MATCHING void ShootingStarMgr::initSchedule() { if (sHours.start >= sHours.end) { sead::FixedObjArray validHours; @@ -54,6 +54,7 @@ void ShootingStarMgr::initSchedule() { mFallMinute = sead::GlobalRandom::instance()->getU32(59); mInitialised = true; } +#endif void ShootingStarMgr::calc_() { if (Manager::instance() != nullptr) {