Add #ifdef declarations for NON_MATCHING code

This commit is contained in:
AlexApps99 2021-07-26 21:58:51 +12:00
parent 88bcc9eec1
commit 42807160cf
No known key found for this signature in database
GPG Key ID: 7CDEAB71F74AA68D
55 changed files with 274 additions and 95 deletions

View File

@ -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)

View File

@ -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`.

View File

@ -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");

View File

@ -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

View File

@ -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())

View File

@ -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;

View File

@ -1052,7 +1052,8 @@ void PauseMenuDataMgr::autoEquipLastAddedItem() {
}
}
// NON_MATCHING: branching
// branching
#ifdef NON_MATCHING
const sead::SafeString& PauseMenuDataMgr::autoEquip(PouchItem* item,
const sead::OffsetList<PouchItem>& 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<PouchItem>& 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) {

View File

@ -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

View File

@ -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<res::ASSetting>(mHandle.getResource());
if (!res)
@ -27,5 +28,6 @@ res::ASParamParser* ASSetting::getBoneParams(const sead::SafeString& key) const
}
return nullptr;
}
#endif
} // namespace ksys::act

View File

@ -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);

View File

@ -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<ParamIO*>(res)->getPath()
// different address calculation for static_cast<ParamIO*>(res)->getPath()
#ifdef NON_MATCHING
template <typename T>
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;

View File

@ -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) {

View File

@ -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 {

View File

@ -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))

View File

@ -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<BaseProcJobLink>& links) {

View File

@ -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<BaseProc*>& callback, ProcFilters filters) {
const auto lock = sead::makeScopedLock(mProcMapCS);
@ -542,6 +545,7 @@ void BaseProcMgr::forEachProc(sead::IDelegate1<BaseProc*>& callback, ProcFilters
mProcMap.forEach(sead::Delegate1<ProcForEachContext, util::StrTreeMapNode*>(
&context, &ProcForEachContext::forEach));
}
#endif
void BaseProcMgr::forEachProc(const sead::SafeString& proc_name,
sead::IDelegate1<BaseProc*>& 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]) {

View File

@ -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;

View File

@ -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;

View File

@ -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<evfl::TimelineObj> 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];

View File

@ -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) {

View File

@ -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

View File

@ -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"))

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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)

View File

@ -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) {

View File

@ -68,7 +68,8 @@ static bool parseBehaviorIdx(agl::utl::ResParameterObj obj, sead::Buffer<u8>& 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<AIActionDef>& 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<AIActionDef>& 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");

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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(

View File

@ -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<agl::utl::Parameter<sead::SafeString>>* buffer,

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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) {

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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<res::Resource>(mResource);
@ -201,6 +204,7 @@ bool ResourceUnit::isParseOk() const {
return false;
}
#endif
bool ResourceUnit::isStatusFlag8000Set() const {
return mStatusFlags.isOn(StatusFlag::NeedToIncrementRefCount);

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -69,11 +69,13 @@ const char* ParamIO::getString(const agl::utl::ResParameterObj& obj, const char*
return param.getData<const char>();
}
// 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<sead::Vector3f>() : default_value;
}
#endif
} // namespace ksys

View File

@ -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

View File

@ -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

View File

@ -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 =

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<u32, 24> validHours;
@ -54,6 +54,7 @@ void ShootingStarMgr::initSchedule() {
mFallMinute = sead::GlobalRandom::instance()->getU32(59);
mInitialised = true;
}
#endif
void ShootingStarMgr::calc_() {
if (Manager::instance() != nullptr) {