Skip to content

Commit 4b64d82

Browse files
authored
Reorganize project, add custom linter (#42)
The first major refactor of this project. - Files have been reorganized to match Java Edition b1.2 and 1.14.4 locations - GitHub Actions workflows have been added to verify compilation, clang-format, and linter - `tools/lint.py` has been added, conforming some stylistic choices across the repo - Current lint checks: - - void params: `(void);` is not allowed, linter replaces with `()` - - consistent float literals: `.f` is not allowed, linter replaces with `.0f` - - newline at end of file - - absolute include paths, newline after last include - - `#pragma once` at the start of headers, newline after pragma - - no written `virtual` if a virtual function is overriden - - includes are placed at the top of a source file Current progress: **6.975%** 4036/57867 functions decompiled
1 parent 040277a commit 4b64d82

1,039 files changed

Lines changed: 8187 additions & 5156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
Language: Cpp
2+
Language: Cpp
33
AccessModifierOffset: -4
44
AlignAfterOpenBracket: Align
55
AlignConsecutiveAssignments: false
66
AlignConsecutiveDeclarations: false
7-
AlignOperands: true
7+
AlignOperands: true
88
AlignTrailingComments: true
99
AllowAllParametersOfDeclarationOnNextLine: true
1010
AllowShortBlocksOnASingleLine: Never
@@ -22,21 +22,21 @@ BreakBeforeBinaryOperators: All
2222
BreakBeforeBraces: Attach
2323
BreakBeforeTernaryOperators: false
2424
BreakConstructorInitializersBeforeComma: false
25-
ColumnLimit: 110
26-
CommentPragmas: '^ (IWYU pragma:|NOLINT)'
25+
ColumnLimit: 110
26+
CommentPragmas: "^ (IWYU pragma:|NOLINT)"
2727
ConstructorInitializerAllOnOneLineOrOnePerLine: false
2828
ConstructorInitializerIndentWidth: 4
2929
ContinuationIndentWidth: 4
3030
Cpp11BracedListStyle: true
3131
DerivePointerAlignment: false
32-
DisableFormat: false
33-
ForEachMacros: []
32+
DisableFormat: false
33+
ForEachMacros: []
3434
IndentCaseLabels: false
35-
IndentWidth: 4
35+
IndentWidth: 4
3636
IndentWrappedFunctionNames: false
3737
KeepEmptyLinesAtTheStartOfBlocks: false
38-
MacroBlockBegin: ''
39-
MacroBlockEnd: ''
38+
MacroBlockBegin: ""
39+
MacroBlockEnd: ""
4040
MaxEmptyLinesToKeep: 1
4141
NamespaceIndentation: None
4242
ObjCBlockIndentWidth: 4
@@ -50,40 +50,22 @@ PenaltyExcessCharacter: 1000000
5050
PenaltyReturnTypeOnItsOwnLine: 60
5151
PointerAlignment: Left
5252
QualifierAlignment: Left
53-
ReflowComments: true
53+
ReflowComments: true
5454
SpaceAfterCStyleCast: false
5555
SpaceBeforeAssignmentOperators: true
5656
SpaceBeforeParens: ControlStatements
5757
SpaceInEmptyParentheses: false
5858
SpacesBeforeTrailingComments: 2
59-
SpacesInAngles: false
59+
SpacesInAngles: false
6060
SpacesInContainerLiterals: true
6161
SpacesInCStyleCastParentheses: false
6262
SpacesInParentheses: false
6363
SpacesInSquareBrackets: false
6464
Standard: c++17
65-
TabWidth: 4
66-
UseTab: Never
65+
TabWidth: 4
66+
UseTab: Never
6767
WhitespaceSensitiveMacros: []
6868

6969
SortIncludes: true
7070
IncludeBlocks: Preserve
7171
IncludeIsMainRegex: '([-_a-zA-Z0-9]+)\.(h|hpp)'
72-
IncludeCategories:
73-
- Regex: '".*types\.h"'
74-
Priority: 1
75-
- Regex: '^"4J_Libraries_Source/'
76-
Priority: 2
77-
- Regex: '^"Minecraft\.Client/'
78-
Priority: 3
79-
- Regex: '^"Minecraft\.Nbt/'
80-
Priority: 4
81-
- Regex: '^"Minecraft\.Server/'
82-
Priority: 5
83-
- Regex: '^"Minecraft\.World/'
84-
Priority: 6
85-
- Regex: '^"PlatformLibraries_Source/'
86-
Priority: 7
87-
- Regex: '.*'
88-
Priority: 8
89-
...

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: lint
2+
on: [push, pull_request]
3+
jobs:
4+
clang-format:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: DoozyX/clang-format-lint-action@v0.20
9+
with:
10+
source: 'src'
11+
clangFormatVersion: 20
12+
custom-lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
- name: Set up python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.13'
22+
cache: 'pip'
23+
- name: Set up python package dependencies
24+
run: pip install pyyaml
25+
- name: Run custom code styling checks
26+
run: python3 tools/lint.py

.github/workflows/test-compile.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Based on https://raw.githubusercontent.com/MonsterDruide1/OdysseyDecomp
2+
3+
name: testcompile
4+
on: [push, pull_request]
5+
6+
jobs:
7+
test_compile:
8+
runs-on: ubuntu-24.04
9+
steps:
10+
- name: Check out project
11+
uses: actions/checkout@v4
12+
with:
13+
submodules: recursive
14+
- name: Set up dependencies
15+
run: |
16+
sudo apt update && sudo apt install -y ninja-build cmake ccache clang curl
17+
wget http://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2_amd64.deb && sudo dpkg -i libtinfo5_6.3-2_amd64.deb && rm -f libtinfo5_6.3-2_amd64.deb
18+
- name: Set up python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.13'
22+
cache: 'pip'
23+
- name: Set up python package dependencies
24+
run: pip install toml
25+
- name: Set up cache for toolchain
26+
uses: actions/cache@v4
27+
with:
28+
key: clang-401
29+
path: |
30+
toolchain/clang-4.0.1
31+
- name: Run simplified setup
32+
run: python3 tools/setup.py --project
33+
- name: Build project
34+
run: python3 tools/build.py

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ set(NN_SDK_PATCH 1)
3838
set(NN_SDK_TYPE "Release")
3939

4040
target_include_directories(mcswitch PRIVATE src)
41+
target_include_directories(mcswitch PRIVATE src/Minecraft.Client)
42+
target_include_directories(mcswitch PRIVATE src/Minecraft.World)
43+
target_include_directories(mcswitch PRIVATE src/4JLibraries_Source)
44+
target_include_directories(mcswitch PRIVATE src/PlatformLibraries_Source)
4145
target_include_directories(mcswitch PUBLIC lib/nnheaders/include)
4246

4347
target_include_directories(mcswitch PUBLIC lib/stb_image)

0 commit comments

Comments
 (0)