From 06ed9fc641e16db1463a23883279d4efeedcb0e8 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Thu, 5 Oct 2023 22:38:02 +0200 Subject: [PATCH] Add workflow for verify --- .github/workflows/compile-check.yml | 57 +++++++++++++++++++ .github/workflows/lint.yml | 12 ++++ README.md | 2 +- .../Library/LiveActor/SubActorKeeper.h | 44 ++++---------- lib/al/include/Library/Math/MathAngleUtil.h | 15 +++-- lib/al/include/Library/Matrix/MatrixUtil.h | 57 ++++++++++++------- lib/al/src/Library/Area/AreaShapeCube.cpp | 17 ++++-- .../LiveActor/ActorMovementFunction.cpp | 1 - lib/al/src/Library/Obj/PartsModel.cpp | 2 +- src/Scene/ProjectAppearSwitchFactory.cpp | 39 ++++++------- 10 files changed, 161 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/compile-check.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/compile-check.yml b/.github/workflows/compile-check.yml new file mode 100644 index 00000000..4bbe858c --- /dev/null +++ b/.github/workflows/compile-check.yml @@ -0,0 +1,57 @@ +name: Compile and verify functions +on: [push, pull_request] + +jobs: + compile_verify: + runs-on: ubuntu-latest + steps: + - name: Check out project + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Check for W-state functions + run: | + if grep -q ",W," "data/odyssey_functions.csv"; then + echo "Function list should not contain WIP-functions!" + echo "Found the following lines:" + grep ",W," "data/odyssey_functions.csv" + exit 1 + fi + - name: Set up dependencies + run: | + sudo apt install -y python3-pip ninja-build cmake ccache xdelta3 clang libssl-dev python-is-python3 curl libncurses5 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' + - name: Set up python package dependencies + run: pip install capstone colorama cxxfilt pyelftools ansiwrap watchdog python-Levenshtein toml + - name: Set up rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.5.0 + with: + cache: false + - name: Set up rust caching + uses: Swatinem/rust-cache@v2 + with: + workspaces: "tools/common/viking" + cache-directories: | + toolchain/clang-3.9.1 + toolchain/clang-4.0.1 + - name: Download main.nso from secret + env: + EXEFS_SHARED_PASS: ${{ secrets.EXEFS_SHARED_PASS }} + run: curl -u "github-odyssey:$EXEFS_SHARED_PASS" https://monsterdruide.one/secrets/smo-main.nso -O + - name: Run setup + run: tools/setup.py smo-main.nso + - name: Build project + run: tools/build.py + - name: Verify function states + run: | + var="$(tools/check 2>&1)" + if [[ "$var" == "OK" ]]; then + exit 0 + else + echo $var; + exit 1 + fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..e87d5709 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,12 @@ +name: lint +on: [push, pull_request] +jobs: + clang-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.12 + with: + source: 'src lib' + exclude: 'lib/NintendoSDK lib/aarch64 lib/agl lib/eui lib/sead' + clangFormatVersion: 12 diff --git a/README.md b/README.md index 6aa147e2..b2c95fe1 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The instructions below assume that you are using Linux (native or WSL) or macOS. Ubuntu users can install those dependencies by running: ```shell -sudo apt install python3 ninja-build cmake ccache xdelta3 clang libssl-dev +sudo apt install python3 ninja-build cmake ccache xdelta3 clang libssl-dev libncurses5 ``` Additionally, you'll also need: diff --git a/lib/al/include/Library/LiveActor/SubActorKeeper.h b/lib/al/include/Library/LiveActor/SubActorKeeper.h index b5d2a2d6..c1f7446e 100644 --- a/lib/al/include/Library/LiveActor/SubActorKeeper.h +++ b/lib/al/include/Library/LiveActor/SubActorKeeper.h @@ -11,39 +11,17 @@ public: CLASS(const CLASS& c) : m_value(c.m_value) {} \ CLASS(s32 i) : m_value(i) {} \ CLASS(Enum e) : m_value(e) {} \ - operator s32() const { \ - return m_value; \ - } \ - bool operator==(const CLASS& c) const { \ - return m_value == c.m_value; \ - } \ - bool operator==(const Enum& e) const { \ - return m_value == e; \ - } \ - bool operator!=(const CLASS& c) const { \ - return m_value != c.m_value; \ - } \ - bool operator!=(const Enum& e) const { \ - return m_value != e; \ - } \ - CLASS operator|(const CLASS& c) const { \ - return CLASS(m_value | c.m_value); \ - } \ - CLASS operator|(const Enum& e) const { \ - return CLASS(m_value | e); \ - } \ - CLASS operator&(const CLASS& c) const { \ - return CLASS(m_value & c.m_value); \ - } \ - CLASS operator&(const Enum& e) const { \ - return CLASS(m_value & e); \ - } \ - CLASS operator^(const CLASS& c) const { \ - return CLASS(m_value ^ c.m_value); \ - } \ - CLASS operator^(const Enum& e) const { \ - return CLASS(m_value ^ e); \ - } \ + operator s32() const { return m_value; } \ + bool operator==(const CLASS& c) const { return m_value == c.m_value; } \ + bool operator==(const Enum& e) const { return m_value == e; } \ + bool operator!=(const CLASS& c) const { return m_value != c.m_value; } \ + bool operator!=(const Enum& e) const { return m_value != e; } \ + CLASS operator|(const CLASS& c) const { return CLASS(m_value | c.m_value); } \ + CLASS operator|(const Enum& e) const { return CLASS(m_value | e); } \ + CLASS operator&(const CLASS& c) const { return CLASS(m_value & c.m_value); } \ + CLASS operator&(const Enum& e) const { return CLASS(m_value & e); } \ + CLASS operator^(const CLASS& c) const { return CLASS(m_value ^ c.m_value); } \ + CLASS operator^(const Enum& e) const { return CLASS(m_value ^ e); } \ CLASS& operator|=(const CLASS& c) { \ m_value |= c.m_value; \ return *this; \ diff --git a/lib/al/include/Library/Math/MathAngleUtil.h b/lib/al/include/Library/Math/MathAngleUtil.h index 621c2e90..2bd351db 100644 --- a/lib/al/include/Library/Math/MathAngleUtil.h +++ b/lib/al/include/Library/Math/MathAngleUtil.h @@ -10,11 +10,13 @@ f32 calcAngleDegree(const sead::Vector3f&, const sead::Vector3f&); f32 calcAngleDegree(const sead::Vector2f&, const sead::Vector2f&); f32 calcAngleOnPlaneRadian(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); f32 calcAngleOnPlaneDegree(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -f32 calcAngleOnPlaneDegreeOrZero(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); +f32 calcAngleOnPlaneDegreeOrZero(const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); s32 calcAngleSignOnPlane(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); bool tryCalcAngleDegree(f32*, const sead::Vector3f&, const sead::Vector3f&); -bool tryCalcAngleOnPlaneDegree(f32*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); +bool tryCalcAngleOnPlaneDegree(f32*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); bool isNearZero(const sead::Vector2f& vec, f32 tolerance); bool isNearZero(const sead::Vector3f& vec, f32 tolerance); @@ -23,9 +25,12 @@ bool isNearAngleRadian(const sead::Vector2f&, const sead::Vector2f&, f32); bool isNearAngleRadian(const sead::Vector3f&, const sead::Vector3f&, f32); bool isNearAngleDegree(const sead::Vector2f&, const sead::Vector2f&, f32); bool isNearAngleDegree(const sead::Vector3f&, const sead::Vector3f&, f32); -bool isNearAngleRadianHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, f32, f32); -bool isNearAngleDegreeHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, f32, f32); -bool isInAngleOnPlaneDegreeHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, f32, f32, f32, f32); +bool isNearAngleRadianHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, f32, + f32); +bool isNearAngleDegreeHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, f32, + f32); +bool isInAngleOnPlaneDegreeHV(const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&, + f32, f32, f32, f32); void normalize(sead::Vector2f*, const sead::Vector2f&); void normalize(sead::Vector3f*, const sead::Vector3f&); diff --git a/lib/al/include/Library/Matrix/MatrixUtil.h b/lib/al/include/Library/Matrix/MatrixUtil.h index 46896f33..f306472d 100644 --- a/lib/al/include/Library/Matrix/MatrixUtil.h +++ b/lib/al/include/Library/Matrix/MatrixUtil.h @@ -32,29 +32,47 @@ void makeMtxUpNoSupportPos(sead::Matrix34f*, const sead::Vector3f&, const sead:: void makeMtxSideNoSupport(sead::Matrix34f*, const sead::Vector3f&); void makeMtxSideNoSupportPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&); void makeMtxQuatPos(sead::Matrix34f*, const sead::Quatf&, const sead::Vector3f&); -void makeMtxQuatScalePos(sead::Matrix34f*, const sead::Quatf&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxQuatScalePos(sead::Matrix44f*, const sead::Quatf&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxFrontUpPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxFrontSidePos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxUpFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxUpSidePos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxSideUpPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxSideFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxFollowTarget(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxProj(sead::Matrix44f*, const sead::Vector2f&, const sead::Vector3f&, const sead::Vector3f&); -void makeMtxProjFromQuatPoseUp(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, const sead::Vector3f&); -void makeMtxProjFromQuatPoseFront(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, const sead::Vector3f&); -void makeMtxProjFromQuatPoseSide(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, const sead::Vector3f&); +void makeMtxQuatScalePos(sead::Matrix34f*, const sead::Quatf&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxQuatScalePos(sead::Matrix44f*, const sead::Quatf&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxFrontUpPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxFrontSidePos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxUpFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxUpSidePos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxSideUpPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxSideFrontPos(sead::Matrix34f*, const sead::Vector3f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxFollowTarget(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxProj(sead::Matrix44f*, const sead::Vector2f&, const sead::Vector3f&, + const sead::Vector3f&); +void makeMtxProjFromQuatPoseUp(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, + const sead::Vector3f&); +void makeMtxProjFromQuatPoseFront(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, + const sead::Vector3f&); +void makeMtxProjFromQuatPoseSide(sead::Matrix44f*, const sead::Quatf&, const sead::Vector2f&, + const sead::Vector3f&); void makeMtxProjFromUp(sead::Matrix44f*, const sead::Vector2f&, const sead::Vector3f&); void rotateMtxXDirDegree(sead::Matrix34f*, const sead::Matrix34f&, f32); void rotateMtxYDirDegree(sead::Matrix34f*, const sead::Matrix34f&, f32); void rotateMtxZDirDegree(sead::Matrix34f*, const sead::Matrix34f&, f32); -void rotateMtxCenterPosXDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, f32); -void rotateMtxCenterPosAxisDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, const sead::Vector3f&, f32); -void rotateMtxCenterPosYDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, f32); -void rotateMtxCenterPosZDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, f32); -void rotateMtxCenterPosQuat(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, const sead::Quatf&); +void rotateMtxCenterPosXDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + f32); +void rotateMtxCenterPosAxisDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + const sead::Vector3f&, f32); +void rotateMtxCenterPosYDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + f32); +void rotateMtxCenterPosZDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + f32); +void rotateMtxCenterPosQuat(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, + const sead::Quatf&); bool turnMtxXDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, f32); bool turnMtxYDirDegree(sead::Matrix34f*, const sead::Matrix34f&, const sead::Vector3f&, f32); @@ -82,7 +100,8 @@ bool calcRotAxisOrZero(sead::Vector3f*, const sead::Matrix34f&); void calcMxtInvertOrtho(sead::Matrix34f*, const sead::Matrix34f&); void calcNearFarByInvProjection(f32*, f32*, const sead::Matrix44f&); void calcMovedInertiaTensor(sead::Matrix33f*, const sead::Matrix33f&, const sead::Vector3f&, f32); -void calcInertiaTensorByMovedTensorAndCenter(sead::Matrix33f*, const sead::Matrix33f&, const sead::Vector3f&, f32); +void calcInertiaTensorByMovedTensorAndCenter(sead::Matrix33f*, const sead::Matrix33f&, + const sead::Vector3f&, f32); void calcInertiaTensorSphere(sead::Matrix33f*, f32, f32); void calcInertiaTensorBox(sead::Matrix33f*, const sead::Vector3f&, f32); diff --git a/lib/al/src/Library/Area/AreaShapeCube.cpp b/lib/al/src/Library/Area/AreaShapeCube.cpp index 6b9d5a08..f4662540 100644 --- a/lib/al/src/Library/Area/AreaShapeCube.cpp +++ b/lib/al/src/Library/Area/AreaShapeCube.cpp @@ -12,18 +12,23 @@ bool AreaShapeCube::isInVolume(const sead::Vector3f& trans) const { } // bool AreaShapeCube::isInVolumeOffset(const sead::Vector3f& trans, f32 offset) const {} -// bool AreaShapeCube::calcNearestEdgePoint(sead::Vector3f* edgePoint, const sead::Vector3f& trans) const {} -// bool AreaShapeCube::checkArrowCollision(sead::Vector3f*, sead::Vector3f*, const sead::Vector3f&, const sead::Vector3f&) const {} -// bool AreaShapeCube::calcLocalBoundingBox(sead::BoundBox3f* boundingBox) const {} +// bool AreaShapeCube::calcNearestEdgePoint(sead::Vector3f* edgePoint, const sead::Vector3f& trans) +// const {} bool AreaShapeCube::checkArrowCollision(sead::Vector3f*, sead::Vector3f*, const +// sead::Vector3f&, const sead::Vector3f&) const {} bool +// AreaShapeCube::calcLocalBoundingBox(sead::BoundBox3f* boundingBox) const {} bool AreaShapeCube::isInLocalVolume(const sead::Vector3f& trans) const { - float bottom = mOriginType == OriginType::Base ? 0.0f : (mOriginType == OriginType::Top ? -1000.0f : 500.0f); - float top = mOriginType == OriginType::Base ? 1000.0f : (mOriginType == OriginType::Top ? 0.0f : 500.0f); + float bottom = mOriginType == OriginType::Base ? + 0.0f : + (mOriginType == OriginType::Top ? -1000.0f : 500.0f); + float top = mOriginType == OriginType::Base ? 1000.0f : + (mOriginType == OriginType::Top ? 0.0f : 500.0f); sead::Vector3f min = {-500.0f, bottom, -500.0f}; sead::Vector3f max = {500.0f, top, 500.0f}; - if ((trans.y < min.y || max.y < trans.y) || (trans.x < min.x || max.x < trans.x) || (trans.z < min.z || max.z < trans.z)) + if ((trans.y < min.y || max.y < trans.y) || (trans.x < min.x || max.x < trans.x) || + (trans.z < min.z || max.z < trans.z)) return false; return true; diff --git a/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp b/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp index 19c5d827..987c9e80 100644 --- a/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp +++ b/lib/al/src/Library/LiveActor/ActorMovementFunction.cpp @@ -122,5 +122,4 @@ void addVelocityZ(al::LiveActor* actor, f32 z) { currentVelocity->z += z; } - } // namespace al diff --git a/lib/al/src/Library/Obj/PartsModel.cpp b/lib/al/src/Library/Obj/PartsModel.cpp index e88c226e..fdaaacb1 100644 --- a/lib/al/src/Library/Obj/PartsModel.cpp +++ b/lib/al/src/Library/Obj/PartsModel.cpp @@ -11,8 +11,8 @@ #include "Library/LiveActor/SubActorKeeper.h" #include "Library/Math/MathAngleUtil.h" #include "Library/Math/MathLengthUtil.h" -#include "Library/Matrix/MatrixUtil.h" #include "Library/Math/MathUtil.h" +#include "Library/Matrix/MatrixUtil.h" #include "Library/Yaml/ByamlUtil.h" namespace al { diff --git a/src/Scene/ProjectAppearSwitchFactory.cpp b/src/Scene/ProjectAppearSwitchFactory.cpp index 0d4cf615..6309a140 100644 --- a/src/Scene/ProjectAppearSwitchFactory.cpp +++ b/src/Scene/ProjectAppearSwitchFactory.cpp @@ -4,25 +4,26 @@ namespace al { // FIXME fill in method references: (1.0) off_7101D89F18 -static NameToCreator sProjectAppearSwitchFactoryEntries[] = {{"FixMapParts", nullptr}, - {"FallMapParts", nullptr}, - {"CapHanger", nullptr}, - {"Coin", nullptr}, - {"CoinCollect", nullptr}, - {"FixMapPartsCapHanger", nullptr}, - {"FloaterMapParts", nullptr}, - {"KeyMoveMapParts", nullptr}, - {"MeganeMapParts", nullptr}, - {"PoleGrabCeil", nullptr}, - {"RailDrawer", nullptr}, - {"ReactionObject", nullptr}, - {"RotateMapParts", nullptr}, - {"SeesawMapParts", nullptr}, - {"Tank", nullptr}, - {"TreasureBox", nullptr}, - {"TreasureBoxKey", nullptr}, - {"WaveSurfMapParts", nullptr}, - {"WobbleMapParts", nullptr}}; +static NameToCreator sProjectAppearSwitchFactoryEntries[] = { + {"FixMapParts", nullptr}, + {"FallMapParts", nullptr}, + {"CapHanger", nullptr}, + {"Coin", nullptr}, + {"CoinCollect", nullptr}, + {"FixMapPartsCapHanger", nullptr}, + {"FloaterMapParts", nullptr}, + {"KeyMoveMapParts", nullptr}, + {"MeganeMapParts", nullptr}, + {"PoleGrabCeil", nullptr}, + {"RailDrawer", nullptr}, + {"ReactionObject", nullptr}, + {"RotateMapParts", nullptr}, + {"SeesawMapParts", nullptr}, + {"Tank", nullptr}, + {"TreasureBox", nullptr}, + {"TreasureBoxKey", nullptr}, + {"WaveSurfMapParts", nullptr}, + {"WobbleMapParts", nullptr}}; ProjectAppearSwitchFactory::ProjectAppearSwitchFactory() : ActorFactory("アクター生成") { initFactory(sProjectAppearSwitchFactoryEntries);