Skip to content

Commit

Permalink
Clang: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed May 26, 2024
1 parent 215af4b commit 9cb95b5
Show file tree
Hide file tree
Showing 26 changed files with 7,304 additions and 7,244 deletions.
32 changes: 32 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
BasedOnStyle: Google
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
UseTab: Always
ReflowComments: false
AccessModifierOffset: -4
IncludeBlocks: Preserve
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: NonAssignment
SpaceInEmptyBlock: true
SpacesBeforeTrailingComments: 1
SpaceAfterTemplateKeyword: true
IndentAccessModifiers: false
IndentRequiresClause: false
IndentCaseLabels: false
IndentPPDirectives: BeforeHash
InsertNewlineAtEOF: true
BinPackArguments: true
BinPackParameters: true
PackConstructorInitializers: BinPack
NamespaceIndentation: All
Cpp11BracedListStyle: false
FixNamespaceComments: false
AlignAfterOpenBracket: DontAlign
AlignOperands: false
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowAllArgumentsOnNextLine: false
6 changes: 6 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Checks: >
-*
clang-analyzer-*
WarningsAsErrors: "*"
FormatStyle: file
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
88 changes: 44 additions & 44 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
name: Linux

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

env:
BUILD_TYPE: Release
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3

- name: Build
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=".vcpkg/linux.cmake" -DBUILD_TESTING=True
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build

tests:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build

- name: Tests
run: |
ctest -C ${{env.BUILD_TYPE}}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3

- name: Build
run: |
mkdir build && cd build
cmake .. --preset linux -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=True
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build

tests:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build

- name: Tests
run: |
ctest -C ${{env.BUILD_TYPE}}
104 changes: 52 additions & 52 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
name: Windows

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

env:
BUILD_TYPE: Release
BUILD_TYPE: Release

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3
- name: Vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 4a600e9fea71bd7872080cbb716797e04d30e6d3

- name: Build
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=".vcpkg/windows.cmake" -DBUILD_TESTING=True
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Build
run: |
mkdir build && cd build
cmake .. --preset windows -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=True
cmake --build . --config ${{env.BUILD_TYPE}}
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: build

tests:
runs-on: windows-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2
tests:
runs-on: windows-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: OpenCppCoverage
shell: bash
run: |
choco install -y opencppcoverage
echo "C:\Program Files\OpenCppCoverage" >> $GITHUB_PATH
- name: OpenCppCoverage
shell: bash
run: |
choco install -y opencppcoverage
echo "C:\Program Files\OpenCppCoverage" >> $GITHUB_PATH
- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build
- name: Artifact
uses: actions/download-artifact@v2
with:
name: build-artifact
path: build

- name: Tests
run: |
opencppcoverage --quiet --export_type=cobertura:opencppcoverageCoverage.xml --working_dir build --sources src -- build/Release/CoD4DM1.Tests.exe
- name: Tests
run: |
opencppcoverage --quiet --export_type=cobertura:opencppcoverageCoverage.xml --working_dir build --sources src -- build/Release/CoD4DM1.Tests.exe
- name: CodeCov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./opencppcoverageCoverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: CodeCov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./opencppcoverageCoverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# CMake
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(ClangTools)

# CPack
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
Expand Down
30 changes: 30 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 7,
"cmakeMinimumRequired": {
"major": 3,
"minor": 27,
"patch": 0
},
"configurePresets": [
{
"name": "windows",
"generator": "Visual Studio 17 2022",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": ".vcpkg/windows.cmake"
}
},
{
"name": "windows-mingw",
"generator": "MinGW Makefiles",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": ".vcpkg/windows.cmake"
}
},
{
"name": "linux",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": ".vcpkg/linux.cmake"
}
}
]
}
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
[![CodeCov](https://img.shields.io/codecov/c/github/Iswenzz/CoD4-DM1?label=codecov&logo=codecov)](https://codecov.io/gh/Iswenzz/CoD4-DM1)
[![License](https://img.shields.io/github/license/Iswenzz/CoD4-DM1?color=blue&logo=gitbook&logoColor=white)](https://github.com/Iswenzz/CoD4-DM1/blob/master/LICENSE)

Reverse of CoD4 & CoD4X ``.DM_1`` demo files with features such as parsing snapshot informations, frames, entities, clients and server messages. This project comes with a CLI and a library.
Reverse of CoD4 & CoD4X `.DM_1` demo files with features such as parsing snapshot informations, frames, entities, clients and server messages. This project comes with a CLI and a library.

## Features
* Protocol CoD4 & CoD4X 16+
* Parsing of gamestate, snapshot, frames, entities, clients, configs and server messages
* CoD4 & Q3 huffman code
* Demo reader API

- Protocol CoD4 & CoD4X 16+
- Parsing of gamestate, snapshot, frames, entities, clients, configs and server messages
- CoD4 & Q3 huffman code
- Demo reader API

## Building

Expand All @@ -21,16 +22,18 @@ Reverse of CoD4 & CoD4X ``.DM_1`` demo files with features such as parsing snaps
_Build Command:_

mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=.vcpkg/windows.cmake
cmake .. --preset windows
cmake --build .

### [Download](https://github.com/Iswenzz/CoD4-DM1/releases)

## Package

This package is available for use via [vcpkg-registry](https://github.com/Iswenzz/vcpkg-registry).

## Contributors
***Note:*** If you would like to contribute to this repository, feel free to send a pull request, and I will review your code.

**_Note:_** If you would like to contribute to this repository, feel free to send a pull request, and I will review your code.
Also feel free to post about any problems that may arise in the issues section of the repository.

<a href="https://github.com/Caball009"><img src="https://avatars.githubusercontent.com/u/82909616?v=4" height=64 style="border-radius: 50%"></a>
12 changes: 12 additions & 0 deletions cmake/ClangTools.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_custom_target(clang-tidy
COMMAND find . -type f \( -name '*.cpp' -o -name '*.hpp' \) -not -path './build/*' -exec clang-tidy --config-file=.clang-tidy {} +
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

add_custom_target(clang-format
COMMAND find . -type f \( -name '*.cpp' -o -name '*.hpp' \) -not -path './build/*' -exec clang-format -style=file -i --verbose {} +
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

set_target_properties(clang-tidy PROPERTIES FOLDER Clang)
set_target_properties(clang-format PROPERTIES FOLDER Clang)
Loading

0 comments on commit 9cb95b5

Please sign in to comment.