Skip to content

Commit

Permalink
Custom format validation (Linting) (#17)
Browse files Browse the repository at this point in the history
* Add script to verify formatting
* Add newline to end of files
* Add `#pragma once` to top of headers
* Add own header to includes at top of source files
* Remove useless namespace qualifiers
* Sort visibility modifiers correctly
* Format `#include`s in three blocks
* Remove `;` after namespaces
* Add for custom style checking to `lint`-GitHub-Action
* Format: No "// 0x" offset comments
* Remove macros from padding
  • Loading branch information
MonsterDruide1 authored Jan 6, 2024
1 parent 4a231bb commit 69d81eb
Show file tree
Hide file tree
Showing 141 changed files with 641 additions and 324 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ jobs:
source: 'src lib'
exclude: 'lib/NintendoSDK lib/aarch64 lib/agl lib/eui lib/sead'
clangFormatVersion: 12
custom-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- 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: Run custom code styling checks
run: tools/check-format.py
8 changes: 7 additions & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Before opening a PR, please format your code with clang-format 12 and ensure the
### Includes

* Use `#include "..."` when including `al` and `rs` (SMO) header files.
* Include paths should be relative to lib/.
* Include paths should be relative to `lib/al` or `src`.
* OK: `#include "Library/LiveActor/LiveActor.h"`
* Not OK: `#include "LiveActor.h"`

Expand All @@ -132,6 +132,12 @@ Before opening a PR, please format your code with clang-format 12 and ensure the
* sead (e.g. `<prim/seadSafeString.h>`)
* Other Nintendo libraries like agl, eui, ...

* Format `#include`s in three blocks, separating them by one empty line.
* First up, all includes with angle brackets (`<>`)
* Then, all includes from `al`, starting with `Library` and `Project` (`""`)
* Finally, all game headers with no common prefix (`""`)
* For ordering within the blocks, run `clang-format`

### Naming

* Type names (classes/structs, enums, typedefs/alias declarations) and compile-time constants should be in UpperCamelCase.
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ Anyone is welcome to contribute to this project, just send a pull request!
- Find proper place for Factories (+Placement of ActorFactory?)
- Graph in Rails misordered
- LiveActorGroup vs. Kit are in the wrong order
- Merge LiveActor/-flag
- Split files/functions in Library/Resource
- Library/Stage: Proper place for StageInfo
- Library/Math: Split up into multiple files
Expand Down
4 changes: 2 additions & 2 deletions data/odyssey_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -29988,7 +29988,7 @@ Address,Quality,Size,Name
0x00000071004b5dc0,U,000008,_ZNK2al7FactoryIPFP15PlayerActorBasePKcEE11convertNameES4_
0x00000071004b5dc8,U,000052,_Z20createPlayerFunctionI19PlayerActorHakoniwaEP15PlayerActorBasePKc
0x00000071004b5dfc,U,000052,_Z20createPlayerFunctionI18YukimaruRacePlayerEP15PlayerActorBasePKc
0x00000071004b5e30,O,000076,_ZN2al19ProjectActorFactoryC1Ev
0x00000071004b5e30,O,000076,_ZN19ProjectActorFactoryC2Ev
0x00000071004b5e7c,O,000008,_ZNK2al7FactoryIPFPNS_9LiveActorEPKcEE11convertNameES4_
0x00000071004b5e84,U,000052,_ZN2al19createActorFunctionI14AchievementNpcEEPNS_9LiveActorEPKc
0x00000071004b5eb8,U,000056,_ZN2al19createActorFunctionI9AirBubbleEEPNS_9LiveActorEPKc
Expand Down Expand Up @@ -30551,7 +30551,7 @@ Address,Quality,Size,Name
0x00000071004be198,U,000164,_ZN2al12PrePassLightINS_12LppSpotParamEE14trySetupShadowEiPN3agl4lght12LightPrePassEPNS_14ShadowDirectorE
0x00000071004be23c,U,000008,_ZNK2al12PrePassLightINS_12LppSpotParamEE12getLightTypeEv
0x00000071004be244,U,000036,_ZN2al12PrePassLightINS_12LppSpotParamEED0Ev
0x00000071004be268,O,000076,_ZN2al26ProjectAppearSwitchFactoryC1Ev
0x00000071004be268,O,000076,_ZN26ProjectAppearSwitchFactoryC1Ev
0x00000071004be2b4,U,000052,_ZN2al19createActorFunctionI23AppearSwitchFixMapPartsEEPNS_9LiveActorEPKc
0x00000071004be2e8,U,000052,_ZN2al19createActorFunctionI24AppearSwitchFallMapPartsEEPNS_9LiveActorEPKc
0x00000071004be31c,U,000096,_ZN18ProjectAreaFactoryC2Ev
Expand Down
22 changes: 11 additions & 11 deletions lib/al/include/Library/Area/AreaInitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ class SceneObjHolder;
class AreaInitInfo {
public:
AreaInitInfo();
AreaInitInfo(const al::PlacementInfo& placementInfo,
al::StageSwitchDirector* stageSwitchDirector, al::SceneObjHolder* sceneObjHolder);
AreaInitInfo(const al::PlacementInfo& placementInfo, const al::AreaInitInfo& initInfo);
AreaInitInfo(const PlacementInfo& placementInfo, StageSwitchDirector* stageSwitchDirector,
SceneObjHolder* sceneObjHolder);
AreaInitInfo(const PlacementInfo& placementInfo, const AreaInitInfo& initInfo);

void set(const al::PlacementInfo& placementInfo, al::StageSwitchDirector* stageSwitchDirector,
al::SceneObjHolder* sceneObjHolder);
void set(const PlacementInfo& placementInfo, StageSwitchDirector* stageSwitchDirector,
SceneObjHolder* sceneObjHolder);

const al::PlacementInfo& getPlacementInfo() const { return mPlacementInfo; }
al::StageSwitchDirector* getStageSwitchDirector() const { return mStageSwitchDirector; }
al::SceneObjHolder* getSceneObjHolder() const { return mSceneObjHolder; }
const PlacementInfo& getPlacementInfo() const { return mPlacementInfo; }
StageSwitchDirector* getStageSwitchDirector() const { return mStageSwitchDirector; }
SceneObjHolder* getSceneObjHolder() const { return mSceneObjHolder; }

private:
al::PlacementInfo mPlacementInfo;
al::StageSwitchDirector* mStageSwitchDirector;
al::SceneObjHolder* mSceneObjHolder;
PlacementInfo mPlacementInfo;
StageSwitchDirector* mStageSwitchDirector;
SceneObjHolder* mSceneObjHolder;
};
} // namespace al
1 change: 1 addition & 0 deletions lib/al/include/Library/Area/AreaShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <math/seadBoundBox.h>
#include <math/seadMatrix.h>
#include <math/seadVector.h>

