From 20b75563712db7797b9d14847969f2e3fd1a5aab Mon Sep 17 00:00:00 2001 From: Marco Antonio Jaguaribe Costa Date: Fri, 9 Dec 2022 09:17:18 -0300 Subject: [PATCH] remove Mutex Manager and associated dead code this does nothing --- MPChatScreen.cpp | 1 - Standard Gaming Platform/Cursor Control.cpp | 3 - Standard Gaming Platform/JA2 SGP ALL.H | 1 - Standard Gaming Platform/Mutex Manager.cpp | 223 ------------------ Standard Gaming Platform/Mutex Manager.h | 20 -- Standard Gaming Platform/SGP_VS2005.vcproj | 8 - Standard Gaming Platform/SGP_VS2008.vcproj | 8 - Standard Gaming Platform/SGP_VS2010.vcxproj | 2 - .../SGP_VS2010.vcxproj.filters | 6 - Standard Gaming Platform/SGP_VS2013.vcxproj | 2 - .../SGP_VS2013.vcxproj.filters | 6 - Standard Gaming Platform/SGP_VS2017.vcxproj | 2 - Standard Gaming Platform/SGP_VS2019.vcxproj | 2 - .../SGP_VS2019.vcxproj.filters | 2 - Standard Gaming Platform/TopicIDs.h | 1 - Standard Gaming Platform/sgp.cpp | 14 -- Standard Gaming Platform/sgp.h | 1 - Standard Gaming Platform/video.cpp | 18 -- Standard Gaming Platform/video.h | 1 - Utils/Cursors.cpp | 4 - Utils/Utils All.h | 1 - Utils/message.cpp | 7 - local.h | 13 - 23 files changed, 346 deletions(-) delete mode 100644 Standard Gaming Platform/Mutex Manager.cpp delete mode 100644 Standard Gaming Platform/Mutex Manager.h diff --git a/MPChatScreen.cpp b/MPChatScreen.cpp index 6cd03a9c1..060f259e2 100644 --- a/MPChatScreen.cpp +++ b/MPChatScreen.cpp @@ -1407,7 +1407,6 @@ void ChatLogMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) MoveToEndOfChatScreenMessageList( ); - //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); } diff --git a/Standard Gaming Platform/Cursor Control.cpp b/Standard Gaming Platform/Cursor Control.cpp index fc9bd1ecc..3e78847d4 100644 --- a/Standard Gaming Platform/Cursor Control.cpp +++ b/Standard Gaming Platform/Cursor Control.cpp @@ -331,9 +331,6 @@ BOOLEAN SetCurrentCursorFromDatabase( UINT32 uiCursorIndex ) if ( gfCursorDatabaseInit ) { - // Enter mouse buffer mutex - //EnterMutex(MOUSE_BUFFER_MUTEX, __LINE__, __FILE__); - // If the current cursor is the first index, disable cursors if ( uiCursorIndex == VIDEO_NO_CURSOR ) diff --git a/Standard Gaming Platform/JA2 SGP ALL.H b/Standard Gaming Platform/JA2 SGP ALL.H index ad188eb21..0d9e6e38f 100644 --- a/Standard Gaming Platform/JA2 SGP ALL.H +++ b/Standard Gaming Platform/JA2 SGP ALL.H @@ -83,7 +83,6 @@ #include #endif #include "mousesystem.h" -#include "Mutex Manager.h" #include "Random.h" #include #include "vobject_private.h" diff --git a/Standard Gaming Platform/Mutex Manager.cpp b/Standard Gaming Platform/Mutex Manager.cpp deleted file mode 100644 index 088a4bcde..000000000 --- a/Standard Gaming Platform/Mutex Manager.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#ifdef JA2_PRECOMPILED_HEADERS - #include "JA2 SGP ALL.H" -#elif defined( WIZ8_PRECOMPILED_HEADERS ) - #include "WIZ8 SGP ALL.H" -#else - #include "Mutex Manager.h" - #include "debug.h" -#endif -//#define __MUTEX_TYPE - -#ifdef __MUTEX_TYPE - -// -// Use defines to allocate slots in the mutex manager. Put these defines in LOCAL.H -// - -HANDLE MutexTable[MAX_MUTEX_HANDLES]; - -BOOLEAN InitializeMutexManager(void) -{ - UINT32 uiIndex; - - // - // Register the Mutex Manager debug topic - // - - RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager"); - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Initializing the Mutex Manager"); - - // - // Initialize the table of mutex handles to NULL - // - - for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++) - { - MutexTable[uiIndex] = NULL; - } - - return TRUE; -} - -void ShutdownMutexManager(void) -{ - UINT32 uiIndex; - - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager"); - - // - // Make sure all mutex handles are closed - // - - for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++) - { - if (MutexTable[uiIndex] != NULL) - { - CloseHandle(MutexTable[uiIndex]); - MutexTable[uiIndex] = NULL; - } - } - - UnRegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager"); -} - -BOOLEAN InitializeMutex(UINT32 uiMutexIndex, UINT8 *ubMutexName) -{ - MutexTable[uiMutexIndex] = CreateMutex(NULL, FALSE, ubMutexName); - if (MutexTable[uiMutexIndex] == NULL) - { - // - // Mutex creation has failed. - // - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Mutex initialization has failed."); - return FALSE; - } - - return TRUE; -} - -BOOLEAN DeleteMutex(UINT32 uiMutexIndex) -{ - if (MutexTable[uiMutexIndex] == NULL) - { - // - // Hum ?? We just tried to initialize a mutex entry which doesn't have a reserved slot - // - - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Mutex cannot be deleted since it does not exit"); - return FALSE; - } - - if (CloseHandle(MutexTable[uiMutexIndex]) == FALSE) - { - // - // Hum, the mutex deletion has failed - // - - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Mutex cannot be deleted since it does not exit"); - return FALSE; - } - - MutexTable[uiMutexIndex] = NULL; - - return TRUE; -} - -BOOLEAN EnterMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename) -{ - switch (WaitForSingleObject(MutexTable[uiMutexIndex], INFINITE)) - { - case WAIT_OBJECT_0 - : return TRUE; - case WAIT_TIMEOUT - : DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Possible infinite loop detected due to enter mutex timeout"); - return FALSE; - case WAIT_ABANDONED - : DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Abandoned mutex has been found"); - return FALSE; - } -} - -BOOLEAN EnterMutexWithTimeout(UINT32 uiMutexIndex, UINT32 uiTimeout, INT32 nLine, STR8 szFilename) -{ - switch (WaitForSingleObject(MutexTable[uiMutexIndex], uiTimeout)) - { - case WAIT_OBJECT_0 - : return TRUE; - case WAIT_TIMEOUT - : return FALSE; - case WAIT_ABANDONED - : return FALSE; - } - return TRUE; -} - -BOOLEAN LeaveMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename) -{ - if (ReleaseMutex(MutexTable[uiMutexIndex]) == FALSE) - { - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Failed to leave mutex"); - return FALSE; - } - - return TRUE; -} - -#else - -// -// Use defines to allocate slots in the mutex manager. Put these defines in LOCAL.H -// - -CRITICAL_SECTION MutexTable[MAX_MUTEX_HANDLES]; - -BOOLEAN InitializeMutexManager(void) -{ - UINT32 uiIndex; - - // - // Make sure all mutex handles are opened - // - - for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++) - { - InitializeCriticalSection(&MutexTable[uiIndex]); - } - - RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager"); - - return TRUE; -} - -void ShutdownMutexManager(void) -{ - UINT32 uiIndex; - - DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager"); - - // - // Make sure all mutex handles are closed - // - - for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++) - { - DeleteCriticalSection(&MutexTable[uiIndex]); - } - - UnRegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager"); -} - -BOOLEAN InitializeMutex(UINT32 uiMutexIndex, UINT8 *ubMutexName) -{ - //InitializeCriticalSection(&MutexTable[uiMutexIndex]); - - return TRUE; -} - -BOOLEAN DeleteMutex(UINT32 uiMutexIndex) -{ - //DeleteCriticalSection(&MutexTable[uiMutexIndex]); - - return TRUE; -} - -BOOLEAN EnterMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename) -{ - EnterCriticalSection(&MutexTable[uiMutexIndex]); - return TRUE; -} - -BOOLEAN EnterMutexWithTimeout(UINT32 uiMutexIndex, UINT32 uiTimeout, INT32 nLine, STR8 szFilename) -{ - EnterCriticalSection(&MutexTable[uiMutexIndex]); - return TRUE; -} - -BOOLEAN LeaveMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename) -{ - LeaveCriticalSection(&MutexTable[uiMutexIndex]); - - return TRUE; -} - -#endif diff --git a/Standard Gaming Platform/Mutex Manager.h b/Standard Gaming Platform/Mutex Manager.h deleted file mode 100644 index b428dea48..000000000 --- a/Standard Gaming Platform/Mutex Manager.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __MUTEX_ -#define __MUTEX_ - -#include -#include "Types.h" -#include "Local.h" - -extern BOOLEAN InitializeMutexManager(void); -extern void ShutdownMutexManager(void); -extern BOOLEAN InitializeMutex(UINT32 uiMutexIndex, UINT8 *ubMutexName); -extern BOOLEAN DeleteMutex(UINT32 uiMutexIndex); -extern BOOLEAN EnterMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename); -extern BOOLEAN EnterMutexWithTimeout(UINT32 uiMutexIndex, UINT32 uiTimeout, INT32 nLine, STR8 szFilename); -extern BOOLEAN LeaveMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename); - -// -// Use defines to allocate slots in the mutex manager. Put these defines in LOCAL.H -// - -#endif \ No newline at end of file diff --git a/Standard Gaming Platform/SGP_VS2005.vcproj b/Standard Gaming Platform/SGP_VS2005.vcproj index 354043ea6..3c294cb12 100644 --- a/Standard Gaming Platform/SGP_VS2005.vcproj +++ b/Standard Gaming Platform/SGP_VS2005.vcproj @@ -482,10 +482,6 @@ RelativePath=".\Mss.h" > - - @@ -724,10 +720,6 @@ RelativePath=".\mousesystem.cpp" > - - diff --git a/Standard Gaming Platform/SGP_VS2008.vcproj b/Standard Gaming Platform/SGP_VS2008.vcproj index e1c23c641..3b77d82ea 100644 --- a/Standard Gaming Platform/SGP_VS2008.vcproj +++ b/Standard Gaming Platform/SGP_VS2008.vcproj @@ -482,10 +482,6 @@ RelativePath="Mss.h" > - - @@ -722,10 +718,6 @@ RelativePath="mousesystem.cpp" > - - diff --git a/Standard Gaming Platform/SGP_VS2010.vcxproj b/Standard Gaming Platform/SGP_VS2010.vcxproj index 357f3ac21..be699a528 100644 --- a/Standard Gaming Platform/SGP_VS2010.vcxproj +++ b/Standard Gaming Platform/SGP_VS2010.vcxproj @@ -59,7 +59,6 @@ - @@ -120,7 +119,6 @@ - diff --git a/Standard Gaming Platform/SGP_VS2010.vcxproj.filters b/Standard Gaming Platform/SGP_VS2010.vcxproj.filters index 4d7304a1b..b8ed09426 100644 --- a/Standard Gaming Platform/SGP_VS2010.vcxproj.filters +++ b/Standard Gaming Platform/SGP_VS2010.vcxproj.filters @@ -120,9 +120,6 @@ Header Files - - Header Files - Header Files @@ -296,9 +293,6 @@ Source Files - - Source Files - Source Files diff --git a/Standard Gaming Platform/SGP_VS2013.vcxproj b/Standard Gaming Platform/SGP_VS2013.vcxproj index f824da53d..807239723 100644 --- a/Standard Gaming Platform/SGP_VS2013.vcxproj +++ b/Standard Gaming Platform/SGP_VS2013.vcxproj @@ -59,7 +59,6 @@ - @@ -120,7 +119,6 @@ - diff --git a/Standard Gaming Platform/SGP_VS2013.vcxproj.filters b/Standard Gaming Platform/SGP_VS2013.vcxproj.filters index 4d7304a1b..b8ed09426 100644 --- a/Standard Gaming Platform/SGP_VS2013.vcxproj.filters +++ b/Standard Gaming Platform/SGP_VS2013.vcxproj.filters @@ -120,9 +120,6 @@ Header Files - - Header Files - Header Files @@ -296,9 +293,6 @@ Source Files - - Source Files - Source Files diff --git a/Standard Gaming Platform/SGP_VS2017.vcxproj b/Standard Gaming Platform/SGP_VS2017.vcxproj index 5770271c0..41584cb9d 100644 --- a/Standard Gaming Platform/SGP_VS2017.vcxproj +++ b/Standard Gaming Platform/SGP_VS2017.vcxproj @@ -59,7 +59,6 @@ - @@ -120,7 +119,6 @@ - diff --git a/Standard Gaming Platform/SGP_VS2019.vcxproj b/Standard Gaming Platform/SGP_VS2019.vcxproj index 9854c599c..6f1613994 100644 --- a/Standard Gaming Platform/SGP_VS2019.vcxproj +++ b/Standard Gaming Platform/SGP_VS2019.vcxproj @@ -79,7 +79,6 @@ - @@ -140,7 +139,6 @@ - diff --git a/Standard Gaming Platform/SGP_VS2019.vcxproj.filters b/Standard Gaming Platform/SGP_VS2019.vcxproj.filters index 2632c47a8..b12f8ded7 100644 --- a/Standard Gaming Platform/SGP_VS2019.vcxproj.filters +++ b/Standard Gaming Platform/SGP_VS2019.vcxproj.filters @@ -27,7 +27,6 @@ - @@ -83,7 +82,6 @@ - diff --git a/Standard Gaming Platform/TopicIDs.h b/Standard Gaming Platform/TopicIDs.h index 4ec014872..e549e4e05 100644 --- a/Standard Gaming Platform/TopicIDs.h +++ b/Standard Gaming Platform/TopicIDs.h @@ -23,7 +23,6 @@ const unsigned TOPIC_FONT_HANDLER = 9; const unsigned TOPIC_VIDEOSURFACE = 8; const unsigned TOPIC_MOUSE_SYSTEM = 7; const unsigned TOPIC_BUTTON_HANDLER = 6; -const unsigned TOPIC_MUTEX = 5; const unsigned TOPIC_JA2INTERRUPT = 4; const unsigned TOPIC_JA2 = 3; const unsigned TOPIC_BLIT_QUEUE = INVALID_TOPIC; diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index 82063568d..396573dbd 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -689,17 +689,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow) return FALSE; } -#ifdef JA2 - FastDebugMsg("Initializing Mutex Manager"); - // Initialize the Dirty Rectangle Manager - if (InitializeMutexManager() == FALSE) - { - // We were unable to initialize the game - FastDebugMsg("FAILED : Initializing Mutex Manager"); - return FALSE; - } -#endif - FastDebugMsg("Initializing File Manager"); // Initialize the File Manager if (InitializeFileManager(NULL) == FALSE) @@ -972,9 +961,6 @@ void ShutdownStandardGamingPlatform(void) ShutdownInputManager(); ShutdownContainers(); ShutdownFileManager(); -#ifdef JA2 - ShutdownMutexManager(); -#endif #ifdef EXTREME_MEMORY_DEBUGGING DumpMemoryInfoIntoFile( "ExtremeMemoryDump.txt", FALSE ); diff --git a/Standard Gaming Platform/sgp.h b/Standard Gaming Platform/sgp.h index 7d8c7fe69..6caba4adc 100644 --- a/Standard Gaming Platform/sgp.h +++ b/Standard Gaming Platform/sgp.h @@ -23,7 +23,6 @@ #include "gameloop.h" #include "font.h" #include "english.h" -#include "Mutex Manager.h" #include "vobject.h" #include "Random.h" #include "shading.h" diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index fd623560c..265cf4ed3 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -620,24 +620,6 @@ BOOLEAN InitializeVideoManager(HINSTANCE hInstance, UINT16 usCommandShow, void * } } - // - // Initialize the mutex sections - // - - // ATE: Keep these mutexes for now! - if (InitializeMutex(REFRESH_THREAD_MUTEX, (UINT8 *)"RefreshThreadMutex") == FALSE) - { - return FALSE; - } - if (InitializeMutex(FRAME_BUFFER_MUTEX, (UINT8 *)"FrameBufferMutex") == FALSE) - { - return FALSE; - } - if (InitializeMutex(MOUSE_BUFFER_MUTEX, (UINT8 *)"MouseBufferMutex") == FALSE) - { - return FALSE; - } - // // Initialize state variables // diff --git a/Standard Gaming Platform/video.h b/Standard Gaming Platform/video.h index a0dd64d80..02527b3ac 100644 --- a/Standard Gaming Platform/video.h +++ b/Standard Gaming Platform/video.h @@ -10,7 +10,6 @@ #include "Types.h" #include "DirectDraw Calls.h" #include "VSurface.h" -#include "Mutex Manager.h" #define BUFFER_READY 0x00 #define BUFFER_BUSY 0x01 diff --git a/Utils/Cursors.cpp b/Utils/Cursors.cpp index 2fccde31d..7d0f1272b 100644 --- a/Utils/Cursors.cpp +++ b/Utils/Cursors.cpp @@ -1659,8 +1659,6 @@ void DrawMouseText( ) static BOOLEAN fShow = FALSE; static BOOLEAN fHoldInvalid = TRUE; - //EnterMutex(MOUSE_BUFFER_MUTEX, __LINE__, __FILE__); - if ( gfUIBodyHitLocation ) { // Set dest for gprintf to be different @@ -1856,8 +1854,6 @@ void DrawMouseText( ) mprintf( sX, sY, L"%d", gsCurrentActionPoints ); //mprintf( sX, sY, L"%d %d", sX, sY ); - //LeaveMutex(MOUSE_BUFFER_MUTEX, __LINE__, __FILE__); - SetFontShadow( DEFAULT_SHADOW ); // reset diff --git a/Utils/Utils All.h b/Utils/Utils All.h index fe283b032..dd77c7179 100644 --- a/Utils/Utils All.h +++ b/Utils/Utils All.h @@ -63,7 +63,6 @@ #include "Message.h" #include #include "mbstring.h" -#include "Mutex Manager.h" #include "local.h" #include "Map Screen Interface Bottom.h" #include "Soundman.h" diff --git a/Utils/message.cpp b/Utils/message.cpp index 6616aa072..3d5909bde 100644 --- a/Utils/message.cpp +++ b/Utils/message.cpp @@ -12,7 +12,6 @@ #include "Timer Control.h" #include "render dirty.h" #include "renderworld.h" - #include "Mutex Manager.h" #include "local.h" #include "interface.h" #include "Map Screen Interface Bottom.h" @@ -806,8 +805,6 @@ void TacticalScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) // Init display array! memset( gpDisplayList, 0, sizeof( gpDisplayList ) ); fFirstTimeInMessageSystem = FALSE; - //if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" ))) - // return; } @@ -891,7 +888,6 @@ void TacticalScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) // clear up list of wrapped strings ClearWrappedStrings( pStringWrapperHead ); - //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); return; } @@ -1010,8 +1006,6 @@ void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) // Init display array! memset( gpDisplayList, 0, sizeof( gpDisplayList ) ); fFirstTimeInMessageSystem = FALSE; - //if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" ))) - // return; } @@ -1079,7 +1073,6 @@ void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) MoveToEndOfMapScreenMessageList( ); - //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); } diff --git a/local.h b/local.h index 3f59e708b..cf0bba6f2 100644 --- a/local.h +++ b/local.h @@ -82,17 +82,4 @@ extern BOOLEAN fDisplayOverheadMap; #define PIXEL_DEPTH 16 -// -// These defines are used as MUTEX handles. -// - -#define MAX_MUTEX_HANDLES 32 - -#define REFRESH_THREAD_MUTEX 0 -#define FRAME_BUFFER_MUTEX 1 -#define MOUSE_BUFFER_MUTEX 2 -#define DIRTY_BUFFER_MUTEX 3 -#define SCROLL_MESSAGE_MUTEX 4 - - #endif \ No newline at end of file