From a43b95cbaa1105fd4e591cad708364b9872beaac Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 22 Apr 2023 18:56:29 +0200 Subject: [PATCH] [General]: Small cleanup (#963) --- CHANGELOG.md | 18 ++++++++++++++++++ src/Components/Modules/Debug.cpp | 2 +- src/Components/Modules/SoundMutexFix.cpp | 14 +++++++------- src/Components/Modules/SoundMutexFix.hpp | 4 ++-- src/Game/Engine/ScopedCriticalSection.cpp | 21 ++++++++++----------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de00a75..72cfcf32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.3.0/). +## r4208 - 2023-04-22 + +### Changed + +- `Noclip` GSC method does not require `sv_cheats` to be set to "1" for it to work (#962) +- `Ufo` GSC method does not require `sv_cheats` to be set to "1" for it to work (#962) + +### Fixed + +- Fix `InfoString` output (#961) +- Fix parsing of the server info (client-side) (#953) +- Fix bug in the /info TCP endpoint (#955) + +### Known issues + +- Sound issue fix is experimental as the bug is not fully understood. + ## r4193 - 2023-04-19 ### Added @@ -20,6 +37,7 @@ The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0. ### Fixed - `sv_privatePassword` will work as intended (#908) +- Fix crash when loading bots.txt file (#927) ### Known issues diff --git a/src/Components/Modules/Debug.cpp b/src/Components/Modules/Debug.cpp index 4e7b7c95..a5c66fb3 100644 --- a/src/Components/Modules/Debug.cpp +++ b/src/Components/Modules/Debug.cpp @@ -317,7 +317,7 @@ namespace Components void Debug::Com_BugNameInc_f() { - char buf[260]{}; + char buf[512]{}; if (std::strlen(BugName->current.string) < 4) { diff --git a/src/Components/Modules/SoundMutexFix.cpp b/src/Components/Modules/SoundMutexFix.cpp index 935ffefd..5a3c66b9 100644 --- a/src/Components/Modules/SoundMutexFix.cpp +++ b/src/Components/Modules/SoundMutexFix.cpp @@ -23,18 +23,18 @@ namespace Components // team switch and intermission. // - std::mutex SoundMutexFix::SNDMutex; + std::mutex SoundMutexFix::CloseStreamMutex; - void __stdcall SoundMutexFix::LockSoundMutex(int unk) + void WINAPI SoundMutexFix::AIL_close_stream_Stub(int h_stream) { - std::lock_guard lock(SNDMutex); + std::lock_guard lock(CloseStreamMutex); - DWORD funcPtr = *reinterpret_cast(0x6D7554); // AIL_close_stream - Utils::Hook::Call(funcPtr)(unk); + const auto ptr = *reinterpret_cast(0x6D7554); // AIL_close_stream + Utils::Hook::Call(ptr)(h_stream); } SoundMutexFix::SoundMutexFix() { - Utils::Hook(0x689EFE, &LockSoundMutex, HOOK_JUMP).install()->quick(); + Utils::Hook(0x689EFE, &AIL_close_stream_Stub, HOOK_JUMP).install()->quick(); } -} \ No newline at end of file +} diff --git a/src/Components/Modules/SoundMutexFix.hpp b/src/Components/Modules/SoundMutexFix.hpp index ef62050f..5c4d8988 100644 --- a/src/Components/Modules/SoundMutexFix.hpp +++ b/src/Components/Modules/SoundMutexFix.hpp @@ -9,7 +9,7 @@ namespace Components SoundMutexFix(); private: - static std::mutex SNDMutex; - static void _stdcall LockSoundMutex(int unk); + static std::mutex CloseStreamMutex; + static void WINAPI AIL_close_stream_Stub(int h_stream); }; } diff --git a/src/Game/Engine/ScopedCriticalSection.cpp b/src/Game/Engine/ScopedCriticalSection.cpp index 9a756c94..8b62ef4f 100644 --- a/src/Game/Engine/ScopedCriticalSection.cpp +++ b/src/Game/Engine/ScopedCriticalSection.cpp @@ -10,23 +10,22 @@ namespace Game::Engine { Sys_EnterCriticalSection(this->s_); this->hasOwnership_ = true; + return; + } + + if (type == SCOPED_CRITSECT_TRY) + { + this->hasOwnership_ = Sys_TryEnterCriticalSection(this->s_); } else { - if (type == SCOPED_CRITSECT_TRY) + if (type == SCOPED_CRITSECT_RELEASE) { - this->hasOwnership_ = Sys_TryEnterCriticalSection(this->s_); + Sys_LeaveCriticalSection(this->s_); + this->isScopedRelease_ = true; } - else - { - if (type == SCOPED_CRITSECT_RELEASE) - { - Sys_LeaveCriticalSection(this->s_); - this->isScopedRelease_ = true; - } - this->hasOwnership_ = false; - } + this->hasOwnership_ = false; } }