Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Tested with clang-format 6.0.1
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: true
BraceWrapping:
Expand All @@ -21,6 +20,10 @@ BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
ColumnLimit: 120
Cpp11BracedListStyle: true
FixNamespaceComments: false
IndentCaseLabels: true
IndentWidth: 4
NamespaceIndentation: All
PointerAlignment: Left
SpaceAfterTemplateKeyword: false
SortIncludes: Never
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ jobs:
shell: cmd
working-directory: ${{github.workspace}}/build
run: cmake --build . --config %BUILD_TYPE% -j 4

check:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check formatting
run: tools/format.sh
env:
CMAKE_FORMAT_FLAGS: -n -Werror
11 changes: 4 additions & 7 deletions common/include/common/ComPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@ template<typename T>
class ComPtr
{
private:
T *m_ptr = nullptr;
T* m_ptr = nullptr;

public:
ComPtr() = default;

ComPtr(const ComPtr& other) :
m_ptr(other.m_ptr)
ComPtr(const ComPtr& other) : m_ptr(other.m_ptr)
{
if (m_ptr) {
m_ptr->AddRef();
}
}

ComPtr(ComPtr&& other) :
m_ptr(other.m_ptr)
ComPtr(ComPtr&& other) : m_ptr(other.m_ptr)
{
other.m_ptr = nullptr;
}

ComPtr(T* ptr) :
m_ptr(ptr)
ComPtr(T* ptr) : m_ptr(ptr)
{
if (m_ptr) {
m_ptr->AddRef();
Expand Down
7 changes: 3 additions & 4 deletions common/include/common/DynamicLinkLibrary.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <utility>
#include <windows.h>

class DynamicLinkLibrary
{
Expand All @@ -12,9 +13,7 @@ class DynamicLinkLibrary

DynamicLinkLibrary(const DynamicLinkLibrary& other) = delete;

DynamicLinkLibrary(DynamicLinkLibrary&& other) noexcept
: handle_(std::exchange(other.handle_, nullptr))
{}
DynamicLinkLibrary(DynamicLinkLibrary&& other) noexcept : handle_(std::exchange(other.handle_, nullptr)) {}

~DynamicLinkLibrary()
{
Expand All @@ -41,7 +40,7 @@ class DynamicLinkLibrary
{
static_assert(std::is_pointer_v<T>);
// Note: double cast is needed to fix cast-function-type GCC warning
return reinterpret_cast<T>(reinterpret_cast<void(*)()>(GetProcAddress(handle_, name)));
return reinterpret_cast<T>(reinterpret_cast<void (*)()>(GetProcAddress(handle_, name)));
}

private:
Expand Down
4 changes: 2 additions & 2 deletions common/include/common/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InternetHandle
InternetCloseHandle(m_handle);
}

InternetHandle(const InternetHandle&) = delete; // copy constructor
InternetHandle(const InternetHandle&) = delete; // copy constructor
InternetHandle& operator=(const InternetHandle&) = delete; // assignment operator

InternetHandle(InternetHandle&& other) noexcept : // move constructor
Expand All @@ -33,7 +33,7 @@ class InternetHandle
return *this;
}

InternetHandle &operator=(HINTERNET handle)
InternetHandle& operator=(HINTERNET handle)
{
if (m_handle)
InternetCloseHandle(m_handle);
Expand Down
5 changes: 3 additions & 2 deletions common/include/common/config/GameConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct GameConfig
CfgVar<bool> nearest_texture_filtering = false;
CfgVar<unsigned> msaa = 0;


CfgVar<bool> high_scanner_res = true;
CfgVar<bool> high_monitor_res = true;
CfgVar<bool> true_color_textures = true;
Expand All @@ -74,7 +73,9 @@ struct GameConfig
static constexpr unsigned default_update_rate = 200000; // T1/LAN in stock launcher
CfgVar<unsigned> update_rate = default_update_rate;

CfgVar<unsigned> force_port{0, [](auto val) { return std::min<unsigned>(val, std::numeric_limits<uint16_t>::max()); }};
CfgVar<unsigned> force_port{0, [](auto val) {
return std::min<unsigned>(val, std::numeric_limits<uint16_t>::max());
}};

// Input
CfgVar<bool> direct_input = false;
Expand Down
12 changes: 7 additions & 5 deletions common/include/common/config/RegKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class RegKey

RegKey(RegKey&& other) noexcept :
m_key(std::exchange(other.m_key, nullptr)), m_open(std::exchange(other.m_open, false))
{
}
{}

RegKey& operator=(RegKey&& other) noexcept
{
Expand Down Expand Up @@ -114,7 +113,8 @@ class RegKey
bool read_value(const char* name, float* value)
{
static_assert(sizeof(float) == sizeof(uint32_t));
union {
union
{
float f;
uint32_t u32;
} u;
Expand Down Expand Up @@ -144,7 +144,8 @@ class RegKey

void write_value(const char* name, const std::string& value)
{
LONG error = RegSetValueExA(m_key, name, 0, REG_SZ, reinterpret_cast<const BYTE*>(value.c_str()), value.size() + 1);
LONG error =
RegSetValueExA(m_key, name, 0, REG_SZ, reinterpret_cast<const BYTE*>(value.c_str()), value.size() + 1);
if (error != ERROR_SUCCESS)
throw Win32Error(error, "RegSetValueExA failed");
}
Expand All @@ -162,7 +163,8 @@ class RegKey
void write_value(const char* name, float value)
{
static_assert(sizeof(float) == sizeof(uint32_t));
union {
union
{
float f;
uint32_t u32;
} u;
Expand Down
9 changes: 2 additions & 7 deletions common/include/common/error/Win32Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
class Win32Error : public std::exception
{
public:
Win32Error(const char* msg = "") :
Win32Error(GetLastError(), msg)
{}
Win32Error(const char* msg = "") : Win32Error(GetLastError(), msg) {}

Win32Error(DWORD error, const char* msg = "") :
m_error(error),
m_what(msg)
Win32Error(DWORD error, const char* msg = "") : m_error(error), m_what(msg)
{
if (!m_what.empty())
m_what += ": ";
Expand All @@ -37,7 +33,6 @@ class Win32Error : public std::exception
std::string m_what;
};


#define S(x) #x
#define S_(x) S(x)
#define S_LINE S_(__LINE__)
Expand Down
7 changes: 5 additions & 2 deletions common/include/common/error/error-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ inline void print_exception(const std::exception& e, std::string& buf, int level
buf += '\n';
try {
std::rethrow_if_nested(e);
} catch(const std::exception& e) {
}
catch (const std::exception& e) {
print_exception(e, buf, level + 1);
} catch(...) {}
}
catch (...) {
}
}

inline std::string generate_message_for_exception(const std::exception& e)
Expand Down
Loading