diff --git a/.clang-format b/.clang-format index 641238e2..f2c66aee 100644 --- a/.clang-format +++ b/.clang-format @@ -57,6 +57,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left ReflowComments: true +RemoveBracesLLVM: true SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true diff --git a/lib/al/include/Library/Execute/ExecuteTablesImpl.h b/lib/al/include/Library/Execute/ExecuteTablesImpl.h index 50824d68..b91c4e38 100644 --- a/lib/al/include/Library/Execute/ExecuteTablesImpl.h +++ b/lib/al/include/Library/Execute/ExecuteTablesImpl.h @@ -384,11 +384,9 @@ constexpr bool strings_equal(const char* a, const char* b) { } static constexpr s32 getUpdateTableIndex(const char* listName) { - for (s32 i = 0; i < sizeof(updateTableArr) / sizeof(updateTableArr[0]); i++) { - if (strings_equal(updateTableArr[i].mListName, listName)) { + for (s32 i = 0; i < sizeof(updateTableArr) / sizeof(updateTableArr[0]); i++) + if (strings_equal(updateTableArr[i].mListName, listName)) return i; - } - } return 0; } @@ -403,12 +401,10 @@ createUpdateTable(const char* tableName, const char* startListName, const char* } static constexpr s32 getDrawTableIndex(const char* listName, const char* groupName) { - for (s32 i = 0; i < sizeof(drawTableArr) / sizeof(drawTableArr[0]); i++) { + for (s32 i = 0; i < sizeof(drawTableArr) / sizeof(drawTableArr[0]); i++) if (strings_equal(drawTableArr[i].mListName, listName) && - strings_equal(drawTableArr[i].mExecuteGroup, groupName)) { + strings_equal(drawTableArr[i].mExecuteGroup, groupName)) return i; - } - } return 0; } diff --git a/lib/al/include/Library/Rail/Graph.h b/lib/al/include/Library/Rail/Graph.h old mode 100755 new mode 100644 index 9b4c81c7..f2adc696 --- a/lib/al/include/Library/Rail/Graph.h +++ b/lib/al/include/Library/Rail/Graph.h @@ -16,11 +16,9 @@ public: s32 getIndex() const { return mIndex; } void addEdge(Edge* edge) { mEdges.pushBack(edge); } void tryAddEdge(Edge* edge) { - for (s32 i = 0; i < mEdges.size(); i++) { - if (mEdges[i] == edge) { + for (s32 i = 0; i < mEdges.size(); i++) + if (mEdges[i] == edge) return; - } - } addEdge(edge); } diff --git a/lib/al/include/Library/Yaml/ByamlUtil.h b/lib/al/include/Library/Yaml/ByamlUtil.h old mode 100755 new mode 100644 index cc14e525..8d0dce42 --- a/lib/al/include/Library/Yaml/ByamlUtil.h +++ b/lib/al/include/Library/Yaml/ByamlUtil.h @@ -56,17 +56,15 @@ void getByamlIterByIndex(ByamlIter*, const ByamlIter&, s32); template bool isTypeByIndex(const ByamlIter& rIter, s32 index) { ByamlData data; - if (rIter.getByamlDataByIndex(&data, index)) { + if (rIter.getByamlDataByIndex(&data, index)) return data.getType() == T; - } return false; } template bool isTypeByKey(const ByamlIter& rIter, const char* key) { ByamlData data; - if (rIter.getByamlDataByKey(&data, key)) { + if (rIter.getByamlDataByKey(&data, key)) return data.getType() == T; - } return false; } bool isTypeBoolByIndex(const ByamlIter&, s32); diff --git a/lib/al/src/Library/Action/ActorActionKeeper.cpp b/lib/al/src/Library/Action/ActorActionKeeper.cpp index bc7d3b50..b0ec2ff4 100644 --- a/lib/al/src/Library/Action/ActorActionKeeper.cpp +++ b/lib/al/src/Library/Action/ActorActionKeeper.cpp @@ -69,9 +69,8 @@ ActorActionKeeper* ActorActionKeeper::tryCreate(LiveActor* actor, const ActorRes } void ActorActionKeeper::init() { - if (mFlagCtrl) { + if (mFlagCtrl) mFlagCtrl->initPost(); - } } bool ActorActionKeeper::startAction(const char* name) { mIsActionRunning = true; diff --git a/lib/al/src/Library/Application/ApplicationMessageReceiver.cpp b/lib/al/src/Library/Application/ApplicationMessageReceiver.cpp index efc60467..6418dd64 100644 --- a/lib/al/src/Library/Application/ApplicationMessageReceiver.cpp +++ b/lib/al/src/Library/Application/ApplicationMessageReceiver.cpp @@ -64,8 +64,7 @@ void ApplicationMessageReceiver::update() { mIsUpdatedPerformanceMode = false; u32 message; - if (nn::oe::TryPopNotificationMessage(&message)) { + if (nn::oe::TryPopNotificationMessage(&message)) procMessage(message); - } } } // namespace al diff --git a/lib/al/src/Library/Area/AreaShape.cpp b/lib/al/src/Library/Area/AreaShape.cpp index 568ad42c..5e17cf7e 100644 --- a/lib/al/src/Library/Area/AreaShape.cpp +++ b/lib/al/src/Library/Area/AreaShape.cpp @@ -84,11 +84,10 @@ bool AreaShape::calcWorldDir(sead::Vector3f* worldDir, const sead::Vector3f& tra } void AreaShape::calcTrans(sead::Vector3f* trans) const { - if (mBaseMtxPtr) { + if (mBaseMtxPtr) mBaseMtxPtr->getTranslation(*trans); - } else { + else trans->e = sead::Vector3f::zero.e; - } } template diff --git a/lib/al/src/Library/Base/HashCodeUtil.cpp b/lib/al/src/Library/Base/HashCodeUtil.cpp index f5e4f038..a6a45e40 100644 --- a/lib/al/src/Library/Base/HashCodeUtil.cpp +++ b/lib/al/src/Library/Base/HashCodeUtil.cpp @@ -6,23 +6,20 @@ namespace al { s32 calcHashCode(const char* str) { - if (str[0] == '\0') { + if (str[0] == '\0') return 0; - } s32 hashCode = 0; - for (s32 i = 0; str[i] != '\0'; i++) { + for (s32 i = 0; str[i] != '\0'; i++) hashCode = (hashCode * 0x1f) + str[i]; - } return hashCode; } s32 calcHashCodeLower(const char* str) { s32 hashCode = 0; - for (s32 i = 0; str[i] != '\0'; i++) { + for (s32 i = 0; str[i] != '\0'; i++) hashCode = (hashCode * 0x1f) + tolower(str[i]); - } return hashCode; } diff --git a/lib/al/src/Library/Base/StringUtil.cpp b/lib/al/src/Library/Base/StringUtil.cpp old mode 100755 new mode 100644 index 89651452..018695dd --- a/lib/al/src/Library/Base/StringUtil.cpp +++ b/lib/al/src/Library/Base/StringUtil.cpp @@ -9,16 +9,14 @@ bool isEqualString(const char16_t* pString_0, const char16_t* pString_1) { while (1) { val = *pString_0; - if (val != *pString_1) { + if (val != *pString_1) break; - } ++pString_1; ++pString_0; - if (!val) { + if (!val) return true; - } } return false; diff --git a/lib/al/src/Library/Bgm/BgmKeeper.cpp b/lib/al/src/Library/Bgm/BgmKeeper.cpp index 59ef0300..a1ccb9ae 100644 --- a/lib/al/src/Library/Bgm/BgmKeeper.cpp +++ b/lib/al/src/Library/Bgm/BgmKeeper.cpp @@ -11,9 +11,8 @@ namespace al { BgmKeeper::BgmKeeper(const AudioSystemInfo* audioInfo, BgmDirector* director, const char* string) : mBgmDirector(director) { - if (string != nullptr) { + if (string != nullptr) mBgmUserInfo = alBgmFunction::tryFindBgmUserInfo(audioInfo->getBgmDataBase(), string); - } } BgmKeeper* BgmKeeper::create(const AudioSystemInfo* audioInfo, BgmDirector* director, @@ -26,9 +25,8 @@ BgmKeeper* BgmKeeper::create(const AudioSystemInfo* audioInfo, BgmDirector* dire void BgmKeeper::update() {} const char* BgmKeeper::getUserName() const { - if (mBgmUserInfo == nullptr) { + if (mBgmUserInfo == nullptr) return nullptr; - } return mBgmUserInfo->mName; } } // namespace al diff --git a/lib/al/src/Library/Controller/InputFunction.cpp b/lib/al/src/Library/Controller/InputFunction.cpp index 8d8165b5..19bc9ac6 100644 --- a/lib/al/src/Library/Controller/InputFunction.cpp +++ b/lib/al/src/Library/Controller/InputFunction.cpp @@ -8,9 +8,8 @@ sead::ControllerBase* getController_(s32 port) { } sead::ControllerBase* getController(s32 port) { - if (port == -1) { + if (port == -1) port = getMainControllerPort(); - } return getController_(port); } diff --git a/lib/al/src/Library/Event/SceneEventFlowMsg.cpp b/lib/al/src/Library/Event/SceneEventFlowMsg.cpp index a1e4e9e8..f7ef0870 100644 --- a/lib/al/src/Library/Event/SceneEventFlowMsg.cpp +++ b/lib/al/src/Library/Event/SceneEventFlowMsg.cpp @@ -6,9 +6,8 @@ namespace al { SceneEventFlowMsg::SceneEventFlowMsg() {} bool SceneEventFlowMsg::isReceiveCommand(const char* cmd) const { - if (mCmd.isEmpty()) { + if (mCmd.isEmpty()) return false; - } return isEqualString(cmd, mCmd.cstr()); } diff --git a/lib/al/src/Library/Execute/ExecuteDirector.cpp b/lib/al/src/Library/Execute/ExecuteDirector.cpp index af1112c9..78a12216 100644 --- a/lib/al/src/Library/Execute/ExecuteDirector.cpp +++ b/lib/al/src/Library/Execute/ExecuteDirector.cpp @@ -39,20 +39,16 @@ void ExecuteDirector::init(const ExecuteSystemInitInfo& initInfo) { } void ExecuteDirector::registerActorUpdate(LiveActor* actor, const char* tableName) { - if (!actor->getExecuteInfo()) { + if (!actor->getExecuteInfo()) actor->initExecuteInfo(new ActorExecuteInfo(mRequestKeeper)); - } - if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { + if (mUpdateTableCount >= 1) + for (s32 i = 0; i < mUpdateTableCount; ++i) mUpdateTables[i]->tryRegisterActor(actor, tableName); - } - } } void ExecuteDirector::registerActorDraw(LiveActor* actor, const char* tableName) { - if (!actor->getExecuteInfo()) { + if (!actor->getExecuteInfo()) actor->initExecuteInfo(new ActorExecuteInfo(mRequestKeeper)); - } if (mDrawTableCount >= 1) { for (s32 i = 0; i < mDrawTableCount; ++i) { mDrawTables[i]->tryRegisterActor(actor, tableName); @@ -62,83 +58,60 @@ void ExecuteDirector::registerActorDraw(LiveActor* actor, const char* tableName) } void ExecuteDirector::registerActorModelDraw(LiveActor* actor, const char* tableName) { - if (!actor->getExecuteInfo()) { + if (!actor->getExecuteInfo()) actor->initExecuteInfo(new ActorExecuteInfo(mRequestKeeper)); - } - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->tryRegisterActorModel(actor, tableName); - } - } } void ExecuteDirector::registerLayoutUpdate(LayoutActor* lyt, const char* tableName) { - if (!lyt->getExecuteInfo()) { + if (!lyt->getExecuteInfo()) lyt->initExecuteInfo(new LayoutExecuteInfo()); - } - if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { + if (mUpdateTableCount >= 1) + for (s32 i = 0; i < mUpdateTableCount; ++i) mUpdateTables[i]->tryRegisterLayout(lyt, tableName); - } - } } void ExecuteDirector::registerLayoutDraw(LayoutActor* lyt, const char* tableName) { - if (!lyt->getExecuteInfo()) { + if (!lyt->getExecuteInfo()) lyt->initExecuteInfo(new LayoutExecuteInfo()); - } - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->tryRegisterLayout(lyt, tableName); - } - } } void ExecuteDirector::registerUser(IUseExecutor* user, const char* tableName) { - if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { + if (mUpdateTableCount >= 1) + for (s32 i = 0; i < mUpdateTableCount; ++i) mUpdateTables[i]->tryRegisterUser(user, tableName); - } - } - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->tryRegisterUser(user, tableName); - } - } } void ExecuteDirector::registerFunctor(const FunctorBase& functor, const char* tableName) { - if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { + if (mUpdateTableCount >= 1) + for (s32 i = 0; i < mUpdateTableCount; ++i) mUpdateTables[i]->tryRegisterFunctor(functor, tableName); - } - } - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->tryRegisterFunctor(functor, tableName); - } - } } void ExecuteDirector::registerFunctorDraw(const FunctorBase& functor, const char* tableName) { - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->tryRegisterFunctor(functor, tableName); - } - } } void ExecuteDirector::createExecutorListTable() { - if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { + if (mUpdateTableCount >= 1) + for (s32 i = 0; i < mUpdateTableCount; ++i) mUpdateTables[i]->createExecutorListTable(); - } - } - if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { + if (mDrawTableCount >= 1) + for (s32 i = 0; i < mDrawTableCount; ++i) mDrawTables[i]->createExecutorListTable(); - } - } } void ExecuteDirector::execute(const char* tableName) const { @@ -188,11 +161,9 @@ void ExecuteDirector::executeList(const char* tableName, const char* listName) c mRequestKeeper->executeRequestActorDrawAllOn(); if (tableName) { if (mUpdateTableCount >= 1) { - for (s32 i = 0; i < mUpdateTableCount; ++i) { - if (isEqualString(tableName, mUpdateTables[i]->getName())) { + for (s32 i = 0; i < mUpdateTableCount; ++i) + if (isEqualString(tableName, mUpdateTables[i]->getName())) mUpdateTables[i]->executeList(listName); - } - } } } else { mUpdateTables[0]->executeList(listName); @@ -230,11 +201,9 @@ void ExecuteDirector::drawList(const char* tableName, const char* listName) cons bool ExecuteDirector::isActiveDraw(const char* tableName) const { if (tableName) { if (mDrawTableCount >= 1) { - for (s32 i = 0; i < mDrawTableCount; ++i) { - if (isEqualString(tableName, mDrawTables[i]->getName())) { + for (s32 i = 0; i < mDrawTableCount; ++i) + if (isEqualString(tableName, mDrawTables[i]->getName())) return mDrawTables[i]->isActive(); - } - } } } else { return mDrawTables[0]->isActive(); diff --git a/lib/al/src/Library/Layout/LayoutPartsActorKeeper.cpp b/lib/al/src/Library/Layout/LayoutPartsActorKeeper.cpp index be355332..e01b9c6f 100644 --- a/lib/al/src/Library/Layout/LayoutPartsActorKeeper.cpp +++ b/lib/al/src/Library/Layout/LayoutPartsActorKeeper.cpp @@ -5,14 +5,12 @@ namespace al { void LayoutPartsActorKeeper::resisterPartsActor(LayoutActor* actor) {} void LayoutPartsActorKeeper::appear() { - for (s32 i = 0; i < mNumActors; i++) { + for (s32 i = 0; i < mNumActors; i++) mPartsActors[i]->appear(); - } } void LayoutPartsActorKeeper::calcAnim(bool recursive) { - for (s32 i = 0; i < mNumActors; i++) { + for (s32 i = 0; i < mNumActors; i++) mPartsActors[i]->calcAnim(recursive); - } } LayoutPartsActorKeeper::LayoutPartsActorKeeper(s32 maxActors) : mMaxActors(maxActors) { mPartsActors = new LayoutActor*[maxActors]; diff --git a/lib/al/src/Library/LiveActor/ActorActionFunction.cpp b/lib/al/src/Library/LiveActor/ActorActionFunction.cpp index b82b0a9d..5cb176a9 100644 --- a/lib/al/src/Library/LiveActor/ActorActionFunction.cpp +++ b/lib/al/src/Library/LiveActor/ActorActionFunction.cpp @@ -24,12 +24,10 @@ bool tryStartAction(LiveActor* actor, const char* actionName) { bool mtsStarted = tryStartMtsAnimIfExist(actor, actionName); bool visStarted = tryStartVisAnimIfExistForAction(actor, actionName); - if (!sklStarted && !mtpStarted && !mclStarted && !mtsStarted && !visStarted) { + if (!sklStarted && !mtpStarted && !mclStarted && !mtsStarted && !visStarted) return false; - } - if (!actor->getActorActionKeeper()) { + if (!actor->getActorActionKeeper()) return true; - } } actor->getActorActionKeeper()->startAction(actionName); return true; diff --git a/lib/al/src/Library/LiveActor/ActorAnimFunction.cpp b/lib/al/src/Library/LiveActor/ActorAnimFunction.cpp index e1d953e7..3672fdd0 100644 --- a/lib/al/src/Library/LiveActor/ActorAnimFunction.cpp +++ b/lib/al/src/Library/LiveActor/ActorAnimFunction.cpp @@ -158,10 +158,9 @@ void setSklAnimBlendFrameAll(LiveActor* actor, f32 frame, bool isSync) { } } } else { - for (s32 j = 1; j < sklAnim->getSklAnimBlendNum(); j++) { + for (s32 j = 1; j < sklAnim->getSklAnimBlendNum(); j++) if (getSkl(actor)->isSklAnimPlaying(j)) getSkl(actor)->setSklAnimFrame(j, frame); - } } } void setSklAnimBlendFrameRateAll(LiveActor* actor, f32 frameRate, bool isSync) { @@ -177,10 +176,9 @@ void setSklAnimBlendFrameRateAll(LiveActor* actor, f32 frameRate, bool isSync) { } } } else { - for (s32 j = 1; j < sklAnim->getSklAnimBlendNum(); j++) { + for (s32 j = 1; j < sklAnim->getSklAnimBlendNum(); j++) if (getSkl(actor)->isSklAnimPlaying(j)) getSkl(actor)->setSklAnimFrameRate(j, frameRate); - } } } void startMtpAnim(LiveActor* actor, const char* animName) { diff --git a/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp b/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp index 66523f57..9a7539b8 100644 --- a/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp +++ b/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp @@ -44,9 +44,8 @@ void resetPosition(LiveActor* actor) { alSensorFunction::clearHitSensors(actor); alSensorFunction::updateHitSensorsAll(actor); } - if (actor->getScreenPointKeeper()) { + if (actor->getScreenPointKeeper()) alScreenPointFunction::updateScreenPointAll(actor); - } if (actor->getCollider()) actor->getCollider()->onInvalidate(); if (actor->getCollisionParts()) diff --git a/lib/al/src/Library/LiveActor/LiveActorGroup.cpp b/lib/al/src/Library/LiveActor/LiveActorGroup.cpp old mode 100755 new mode 100644 index f592df87..0568b7b1 --- a/lib/al/src/Library/LiveActor/LiveActorGroup.cpp +++ b/lib/al/src/Library/LiveActor/LiveActorGroup.cpp @@ -31,15 +31,12 @@ void LiveActorGroup::removeActorAll() { } bool LiveActorGroup::isExistActor(const LiveActor* pActor) const { - if (mActorCount < 1) { + if (mActorCount < 1) return false; - } - for (s32 i = 0; i < mActorCount; i++) { - if (mActors[i] == pActor) { + for (s32 i = 0; i < mActorCount; i++) + if (mActors[i] == pActor) return true; - } - } return false; } @@ -51,60 +48,48 @@ bool LiveActorGroup::isFull() const { s32 LiveActorGroup::calcAliveActorNum() const { s32 count = 0; - for (s32 i = 0; i < mActorCount; i++) { - if (!isDead(mActors[i])) { + for (s32 i = 0; i < mActorCount; i++) + if (!isDead(mActors[i])) count++; - } - } return count; } LiveActor* LiveActorGroup::getDeadActor() const { - for (s32 i = 0; i < mActorCount; i++) { - if (isDead(mActors[i])) { + for (s32 i = 0; i < mActorCount; i++) + if (isDead(mActors[i])) return mActors[i]; - } - } return nullptr; } LiveActor* LiveActorGroup::tryFindDeadActor() const { - for (s32 i = 0; i < mActorCount; i++) { - if (isDead(mActors[i])) { + for (s32 i = 0; i < mActorCount; i++) + if (isDead(mActors[i])) return mActors[i]; - } - } return nullptr; } void LiveActorGroup::appearAll() { - for (s32 i = 0; i < mActorCount; i++) { - if (isDead(mActors[i])) { + for (s32 i = 0; i < mActorCount; i++) + if (isDead(mActors[i])) mActors[i]->appear(); - } - } } void LiveActorGroup::killAll() { - for (s32 i = 0; i < mActorCount; i++) { - if (isAlive(mActors[i])) { + for (s32 i = 0; i < mActorCount; i++) + if (isAlive(mActors[i])) mActors[i]->kill(); - } - } } void LiveActorGroup::makeActorAliveAll() { - for (s32 i = 0; i < mActorCount; i++) { + for (s32 i = 0; i < mActorCount; i++) mActors[i]->makeActorAlive(); - } } void LiveActorGroup::makeActorDeadAll() { - for (s32 i = 0; i < mActorCount; i++) { + for (s32 i = 0; i < mActorCount; i++) mActors[i]->makeActorDead(); - } } } // namespace al diff --git a/lib/al/src/Library/LiveActor/LiveActorKit.cpp b/lib/al/src/Library/LiveActor/LiveActorKit.cpp index 7a92021c..7b22f5ac 100644 --- a/lib/al/src/Library/LiveActor/LiveActorKit.cpp +++ b/lib/al/src/Library/LiveActor/LiveActorKit.cpp @@ -54,30 +54,25 @@ LiveActorKit::~LiveActorKit() { delete mModelGroup; mModelGroup = nullptr; } - if (mGraphicsSystemInfo) { + if (mGraphicsSystemInfo) delete mGraphicsSystemInfo; - } - if (mModelDrawBufferUpdater) { + if (mModelDrawBufferUpdater) delete mModelDrawBufferUpdater; - } if (mExecutorCore1) delete mExecutorCore1; if (mExecutorCore2) delete mExecutorCore2; - if (mDynamicDrawActorGroup) { - for (s32 i = 0; i < mDynamicDrawActorGroup->getActorCount(); i++) { + if (mDynamicDrawActorGroup) + for (s32 i = 0; i < mDynamicDrawActorGroup->getActorCount(); i++) ((DynamicDrawActor*)mDynamicDrawActorGroup->getActor(i))->finalize(); - } - } if (mEffectSystem) { mEffectSystem->endScene(); mEffectSystem->setCameraDirector(nullptr); - if (mEffectSystem) { + if (mEffectSystem) mEffectSystem->setGraphicsSystemInfo(nullptr); - } } } diff --git a/lib/al/src/Library/LiveActor/SubActorKeeper.cpp b/lib/al/src/Library/LiveActor/SubActorKeeper.cpp index a22258da..3cbf5842 100644 --- a/lib/al/src/Library/LiveActor/SubActorKeeper.cpp +++ b/lib/al/src/Library/LiveActor/SubActorKeeper.cpp @@ -31,9 +31,8 @@ void SubActorKeeper::init(const ActorInitInfo& initInfo, const char* suffix, s32 u8* modelResourceYaml; if (isExistModelResource(mRootActor) && - !tryGetActorInitFileName(&actorInitFileName, mRootActor, "InitSubActor", suffix)) { + !tryGetActorInitFileName(&actorInitFileName, mRootActor, "InitSubActor", suffix)) createFileNameBySuffix(&actorInitFileName, "InitSubActor", suffix); - } if (isExistModelResource(mRootActor) && isExistModelResourceYaml(mRootActor, actorInitFileName.cstr(), nullptr)) { diff --git a/lib/al/src/Library/MapObj/FixMapParts.cpp b/lib/al/src/Library/MapObj/FixMapParts.cpp index 6375ee53..08bebfd3 100644 --- a/lib/al/src/Library/MapObj/FixMapParts.cpp +++ b/lib/al/src/Library/MapObj/FixMapParts.cpp @@ -16,9 +16,8 @@ void FixMapParts::init(const ActorInitInfo& info) { trySyncStageSwitchAppearAndKill(this); registActorToDemoInfo(this, info); - if (getModelKeeper() != nullptr && !isExistAction(this) && !isViewDependentModel(this)) { + if (getModelKeeper() != nullptr && !isExistAction(this) && !isViewDependentModel(this)) mIsStatic = true; - } } void FixMapParts::appear() { LiveActor::appear(); diff --git a/lib/al/src/Library/Math/MathUtil.cpp b/lib/al/src/Library/Math/MathUtil.cpp old mode 100755 new mode 100644 index 718746fe..13ddf113 --- a/lib/al/src/Library/Math/MathUtil.cpp +++ b/lib/al/src/Library/Math/MathUtil.cpp @@ -55,23 +55,19 @@ f32 easeInOut(f32 var) { f32 sign(f32 result) { f32 v1; v1 = result < 0.0f; - if (result > 0.0f) { + if (result > 0.0f) result = 1.0f; - } - if (v1) { + if (v1) result = -1.0f; - } return result; } s32 sign(s32 var) { - if (var < 0) { + if (var < 0) return -1; - } - if (var > 0) { + if (var > 0) return 1; - } return 0; } diff --git a/lib/al/src/Library/Memory/HeapUtil.cpp b/lib/al/src/Library/Memory/HeapUtil.cpp index 19c64d82..ec6cd93c 100644 --- a/lib/al/src/Library/Memory/HeapUtil.cpp +++ b/lib/al/src/Library/Memory/HeapUtil.cpp @@ -145,9 +145,8 @@ void createWorldResourceHeap(bool useCategory) { } void destroyWorldResourceHeap(bool removeCategory) { - if (removeCategory) { + if (removeCategory) removeResourceCategory("ワールド常駐"); - } clearFileLoaderEntry(); alProjectInterface::getSystemKit()->getMemorySystem()->destroyWorldResourceHeap(); diff --git a/lib/al/src/Library/Nerve/NerveKeeper.cpp b/lib/al/src/Library/Nerve/NerveKeeper.cpp index c44110fa..88d8b252 100644 --- a/lib/al/src/Library/Nerve/NerveKeeper.cpp +++ b/lib/al/src/Library/Nerve/NerveKeeper.cpp @@ -6,9 +6,8 @@ namespace al { NerveKeeper::NerveKeeper(IUseNerve* parent, const Nerve* nerve, s32 maxStates) : mParent(parent), mNextNerve(nullptr) { - if (maxStates > 0) { + if (maxStates > 0) mStateCtrl = new NerveStateCtrl(maxStates); - } } void NerveKeeper::initNerveAction(NerveActionCtrl* actionCtrl) { mActionCtrl = actionCtrl; diff --git a/lib/al/src/Library/Nerve/NerveStateBase.cpp b/lib/al/src/Library/Nerve/NerveStateBase.cpp index cbdf109a..8c900ed0 100644 --- a/lib/al/src/Library/Nerve/NerveStateBase.cpp +++ b/lib/al/src/Library/Nerve/NerveStateBase.cpp @@ -17,9 +17,8 @@ void NerveStateBase::kill() { bool NerveStateBase::update() { updateNerve(); - if (mIsDead) { + if (mIsDead) return true; - } control(); diff --git a/lib/al/src/Library/Nerve/NerveStateCtrl.cpp b/lib/al/src/Library/Nerve/NerveStateCtrl.cpp index 899b2bca..cc63a896 100644 --- a/lib/al/src/Library/Nerve/NerveStateCtrl.cpp +++ b/lib/al/src/Library/Nerve/NerveStateCtrl.cpp @@ -12,9 +12,8 @@ void NerveStateCtrl::addState(NerveStateBase* state, const Nerve* nerve, const c // run the state's update function, if there is a current state active bool NerveStateCtrl::updateCurrentState() { - if (!mCurrentState) { + if (!mCurrentState) return false; - } return mCurrentState->state->update(); } @@ -23,11 +22,9 @@ bool NerveStateCtrl::updateCurrentState() { // uses a supplied nerve pointer to compare it with the nerves contained in states // returns the matching nerve, if any NerveStateCtrl::State* NerveStateCtrl::findStateInfo(const Nerve* nerve) { - for (s32 i = 0; i < mStateCount; i++) { - if (mStates[i].nerve == nerve) { + for (s32 i = 0; i < mStateCount; i++) + if (mStates[i].nerve == nerve) return &mStates[i]; - } - } return nullptr; } @@ -35,9 +32,8 @@ NerveStateCtrl::State* NerveStateCtrl::findStateInfo(const Nerve* nerve) { // determines if the current state on the controller has ended // this can occur if there is no state, or if the base is not considered dead bool NerveStateCtrl::isCurrentStateEnd() const { - if (!mCurrentState) { + if (!mCurrentState) return true; - } return mCurrentState->state->isDead() != 0; } @@ -46,18 +42,16 @@ bool NerveStateCtrl::isCurrentStateEnd() const { // controller contained in the nerve keeper void NerveStateCtrl::tryEndCurrentState() { if (mCurrentState) { - if (!mCurrentState->state->isDead()) { + if (!mCurrentState->state->isDead()) mCurrentState->state->kill(); - } NerveKeeper* keeper = mCurrentState->state->getNerveKeeper(); if (keeper) { NerveStateCtrl* ctrl = keeper->getStateCtrl(); - if (ctrl) { + if (ctrl) ctrl->tryEndCurrentState(); - } } mCurrentState = nullptr; diff --git a/lib/al/src/Library/Network/AccountHolder.cpp b/lib/al/src/Library/Network/AccountHolder.cpp index d94f6869..9784ba50 100644 --- a/lib/al/src/Library/Network/AccountHolder.cpp +++ b/lib/al/src/Library/Network/AccountHolder.cpp @@ -6,9 +6,8 @@ AccountHolder::AccountHolder() { mUserHandle = new nn::account::UserHandle; if (nn::account::OpenPreselectedUser(mUserHandle).IsSuccess() && - nn::account::GetUserId(&mUid, *mUserHandle).IsSuccess()) { + nn::account::GetUserId(&mUid, *mUserHandle).IsSuccess()) mIsValid = true; - } } AccountHolder::~AccountHolder() { diff --git a/lib/al/src/Library/Obj/AllDeadWatcher.cpp b/lib/al/src/Library/Obj/AllDeadWatcher.cpp index 45a931b8..66407783 100644 --- a/lib/al/src/Library/Obj/AllDeadWatcher.cpp +++ b/lib/al/src/Library/Obj/AllDeadWatcher.cpp @@ -13,30 +13,25 @@ AllDeadWatcher::AllDeadWatcher(const char* name) : LiveActor(name) {} void AllDeadWatcher::appear() { LiveActor::appear(); - if (mIsNotControlActorAppear) { + if (mIsNotControlActorAppear) return; - } - for (s32 i = 0; i < mTargetCount; i++) { + for (s32 i = 0; i < mTargetCount; i++) mTargets[i]->appear(); - } } void AllDeadWatcher::exeWait() { - if (!isGreaterEqualStep(this, mSwitchOnDelayStep)) { + if (!isGreaterEqualStep(this, mSwitchOnDelayStep)) return; - } kill(); tryOnSwitchDeadOn(this); } void AllDeadWatcher::exeWatch() { - for (s32 i = 0; i < mTargetCount; i++) { - if (isAlive(mTargets[i])) { + for (s32 i = 0; i < mTargetCount; i++) + if (isAlive(mTargets[i])) return; - } - } setNerve(this, &NrvAllDeadWatcher.Watch); } @@ -50,20 +45,17 @@ void AllDeadWatcher::init(const ActorInitInfo& info) { mTargetCount = calcLinkChildNum(info, "WatchTargetEnemy"); mTargets = new LiveActor*[mTargetCount]; - for (s32 i = 0; i < mTargetCount; i++) { + for (s32 i = 0; i < mTargetCount; i++) mTargets[i] = createLinksActorFromFactory(info, "WatchTargetEnemy", i); - } tryGetArg(&mSwitchOnDelayStep, info, "SwitchOnDelayStep"); mIsNotControlActorAppear = tryGetBoolArgOrFalse(info, "IsNotControlActorAppear"); - if (!trySyncStageSwitchAppear(this) || mIsNotControlActorAppear) { + if (!trySyncStageSwitchAppear(this) || mIsNotControlActorAppear) return; - } - for (s32 i = 0; i < mTargetCount; i++) { + for (s32 i = 0; i < mTargetCount; i++) mTargets[i]->makeActorDead(); - } } void AllDeadWatcher::kill() { diff --git a/lib/al/src/Library/Placement/PlacementFunction.cpp b/lib/al/src/Library/Placement/PlacementFunction.cpp old mode 100755 new mode 100644 index ba2d5a25..77f28335 --- a/lib/al/src/Library/Placement/PlacementFunction.cpp +++ b/lib/al/src/Library/Placement/PlacementFunction.cpp @@ -14,18 +14,16 @@ void getPlacementInfoByKey(PlacementInfo* pOutInfo, const PlacementInfo& rInfo, ByamlIter iterator; bool ret = rInfo.getPlacementIter().tryGetIterByKey(&iterator, pKey); - if (ret) { + if (ret) pOutInfo->set(iterator, rInfo.getZoneIter()); - } } void getPlacementInfoByIndex(PlacementInfo* pOutInfo, const PlacementInfo& rInfo, s32 idx) { ByamlIter iterator; bool ret = rInfo.getPlacementIter().tryGetIterByIndex(&iterator, idx); - if (ret) { + if (ret) pOutInfo->set(iterator, rInfo.getZoneIter()); - } } bool tryGetPlacementInfoByIndex(PlacementInfo* pOutInfo, const PlacementInfo& rInfo, s32 idx) { @@ -50,9 +48,8 @@ void getPlacementInfoAndKeyNameByIndex(PlacementInfo* pOutInfo, const char** pOu bool ret = rInfo.getPlacementIter().tryGetIterAndKeyNameByIndex(&iterator, pOutKeyName, idx); - if (ret) { + if (ret) pOutInfo->set(iterator, rInfo.getZoneIter()); - } } bool tryGetPlacementInfoAndKeyNameByIndex(PlacementInfo* pOutInfo, const char** pOutKeyName, @@ -112,11 +109,10 @@ bool isEqualPlacementId(const PlacementInfo& rLhs, const PlacementInfo& rRhs) { if (id_lhs.init(rLhs)) { PlacementId id_rhs; - if (id_rhs.init(rRhs)) { + if (id_rhs.init(rRhs)) res = id_lhs.isEqual(id_rhs); - } else { + else res = false; - } } else { res = false; diff --git a/lib/al/src/Library/Play/Camera/CameraVerticalAbsorber.cpp b/lib/al/src/Library/Play/Camera/CameraVerticalAbsorber.cpp index 5cfafe13..fb10fbe7 100644 --- a/lib/al/src/Library/Play/Camera/CameraVerticalAbsorber.cpp +++ b/lib/al/src/Library/Play/Camera/CameraVerticalAbsorber.cpp @@ -104,9 +104,8 @@ void CameraVerticalAbsorber::update() { mLookAtCamera.getUp().normalize(); if (!unk_unusedBool && !mIsInvalidated) { mLookAtCamera.getAt() -= mTargetInterp; - if (!mIsNoCameraPosAbsorb) { + if (!mIsNoCameraPosAbsorb) mLookAtCamera.getPos() -= mTargetInterp; - } } mLookAtCamera.doUpdateMatrix(&mLookAtCamera.getMatrix()); mProjection.set(alCameraPoserFunction::getNear(mCameraPoser), @@ -115,13 +114,11 @@ void CameraVerticalAbsorber::update() { alCameraPoserFunction::getAspect(mCameraPoser)); alCameraPoserFunction::calcTargetFront(&mTargetFront, mCameraPoser); if (!isNerve(this, &NrvCameraVerticalAbsorber.FollowGround) && - alCameraPoserFunction::isTargetCollideGround(mCameraPoser)) { + alCameraPoserFunction::isTargetCollideGround(mCameraPoser)) setNerve(this, &NrvCameraVerticalAbsorber.FollowGround); - } if (!isNerve(this, &NrvCameraVerticalAbsorber.FollowAbsolute) && - alCameraPoserFunction::isPlayerTypeNotTouchGround(mCameraPoser)) { + alCameraPoserFunction::isPlayerTypeNotTouchGround(mCameraPoser)) setNerve(this, &NrvCameraVerticalAbsorber.FollowAbsolute); - } updateNerve(); sead::Vector3f prevTargetTrans = sead::Vector3f::zero; if (!mIsKeepInFrame) { diff --git a/lib/al/src/Library/Player/PlayerHolder.cpp b/lib/al/src/Library/Player/PlayerHolder.cpp index e98e8ad1..34977877 100644 --- a/lib/al/src/Library/Player/PlayerHolder.cpp +++ b/lib/al/src/Library/Player/PlayerHolder.cpp @@ -26,11 +26,10 @@ LiveActor* PlayerHolder::getPlayer(s32 index) const { } LiveActor* PlayerHolder::tryGetPlayer(s32 index) const { - if (mBufferSize <= index) { + if (mBufferSize <= index) return nullptr; - } else if (mPlayerNum <= index) { + else if (mPlayerNum <= index) return nullptr; - } return mPlayers[index].mActor; } diff --git a/lib/al/src/Library/Player/PlayerUtil.cpp b/lib/al/src/Library/Player/PlayerUtil.cpp index 81c6ca55..ee501b1d 100644 --- a/lib/al/src/Library/Player/PlayerUtil.cpp +++ b/lib/al/src/Library/Player/PlayerUtil.cpp @@ -18,9 +18,8 @@ s32 getAlivePlayerNum(const PlayerHolder* holder) { for (s32 i = 0; i < player_num; i++) { LiveActor* player = holder->tryGetPlayer(i); - if (isAlive(player)) { + if (isAlive(player)) alive_players++; - } } return alive_players; @@ -54,9 +53,8 @@ LiveActor* tryFindAlivePlayerActorFirst(const PlayerHolder* holder) { for (u32 i = 0; i < player_num; i++) { LiveActor* player = holder->tryGetPlayer(i); - if (!isDead(player)) { + if (!isDead(player)) return player; - } } return nullptr; @@ -67,9 +65,8 @@ LiveActor* findAlivePlayerActorFirst(const PlayerHolder* holder) { for (u32 i = 0; i < player_num; i++) { LiveActor* player = holder->tryGetPlayer(i); - if (!isDead(player)) { + if (!isDead(player)) return player; - } } return nullptr; diff --git a/lib/al/src/Library/Rail/Graph.cpp b/lib/al/src/Library/Rail/Graph.cpp index 30d4df9d..179bf025 100644 --- a/lib/al/src/Library/Rail/Graph.cpp +++ b/lib/al/src/Library/Rail/Graph.cpp @@ -22,9 +22,8 @@ void Graph::appendVertex(Vertex* vertex) { void Graph::removeVertex(const Vertex* vertex) { // FIXME mismatching for (s32 i = 0; i < mVertices.size(); i++) { if (mVertices[i] == vertex) { - for (s32 i = 0; i < vertex->getEdges().size(); i++) { + for (s32 i = 0; i < vertex->getEdges().size(); i++) removeEdge(vertex->getEdges()[i]); - } mVertices.erase(i); return; } @@ -44,9 +43,8 @@ Graph::Edge* Graph::tryFindEdge(s32 index_vertex1, s32 index_vertex2) const { for (s32 i = 0; i < mEdges.size(); i++) { auto* edge = mEdges[i]; if (edge->getVertex1()->getIndex() == index_vertex1 && - edge->getVertex2()->getIndex() == index_vertex2) { + edge->getVertex2()->getIndex() == index_vertex2) return edge; - } } return nullptr; } diff --git a/lib/al/src/Library/Rail/Rail.cpp b/lib/al/src/Library/Rail/Rail.cpp index 94b75074..b393dddf 100644 --- a/lib/al/src/Library/Rail/Rail.cpp +++ b/lib/al/src/Library/Rail/Rail.cpp @@ -72,11 +72,10 @@ s32 Rail::getIncludedSection(const RailPart** part, f32* partDistance, f32 dista s64 longI = -0x100000000; for (s32 i = 0; i < mRailPartCount; i++) { if (distanceOnRail <= mRailPart[i].getTotalDistance()) { - if (i <= 0) { + if (i <= 0) startDistanceOnRail = distanceOnRail; - } else { + else startDistanceOnRail = distanceOnRail - mRailPart[longI >> 32].getTotalDistance(); - } maxRailPart = i; break; } @@ -249,19 +248,17 @@ f32 Rail::getIncludedSectionLength(f32* partDistance, f32* length, f32 distance) const RailPart* part = nullptr; getIncludedSection(&part, partDistance, distance); f32 partLength = part->getPartLength(); - if (partDistance && length) { + if (partDistance && length) *length = partLength - *partDistance; - } return partLength; } s32 Rail::getIncludedSectionIndex(f32 distance) const { return getIncludedSection(nullptr, nullptr, distance); } bool Rail::isIncludeBezierRailPart() const { - for (s32 i = 0; i < mRailPartCount; i++) { + for (s32 i = 0; i < mRailPartCount; i++) if (isBezierRailPart(i)) return true; - } return false; } bool Rail::isBezierRailPart(s32 index) const { diff --git a/lib/al/src/Library/Rail/RailPart.cpp b/lib/al/src/Library/Rail/RailPart.cpp index c9d56aa5..9a714e85 100644 --- a/lib/al/src/Library/Rail/RailPart.cpp +++ b/lib/al/src/Library/Rail/RailPart.cpp @@ -43,11 +43,10 @@ void RailPart::calcDir(sead::Vector3f* dir, f32 param) const { dir->x = endPos.x - startPos.x; dir->y = endPos.y - startPos.y; dir->z = endPos.z - startPos.z; - if (isNearZero(*dir, 0.001)) { + if (isNearZero(*dir, 0.001)) *dir = {0, 0, 1}; - } else { + else normalize(dir); - } } void RailPart::calcStartPos(sead::Vector3f* pos) const { return mBezierCurve ? mBezierCurve->calcStartPos(pos) : mLinearCurve->calcStartPos(pos); diff --git a/lib/al/src/Library/Scene/SceneObjHolder.cpp b/lib/al/src/Library/Scene/SceneObjHolder.cpp index 4841a71d..1b5676bb 100644 --- a/lib/al/src/Library/Scene/SceneObjHolder.cpp +++ b/lib/al/src/Library/Scene/SceneObjHolder.cpp @@ -8,9 +8,8 @@ SceneObjHolder::SceneObjHolder(ISceneObj* (*creator)(s32), s32 size) : mCreator(creator), mArraySize(size) { mSceneObjArray = new ISceneObj*[size]; - for (s32 i = 0; i < mArraySize; i++) { + for (s32 i = 0; i < mArraySize; i++) mSceneObjArray[i] = nullptr; - } } ISceneObj* SceneObjHolder::create(s32 index) { @@ -37,10 +36,9 @@ void SceneObjHolder::setSceneObj(ISceneObj* obj, s32 index) { } void SceneObjHolder::initAfterPlacementSceneObj(const ActorInitInfo& info) { - for (s32 i = 0; i < mArraySize; i++) { + for (s32 i = 0; i < mArraySize; i++) if (mSceneObjArray[i]) mSceneObjArray[i]->initAfterPlacementSceneObj(info); - } } } // namespace al diff --git a/lib/al/src/Library/Yaml/ByamlData.cpp b/lib/al/src/Library/Yaml/ByamlData.cpp old mode 100755 new mode 100644 index c6703245..9d5f5d5a --- a/lib/al/src/Library/Yaml/ByamlData.cpp +++ b/lib/al/src/Library/Yaml/ByamlData.cpp @@ -51,9 +51,8 @@ const ByamlHashPair* ByamlHashIter::findPair(s32 key) const { s32 avg = (lowerBound + upperBound) / 2; const ByamlHashPair* pair = &pairTable[avg]; s32 result = key - pair->getKey(mIsRev); - if (result == 0) { + if (result == 0) return pair; - } if (result > 0) lowerBound = avg + 1; @@ -92,9 +91,8 @@ bool ByamlHashIter::getDataByKey(ByamlData* data, s32 key) const { s32 avg = (lowerBound + upperBound) / 2; pair = &pairTable[avg]; s32 result = key - pair->getKey(mIsRev); - if (result == 0) { + if (result == 0) break; - } if (result > 0) lowerBound = avg + 1; diff --git a/lib/al/src/Library/Yaml/ByamlIter.cpp b/lib/al/src/Library/Yaml/ByamlIter.cpp index 63475b78..651fc33e 100644 --- a/lib/al/src/Library/Yaml/ByamlIter.cpp +++ b/lib/al/src/Library/Yaml/ByamlIter.cpp @@ -168,12 +168,10 @@ bool ByamlIter::tryGetIterAndKeyNameByIndex(ByamlIter* iter, const char** key, s return iter->isValid(); } - if (data.getType() == ByamlDataType::TYPE_ARRAY || data.getType() == ByamlDataType::TYPE_HASH) { + if (data.getType() == ByamlDataType::TYPE_ARRAY || data.getType() == ByamlDataType::TYPE_HASH) *iter = {mData, &mData[data.getValue()]}; - } - if (data.getType() == ByamlDataType::TYPE_NULL) { + if (data.getType() == ByamlDataType::TYPE_NULL) *iter = {mData, nullptr}; - } return true; } bool ByamlIter::tryGetIterByKey(ByamlIter* iter, const char* key) const { @@ -195,17 +193,15 @@ bool ByamlIter::tryConvertIter(ByamlIter* iter, const ByamlData* data) const { bool ByamlIter::tryGetStringByIndex(const char** value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertString(value, &data); } bool ByamlIter::tryGetStringByKey(const char** value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -213,9 +209,8 @@ bool ByamlIter::tryGetStringByKey(const char** value, const char* key) const { } bool ByamlIter::tryConvertString(const char** value, const ByamlData* data) const { - if (data->getType() != ByamlDataType::TYPE_STRING) { + if (data->getType() != ByamlDataType::TYPE_STRING) return false; - } const auto string_table = alByamlLocalUtil::getStringTable(mData); if (!string_table.isValidate()) @@ -226,24 +221,21 @@ bool ByamlIter::tryConvertString(const char** value, const ByamlData* data) cons } bool ByamlIter::tryGetBinaryByIndex(const u8** value, s32* size, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertBinary(value, size, &data); } bool ByamlIter::tryGetBinaryByKey(const u8** value, s32* size, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } return tryConvertBinary(value, size, &data); } bool ByamlIter::tryConvertBinary(const u8** value, s32* size, const ByamlData* data) const { - if (data->getType() != ByamlDataType::TYPE_STRING) { + if (data->getType() != ByamlDataType::TYPE_STRING) return false; - } const auto string_table = alByamlLocalUtil::getStringTable(mData); if (!string_table.isValidate()) @@ -256,18 +248,16 @@ bool ByamlIter::tryConvertBinary(const u8** value, s32* size, const ByamlData* d bool ByamlIter::tryGetIntByIndex(s32* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertInt(value, &data); } bool ByamlIter::tryGetIntByKey(s32* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -275,9 +265,8 @@ bool ByamlIter::tryGetIntByKey(s32* value, const char* key) const { } bool ByamlIter::tryConvertInt(s32* value, const ByamlData* data) const { - if (data->getType() != ByamlDataType::TYPE_INT) { + if (data->getType() != ByamlDataType::TYPE_INT) return false; - } *value = data->getValue(); return true; @@ -286,9 +275,8 @@ bool ByamlIter::tryConvertInt(s32* value, const ByamlData* data) const { // NON_MATCHING: mismatch in inlined convert bool ByamlIter::tryGetUIntByIndex(u32* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertUInt(value, &data); } @@ -296,9 +284,8 @@ bool ByamlIter::tryGetUIntByIndex(u32* value, s32 index) const { // NON_MATCHING: mismatch in inlined convert bool ByamlIter::tryGetUIntByKey(u32* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -322,26 +309,23 @@ bool ByamlIter::tryConvertUInt(u32* value, const ByamlData* data) const { bool ByamlIter::tryGetFloatByIndex(f32* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertFloat(value, &data); } bool ByamlIter::tryGetFloatByKey(f32* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; return tryConvertFloat(value, &data); } bool ByamlIter::tryConvertFloat(f32* value, const ByamlData* data) const { - if (data->getType() != ByamlDataType::TYPE_FLOAT) { + if (data->getType() != ByamlDataType::TYPE_FLOAT) return false; - } *value = data->getValue(); return true; @@ -349,18 +333,16 @@ bool ByamlIter::tryConvertFloat(f32* value, const ByamlData* data) const { bool ByamlIter::tryGetBoolByIndex(bool* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } return tryConvertBool(value, &data); } bool ByamlIter::tryGetBoolByKey(bool* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -368,9 +350,8 @@ bool ByamlIter::tryGetBoolByKey(bool* value, const char* key) const { } bool ByamlIter::tryConvertBool(bool* value, const ByamlData* data) const { - if (data->getType() != ByamlDataType::TYPE_BOOL) { + if (data->getType() != ByamlDataType::TYPE_BOOL) return false; - } *value = data->getValue() != 0; return true; @@ -378,9 +359,8 @@ bool ByamlIter::tryConvertBool(bool* value, const ByamlData* data) const { bool ByamlIter::tryGetInt64ByIndex(s64* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -389,9 +369,8 @@ bool ByamlIter::tryGetInt64ByIndex(s64* value, s32 index) const { bool ByamlIter::tryGetInt64ByKey(s64* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -418,9 +397,8 @@ bool ByamlIter::tryConvertInt64(s64* value, const ByamlData* data) const { bool ByamlIter::tryGetUInt64ByIndex(u64* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -429,9 +407,8 @@ bool ByamlIter::tryGetUInt64ByIndex(u64* value, s32 index) const { bool ByamlIter::tryGetUInt64ByKey(u64* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -466,9 +443,8 @@ bool ByamlIter::tryConvertUInt64(u64* value, const ByamlData* data) const { bool ByamlIter::tryGetDoubleByIndex(f64* value, s32 index) const { ByamlData data; - if (!getByamlDataByIndex(&data, index)) { + if (!getByamlDataByIndex(&data, index)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -477,9 +453,8 @@ bool ByamlIter::tryGetDoubleByIndex(f64* value, s32 index) const { bool ByamlIter::tryGetDoubleByKey(f64* value, const char* key) const { ByamlData data; - if (!getByamlDataByKey(&data, key)) { + if (!getByamlDataByKey(&data, key)) return false; - } if (data.getType() == ByamlDataType::TYPE_NULL) return false; @@ -502,9 +477,8 @@ bool ByamlIter::tryConvertDouble(f64* value, const ByamlData* data) const { } bool ByamlIter::isEqualData(const ByamlIter& other) const { - if (!mData || !other.mData) { + if (!mData || !other.mData) return false; - } return mData == other.mData && mRootNode == other.mRootNode; } diff --git a/lib/al/src/Library/Yaml/ByamlUtil.cpp b/lib/al/src/Library/Yaml/ByamlUtil.cpp old mode 100755 new mode 100644 index 82db3a56..10a3e025 --- a/lib/al/src/Library/Yaml/ByamlUtil.cpp +++ b/lib/al/src/Library/Yaml/ByamlUtil.cpp @@ -38,9 +38,8 @@ bool tryGetByamlS32(s32* pOut, const ByamlIter& rIter, const char* pKey) { bool tryGetByamlU32(u32* pOut, const ByamlIter& rIter, const char* pKey) { s32 value = 0; bool res = rIter.tryGetIntByKey(&value, pKey); - if (res) { + if (res) *pOut = value; - } return res; } @@ -51,9 +50,8 @@ bool tryGetByamlS64(s64* pOut, const ByamlIter& rIter, const char* pKey) { bool tryGetByamlU64(u64* pOut, const ByamlIter& rIter, const char* pKey) { u64 value = 0; bool res = rIter.tryGetUInt64ByKey(&value, pKey); - if (res) { + if (res) *pOut = value; - } return res; } diff --git a/lib/al/src/Library/Yaml/Writer/ByamlWriter.cpp b/lib/al/src/Library/Yaml/Writer/ByamlWriter.cpp index a87b3474..03d41676 100644 --- a/lib/al/src/Library/Yaml/Writer/ByamlWriter.cpp +++ b/lib/al/src/Library/Yaml/Writer/ByamlWriter.cpp @@ -26,9 +26,8 @@ ByamlWriter::~ByamlWriter() { delete mBigDataList; delete[] mContainerStack; - for (auto* node : mContainerList) { + for (auto* node : mContainerList) node->deleteData(); - } while (auto* node = mContainerList.popBack()) { node->mList = nullptr; delete node->mData; @@ -168,17 +167,17 @@ void ByamlWriter::pushLocalIter(const ByamlIter& iter, const char* iterKey) { return; s32 size = iter.getSize(); - if (iter.isTypeHash()) { + if (iter.isTypeHash()) if (iterKey) pushHash(iterKey); else pushHash(); - } else if (iter.isTypeArray()) { + else if (iter.isTypeArray()) if (iterKey) pushArray(iterKey); else pushArray(); - } else + else return; for (s32 i = 0; i < size; i++) { @@ -290,9 +289,8 @@ u32 ByamlWriter::calcPackSize() const { size += mStringTable2->calcPackSize(); if (mBigDataList) size += mBigDataList->calcPackSize(); - for (auto* container : mContainerList) { + for (auto* container : mContainerList) size += container->calcPackSize(); - } return size; } // NON_MATCHING: offsetBigDataList increased "too early" @@ -317,9 +315,8 @@ void ByamlWriter::write(sead::WriteStream* stream) { container->setOffset(offsetBigDataList); offsetBigDataList += container->calcPackSize(); } - for (auto* container : mContainerList) { + for (auto* container : mContainerList) container->writeContainer(stream); - } } void ByamlWriter::print() const { @@ -327,9 +324,8 @@ void ByamlWriter::print() const { mStringTable1->print(); if (mStringTable2) mStringTable2->print(); - if (mCurrentContainerIndex >= 0) { + if (mCurrentContainerIndex >= 0) mContainerStack[0]->print(1); - } } } // namespace al diff --git a/lib/al/src/Library/Yaml/Writer/ByamlWriterBigDataList.cpp b/lib/al/src/Library/Yaml/Writer/ByamlWriterBigDataList.cpp index 40ab6f48..9b4bc8a3 100644 --- a/lib/al/src/Library/Yaml/Writer/ByamlWriterBigDataList.cpp +++ b/lib/al/src/Library/Yaml/Writer/ByamlWriterBigDataList.cpp @@ -6,18 +6,16 @@ namespace al { ByamlWriterBigDataList::ByamlWriterBigDataList() = default; ByamlWriterBigDataList::~ByamlWriterBigDataList() { - while (auto* node = mList.popBack()) { + while (auto* node = mList.popBack()) delete node; - } } void ByamlWriterBigDataList::addData(ByamlWriterBigData* data) { mList.pushBack(new sead::TListNode(data)); } u32 ByamlWriterBigDataList::calcPackSize() const { u32 size = 0; - for (auto& node : mList) { + for (auto& node : mList) size += node->calcBigDataSize(); - } return size; } s32 ByamlWriterBigDataList::setOffset(s32 offset) { @@ -28,9 +26,8 @@ s32 ByamlWriterBigDataList::setOffset(s32 offset) { return offset; } void ByamlWriterBigDataList::write(sead::WriteStream* stream) { - for (auto& node : mList) { + for (auto& node : mList) node->writeBigData(stream); - } } } // namespace al diff --git a/lib/al/src/Library/Yaml/Writer/ByamlWriterData.cpp b/lib/al/src/Library/Yaml/Writer/ByamlWriterData.cpp index ef955718..ce7a553c 100644 --- a/lib/al/src/Library/Yaml/Writer/ByamlWriterData.cpp +++ b/lib/al/src/Library/Yaml/Writer/ByamlWriterData.cpp @@ -164,9 +164,8 @@ void ByamlWriterContainer::deleteData() {} ByamlWriterArray::ByamlWriterArray(ByamlWriterStringTable* stringTable) : mStringTable(stringTable) {} ByamlWriterArray::~ByamlWriterArray() { - while (auto* node = mList.popBack()) { + while (auto* node = mList.popBack()) delete node; - } } void ByamlWriterArray::deleteData() { for (auto it = mList.robustBegin(); it != mList.robustEnd(); ++it) { @@ -224,29 +223,25 @@ void ByamlWriterArray::writeContainer(sead::WriteStream* stream) const { stream->writeU8(0xC0); alByamlLocalUtil::writeU24(stream, mList.size()); - for (auto& node : mList) { + for (auto& node : mList) stream->writeU8(node->getTypeCode()); - } s32 i = mList.size(); s32 v12 = i < 0 ? i + 3 : i; s32 v14 = i - (v12 & 0xFFFFFFFC); s32 v15 = 4 - v14; s32 v16 = v14 == 0 ? 0 : v15; - for (s32 j = 0; j < v16; j++) { + for (s32 j = 0; j < v16; j++) stream->writeU8(0); - } - for (auto& node : mList) { + for (auto& node : mList) node->write(stream); - } } void ByamlWriterArray::write(sead::WriteStream* stream) const { stream->writeU32(getOffset()); } void ByamlWriterArray::print(s32 unknown) const { - for (auto node : mList) { + for (auto node : mList) node->print(unknown + 1); - } } bool ByamlWriterArray::isArray() const { return true; @@ -259,9 +254,8 @@ ByamlWriterHash::ByamlWriterHash(ByamlWriterStringTable* stringTable1, ByamlWriterStringTable* stringTable2) : mStringTable1(stringTable1), mStringTable2(stringTable2) {} ByamlWriterHash::~ByamlWriterHash() { - while (auto* node = mList.popBack()) { + while (auto* node = mList.popBack()) delete node; - } } u32 ByamlWriterHash::calcPackSize() const { return mList.size() * 8 + 4; diff --git a/lib/al/src/Library/Yaml/Writer/ByamlWriterStringTable.cpp b/lib/al/src/Library/Yaml/Writer/ByamlWriterStringTable.cpp index 3562cf2b..f0692b0b 100644 --- a/lib/al/src/Library/Yaml/Writer/ByamlWriterStringTable.cpp +++ b/lib/al/src/Library/Yaml/Writer/ByamlWriterStringTable.cpp @@ -26,9 +26,8 @@ inline char* add(const char* string, sead::TList& list) { const char* ByamlWriterStringTable::tryAdd(const char* string) { for (auto it = mList.robustBegin(); it != mList.robustEnd(); ++it) { s32 result = strcmp(string, it->mData); - if (result == 0) { + if (result == 0) return it->mData; - } if (result < 0) { s32 length = (s64)((strlen(string) << 32) + 0x100000000LL) >> 32; char* array = new char[length]; @@ -50,9 +49,8 @@ u32 ByamlWriterStringTable::calcHeaderSize() const { } u32 ByamlWriterStringTable::calcContentSize() const { u32 size = 0; - for (auto& node : mList) { + for (auto& node : mList) size += strlen(node) + 1; - } return (size + 3) & 0xFFFFFFFC; } u32 ByamlWriterStringTable::calcPackSize() const { @@ -100,14 +98,12 @@ void ByamlWriterStringTable::write(sead::WriteStream* stream) const { s32 v15 = 4 - v14; s32 v16 = v14 == 0 ? 0 : v15; - for (s32 j = 0; j < v16; j++) { + for (s32 j = 0; j < v16; j++) stream->writeU8(0); - } } void ByamlWriterStringTable::print() const { - for (auto& node : mList) { + for (auto& node : mList) ; - } } } // namespace al diff --git a/lib/al/src/Project/Action/ActionFunction.cpp b/lib/al/src/Project/Action/ActionFunction.cpp index a02e9d46..dc3c4ad5 100644 --- a/lib/al/src/Project/Action/ActionFunction.cpp +++ b/lib/al/src/Project/Action/ActionFunction.cpp @@ -7,9 +7,8 @@ namespace alActionFunction { const char* getAnimName(const al::ActionAnimCtrlInfo* infoCtrl, const al::ActionAnimDataInfo* infoData) { const char* animName = infoData->mActionName; - if (animName == nullptr) { + if (animName == nullptr) animName = infoCtrl->mActionName; - } return animName; } } // namespace alActionFunction diff --git a/lib/al/src/Project/HitSensor/HitSensor.cpp b/lib/al/src/Project/HitSensor/HitSensor.cpp old mode 100755 new mode 100644 index 7c03591e..c247643a --- a/lib/al/src/Project/HitSensor/HitSensor.cpp +++ b/lib/al/src/Project/HitSensor/HitSensor.cpp @@ -15,9 +15,8 @@ void HitSensor::validate() { mIsValid = true; if (mMaxSensorCount) { - if (mIsValidBySystem) { + if (mIsValidBySystem) mHitGroup->add(this); - } } } @@ -29,9 +28,8 @@ void HitSensor::invalidate() { mIsValid = false; if (mMaxSensorCount) { - if (mIsValidBySystem) { + if (mIsValidBySystem) mHitGroup->remove(this); - } } } diff --git a/lib/al/src/Project/Rail/BezierCurve.cpp b/lib/al/src/Project/Rail/BezierCurve.cpp index d77b28db..8b913e53 100644 --- a/lib/al/src/Project/Rail/BezierCurve.cpp +++ b/lib/al/src/Project/Rail/BezierCurve.cpp @@ -34,9 +34,8 @@ f32 BezierCurve::calcLength(f32 startParam, f32 endParam, s32 stepCount) const { sumVelHalfStep += calcDeltaLength((halfStepSize * (doubleI - 1)) + startParam); - if (i != stepCount) { + if (i != stepCount) sumVelFullStep += calcDeltaLength((halfStepSize * (doubleI)) + startParam); - } } return std::floor((halfStepSize * 0.33333f) * @@ -97,9 +96,8 @@ f32 BezierCurve::calcCurveParam(f32 distance) const { return percent; } - if (percent > 1.0f || partLength < 0.0f) { + if (percent > 1.0f || partLength < 0.0f) return sead::Mathf::clamp(percent, 0.0f, 1.0f); - } return percent; } diff --git a/src/MapObj/FireDrum2D.cpp b/src/MapObj/FireDrum2D.cpp index 07b1c172..593287a2 100644 --- a/src/MapObj/FireDrum2D.cpp +++ b/src/MapObj/FireDrum2D.cpp @@ -40,24 +40,20 @@ ActorDimensionKeeper* FireDrum2D::getActorDimensionKeeper() const { } void FireDrum2D::exeWait() { - if (al::isFirstStep(this)) { + if (al::isFirstStep(this)) al::startAction(this, "Burn"); - } } void FireDrum2D::exeBurn() { - if (al::isFirstStep(this)) { + if (al::isFirstStep(this)) al::startAction(this, "Wait"); - } - if (al::isActionEnd(this)) { + if (al::isActionEnd(this)) al::setNerve(this, &Wait); - } } void FireDrum2D::attackSensor(al::HitSensor* source, al::HitSensor* target) { - if (rs::sendMsgTouchFireDrum2D(target, source) || rs::sendMsgEnemyAttack2D(target, source)) { + if (rs::sendMsgTouchFireDrum2D(target, source) || rs::sendMsgEnemyAttack2D(target, source)) al::setNerve(this, &Burn); - } } bool FireDrum2D::receiveMsg(const al::SensorMsg* message, al::HitSensor* source, diff --git a/src/Npc/AchievementHolder.cpp b/src/Npc/AchievementHolder.cpp index d34a67bb..82c8fa18 100644 --- a/src/Npc/AchievementHolder.cpp +++ b/src/Npc/AchievementHolder.cpp @@ -15,18 +15,16 @@ void AchievementHolder::init(const al::ActorInitInfo&) { mAchievementInfoReader->init(); mArray.allocBuffer(mAchievementInfoReader->size(), nullptr); - for (s32 i = 0; i < mArray.capacity(); i++) { + for (s32 i = 0; i < mArray.capacity(); i++) mArray.pushBack(new Achievement(mAchievementInfoReader->get(i))); - } } void AchievementHolder::init() { mAchievementInfoReader = new AchievementInfoReader(); mAchievementInfoReader->init(); mArray.allocBuffer(mAchievementInfoReader->size(), nullptr); - for (s32 i = 0; i < mArray.capacity(); i++) { + for (s32 i = 0; i < mArray.capacity(); i++) mArray.pushBack(new Achievement(mAchievementInfoReader->get(i))); - } } bool AchievementHolder::isGetMoon(s32 index, GameDataHolderAccessor accessor) const { @@ -53,9 +51,8 @@ s32 AchievementHolder::getAchievementProgressCurrent(s32 index, return progressCurrentRow < 0 ? 0 : max; } if (!al::isEqualSubString(*name, "Other_Coin_") && !al::isEqualString(*name, "Other_Jump") && - !al::isEqualString(*name, "Other_CapThrow")) { + !al::isEqualString(*name, "Other_CapThrow")) return progressCurrentRow; - } s32 max = 999999999; @@ -171,10 +168,9 @@ s32 AchievementHolder::getAchievementProgressCurrentRow(s32 index, s32 AchievementHolder::calcAchieveTotalNum(GameDataHolderAccessor accessor) const { s32 count = 0; - for (s32 i = 0; i < mArray.capacity(); i++) { + for (s32 i = 0; i < mArray.capacity(); i++) if (getAchievementProgressCurrent(i, accessor) >= mAchievementInfoReader->get(i)->mNum) count++; - } return count; } @@ -182,10 +178,9 @@ s32 AchievementHolder::calcAchieveTotalNum(GameDataHolderAccessor accessor) cons s32 AchievementHolder::calcMoonGetTotalNum(GameDataHolderAccessor accessor) const { s32 count = 0; - for (s32 i = 0; i < mArray.capacity(); i++) { + for (s32 i = 0; i < mArray.capacity(); i++) if (mArray[i]->isGet(accessor)) count++; - } return count; } @@ -193,10 +188,9 @@ s32 AchievementHolder::calcMoonGetTotalNum(GameDataHolderAccessor accessor) cons Achievement* AchievementHolder::tryGetNewAchievement(GameDataHolderAccessor accessor) const { // TODO mismatch s32 i = 0; - for (; i < mArray.capacity(); i++) { + for (; i < mArray.capacity(); i++) if (!mArray[i]->isGet(accessor) && getAchievementProgressCurrent(i, accessor) >= mAchievementInfoReader->get(i)->mNum) break; - } return mArray[i]; } diff --git a/src/Npc/AchievementInfoReader.cpp b/src/Npc/AchievementInfoReader.cpp index fda88cee..963fead8 100644 --- a/src/Npc/AchievementInfoReader.cpp +++ b/src/Npc/AchievementInfoReader.cpp @@ -39,9 +39,8 @@ void AchievementInfoReader::init() { // TODO minor mismatches during loop } s32 AchievementInfoReader::tryFindIndexByName(const char* name) const { - for (s32 i = 0; i < mAchievements.size(); i++) { + for (s32 i = 0; i < mAchievements.size(); i++) if (al::isEqualString(name, mAchievements[i]->mName)) return i; - } return -1; } diff --git a/src/Player/Player.cpp b/src/Player/Player.cpp index 883d8f20..69891659 100644 --- a/src/Player/Player.cpp +++ b/src/Player/Player.cpp @@ -153,9 +153,8 @@ void Player::attackSensor(al::HitSensor* target, al::HitSensor* source) { (al::isSensorEnemy(source) || al::isSensorPlayer(source)) && (al::getVelocity(this).dot(al::getGravity(this)) > 0.0f) && ((actorTrans - trans).dot(al::getGravity(this)) > 0.0f) && - al::sendMsgPlayerAttackTrample(source, target, nullptr)) { + al::sendMsgPlayerAttackTrample(source, target, nullptr)) al::setVelocityJump(this, 23.0f); - } } bool Player::receiveMsg(const al::SensorMsg* message, al::HitSensor* source, diff --git a/src/Player/PlayerContinuousJump.cpp b/src/Player/PlayerContinuousJump.cpp index 07188f21..9baa9ff9 100644 --- a/src/Player/PlayerContinuousJump.cpp +++ b/src/Player/PlayerContinuousJump.cpp @@ -12,9 +12,8 @@ void PlayerContinuousJump::update(bool shouldCountDown) { if (mCount > 0) { mTimer++; - if (mTimer >= mConst->getContinuousJumpTimer()) { + if (mTimer >= mConst->getContinuousJumpTimer()) clear(); - } } } diff --git a/src/Player/PlayerCounterQuickTurnJump.cpp b/src/Player/PlayerCounterQuickTurnJump.cpp index a6f3fe70..9e61f0f6 100644 --- a/src/Player/PlayerCounterQuickTurnJump.cpp +++ b/src/Player/PlayerCounterQuickTurnJump.cpp @@ -10,11 +10,10 @@ PlayerCounterQuickTurnJump::PlayerCounterQuickTurnJump(const PlayerConst* pConst : mConst(pConst), mTrigger(trigger) {} void PlayerCounterQuickTurnJump::update() { - if (mTrigger->isOn(PlayerTrigger::EActionTrigger_QuickTurn)) { + if (mTrigger->isOn(PlayerTrigger::EActionTrigger_QuickTurn)) mCounter = mConst->getQuickTurnJumpFrame(); - } else { + else mCounter = al::converge(mCounter, 0, 1); - } } bool PlayerCounterQuickTurnJump::isEnableTurnJump() const { diff --git a/src/Player/PlayerInput.cpp b/src/Player/PlayerInput.cpp index 6854ed01..955062a0 100644 --- a/src/Player/PlayerInput.cpp +++ b/src/Player/PlayerInput.cpp @@ -221,9 +221,8 @@ bool PlayerInput::isHoldJump() const { if (mIsDisableInput) return false; auto* dimension = mDimension; - if (dimension && rs::is2D(dimension) && rs::isIn2DArea(dimension) && _88 > 0) { + if (dimension && rs::is2D(dimension) && rs::isIn2DArea(dimension) && _88 > 0) return true; - } return PlayerInputFunction::isHoldJump(mLiveActor, PlayerFunction::getPlayerInputPort(mLiveActor)); } diff --git a/src/Player/PlayerInputFunction.cpp b/src/Player/PlayerInputFunction.cpp index b12ff644..dbc47013 100644 --- a/src/Player/PlayerInputFunction.cpp +++ b/src/Player/PlayerInputFunction.cpp @@ -4,8 +4,7 @@ #include "Library/LiveActor/LiveActor.h" bool PlayerInputFunction::isTriggerAction(const al::LiveActor* actor, s32 port) { - if (rs::isSeparatePlay(actor) && al::isPadTypeJoySingle(port)) { + if (rs::isSeparatePlay(actor) && al::isPadTypeJoySingle(port)) return true; - } return al::isPadTriggerX(port) || al::isPadTriggerY(port); } diff --git a/src/Player/PlayerJudgePreInputJump.cpp b/src/Player/PlayerJudgePreInputJump.cpp index 9a1256d2..3bbe5610 100644 --- a/src/Player/PlayerJudgePreInputJump.cpp +++ b/src/Player/PlayerJudgePreInputJump.cpp @@ -17,9 +17,8 @@ void PlayerJudgePreInputJump::reset() { void PlayerJudgePreInputJump::update() { mRemainJumpFrame = sead::Mathi::clampMin(mRemainJumpFrame - 1, 0); - if (mInput->isTriggerJump()) { + if (mInput->isTriggerJump()) mRemainJumpFrame = mConst->getContinuousJumpPreInputFrame(); - } } bool PlayerJudgePreInputJump::judge() const { diff --git a/src/Player/PlayerJudgeStartHipDrop.cpp b/src/Player/PlayerJudgeStartHipDrop.cpp index abd62dfc..164b4de3 100644 --- a/src/Player/PlayerJudgeStartHipDrop.cpp +++ b/src/Player/PlayerJudgeStartHipDrop.cpp @@ -13,9 +13,8 @@ PlayerJudgeStartHipDrop::PlayerJudgeStartHipDrop(const PlayerConst* playerConst, mModelChanger(playerModelChanger) {} bool PlayerJudgeStartHipDrop::judge() const { - if (mModelChanger->is2DModel() || !mInput->isTriggerHipDrop()) { + if (mModelChanger->is2DModel() || !mInput->isTriggerHipDrop()) return false; - } return !(rs::getGroundHeight(mHeightCheck) < mConst->getHipDropHeight()); } diff --git a/src/Player/PlayerModelHolder.cpp b/src/Player/PlayerModelHolder.cpp index 3ed9b089..ee009bed 100644 --- a/src/Player/PlayerModelHolder.cpp +++ b/src/Player/PlayerModelHolder.cpp @@ -20,20 +20,16 @@ void PlayerModelHolder::changeModel(const char* name) { } al::LiveActor* PlayerModelHolder::findModelActor(const char* name) const { - for (auto it = mBuffer.begin(), end = mBuffer.end(); it != end; ++it) { - if (al::isEqualString(it->mName, sead::SafeString(name))) { + for (auto it = mBuffer.begin(), end = mBuffer.end(); it != end; ++it) + if (al::isEqualString(it->mName, sead::SafeString(name))) return it->mLiveActor; - } - } return mCurrentModel->mLiveActor; } al::LiveActor* PlayerModelHolder::tryFindModelActor(const char* name) const { - for (auto it = mBuffer.begin(), end = mBuffer.end(); it != end; ++it) { - if (al::isEqualString(it->mName, sead::SafeString(name))) { + for (auto it = mBuffer.begin(), end = mBuffer.end(); it != end; ++it) + if (al::isEqualString(it->mName, sead::SafeString(name))) return it->mLiveActor; - } - } return nullptr; } diff --git a/src/Player/PlayerOxygen.cpp b/src/Player/PlayerOxygen.cpp index 91a4a1d6..da1a4de0 100644 --- a/src/Player/PlayerOxygen.cpp +++ b/src/Player/PlayerOxygen.cpp @@ -36,8 +36,7 @@ void PlayerOxygen::recovery() { #endif bool PlayerOxygen::isTriggerDamage() const { - if (mFramesWithoutOxygen) { + if (mFramesWithoutOxygen) return (mFramesWithoutOxygen % mOxygenDamageInterval) == 0; - } return false; } diff --git a/src/Sequence/WorldResourceLoader.cpp b/src/Sequence/WorldResourceLoader.cpp index 3211175b..86af4b10 100644 --- a/src/Sequence/WorldResourceLoader.cpp +++ b/src/Sequence/WorldResourceLoader.cpp @@ -25,9 +25,8 @@ WorldResourceLoader::~WorldResourceLoader() { mIsCancelled = true; mCurLoadCount = 0; - if (mWorldResourceLoader) { + if (mWorldResourceLoader) delete mWorldResourceLoader; - } tryDestroyWorldResource(); } @@ -166,9 +165,8 @@ s32 WorldResourceLoader::getLoadWorldId() const { al::Resource* WorldResourceLoader::tryLoadResource(const char* resPath, const char* category, const char* str3) { if (category) { - if (str3) { + if (str3) return al::findOrCreateResourceCategory(resPath, str3, category); - } return al::findOrCreateResource(resPath, category); } else { return al::findOrCreateResource(resPath, nullptr); @@ -209,11 +207,10 @@ void WorldResourceLoader::loadWorldResource(s32 loadWorldId, s32 scenario, bool resEntry.tryGetStringByKey(&resName, "Name"); resEntry.tryGetStringByKey(&resExt, "Ext"); - if (resExt) { + if (resExt) al::findOrCreateResourceCategory(resName, resourceCategory, resExt); - } else { + else al::findOrCreateResource(resName, nullptr); - } if (mIsCancelled) return; diff --git a/src/System/GameDataFile.cpp b/src/System/GameDataFile.cpp index f8354f4d..52bab92d 100644 --- a/src/System/GameDataFile.cpp +++ b/src/System/GameDataFile.cpp @@ -31,9 +31,8 @@ void GameDataFile::HintInfo::clear() { } bool GameDataFile::HintInfo::isDisableByWorldWarpHole(bool condition) const { - if (!condition && al::isEqualString(mOptionalID.cstr(), "WorldWarpHoleShine")) { + if (!condition && al::isEqualString(mOptionalID.cstr(), "WorldWarpHoleShine")) return true; - } return false; } @@ -43,15 +42,13 @@ bool GameDataFile::HintInfo::isEnableUnlock(s32 curWorldId, bool isGameClear, s3 if (unkBool1) return false; - if (mHintStatus == HintStatus::NONE) { + if (mHintStatus == HintStatus::NONE) return true; - } - if (isGameClear && mIsMoonRock) { + if (isGameClear && mIsMoonRock) return false; - } else if (!isGameClear && mIsMoonRock) { + else if (!isGameClear && mIsMoonRock) return true; - } } return false; @@ -76,28 +73,22 @@ bool GameDataFile::HintInfo::isHintStatusUnlockByAmiibo() const { bool GameDataFile::HintInfo::isEnableNameUnlockByScenario(s32 curWorldId, s32 scenarioNo, bool isInWorld) const { - if (isDisableByWorldWarpHole(isInWorld)) { + if (isDisableByWorldWarpHole(isInWorld)) return false; - } - if (mWorldIndex != curWorldId || unkBool2) { + if (mWorldIndex != curWorldId || unkBool2) return false; - } - if (mProgressBitflag.countOnBit()) { + if (mProgressBitflag.countOnBit()) return mProgressBitflag.isOnBit(scenarioNo - 1); - } return true; } bool GameDataFile::HintInfo::testFunc(s32 curWorldId, bool isGameClear, s32 scenarioNo, bool isInWorld) const { - if (isDisableByWorldWarpHole(isInWorld)) { + if (isDisableByWorldWarpHole(isInWorld)) return false; - } - if (mWorldIndex != curWorldId || unkBool2 || isGameClear) { + if (mWorldIndex != curWorldId || unkBool2 || isGameClear) return false; - } - if (mProgressBitflag.countOnBit()) { + if (mProgressBitflag.countOnBit()) return mProgressBitflag.isOnBit(scenarioNo - 1); - } return true; } diff --git a/src/Util/StageSceneFunction.cpp b/src/Util/StageSceneFunction.cpp index 599f207b..f2d55418 100644 --- a/src/Util/StageSceneFunction.cpp +++ b/src/Util/StageSceneFunction.cpp @@ -20,9 +20,8 @@ bool rs::updateJudgeAndResult(IJudge* judge) { } bool rs::judgeAndResetReturnTrue(IJudge* judge) { - if (!judge->judge()) { + if (!judge->judge()) return false; - } judge->reset();