diff --git a/.clang-format b/.clang-format index b90bc6c..9fb6d82 100644 --- a/.clang-format +++ b/.clang-format @@ -6,4 +6,7 @@ TabWidth: 4 UseTab: Never InsertNewlineAtEOF: true SpaceInEmptyBraces: Never +PointerAlignment: Left +QualifierAlignment: Custom +QualifierOrder: [inline, static, type, const, volatile] ... diff --git a/src/core/Resolver.cpp b/src/core/Resolver.cpp index 996be6d..410ee13 100644 --- a/src/core/Resolver.cpp +++ b/src/core/Resolver.cpp @@ -9,8 +9,8 @@ static void createRelativeJump(int from, int to) { - const int instructionLength = 5; - const int relativeOffset = to - (from + instructionLength); + int const instructionLength = 5; + int const relativeOffset = to - (from + instructionLength); DWORD oldProtection; if (!VirtualProtect((void*)from, instructionLength, PAGE_EXECUTE_READWRITE, &oldProtection)) { @@ -36,7 +36,7 @@ static void createRelativeJump(int from, int to) #endif void StructResolver::initialize( - bool& initialized, bool isImplemented, int gameAddress, const void* structPtr, const char* typeName) + bool& initialized, bool isImplemented, int gameAddress, void const* structPtr, char const* typeName) { if (initialized) { #ifdef OPEN_SHC_EXE @@ -67,7 +67,7 @@ void StructResolver::initialize( } void FunctionResolver::initialize( - bool& initialized, bool isImplemented, int gameAddress, const void* funcPtr, const char* funcName) + bool& initialized, bool isImplemented, int gameAddress, void const* funcPtr, char const* funcName) { if (initialized) { #ifdef OPEN_SHC_EXE diff --git a/src/precomp/FunctionResolver.h b/src/precomp/FunctionResolver.h index af3a7a9..b90f358 100644 --- a/src/precomp/FunctionResolver.h +++ b/src/precomp/FunctionResolver.h @@ -177,7 +177,7 @@ struct FunctionResolver { }; static void initialize( - bool& initialized, bool isImplemented, int gameAddress, const void* funcPtr, const char* funcName); + bool& initialized, bool isImplemented, int gameAddress, void const* funcPtr, char const* funcName); template struct OptionFlags { enum { @@ -198,18 +198,18 @@ struct FunctionResolver { struct Resolver { private: // only use this for internal logic and declarations/definitions - static const bool isImplemented = OPEN_SHC_IMPLEMENTED(implemented); + static bool const isImplemented = OPEN_SHC_IMPLEMENTED(implemented); typedef OptionFlags Flags; struct Initializer { Initializer(); }; - static const Initializer initializer; + static Initializer const initializer; template struct FunctionPtrUnifier; template struct FunctionPtrUnifier { - inline static const FuncPtrType get() { return funcAddress; } + inline static FuncPtrType const get() { return funcAddress; } }; // At the moment, there is not much sense in allowing the wrapper function for the exe. @@ -218,10 +218,10 @@ struct FunctionResolver { #ifdef OPEN_SHC_DLL template struct FunctionPtrUnifier { - inline static const FuncPtrType get() { return GameFunction::get(); } + inline static FuncPtrType const get() { return GameFunction::get(); } }; template struct FunctionPtrUnifier { - inline static const FuncPtrType get() + inline static FuncPtrType const get() { return reinterpret_cast(&Wrapper::Function::call); } @@ -418,14 +418,14 @@ struct FunctionResolver { template bool FunctionResolver::AddressUsageKeeper
::initialized = false; template -const typename FunctionResolver::Resolver::Initializer +typename FunctionResolver::Resolver::Initializer const FunctionResolver::Resolver::initializer; template FunctionResolver::Resolver::Initializer::Initializer() { - const FuncPtrType funcPtr = Function::get(); - const void* func = *((void**)&funcPtr); + FuncPtrType const funcPtr = Function::get(); + void const* func = *((void**)&funcPtr); initialize(AddressUsageKeeper::initialized, isImplemented, gameAddress, func, getFuncPtrName()); } diff --git a/src/precomp/StructResolver.h b/src/precomp/StructResolver.h index 8392b3b..9383dbe 100644 --- a/src/precomp/StructResolver.h +++ b/src/precomp/StructResolver.h @@ -20,18 +20,18 @@ struct StructResolver { }; static void initialize( - bool& initialized, bool isImplemented, int gameAddress, const void* structPtr, const char* typeName); + bool& initialized, bool isImplemented, int gameAddress, void const* structPtr, char const* typeName); public: template struct Resolver { private: // only use this for internal logic and declarations/definitions - static const bool isImplemented = OPEN_SHC_IMPLEMENTED(implemented); + static bool const isImplemented = OPEN_SHC_IMPLEMENTED(implemented); struct Initializer { Initializer(); }; - static const Initializer initializer; + static Initializer const initializer; public: typedef typename InternalResolver Ptr; @@ -48,7 +48,7 @@ T* const StructResolver::InternalResolver::ptr template bool StructResolver::AddressUsageKeeper
::initialized = false; template -const typename StructResolver::Resolver::Initializer +typename StructResolver::Resolver::Initializer const StructResolver::Resolver::initializer; template diff --git a/src/precomp/TypeUtility.h b/src/precomp/TypeUtility.h index 4b24cb2..9e7afef 100644 --- a/src/precomp/TypeUtility.h +++ b/src/precomp/TypeUtility.h @@ -3,17 +3,17 @@ #include -template const char* getTypeName() +template char const* getTypeName() { static std::string cached; if (!cached.empty()) { return cached.c_str(); } - static const char* fallback = ""; + static char const* fallback = ""; - const char* sig = __FUNCSIG__; - const char* start = std::strchr(sig, '<'); - const char* end = std::strrchr(sig, '>'); + char const* sig = __FUNCSIG__; + char const* start = std::strchr(sig, '<'); + char const* end = std::strrchr(sig, '>'); if (start && end && end > start) { cached = std::string(start + 1, end); @@ -23,29 +23,29 @@ template const char* getTypeName() return cached.c_str(); } -template const char* getFuncPtrName() +template char const* getFuncPtrName() { static std::string cached; if (!cached.empty()) { return cached.c_str(); } - static const char* fallback = ""; + static char const* fallback = ""; - const char* sig = __FUNCSIG__; - const char* typePart = getTypeName(); + char const* sig = __FUNCSIG__; + char const* typePart = getTypeName(); if (!typePart) { cached = fallback; return cached.c_str(); } - const char* typeInThisSig = std::strstr(sig, typePart); + char const* typeInThisSig = std::strstr(sig, typePart); if (!typeInThisSig) { cached = fallback; return cached.c_str(); } - const char* start = typeInThisSig + std::strlen(typePart); - const char* end = std::strrchr(sig, '>'); + char const* start = typeInThisSig + std::strlen(typePart); + char const* end = std::strrchr(sig, '>'); if (start && end && end > start) { cached = std::string(start + 1, end); // 1 for comma } else {