From e018f6c8fd7128f080ae00ebe6351fa7c8b07ca0 Mon Sep 17 00:00:00 2001 From: Edo Date: Thu, 4 May 2023 18:40:38 +0100 Subject: [PATCH] [Voice]: Add debug print (#1009) --- src/Components/Modules/Voice.cpp | 1 + src/Game/Engine/FastCriticalSection.cpp | 39 +++++++++++++++++++++++++ src/Game/Engine/FastCriticalSection.hpp | 24 +++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 src/Game/Engine/FastCriticalSection.cpp create mode 100644 src/Game/Engine/FastCriticalSection.hpp diff --git a/src/Components/Modules/Voice.cpp b/src/Components/Modules/Voice.cpp index b578e9f3..5379eb6c 100644 --- a/src/Components/Modules/Voice.cpp +++ b/src/Components/Modules/Voice.cpp @@ -320,6 +320,7 @@ namespace Components auto* clc = Game::CL_GetLocalClientConnection(0); if (!Game::NET_CompareBaseAdr(clc->serverAddress, *address)) { + Logger::Debug("Ignoring stray 'v' network message from '{}'", Game::NET_AdrToString(*address)); return; } diff --git a/src/Game/Engine/FastCriticalSection.cpp b/src/Game/Engine/FastCriticalSection.cpp new file mode 100644 index 00000000..82ae7082 --- /dev/null +++ b/src/Game/Engine/FastCriticalSection.cpp @@ -0,0 +1,39 @@ +#include +#include "FastCriticalSection.hpp" + +namespace Game::Engine +{ + FastCriticalSectionScopeRead::FastCriticalSectionScopeRead(FastCriticalSection* cs) + : cs_(cs) + { + if (this->cs_) + { + Sys_LockRead(this->cs_); + } + } + + FastCriticalSectionScopeRead::~FastCriticalSectionScopeRead() + { + if (this->cs_) + { + Sys_UnlockRead(this->cs_); + } + } + + FastCriticalSectionScopeWrite::FastCriticalSectionScopeWrite(FastCriticalSection* cs) + : cs_(cs) + { + if (this->cs_) + { + Sys_LockWrite(this->cs_); + } + } + + FastCriticalSectionScopeWrite::~FastCriticalSectionScopeWrite() + { + if (this->cs_) + { + Sys_UnlockWrite(this->cs_); + } + } +} diff --git a/src/Game/Engine/FastCriticalSection.hpp b/src/Game/Engine/FastCriticalSection.hpp new file mode 100644 index 00000000..c50ba734 --- /dev/null +++ b/src/Game/Engine/FastCriticalSection.hpp @@ -0,0 +1,24 @@ +#pragma once + +namespace Game::Engine +{ + class FastCriticalSectionScopeRead + { + public: + FastCriticalSectionScopeRead(FastCriticalSection* cs); + ~FastCriticalSectionScopeRead(); + + private: + FastCriticalSection* cs_; + }; + + class FastCriticalSectionScopeWrite + { + public: + FastCriticalSectionScopeWrite(FastCriticalSection* cs); + ~FastCriticalSectionScopeWrite(); + + private: + FastCriticalSection* cs_; + }; +}