Skip to content

Commit

Permalink
Merge branch 'main' into feat/overhaul-mod-loading-locations
Browse files Browse the repository at this point in the history
  • Loading branch information
GeckoEidechse authored Aug 26, 2024
2 parents 5472a36 + 932735e commit a9d2ce8
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ IndentExternBlock: Indent
PointerAlignment: Left
SortIncludes: false
NamespaceIndentation: All
PackConstructorInitializers: NextLine
BreakConstructorInitializersBeforeComma: true
PackConstructorInitializers: Never
BreakConstructorInitializers: BeforeComma
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ f9bc3c9d1834cb8bd5f872b749b057c33e8b0102

# Clang format change: one-line inline functions
5b2c608b22ba272e4ab1a45adc1f43b60b1aea79

# Clang format change: see PR #775
6e9792f3651d1e0c7045c5d67312c10f91ce6962
10 changes: 8 additions & 2 deletions primedev/client/localchatwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ Color lightColors[8] = {
class AnsiEscapeParser
{
public:
explicit AnsiEscapeParser(LocalChatWriter* writer) : m_writer(writer) {}
explicit AnsiEscapeParser(LocalChatWriter* writer)
: m_writer(writer)
{
}

void HandleVal(unsigned long val)
{
Expand Down Expand Up @@ -257,7 +260,10 @@ class AnsiEscapeParser
}
};

LocalChatWriter::LocalChatWriter(Context context) : m_context(context) {}
LocalChatWriter::LocalChatWriter(Context context)
: m_context(context)
{
}

void LocalChatWriter::Write(const char* str)
{
Expand Down
24 changes: 12 additions & 12 deletions primedev/core/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ void __fileAutohook::DispatchForModule(const char* pModuleName)
hook->Dispatch();
}

ManualHook::ManualHook(const char* funcName, LPVOID func) : pHookFunc(func), ppOrigFunc(nullptr)
ManualHook::ManualHook(const char* funcName, LPVOID func)
: svFuncName(funcName)
, pHookFunc(func)
, ppOrigFunc(nullptr)
{
const size_t iFuncNameStrlen = strlen(funcName);
pFuncName = new char[iFuncNameStrlen];
memcpy(pFuncName, funcName, iFuncNameStrlen);
}

ManualHook::ManualHook(const char* funcName, LPVOID* orig, LPVOID func) : pHookFunc(func), ppOrigFunc(orig)
ManualHook::ManualHook(const char* funcName, LPVOID* orig, LPVOID func)
: svFuncName(funcName)
, pHookFunc(func)
, ppOrigFunc(orig)
{
const size_t iFuncNameStrlen = strlen(funcName);
pFuncName = new char[iFuncNameStrlen];
memcpy(pFuncName, funcName, iFuncNameStrlen);
}

bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig)
Expand All @@ -105,19 +105,19 @@ bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig)
ppOrigFunc = orig;

if (!addr)
spdlog::error("Address for hook {} is invalid", pFuncName);
spdlog::error("Address for hook {} is invalid", svFuncName);
else if (MH_CreateHook(addr, pHookFunc, ppOrigFunc) == MH_OK)
{
if (MH_EnableHook(addr) == MH_OK)
{
spdlog::info("Enabling hook {}", pFuncName);
spdlog::info("Enabling hook {}", svFuncName);
return true;
}
else
spdlog::error("MH_EnableHook failed for function {}", pFuncName);
spdlog::error("MH_EnableHook failed for function {}", svFuncName);
}
else
spdlog::error("MH_CreateHook failed for function {}", pFuncName);
spdlog::error("MH_CreateHook failed for function {}", svFuncName);

return false;
}
Expand Down
12 changes: 8 additions & 4 deletions primedev/core/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ class __autohook
__autohook() = delete;

__autohook(__fileAutohook* autohook, const char* funcName, LPVOID absoluteAddress, LPVOID* orig, LPVOID func)
: pHookFunc(func), ppOrigFunc(orig), iAbsoluteAddress(absoluteAddress)
: pHookFunc(func)
, ppOrigFunc(orig)
, iAbsoluteAddress(absoluteAddress)
{
iAddressResolutionMode = ABSOLUTE_ADDR;

Expand All @@ -152,7 +154,8 @@ class __autohook
}

__autohook(__fileAutohook* autohook, const char* funcName, const char* addrString, LPVOID* orig, LPVOID func)
: pHookFunc(func), ppOrigFunc(orig)
: pHookFunc(func)
, ppOrigFunc(orig)
{
iAddressResolutionMode = OFFSET_STRING;

Expand All @@ -168,7 +171,8 @@ class __autohook
}