#include "Library/Factory/Factory.h"
#include "Library/HostIO/HioNode.h"

Expand Down
11 changes: 6 additions & 5 deletions lib/al/include/Library/Audio/AudioDirector.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <container/seadPtrArray.h>

#include "Library/Area/IUseAreaObj.h"
#include "Library/Audio/IAudioSystemPause.h"
#include "Library/HostIO/HioNode.h"
Expand Down Expand Up @@ -33,19 +34,19 @@ class AudioDirector : public IUseAreaObj, public HioNode, public IAudioSystemPau
};

AudioDirector();
void init(const al::AudioDirectorInitInfo& info);
void init3D(const al::AudioDirectorInitInfo& info);
void init(const AudioDirectorInitInfo& info);
void init3D(const AudioDirectorInitInfo& info);
void initAfterInitPlacement();
void initMic(al::AudioMic* mic);
void setDependentModule(al::AudioDirector* director);
void initMic(AudioMic* mic);
void setDependentModule(AudioDirector* director);
void updatePre();
void updatePost();
void startFinalizeUnsafeModuleInParallelThread();
void updateFinalizeUnsafeModuleInParallelThread();
bool isFinalizedUnsafeModuleInParallelThread();
void finalize();
bool isSystemPauseNow() const;
void setPlayerHolder(const al::PlayerHolder* player_holder);
void setPlayerHolder(const PlayerHolder* player_holder);
void addAudiioFrameProccess(aal::IAudioFrameProcess* process);
void removeAudiioFrameProccess(aal::IAudioFrameProcess* process);
void* getAudioMaximizer() const; // unknown return type
Expand Down
1 change: 1 addition & 0 deletions lib/al/include/Library/Audio/AudioKeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <math/seadMatrix.h>
#include <math/seadVector.h>

