From f14b5d33b4c96e31cb43bcb44bd609308c595775 Mon Sep 17 00:00:00 2001 From: DevGeniusCode <136935333+DevGeniusCode@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:25:27 +0300 Subject: [PATCH] refactor: Eliminate macro-split assignments for better consistency (#2641) --- .../Source/Common/System/ArchiveFileSystem.cpp | 6 ++---- .../Source/GameNetwork/GameSpy/MainMenuUtils.cpp | 6 ++---- .../Source/GameNetwork/GameSpy/PeerDefs.cpp | 6 ++---- .../GameSpy/Thread/PersistentStorageThread.cpp | 6 ++---- Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp | 12 ++++-------- .../Tools/Launcher/Toolkit/Support/StringConvert.cpp | 6 ++---- Generals/Code/GameEngine/Source/Common/Recorder.cpp | 6 ++---- .../Object/Behavior/ParkingPlaceBehavior.cpp | 6 ++---- .../Code/GameEngine/Source/Common/Recorder.cpp | 6 ++---- .../Object/Behavior/ParkingPlaceBehavior.cpp | 6 ++---- 10 files changed, 22 insertions(+), 44 deletions(-) diff --git a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp index 77e9fde8df5..f118b34bad0 100644 --- a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp @@ -230,10 +230,8 @@ void ArchiveFileSystem::loadMods() if (TheGlobalData->m_modDir.isNotEmpty()) { -#ifdef DEBUG_LOGGING - Bool ret = -#endif - loadBigFilesFromDirectory(TheGlobalData->m_modDir, "*.big", TRUE); + MAYBE_UNUSED Bool ret = loadBigFilesFromDirectory(TheGlobalData->m_modDir, "*.big", TRUE); + (void)ret; DEBUG_ASSERTLOG(ret, ("loadBigFilesFromDirectory(%s) returned FALSE!", TheGlobalData->m_modDir.str())); } } diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp index 03116b000d2..b74533d569f 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp @@ -808,10 +808,8 @@ void StopAsyncDNSCheck() { if (s_asyncDNSThreadHandle) { -#ifdef DEBUG_CRASHING - Int res = -#endif - TerminateThread(s_asyncDNSThreadHandle,0); + MAYBE_UNUSED Int res = TerminateThread(s_asyncDNSThreadHandle, 0); + (void)res; DEBUG_ASSERTCRASH(res, ("Could not terminate the Async DNS Lookup thread!")); // Thread still not killed! } s_asyncDNSThreadHandle = nullptr; diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp index 457bdbcc707..60d4be33148 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp @@ -559,10 +559,8 @@ void GameSpyInfo::markAsStagingRoomJoiner( Int game ) GameSpyStagingRoom *info = it->second; info->cleanUpSlotPointers(); AsciiString options = GameInfoToAsciiString(info); -#ifdef DEBUG_CRASHING - Bool res = -#endif - ParseAsciiStringToGameInfo(&m_localStagingRoom, options); + MAYBE_UNUSED Bool res = ParseAsciiStringToGameInfo(&m_localStagingRoom, options); + (void)res; DEBUG_ASSERTCRASH(res, ("Could not parse game info \"%s\"", options.str())); m_localStagingRoom.setInGame(); m_localStagingRoom.setLocalName(m_localName); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp index 2c2fdd85c11..a59587533f8 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp @@ -860,10 +860,8 @@ void PSThreadClass::Thread_Function() if (tryConnect()) { NewGame(0); -#ifdef DEBUG_LOGGING - Int res = -#endif // DEBUG_LOGGING - SendGameSnapShot(nullptr, req.results.c_str(), SNAP_FINAL); + MAYBE_UNUSED Int res = SendGameSnapShot(nullptr, req.results.c_str(), SNAP_FINAL); + (void)res; DEBUG_LOG(("Just sent game results - res was %d", res)); FreeGame(nullptr); } diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp index 0a95846c39f..c5ac68b7647 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp @@ -300,10 +300,8 @@ WWINLINE void Lock_Mem_Log_Mutex() #if MEMLOG_USE_MUTEX void * mutex = Get_Mem_Log_Mutex(); -#ifdef DEBUG_CRASHING - int res = -#endif - WaitForSingleObject(mutex,INFINITE); + MAYBE_UNUSED int res = WaitForSingleObject(mutex,INFINITE); + (void)res; WWASSERT(res==WAIT_OBJECT_0); _MemLogLockCounter++; #endif @@ -344,10 +342,8 @@ WWINLINE void Unlock_Mem_Log_Mutex() void * mutex = Get_Mem_Log_Mutex(); _MemLogLockCounter--; -#ifdef DEBUG_CRASHING - int res= -#endif - ReleaseMutex(mutex); + MAYBE_UNUSED int res = ReleaseMutex(mutex); + (void)res; WWASSERT(res); #endif diff --git a/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp b/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp index 387dfadbb8e..bbb5076b7da 100644 --- a/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp +++ b/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp @@ -89,10 +89,8 @@ Char* UnicodeToANSI(const WChar* string, Char* buffer, UInt bufferLength) return nullptr; } - #ifdef RTS_DEBUG - int result = - #endif - WideCharToMultiByte(CP_ACP, 0, string, -1, buffer, bufferLength, nullptr, nullptr); + MAYBE_UNUSED int result = WideCharToMultiByte(CP_ACP, 0, string, -1, buffer, bufferLength, nullptr, nullptr); + (void)result; #ifdef RTS_DEBUG if (result == 0) diff --git a/Generals/Code/GameEngine/Source/Common/Recorder.cpp b/Generals/Code/GameEngine/Source/Common/Recorder.cpp index 7991cef7d65..1e4fdd83238 100644 --- a/Generals/Code/GameEngine/Source/Common/Recorder.cpp +++ b/Generals/Code/GameEngine/Source/Common/Recorder.cpp @@ -79,10 +79,8 @@ static void writeAtOffset(File* file, Int offset, const void* data, Int dataSize { file->write(data, dataSize); } -#ifdef DEBUG_CRASHING - Int res = -#endif - file->seek(fileSize, File::seekMode::START); + MAYBE_UNUSED Int res = file->seek(fileSize, File::seekMode::START); + (void)res; DEBUG_ASSERTCRASH(res == fileSize, ("Could not seek to end of file!")); } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp index 4b472d1ce53..049dd7019e6 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp @@ -757,10 +757,8 @@ void ParkingPlaceBehavior::exitObjectViaDoor( Object *newObj, ExitDoorType exitD CRCDEBUG_LOG(("Produced at helipad (door = %d)", exitDoor)); DEBUG_ASSERTCRASH(exitDoor == DOOR_NONE_NEEDED, ("Hmm, unlikely")); Matrix3D mtx; -#ifdef DEBUG_CRASHING - Bool boneOk = -#endif - getObject()->getSingleLogicalBonePosition("HeliPark01", &ppinfo.hangarInternal, &mtx); + MAYBE_UNUSED Bool boneOk = getObject()->getSingleLogicalBonePosition("HeliPark01", &ppinfo.hangarInternal, &mtx); + (void)boneOk; DEBUG_ASSERTCRASH(boneOk, ("Could not get bone!")); ppinfo.hangarInternalOrient = mtx.Get_Z_Rotation(); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp index 17d67ef055e..7e38c456b89 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp @@ -79,10 +79,8 @@ static void writeAtOffset(File* file, Int offset, const void* data, Int dataSize { file->write(data, dataSize); } -#ifdef DEBUG_CRASHING - Int res = -#endif - file->seek(fileSize, File::seekMode::START); + MAYBE_UNUSED Int res = file->seek(fileSize, File::seekMode::START); + (void)res; DEBUG_ASSERTCRASH(res == fileSize, ("Could not seek to end of file!")); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp index 64338846eef..d49ff283537 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp @@ -820,10 +820,8 @@ void ParkingPlaceBehavior::exitObjectViaDoor( Object *newObj, ExitDoorType exitD CRCDEBUG_LOG(("Produced at helipad (door = %d)", exitDoor)); DEBUG_ASSERTCRASH(exitDoor == DOOR_NONE_NEEDED, ("Hmm, unlikely")); Matrix3D mtx; -#ifdef DEBUG_CRASHING - Bool boneOk = -#endif - getObject()->getSingleLogicalBonePosition("HeliPark01", &ppinfo.hangarInternal, &mtx); + MAYBE_UNUSED Bool boneOk = getObject()->getSingleLogicalBonePosition("HeliPark01", &ppinfo.hangarInternal, &mtx); + (void)boneOk; DEBUG_ASSERTCRASH(boneOk, ("Could not get bone!")); ppinfo.hangarInternalOrient = mtx.Get_Z_Rotation();