__autohook(__fileAutohook* autohook, const char* funcName, const char* moduleName, const char* procName, LPVOID* orig, LPVOID func)
: pHookFunc(func), ppOrigFunc(orig)
: pHookFunc(func)
, ppOrigFunc(orig)
{
iAddressResolutionMode = PROCADDRESS;

Expand Down Expand Up @@ -278,7 +282,7 @@ class __autohook
class ManualHook
{
public:
char* pFuncName;
std::string svFuncName;

LPVOID pHookFunc;
LPVOID* ppOrigFunc;
Expand Down
42 changes: 36 additions & 6 deletions primedev/core/math/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@ class Vector3
public:
float x, y, z;

Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
Vector3(float _f) : x(_f), y(_f), z(_f) {}
Vector3() : x(0.0f), y(0.0f), z(0.0f) {}
Vector3(float _x, float _y, float _z)
: x(_x)
, y(_y)
, z(_z)
{
}
Vector3(float _f)
: x(_f)
, y(_f)
, z(_f)
{
}
Vector3()
: x(0.0f)
, y(0.0f)
, z(0.0f)
{
}

inline bool IsValid() { return IsFinite(x) && IsFinite(y) && IsFinite(z); }

Expand Down Expand Up @@ -302,9 +317,24 @@ class QAngle
float y;
float z;

QAngle(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
QAngle(float _f) : x(_f), y(_f), z(_f) {}
QAngle() : x(0.0f), y(0.0f), z(0.0f) {}
QAngle(float _x, float _y, float _z)
: x(_x)
, y(_y)
, z(_z)
{
}
QAngle(float _f)
: x(_f)
, y(_f)
, z(_f)
{
}
QAngle()
: x(0.0f)
, y(0.0f)
, z(0.0f)
{
}

Vector3 GetNormal() const;

Expand Down
9 changes: 7 additions & 2 deletions primedev/logging/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class ColoredLogger;
struct custom_log_msg : spdlog::details::log_msg
{
public:
custom_log_msg(ColoredLogger* origin, spdlog::details::log_msg msg) : origin(origin), spdlog::details::log_msg(msg) {}
custom_log_msg(ColoredLogger* origin, spdlog::details::log_msg msg)
: origin(origin)
, spdlog::details::log_msg(msg)
{
}

ColoredLogger* origin;
};
Expand All @@ -38,7 +42,8 @@ class ColoredLogger : public spdlog::logger

std::vector<std::shared_ptr<CustomSink>> custom_sinks_;

ColoredLogger(std::string name, Color color, bool first = false) : spdlog::logger(*spdlog::default_logger())
ColoredLogger(std::string name, Color color, bool first = false)
: spdlog::logger(*spdlog::default_logger())
{
name_ = std::move(name);
if (!first)
Expand Down
7 changes: 6 additions & 1 deletion primedev/masterserver/masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,12 @@ void ConCommand_ns_fetchservers(const CCommand& args)
g_pMasterServerManager->RequestServerList();
}

MasterServerManager::MasterServerManager() : m_pendingConnectionInfo {}, m_sOwnServerId {""}, m_sOwnClientAuthToken {""} {}
MasterServerManager::MasterServerManager()
: m_pendingConnectionInfo {}
, m_sOwnServerId {""}
, m_sOwnClientAuthToken {""}
{
}

ON_DLL_LOAD_RELIESON("engine.dll", MasterServer, (ConCommand, ServerPresence), (CModule module))
{
Expand Down
3 changes: 2 additions & 1 deletion primedev/plugins/interfaces/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

InterfaceReg* s_pInterfaceRegs;

InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char* pName) : m_pName(pName)
InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char* pName)
: m_pName(pName)
{
m_CreateFn = fn;
m_pNext = s_pInterfaceRegs;
Expand Down
3 changes: 2 additions & 1 deletion primedev/plugins/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ bool isValidSquirrelIdentifier(std::string s)
return true;
}

Plugin::Plugin(std::string path) : m_location(path)
Plugin::Plugin(std::string path)
: m_location(path)
{
HMODULE pluginModule = GetModuleHandleA(path.c_str());

Expand Down
3 changes: 2 additions & 1 deletion primedev/squirrel/squirrelclasstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class SquirrelAsset
{
public:
std::string path;
SquirrelAsset(std::string path) : path(path) {};
SquirrelAsset(std::string path)
: path(path) {};
};

#pragma region TypeDefs
Expand Down
5 changes: 4 additions & 1 deletion primedev/util/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ template <typename T> class ScopeGuard
auto operator=(ScopeGuard&) = delete;
ScopeGuard(ScopeGuard&) = delete;

ScopeGuard(T callback) : m_callback(callback) {}
ScopeGuard(T callback)
: m_callback(callback)
{
}
~ScopeGuard()
{
if (!m_dismissed)
Expand Down

0 comments on commit a9d2ce8

Please sign in to comment.