#include "Library/HostIO/HioNode.h"

namespace al {
Expand Down
1 change: 1 addition & 0 deletions lib/al/include/Library/Camera/CameraDirector.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <math/seadMatrix.h>

#include "Library/Execute/IUseExecutor.h"
#include "Library/HostIO/HioNode.h"

Expand Down
5 changes: 2 additions & 3 deletions lib/al/include/Library/Camera/CameraPoserFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ bool isInvalidEndEntranceCamera(const al::CameraPoser*);
bool isPause(const al::CameraPoser*);
void checkFirstCameraCollisionArrow(sead::Vector3f*, sead::Vector3f*, const al::IUseCollision*,
const sead::Vector3f&, const sead::Vector3f&);
void checkFirstCameraCollisionArrow(alCameraPoserFunction::CameraCollisionHitResult*,
const al::IUseCollision*, const sead::Vector3f&,
const sead::Vector3f&);
void checkFirstCameraCollisionArrow(CameraCollisionHitResult*, const al::IUseCollision*,
const sead::Vector3f&, const sead::Vector3f&);
void checkFirstCameraCollisionArrowOnlyCeiling(sead::Vector3f*, sead::Vector3f*,
const al::IUseCollision*, const sead::Vector3f&,
const sead::Vector3f&);
Expand Down
1 change: 1 addition & 0 deletions lib/al/include/Library/Camera/SnapShotCameraCtrl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <gfx/seadCamera.h>

#include "Library/Audio/IUseAudioKeeper.h"
#include "Library/Nerve/NerveExecutor.h"
#include "Library/Yaml/ByamlIter.h"
Expand Down
1 change: 1 addition & 0 deletions lib/al/include/Library/Collision/CollisionDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <container/seadPtrArray.h>
#include <math/seadVector.h>
#include <prim/seadDelegate.h>

#include "Library/Execute/IUseExecutor.h"

namespace al {
Expand Down
50 changes: 25 additions & 25 deletions lib/al/include/Library/Controller/JoyPadAccelPoseAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class JoyPadAccelPoseAnalyzer {
public:
void calcHistory(sead::Vector3f const&, sead::Vector3f const&, f32);

unsigned char padding_0[0x60]; // 0x0 - 0x60
f32 hist0; // 0x60
unsigned char padding_0[0x60];
f32 hist0;
unsigned char padding_1[0x70 - 0x64];
f32 hist1; // 0x70
f32 hist1;
unsigned char padding_2[0x1c];
};

Expand All @@ -22,7 +22,7 @@ class JoyPadAccelPoseAnalyzer {
void calcHistory(sead::Vector3f const&, sead::Vector3f const&);

unsigned char padding_1[0x88];
sead::Vector2f unkVec0; // 0x18
sead::Vector2f unkVec0;
unsigned char padding_0[0x98 - (0x88 + 0x8)];
};

Expand All @@ -38,27 +38,27 @@ class JoyPadAccelPoseAnalyzer {
void update();
JoyPadAccelPoseAnalyzer getSwingDirDoubleHandSameDir() const;

s32 mControllerPort; // 0x0 port of the controller
s32 mAccelDeviceNum; // 0x4 number of accelerometers
bool gap00; // 0x8 unknown
bool mSwingLeft; // 0x9 shaking the left joycon
bool mSwingRight; // 0xa shaking the right joycon
bool mSwingAny; // 0xb shaking anything
sead::Vector2f mSwingBorder; // 0xc Border to trigger a motion shake
sead::Vector2f mAccelLeftVel; // 0x14 Accelerometer of the Left Joycon
sead::Vector2f mAccelRightVel; // 0x1c Accelerometer of the Right Joycon
sead::Vector2f mAccelCombinedVel; // 0x24 Combined vectors of the left and right joycons
sead::Vector2f mAccelLeftAccel; // 0x2c Acceleration of the left joycon
sead::Vector2f mAccelRightAccel; // 0x34 Acceleration of the right joycon
sead::Vector2f mGyroRoll; // 0x3c Roll of the gyroscope, each component is left/right joycon.
unsigned char padding_0[0x4]; // 0x44 padding because there is nothing here
HistoryInfo mHistoryLeft; // 0x48 History info of the left joycon
HistoryInfo mHistoryRight; // 0xd8 History info of the right joycon
bool gap01; // 0x168 unknown bool
unsigned char padding_1[0x7]; // 0x16a padding because there is nothing here
PoseAxisDir unknown0; // 0x170
PoseAxisDir unknown1; // 0x208
PoseAxisDir unknown2; // 0x2a0
s32 mControllerPort; // port of the controller
s32 mAccelDeviceNum; // number of accelerometers
bool gap00; // unknown
bool mSwingLeft; // shaking the left joycon
bool mSwingRight; // shaking the right joycon
bool mSwingAny; // shaking anything
sead::Vector2f mSwingBorder; // Border to trigger a motion shake
sead::Vector2f mAccelLeftVel; // Accelerometer of the Left Joycon
sead::Vector2f mAccelRightVel; // Accelerometer of the Right Joycon
sead::Vector2f mAccelCombinedVel; // Combined vectors of the left and right joycons
sead::Vector2f mAccelLeftAccel; // Acceleration of the left joycon
sead::Vector2f mAccelRightAccel; // Acceleration of the right joycon
sead::Vector2f mGyroRoll; // Roll of the gyroscope, each component is left/right joycon.
unsigned char padding_0[0x4]; // padding because there is nothing here
HistoryInfo mHistoryLeft; // History info of the left joycon
HistoryInfo mHistoryRight; // History info of the right joycon
bool gap01; // unknown bool
unsigned char padding_1[0x7]; // padding because there is nothing here
PoseAxisDir unknown0;
PoseAxisDir unknown1;
PoseAxisDir unknown2;
};

} // namespace al
3 changes: 2 additions & 1 deletion lib/al/include/Library/Execute/ExecuteTablesImpl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "Library/Execute/ExecuteOrder.h"
#include "Library/Execute/ExecuteTable.h"

#include "Library/Execute/ExecuteTableHolderDraw.h"
#include "Library/Execute/ExecuteTableHolderUpdate.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/al/include/Library/HitSensor/HitSensorKeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class HitSensorKeeper {
s32 mSensorCount;
HitSensor** mSensors;
};
}; // namespace al
} // namespace al
2 changes: 1 addition & 1 deletion lib/al/include/Library/HostIO/HioNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class HioNode : public IUseHioNode {
public:
// ??
};
}; // namespace al
} // namespace al
2 changes: 1 addition & 1 deletion lib/al/include/Library/HostIO/IUseName.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ class IUseName {
public:
virtual const char* getName() const = 0;
};
}; // namespace al
} // namespace al
1 change: 1 addition & 0 deletions lib/al/include/Library/Layout/LayoutActor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <prim/seadSafeString.h>

