Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+122 -122
View File
@@ -18,129 +18,129 @@ HANDLE MutexTable[MAX_MUTEX_HANDLES];
BOOLEAN InitializeMutexManager(void)
{
UINT32 uiIndex;
UINT32 uiIndex;
//
// Register the Mutex Manager debug topic
//
//
// Register the Mutex Manager debug topic
//
RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Initializing the Mutex Manager");
RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Initializing the Mutex Manager");
//
// Initialize the table of mutex handles to NULL
//
//
// Initialize the table of mutex handles to NULL
//
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
MutexTable[uiIndex] = NULL;
}
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
MutexTable[uiIndex] = NULL;
}
return TRUE;
return TRUE;
}
void ShutdownMutexManager(void)
{
UINT32 uiIndex;
UINT32 uiIndex;
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager");
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager");
//
// Make sure all mutex handles are closed
//
//
// 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;
}
}
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
if (MutexTable[uiIndex] != NULL)
{
CloseHandle(MutexTable[uiIndex]);
MutexTable[uiIndex] = NULL;
}
}
UnRegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
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;
}
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;
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;
}
if (MutexTable[uiMutexIndex] == NULL)
{
//
// Hum ?? We just tried to initialize a mutex entry which doesn't have a reserved slot
//
MutexTable[uiMutexIndex] = NULL;
return TRUE;
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;
}
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;
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;
if (ReleaseMutex(MutexTable[uiMutexIndex]) == FALSE)
{
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "ERROR : Failed to leave mutex");
return FALSE;
}
return TRUE;
}
#else
@@ -153,71 +153,71 @@ CRITICAL_SECTION MutexTable[MAX_MUTEX_HANDLES];
BOOLEAN InitializeMutexManager(void)
{
UINT32 uiIndex;
UINT32 uiIndex;
//
// Make sure all mutex handles are opened
//
//
// Make sure all mutex handles are opened
//
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
InitializeCriticalSection(&MutexTable[uiIndex]);
}
RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
InitializeCriticalSection(&MutexTable[uiIndex]);
}
return TRUE;
RegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
return TRUE;
}
void ShutdownMutexManager(void)
{
UINT32 uiIndex;
UINT32 uiIndex;
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager");
DbgMessage(TOPIC_MUTEX, DBG_LEVEL_0, "Shutting down the Mutex Manager");
//
// Make sure all mutex handles are closed
//
//
// Make sure all mutex handles are closed
//
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
DeleteCriticalSection(&MutexTable[uiIndex]);
}
for (uiIndex = 0; uiIndex < MAX_MUTEX_HANDLES; uiIndex++)
{
DeleteCriticalSection(&MutexTable[uiIndex]);
}
UnRegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
UnRegisterDebugTopic(TOPIC_MUTEX, "Mutex Manager");
}
BOOLEAN InitializeMutex(UINT32 uiMutexIndex, UINT8 *ubMutexName)
{
//InitializeCriticalSection(&MutexTable[uiMutexIndex]);
//InitializeCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
return TRUE;
}
BOOLEAN DeleteMutex(UINT32 uiMutexIndex)
{
//DeleteCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
//DeleteCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
}
BOOLEAN EnterMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename)
{
EnterCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
EnterCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
}
BOOLEAN EnterMutexWithTimeout(UINT32 uiMutexIndex, UINT32 uiTimeout, INT32 nLine, STR8 szFilename)
{
EnterCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
EnterCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
}
BOOLEAN LeaveMutex(UINT32 uiMutexIndex, INT32 nLine, STR8 szFilename)
{
LeaveCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
LeaveCriticalSection(&MutexTable[uiMutexIndex]);
return TRUE;
}
#endif
#endif