#include "Library/Audio/IUseAudioKeeper.h"
#include "Library/Camera/IUseCamera.h"
#include "Library/Effect/IUseEffectKeeper.h"
Expand Down
5 changes: 3 additions & 2 deletions lib/al/include/Library/LiveActor/ActorInitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <math/seadMatrix.h>
#include <math/seadVector.h>
#include <prim/seadSafeString.h>

#include "Library/LiveActor/ActorSceneInfo.h"
#include "Library/Nerve/NerveUtil.h"
#include "Library/Placement/PlacementInfo.h"
Expand Down Expand Up @@ -95,8 +96,8 @@ class ActorInitInfo {

void initActor(LiveActor* actor, const ActorInitInfo& initInfo);
void initActorSuffix(LiveActor* actor, const ActorInitInfo& initInfo, const char* suffix);
void initActorChangeModel(al::LiveActor* actor, const al::ActorInitInfo& initInfo);
void initActorChangeModelSuffix(al::LiveActor* actor, const al::ActorInitInfo& initInfo,
void initActorChangeModel(LiveActor* actor, const ActorInitInfo& initInfo);
void initActorChangeModelSuffix(LiveActor* actor, const ActorInitInfo& initInfo,
const char* suffix);
void initActorWithArchiveName(LiveActor* actor, const ActorInitInfo& initInfo,
const sead::SafeString& archiveName, const char* suffix);
Expand Down
27 changes: 13 additions & 14 deletions lib/al/include/Library/LiveActor/ActorPoseKeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <math/seadMatrix.h>
#include <math/seadQuat.h>
#include <math/seadVector.h>
#include "math/seadVectorFwd.h"

namespace al {

Expand Down Expand Up @@ -255,9 +254,9 @@ void makeMtxSRT(sead::Matrix34f*, const LiveActor* actor);
void makeMtxRT(sead::Matrix34f*, const LiveActor* actor);
void makeMtxR(sead::Matrix34f*, const LiveActor* actor);
void calcAnimFrontGravityPos(LiveActor* actor, const sead::Vector3f&);
const sead::Vector3f& getGravity(const al::LiveActor* actor);
const sead::Vector3f& getTrans(const al::LiveActor* actor);
const sead::Vector3f& getScale(const al::LiveActor* actor);
const sead::Vector3f& getGravity(const LiveActor* actor);
const sead::Vector3f& getTrans(const LiveActor* actor);
const sead::Vector3f& getScale(const LiveActor* actor);
void copyPose(LiveActor* actor, const LiveActor* target);
void updatePoseTrans(LiveActor* actor, const sead::Vector3f&);
void updatePoseRotate(LiveActor* actor, const sead::Vector3f&);
Expand All @@ -278,7 +277,7 @@ void calcDistanceSignLocalZDir(const LiveActor* actor, const sead::Vector3f&);
void calcDistanceLocalXDir(const LiveActor* actor, const sead::Vector3f&);
void calcDistanceLocalYDir(const LiveActor* actor, const sead::Vector3f&);
void calcDistanceLocalZDir(const LiveActor* actor, const sead::Vector3f&);
sead::Vector3f* getTransPtr(al::LiveActor* actor);
sead::Vector3f* getTransPtr(LiveActor* actor);
void setTrans(LiveActor* actor, f32, f32, f32);
void setTransX(LiveActor* actor, f32);
void setTransY(LiveActor* actor, f32);
Expand All @@ -291,9 +290,9 @@ void setRotateY(LiveActor* actor, f32);
void setRotateZ(LiveActor* actor, f32);
void getScalePtr(LiveActor* actor);
bool tryGetScalePtr(LiveActor* actor);
f32 getScaleX(const al::LiveActor* actor);
f32 getScaleY(const al::LiveActor* actor);
f32 getScaleZ(const al::LiveActor* actor);
f32 getScaleX(const LiveActor* actor);
f32 getScaleY(const LiveActor* actor);
f32 getScaleZ(const LiveActor* actor);
void setScale(LiveActor* actor, const sead::Vector3f&);
void setScale(LiveActor* actor, f32, f32, f32);
void setScaleAll(LiveActor* actor, f32);
Expand All @@ -312,17 +311,17 @@ bool isUpTarget(const LiveActor* actor, const sead::Vector3f&);
bool isUpDir(const LiveActor* actor, const sead::Vector3f&);
bool isDownTarget(const LiveActor* actor, const sead::Vector3f&);
bool isDownDir(const LiveActor* actor, const sead::Vector3f&);
const sead::Quatf& getQuat(const al::LiveActor* actor);
sead::Quatf* getQuatPtr(al::LiveActor* actor);
const sead::Quatf& getQuat(const LiveActor* actor);
sead::Quatf* getQuatPtr(LiveActor* actor);
bool tryGetQuatPtr(LiveActor* actor);
void setQuat(LiveActor* actor, const sead::Quatf&);
void getGravityPtr(const LiveActor* actor);
void setGravity(const LiveActor* actor, const sead::Vector3f&);
const sead::Vector3f& getFront(const al::LiveActor* actor);
sead::Vector3f* getFrontPtr(al::LiveActor* actor);
const sead::Vector3f& getFront(const LiveActor* actor);
sead::Vector3f* getFrontPtr(LiveActor* actor);
void setFront(LiveActor* actor, const sead::Vector3f&);
const sead::Vector3f& getUp(const al::LiveActor* actor);
sead::Vector3f* getUpPtr(al::LiveActor* actor);
const sead::Vector3f& getUp(const LiveActor* actor);
sead::Vector3f* getUpPtr(LiveActor* actor);
void setUp(LiveActor* actor, const sead::Vector3f&);
void multVecPoseNoTrans(sead::Vector3f*, const LiveActor* actor, const sead::Vector3f&);
void multVecPose(sead::Vector3f*, const LiveActor* actor, const sead::Vector3f&);
Expand Down
Loading

0 comments on commit 69d81eb

Please sign in to comment.