diff --git a/Ja25Update.cpp b/Ja25Update.cpp index 101b1152..4fd737e1 100644 --- a/Ja25Update.cpp +++ b/Ja25Update.cpp @@ -11,7 +11,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" -#include "container.h" #include #include "pathai.h" #include "Random.h" diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index e804d037..70404804 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -2,7 +2,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/Button Sound Control.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Button System.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Compression.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/Container.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Cursor Control.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/DEBUG.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/debug_util.cpp" diff --git a/Standard Gaming Platform/Container.cpp b/Standard Gaming Platform/Container.cpp deleted file mode 100644 index ad140dd5..00000000 --- a/Standard Gaming Platform/Container.cpp +++ /dev/null @@ -1,2104 +0,0 @@ -//***************************************************************************** -// -// Filename : Container.c -// -// Purpose : Function definition for the Container -// -// Modification History : -// 25 nov 96 TS creation -// -// 19 Dec 97 AM Replace all memcpy() with memmove(), since overlap possibilities -// abound (and there were already bugs in do_copy() for ordered lists) -// While the memcpy() was working in _DEBUG mode, it was failing -// reproducibly in RELEASE mode whenever regions overlapped! -// Having read the code, I strongly suggest that you DO NOT use this -// stuff at all and write your own instead. Tarun was no Carmack... -// - Alex Meduna -// 1998 KM Detached all references to this file from JA2 as it caused a lot of hard to debug -// crashes. The VOBJECT/VSURFACE lists are now self-maintained and no longer use the -// this crap. DON'T USE THIS -- NO MATTER WHAT!!! -//***************************************************************************** - - #include "types.h" - #include - #include - #include - #include "windows.h" - #include "MemMan.h" - #include "Debug.h" - #include "Container.h" - #if _MSC_VER < 1300 //(iostream.h was removed from VC.NET2003) - #include - #endif - - -//***************************************************************************** -// -// Defines and typedefs -// -// -//***************************************************************************** - -typedef struct StackHeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - -} StackHeader; - -typedef struct HeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - UINT32 uiHead; - UINT32 uiTail; - -} QueueHeader , ListHeader; - -typedef struct OrdHeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - UINT32 uiHead; - UINT32 uiTail; - INT8 (*pCompare)(void *,void *, UINT32); - -} OrdListHeader; - - typedef struct test - { - UINT32 me; - long you; - STR8 k; - STR8 p; - - } TEST; - -//***************************************************************************** -// -// CreateStack -// -// Parameter List : num_items - estimated number -// of items in stack -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -HSTACK CreateStack(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HSTACK hStack; - StackHeader *pStack; - - // assign an initial amount of memory to allocate - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Requested stack items and size have to be >0"); - return NULL; - } - // allocate the container memory - if ((hStack = MemAlloc(uiAmount + sizeof(StackHeader))) == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Could not allocate stack container memory"); - return NULL; - } - pStack = (StackHeader *)hStack; - //initialize the header variables - pStack->uiMax_size = uiAmount + sizeof(StackHeader); - pStack->uiTotal_items = 0; - pStack->uiSiz_of_elem = uiSiz_each; - - // return the pointer to the memory - - return hStack; -} - -//***************************************************************************** -// -// CreateQueue -// -// Parameter List : num_items - estimated number -// of items in queue -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HQUEUE CreateQueue(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HQUEUE hQueue; - QueueHeader *pQueue; - - // check to see if the queue has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Requested queue items and size have to be >0"); - return NULL; - } - - // allocate the queue memory - if ((hQueue = MemAlloc(uiAmount + sizeof(QueueHeader))) == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return NULL; - } - - pQueue = (QueueHeader *)hQueue; - //initialize the queue structure - - pQueue->uiMax_size = uiAmount + sizeof(QueueHeader); - pQueue->uiTotal_items = 0; - pQueue->uiSiz_of_elem = uiSiz_each; - pQueue->uiTail = pQueue->uiHead = sizeof(QueueHeader); - - // return the pointer to memory - return hQueue; -} -//***************************************************************************** -// -// CreateList -// -// Parameter List : num_items - estimated number -// of items in ordered list -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HLIST CreateList(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HLIST hList; - ListHeader *pList; - - // check to see if the queue has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Requested queue items and size have to be >0"); - return 0; - } - - // allocate the list memory - if ((hList = MemAlloc(uiAmount + sizeof(ListHeader))) == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return 0; - } - - pList = (ListHeader *)hList; - //initialize the list structure - - pList->uiMax_size = uiAmount + sizeof(ListHeader); - pList->uiTotal_items = 0; - pList->uiSiz_of_elem = uiSiz_each; - pList->uiTail = pList->uiHead = sizeof(ListHeader); - - // return the pointer to memory - - return hList; - -} - - - -//***************************************************************************** -// -// CreateOrdList -// -// Parameter List : num_items - estimated number -// of items in ordered list -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HORDLIST CreateOrdList(UINT32 uiNum_items, UINT32 uiSiz_each, INT8 (*compare)(void *, void *, UINT32)) -{ - UINT32 uiAmount; - HLIST hOrdList; - OrdListHeader *pOrdList; - - // check to see if the ordered list has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Requested ordered list items and size have to be >0"); - return 0; - } - - // allocate the list memory - if ((hOrdList = MemAlloc(uiAmount + sizeof(OrdListHeader))) == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return 0; - } - - pOrdList = (OrdListHeader *)hOrdList; - //initialize the list structure - - pOrdList->uiMax_size = uiAmount + sizeof(OrdListHeader); - pOrdList->uiTotal_items = 0; - pOrdList->uiSiz_of_elem = uiSiz_each; - pOrdList->uiTail = pOrdList->uiHead = sizeof(OrdListHeader); - pOrdList->pCompare = compare; - - // return the pointer to memory - - return hOrdList; -} - - - -//***************************************************************************** -// -// push -// -// Parameter List : void * - pointer to stack -// container -// data - data to add to stack -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HSTACK Push(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiNew_size; - void *pvoid; - BYTE *pbyte; - - // check for a NULL pointer - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return NULL; - } - - // some valid data should be passed in - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto stack is NULL"); - return NULL; - } - - //perform operations to calculate offset and decide if the container has to resized - pTemp_cont = (StackHeader *)hStack; - uiOffset = (pTemp_cont->uiSiz_of_elem * pTemp_cont->uiTotal_items) + sizeof(StackHeader); - - if ((uiOffset + pTemp_cont->uiSiz_of_elem) > pTemp_cont->uiMax_size) - { - uiNew_size = pTemp_cont->uiMax_size + (pTemp_cont->uiMax_size - sizeof(StackHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hStack = MemRealloc(hStack, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Could not resize stack container memory"); - return NULL; - } - pTemp_cont = (StackHeader *)hStack; - } - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - //copy data from pdata to pvoid - the stack - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - //return push succeeded - return hStack; -} -//***************************************************************************** -// -// pop -// -// Parameter List : void * - pointer to stack -// container -// -// -// Return Value : void * - pointer to stack -// after pushing element -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN Pop(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiSize_of_each; - UINT32 uiTotal; - void *pvoid; - BYTE *pbyte; - - // check for a NULL queue - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Variable where data is to be stored is NULL"); - return FALSE; - } - pTemp_cont = (StackHeader *)hStack; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - if (uiTotal == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "There is no data in stack to pop"); - return FALSE; - } - - // calculate offsets to decide if the page should be rezied - uiOffset = (uiSize_of_each * uiTotal) + sizeof(StackHeader); - uiOffset -= uiSize_of_each; - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - // get the data from pvoid and store in pdata - memmove(pdata, pvoid, uiSize_of_each); - pTemp_cont->uiTotal_items--; - return TRUE; -} -//***************************************************************************** -// -// PeekStack -// -// Parameter List : void * - buffer to hold data -// -// -// Return Value : TRUE if stack not empty -// -// Modification History : -// Apr 14 2000 SCT->Created -// -//***************************************************************************** -BOOLEAN PeekStack(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiSize_of_each; - UINT32 uiTotal; - void *pvoid; - BYTE *pbyte; - - // check for a NULL queue - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Variable where data is to be stored is NULL"); - return FALSE; - } - pTemp_cont = (StackHeader *)hStack; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - if (uiTotal == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "There is no data in stack to pop"); - return FALSE; - } - - // calculate offsets to decide if the page should be rezied - uiOffset = (uiSize_of_each * uiTotal) + sizeof(StackHeader); - uiOffset -= uiSize_of_each; - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - // get the data from pvoid and store in pdata - memmove(pdata, pvoid, uiSize_of_each); - return TRUE; -} -//***************************************************************************** -// -// DeleteStack -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteStack(HSTACK hStack) -{ - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - // free the memory assigned to the handle - MemFree(hStack); - return TRUE; -} -//***************************************************************************** -// -// DeleteQueue -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteQueue(HQUEUE hQueue) -{ - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - // free the memory assigned to the handle - MemFree(hQueue); - return TRUE; -} -//***************************************************************************** -// -// DeleteList -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteList(HLIST hList) -{ - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the list"); - return FALSE; - } - // free the memory assigned to the list - MemFree(hList); - return TRUE; -} -//***************************************************************************** -// -// DeleteOrdList -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteOrdList(HORDLIST hOrdList) -{ - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the ordered list"); - return FALSE; - } - // free the memory assigned to the list - MemFree(hOrdList); - return TRUE; -} -//***************************************************************************** -// -// InitializeContainers -// -// Parameter List : none -// -// Return Value : void -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -void InitializeContainers(void) -{ - // register the appropriate debug topics - RegisterDebugTopic(TOPIC_STACK_CONTAINERS, "Stack Container"); - RegisterDebugTopic(TOPIC_LIST_CONTAINERS, "List Container"); - RegisterDebugTopic(TOPIC_QUEUE_CONTAINERS, "Queue Container"); - RegisterDebugTopic(TOPIC_ORDLIST_CONTAINERS, "Ordered List Container"); -} - -//***************************************************************************** -// -// ShutdownContainers -// -// Parameter List : none -// -// Return Value : void -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -void ShutdownContainers( void ) -{ - UnRegisterDebugTopic(TOPIC_STACK_CONTAINERS, "Stack Container"); - UnRegisterDebugTopic(TOPIC_LIST_CONTAINERS, "List Container"); - UnRegisterDebugTopic(TOPIC_QUEUE_CONTAINERS, "Queue Container"); - UnRegisterDebugTopic(TOPIC_ORDLIST_CONTAINERS, "Ordered List Container"); -} -//***************************************************************************** -// -// PeekQueue - gets the first item in queue without -// actually deleting it. -// -// Parameter List : pvoid_queue - pointer to queue -// container -// data - data removed from queue -// -// Return Value pointer to queue with data removed -// or NULL if failed -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - void *pvoid; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from queue is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (QueueHeader *)hQueue; - - // if theres no elements to remove return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "There is nothing in the queue"); - return FALSE; - } - - //copy the element pointed to by uiHead - - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiHead; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} -//***************************************************************************** -// -// PeekList - gets the specified item in the list without -// actually deleting it. -// -// Parameter List : hList - pointer to list -// container -// data - data where list element is stored -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - void *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the list"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There is nothing in the list"); - return FALSE; - } - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There is no item at this position"); - return FALSE; - } - - //copy the element pointed to by uiHead - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - -//***************************************************************************** -// -// SwapListNode - Swaps the contents of a list node with the given parameter. -// Note: The data being swapped in MUST have the same size as -// the current node size or strange things could happen. -// Contents of node and pdata parameter are swapped. -// -// Parameter List : hList - pointer to list container -// pdata - pointer to data to be swapped -// uiPos - List position with which to swap. -// -// Return Value BOOLEAN - TRUE if successful, FALSE if function fails. -// -// -// Modification History : -// Added to SGP by Bret Rowdon for use with JA2. May 1 '97. -// - This function was based on the PeekList function. -// -//***************************************************************************** -BOOLEAN SwapListNode(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - BYTE *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - BYTE *pSrc; - - - // cannot check for invalid handle, only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer to list"); - return FALSE; - } - - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data pointer to be swapped from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Empty list"); - return FALSE; - } - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid list position"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - pvoid = pbyte; - pSrc = (BYTE *) pdata; - - // possible overlap, use memmove() - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - //memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - - -//***************************************************************************** -// -// StoreListNode - Stores the contents of a list node with the given parameter. -// Unlike SwapListNode(), this does NOT swap previous contents -// back into the pdata buffer! -// -// Parameter List : hList - pointer to list container -// pdata - pointer to data to be stored -// uiPos - List position into which to store. -// -// Return Value BOOLEAN - TRUE if successful, FALSE if function fails. -// -// -// Modification History : -// Added to SGP by Alex Meduna for use with Wiz8. Oct 31 '97. -// - This function is nearly identical to the SwapListNode() function. -// -//***************************************************************************** -BOOLEAN StoreListNode(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer to list"); - return FALSE; - } - - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data pointer to be swapped from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Empty list"); - return FALSE; - } - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid list position"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - - memmove(pbyte, pdata, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - - -//***************************************************************************** -// -// PeekOrdList - gets the specified item in the list without -// actually deleting it. -// -// Parameter List : hList - pointer to ordered list -// container -// data - data where list element is stored -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - void *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the ordered list"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from ordered list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (OrdListHeader *)hOrdList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There is nothing in the list"); - return FALSE; - } - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There is no item at this position"); - return FALSE; - } - - //copy the element pointed to by uiHead - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hOrdList; - pbyte += uiOffsetSrc; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} -//***************************************************************************** -// -// RemfromQueue -// -// Parameter List : pvoid_queue - pointer to queue -// container -// data - data removed from queue -// -// Return Value pointer to queue with data removed -// or NULL if failed -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - void *pvoid; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from queue is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (QueueHeader *)hQueue; - - // if theres no elements to remove return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "There is nothing in the queue to remove"); - return FALSE; - } - - //remove the element pointed to by uiHead - - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiHead; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items--; - pTemp_cont->uiHead += pTemp_cont->uiSiz_of_elem; - - // if after removing an element head = tail then set them both - // to the beginning of the container as it is empty - - if (pTemp_cont->uiHead == pTemp_cont->uiTail) - pTemp_cont->uiHead = pTemp_cont->uiTail = sizeof(QueueHeader); - - // if only the head is at the end of the container then make it point - // to the beginning of the container - - if (pTemp_cont->uiHead == pTemp_cont->uiMax_size) - pTemp_cont->uiHead = sizeof(QueueHeader); - - return TRUE; -} - -//***************************************************************************** -// -// AddtoQueue -// -// Parameter List : pvoid_queue - pointer to queue -// container -// pdata - pointer to data to add to queue -// -// Return Value pointer to queue with data added -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HQUEUE AddtoQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - BYTE *pmaxsize; - BYTE *presize; - BOOLEAN fresize; - - // check for invalid handle = 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Data to be added onto queue is NULL"); - return NULL; - } - - // assign some temporary variables - fresize = FALSE; - pTemp_cont = (QueueHeader *)hQueue; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - if ((uiTail + uiSize_of_each) > uiMax_size) - { - uiTail = pTemp_cont->uiTail = sizeof(QueueHeader); - fresize = TRUE; - } - if ((uiHead == uiTail) && ((uiHead >= (sizeof(QueueHeader) + uiSize_of_each)) || (fresize == TRUE))) - { - uiNew_size = uiMax_size + (uiMax_size - sizeof(QueueHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hQueue = MemRealloc(hQueue, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Could not resize queue container memory"); - return NULL; - } - // copy memory from beginning of container to end of container - // so that all the data is in one continuous block - - pTemp_cont = (QueueHeader *)hQueue; - presize = (BYTE *)hQueue; - pmaxsize = (BYTE *)hQueue; - presize += sizeof(QueueHeader); - pmaxsize += uiMax_size; - if (uiHead > sizeof(QueueHeader)) - memmove(pmaxsize, presize, uiHead-sizeof(QueueHeader)); - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(QueueHeader)); - } - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiTail; - pvoid = (void *)pbyte; - memmove(pvoid, pdata, uiSize_of_each); - pTemp_cont->uiTotal_items++; - pTemp_cont->uiTail += uiSize_of_each; - return hQueue; -} - -//***************************************************************************** -// -// do_copy -// -// Parameter List : pointer to mem, source offset, dest offset, size -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN do_copy(void *pmem_void, UINT32 uiSourceOfst, UINT32 uiDestOfst, UINT32 uiSize) -{ - BYTE *pOffsetSrc; - BYTE *pOffsetDst; - void *pvoid_src; - void *pvoid_dest; - - if ((uiSourceOfst < 0) || (uiDestOfst < 0) || (uiSize < 0)) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid parameters passed to do_copy"); - return FALSE; - } - - if (pmem_void == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer passed to do_copy"); - return FALSE; - } - pOffsetSrc = (BYTE *)pmem_void; - pOffsetSrc += uiSourceOfst; - pOffsetDst = (BYTE *)pmem_void; - pOffsetDst += uiDestOfst; - pvoid_src = (void *)pOffsetSrc; - pvoid_dest = (void *)pOffsetDst; - memmove(pvoid_dest, pvoid_src, uiSize); - return TRUE; -} -//***************************************************************************** -// -// do_copy_data -// -// Parameter List : pointer to mem, pointer to data, source offset, size -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN do_copy_data(void *pmem_void, void *data, UINT32 uiSrcOfst, UINT32 uiSize) -{ - BYTE *pOffsetSrc; - void *pvoid_src; - - if ((uiSrcOfst < 0) || (uiSize < 0)) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid parameters passed to do_copy_data"); - return FALSE; - } - - if (pmem_void == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer passed to do_copy_data"); - return FALSE; - } - pOffsetSrc = (BYTE *)pmem_void; - pOffsetSrc += uiSrcOfst; - pvoid_src = (void *)pOffsetSrc; - memmove(data, pvoid_src, uiSize); - return TRUE; -} -//***************************************************************************** -// -// StackSize -// -// Parameter List : pointer to stack -// -// Return Value UINT32 stack size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 StackSize(HSTACK hStack) -{ - StackHeader *pTemp_cont; - if (hStack == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Stack pointer is NULL"); - return 0; - } - pTemp_cont = (StackHeader *)hStack; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// QueueSize -// -// Parameter List : pointer to queue -// -// Return Value UINT32 queue size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 QueueSize(HQUEUE hQueue) -{ - QueueHeader *pTemp_cont; - if (hQueue == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Queue pointer is NULL"); - return 0; - } - pTemp_cont = (QueueHeader *)hQueue; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// ListSize -// -// Parameter List : pointer to queue -// -// Return Value UINT32 list size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 ListSize(HLIST hList) -{ - ListHeader *pTemp_cont; - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "List pointer is NULL"); - return 0; - } - pTemp_cont = (ListHeader *)hList; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// OrdListSize -// -// Parameter List : pointer to list -// -// Return Value UINT32 Ordlist size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 OrdListSize(HORDLIST hOrdList) -{ - OrdListHeader *pTemp_cont; - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Ordered List pointer is NULL"); - return 0; - } - pTemp_cont = (OrdListHeader *)hOrdList; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// AddtoList -// -// Parameter List : HCONTAINER - handle to list -// container -// data - data to add to queue -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HLIST AddtoList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - BOOLEAN fTail_check=FALSE; - - // check for invalid handle = 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the list"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return NULL; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return NULL; - } - - // assign some temporary variables - - pTemp_cont = (ListHeader *)hList; - if (uiPos > pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There are not enough elements in the list"); - return NULL; - } - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - if (uiTail == uiOffsetSrc) - fTail_check = TRUE; - // copy appropriate blocks - if (((uiTail + uiSize_of_each) <= uiMax_size) && - ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(ListHeader))))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (fTail_check == FALSE) - { - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - if (fTail_check == FALSE) - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail < uiHead)) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead >= (sizeof(ListHeader) + uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiFinalLoc = uiOffsetSrc; - } else - { - uiOffsetSrc = sizeof(ListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(ListHeader); - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - }// end if - - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail == uiHead) && (uiHead >= (sizeof(ListHeader) + uiSize_of_each))) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead == sizeof(ListHeader)))) - { - // need to resize the container - uiNew_size = uiMax_size + (uiMax_size - sizeof(ListHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hList = MemRealloc(hList, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not resize list container memory"); - return NULL; - } - pTemp_cont = (ListHeader *)hList; - if (do_copy(hList, sizeof(ListHeader), uiMax_size, uiHead - sizeof(ListHeader)) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy list container memory"); - return NULL; - } - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(ListHeader)); - - // now make place for the actual element - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - - // finally insert data at position uiFinalLoc - - pbyte = (BYTE *)hList; - if (uiFinalLoc == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This should never happen! report this problem!"); - return NULL; - } - pbyte += uiFinalLoc; - pvoid = (void *)pbyte; - - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - if (fTail_check == TRUE) - pTemp_cont->uiTail += pTemp_cont->uiSiz_of_elem; - return hList; -} - -//***************************************************************************** -// -// RemfromList -// -// Parameter List : HLIST - handle to list -// container -// data - data to remove from list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiHead; - UINT32 uiTail; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - - // check for invalid handle = 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the list"); - return FALSE; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return FALSE; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return FALSE; - } - - // assign some temporary variables - pTemp_cont = (ListHeader *)hList; - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Cannot delete at the specified position"); - return FALSE; - } - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There are no elements in the list to remove"); - return FALSE; - } - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - - // copy appropriate blocks - if ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(ListHeader)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not remove the data the list"); - return FALSE; - } - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } - - - if ((uiTail < uiHead) || ((uiTail == uiHead) && (uiHead <= (sizeof(ListHeader)+uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(ListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(ListHeader); - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - } - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } // end if - - return TRUE; -} - - - -//***************************************************************************** -// -// RemfromOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to remove from ordered list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiHead; - UINT32 uiTail; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - - - // check for invalid handle = 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the ordered list"); - return FALSE; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return FALSE; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return FALSE; - } - - // assign some temporary variables - - pTemp_cont = (OrdListHeader *)hOrdList; - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Cannot delete at the specified position"); - return FALSE; - } - - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There are no elements in the ordered list to remove"); - return FALSE; - } - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - - // copy appropriate blocks - if ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(OrdListHeader)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from ordered list"); - return FALSE; - } - - if (do_copy(hOrdList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not remove the data from the ordered list"); - return FALSE; - } - - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } - - - if ((uiTail < uiHead) || ((uiTail == uiHead) && (uiHead <= (sizeof(OrdListHeader)+uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(OrdListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(OrdListHeader); - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - } - - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } // end if - - - return TRUE; -} - - - -//***************************************************************************** -// -// StoreinOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to add to the ordered list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HORDLIST StoreinOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - BOOLEAN fTail_check=FALSE; - - - // check for invalid handle = 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the ordered list"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return NULL; - } - - // assign some temporary variables - pTemp_cont = (OrdListHeader *)hOrdList; - - // check for invalid position - if (uiPos > pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There are not enough elements in the ordered list to add after"); - return NULL; - } - - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - uiOffsetSrc = pTemp_cont->uiHead + (uiPos * pTemp_cont->uiSiz_of_elem); - - - // this shouldn't be necessary? position should never be outside the range? - if (uiOffsetSrc >= uiMax_size) - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - - if (uiTail == uiOffsetSrc) - fTail_check = TRUE; - - - // now copy the appropriate blocks to make room... - - if (((uiTail + uiSize_of_each) <= uiMax_size) && - ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(OrdListHeader))))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - - if (fTail_check == FALSE) - { - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in ordered list"); - return NULL; - } - } - - if (fTail_check == FALSE) - pTemp_cont->uiTail += uiSize_of_each; - - uiFinalLoc = uiOffsetSrc; - } - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail < uiHead)) || - (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead >= (sizeof(OrdListHeader) + uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(OrdListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(OrdListHeader); - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } // end if - - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail == uiHead) && (uiHead >= (sizeof(OrdListHeader) + uiSize_of_each))) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead == sizeof(OrdListHeader)))) - { - // need to resize the container - uiNew_size = uiMax_size + (uiMax_size - sizeof(OrdListHeader)); - pTemp_cont->uiMax_size = uiNew_size; - - if ((hOrdList = MemRealloc(hOrdList, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not resize ordered list container memory"); - return NULL; - } - - pTemp_cont = (OrdListHeader *)hOrdList; - - if (do_copy(hOrdList, sizeof(OrdListHeader), uiMax_size, uiHead - sizeof(OrdListHeader)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy ordered list container memory"); - return NULL; - } - - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(OrdListHeader)); - - // now make place for the actual element - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - if (uiFinalLoc == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This should never happen! report this problem!"); - return NULL; - } - - - // finally insert data at position uiFinalLoc - pbyte = (BYTE *)hOrdList; - pbyte += uiFinalLoc; - pvoid = (void *)pbyte; - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - - if (fTail_check == TRUE) - pTemp_cont->uiTail += pTemp_cont->uiSiz_of_elem; - - return hOrdList; -} - - - -//***************************************************************************** -// -// AddtoOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to add to the ordered list -// -// Return Value BOOLEAN true if Add ok else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// Dec 19th 1997->verified, cleaned up, and heavily commented by AM -// -//***************************************************************************** -HORDLIST AddtoOrdList(HORDLIST hOrdList, void *pdata) -{ - OrdListHeader *pOrdList; - void *pTemp_data; - UINT32 uiOffset; - BOOLEAN fContinue = FALSE; - INT8 sbResult; - UINT32 uiPosition; - - - // get a pointer into the list header - pOrdList = (OrdListHeader *)hOrdList; - - - // if the list is empty or full) - if (pOrdList->uiHead == pOrdList->uiTail) - { - // if the head offset points to position 0, presumably that means it's empty (?) - if (pOrdList->uiHead == sizeof(OrdListHeader)) - { - // so store it in position 0 - if ((hOrdList = StoreinOrdList(hOrdList, pdata, 0)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - return NULL; - } - - return hOrdList; - } - - // set flag to go through the while loop even though head == tail - fContinue = TRUE; - } - - - // grab enough space to store one list entry - pTemp_data = MemAlloc(pOrdList->uiSiz_of_elem); - - // start offset by pointing at the last entry in the the list - uiOffset = pOrdList->uiTail; - - // figure out the index of the entry that the tail points to - uiPosition = (pOrdList->uiTail - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - - - // continue looping while offset hasn't reached the start of the list yet (or at least once if list is full) - while ((uiOffset != pOrdList->uiHead) || (fContinue)) - { - // when offset reaches the top of the list - if (uiOffset == sizeof(OrdListHeader)) - { - // wrap around to the very bottom of the list (guaranteed to hold data?) - uiOffset = pOrdList->uiMax_size; - uiPosition = (pOrdList->uiMax_size - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - } - - // get entry data at the current offset position and store it in pTemp_data - if (do_copy_data(hOrdList, pTemp_data, (uiOffset - pOrdList->uiSiz_of_elem), pOrdList->uiSiz_of_elem ) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - MemFree(pTemp_data); - return NULL; - } - - // run the compare function - sbResult = pOrdList->pCompare(pTemp_data, pdata, pOrdList->uiSiz_of_elem); - - // and do the right thing based on the result... - switch (sbResult) - { - case ORDLIST_ERROR : - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not perform comparison for ordered lists"); - MemFree(pTemp_data); - return NULL; - } - - case ORDLIST_EQUAL : - case ORDLIST_LEFT_LESS : - { - // found the right spot! Insert it at the current position - if ((hOrdList = StoreinOrdList(hOrdList, pdata, uiPosition)) == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - MemFree(pTemp_data); - return NULL; - } - return hOrdList; - } - - case ORDLIST_RIGHT_LESS : - { - // keep looking - uiOffset -= pOrdList->uiSiz_of_elem; - uiPosition--; - break; - } - - default : - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Invalid result received from Compare function"); - MemFree(pTemp_data); - return NULL; - } - } // end switch - - fContinue = FALSE; - } // end while - - - // don't need this anymore - MemFree(pTemp_data); - pTemp_data = NULL; - - - // never found the right spot, which means we must have reached the head (damn well better) - if (uiOffset != pOrdList->uiHead) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "ERROR - left the while loop but not at the head"); - return NULL; - } - - // the new item will be first in list, so calculate the position based on the head - uiPosition = (pOrdList->uiHead - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - - // and stick it in there... - if ((hOrdList = StoreinOrdList(hOrdList, pdata, uiPosition)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - return NULL; - } - - - return hOrdList; -} - - - -INT8 Compare(void *p, void *q, UINT32 size) -{ - TEST *temp1; - TEST *temp2; - - - temp1 = (TEST *)p; - temp2 = (TEST *)q; - - if (temp1->me < temp2->me) - return ORDLIST_LEFT_LESS; - - if (temp1->me > temp2->me) - return ORDLIST_RIGHT_LESS; - - if (temp1->me == temp2->me) - return ORDLIST_EQUAL; - - return ORDLIST_ERROR; -} diff --git a/Standard Gaming Platform/Container.h b/Standard Gaming Platform/Container.h deleted file mode 100644 index 69dfe1f5..00000000 --- a/Standard Gaming Platform/Container.h +++ /dev/null @@ -1,132 +0,0 @@ -//*********************************************** -// -// Filename : Container.h -// -// Purpose : prototypes for the container file -// -// Modification History : 25 Nov 96 Creation -// -//*********************************************** - -#ifndef _CONTAINER_H -#define _CONTAINER_H - -//*********************************************** -// -// Includes -// -// -//*********************************************** - -#include "types.h" - -//*********************************************** -// -// Defines and typedefs -// -//*********************************************** -#define ORDLIST_ERROR -1 -#define ORDLIST_EQUAL 0 -#define ORDLIST_LEFT_LESS 1 -#define ORDLIST_RIGHT_LESS 2 - -typedef void * HCONTAINER; -typedef HCONTAINER HSTACK; -typedef HCONTAINER HQUEUE; -typedef HCONTAINER HLIST; -typedef HCONTAINER HORDLIST; - -//*********************************************** -// -// Function Prototypes -// -//*********************************************** -#ifdef __cplusplus -extern "C" { -#endif - -// call these functions to initialize and shutdown the debug messages for -// containers -extern void InitializeContainers(void); -extern void ShutdownContainers(void); - -// Stack Functions -// CreateStack(estimated number of items in stack, size of each item -// Push(handle to container returned from CreateStack, data to be passed in (must be void *) -// : returns handle to new stack -// Pop(handle to container returned from CreateStack, data to be passed in (must be void *) -// : returns BOOLEAN -// DeleteStack deletes the stack container -// StackSize returns size of stack - -extern HSTACK CreateStack(UINT32 num_of_elem , UINT32 siz_of_each); -extern HSTACK Push(HSTACK hStack, void *data); -extern BOOLEAN Pop(HSTACK hStack, void *data); -extern UINT32 StackSize(HSTACK hStack); -extern BOOLEAN DeleteStack(HSTACK hStack); -extern BOOLEAN PeekStack(HSTACK hStack, void *data); - -// Queue Functions -// CreateQueue(estimated number of items in queue, size of each item -// AddtoQueue(handle to container returned from CreateQueue, data to be passed in (must be void *)) -// : returns handle to queue -// RemfromQueue(handle to container returned from CreateQueue, variable where data is stored (must be void *)) -// : returns BOOLEAN -// PeekQueue(handle to the queue, variable where peeked data is stored). Item is not deleted. -// : returns BOOLEAN -// QueueSize(handle to the queue) returns the queue size -// DeleteQueue(handle to container) Delete the queue container -// : returns BOOLEAN - -extern HQUEUE CreateQueue(UINT32 num_of_elem, UINT32 siz_of_each); -extern HQUEUE AddtoQueue(HQUEUE hQueue, void *data); -extern BOOLEAN RemfromQueue(HQUEUE hQueue,void *data); -extern BOOLEAN PeekQueue(HQUEUE hQueue, void *data); -extern UINT32 QueueSize(HQUEUE hQueue); -extern BOOLEAN DeleteQueue(HQUEUE hQueue); - -// List Functions -// CreateList(estimated number of items in queue, size of each item -// AddtoList(handle to container returned from CreateQueue, data to be passed in (must be void *) -// position where data is to be added (0...sizeof(list)) -// : returns handle to new list -// RemfromList(handle to container returned from CreateList, variable where data is stored (must be void *) -// position where data is to be deleted (0...sizeof(list)-1) -// PeekList(handle to the list, variable where peeked data is stored). Item is not deleted. -// position where data is to be peeked (0...sizeof(list)-1) -// ListSize(handle to the list) returns the list size -// DeleteList(handle to the list) Delete the list container - -extern HLIST CreateList(UINT32 num_of_elem, UINT32 siz_of_each); -extern HLIST AddtoList(HLIST hList, void *data, UINT32 position); -extern BOOLEAN RemfromList(HLIST hList,void *data, UINT32 position); -extern BOOLEAN PeekList(HLIST hList, void *data, UINT32 position); -extern UINT32 ListSize(HLIST hList); -extern BOOLEAN DeleteList(HLIST hList); -extern BOOLEAN SwapListNode(HLIST hList, void *pdata, UINT32 uiPos); -extern BOOLEAN StoreListNode(HLIST hList, void *pdata, UINT32 uiPos); - -// Ordered List Functions -// CreateOrdList(estimated number of items in ordered list, size of each item, -// pointer to a compare function that returns info on whether the data in the ordered stack -// is < or > the new data to be added into the ordered list. -// AddtoOrdList(handle to container returned from CreateOrdList, data to be passed in (must be void *) -// RemfromOrdList(handle to container returned from CreateList, variable where data is stored (must be void *) -// position where data is to be deleted (0...sizeof(list)-1) -// PeekOrdList(handle to the list, variable where peeked data is stored). Item is not deleted. -// position where data is to be peeked (0...sizeof(list)-1) -// OrdListSize(handle to the list) returns the ordered list size -// DeleteOrdList(handle to the list) Delete the ordered list container - -extern HLIST CreateOrdList(UINT32 num_of_elem, UINT32 siz_of_each, INT8 (*compare)(void *,void *, UINT32)); -extern HLIST AddtoOrdList(HLIST hList, void *data); -extern BOOLEAN RemfromOrdList(HLIST hList,void *data, UINT32 position); -extern BOOLEAN PeekOrdList(HLIST hList, void *data, UINT32 position); -extern UINT32 OrdListSize(HLIST hList); -extern BOOLEAN DeleteOrdList(HLIST hList); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 9e4c3804..ec348b16 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -36,7 +36,6 @@ #include "MemMan.h" #include "Debug.h" #include "RegInst.h" - #include "Container.h" #include "LibraryDataBase.h" #include "io.h" #include "sgp_logger.h" @@ -149,8 +148,6 @@ void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ); void DestroyFileHandle( HWFILE hFile ); -void BuildFileDirectory( void ); -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *, HANDLE hFile, WIN32_FIND_DATA *pFind ); //************************************************************************** // @@ -950,169 +947,6 @@ void DestroyFileHandle( HWFILE hFile ) */ - -//************************************************************************** -// -// BuildFileDirectory -// -// -// -// Parameter List : -// Return Value : -// Modification history : -// -// ??nov96:HJH ->creation -// -//************************************************************************** - -void BuildFileDirectory( void ) -{ - - return; // temporary until container stuff is fixed -/* - INT32 i, iNumFiles = 0; - HANDLE hFile, hFileIn; - WIN32_FIND_DATA find, inFind; - BOOLEAN fMore = TRUE; - CHAR cName[FILENAME_LENGTH], cDir[FILENAME_LENGTH], cSubDir[FILENAME_LENGTH]; - HCONTAINER hStack; - - - - // - // First, push all the file names in the directory (and subdirectories) - // onto the stack. - // - - GetProfileChar( "Startup", "InstPath", "", cDir ); - - if ( strlen( cDir ) == 0 ) - return; - - hStack = CreateStack( 100, FILENAME_LENGTH ); - if (hStack == NULL) - { - FastDebugMsg(String("BuildFileDirectory: CreateStack Failed for the filename stack")); - return; - } - - find.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - - strcpy( &(cDir[strlen(cDir)]), "\\*.*\0" ); - hFile = FindFirstFile( cDir, &find ); - while ( fMore ) - { - if ( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) - { - if ( strcmp( find.cFileName, "." ) != 0 && strcmp( find.cFileName, ".." ) != 0 ) - { - // a valid directory - inFind.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - strcpy( cSubDir, cDir ); - strcpy( &(cSubDir[strlen(cDir)-3]), find.cFileName ); - strcpy( &(cSubDir[strlen(cSubDir)]), "\\*.*\0" ); - hFileIn = FindFirstFile( cSubDir, &inFind ); - iNumFiles += GetFilesInDirectory( hStack, cSubDir, hFileIn, &inFind ); - FindClose( hFileIn ); - } - } - else - { - iNumFiles++; - strcpy( cName, cDir ); - strcpy( &(cName[strlen(cName)-3]), find.cFileName ); - CharLower( cName ); - hStack = Push( hStack, cName ); - } - find.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - fMore = FindNextFile( hFile, &find ); - } - FindClose( hFile ); - - // - // Okay, we have all the files in the stack, now put them in place. - // - gfs.uiNumFilesInDirectory = iNumFiles; - - gfs.pcFileNames = (STR8)MemAlloc( iNumFiles * FILENAME_LENGTH ); - - if ( gfs.pcFileNames ) - { - for ( i=0 ; icreation -// -//************************************************************************** - -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_FIND_DATA *pFind ) -{ - INT32 iNumFiles; - WIN32_FIND_DATA inFind; - BOOLEAN fMore; - CHAR cName[FILENAME_LENGTH], cDir[FILENAME_LENGTH]; - HANDLE hFileIn; - - fMore = TRUE; - iNumFiles = 0; - - while ( fMore ) - { - if ( pFind->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) - { - if ( strcmp( pFind->cFileName, "." ) != 0 && strcmp( pFind->cFileName, ".." ) != 0 ) - { - // a valid directory - recurse and find the files in that directory - - inFind.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - strcpy( cDir, pcDir ); - strcpy( &(cDir[strlen(cDir)-3]), pFind->cFileName ); - strcpy( &(cDir[strlen(cDir)]), "\\*.*\0" ); - hFileIn = FindFirstFile( cDir, &inFind ); - iNumFiles += GetFilesInDirectory( hStack, cDir, hFileIn, &inFind ); - FindClose( hFileIn ); - } - } - else - { - iNumFiles++; - strcpy( cName, pcDir ); - strcpy( &(cName[strlen(cName)-3]), pFind->cFileName ); - CharLower( cName ); - hStack = Push( hStack, cName ); - } - pFind->dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - fMore = FindNextFile( hFile, pFind ); - } - - return(iNumFiles); -} - BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { try diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index e5ba0854..cf38d7b4 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -25,7 +25,6 @@ #include "FileCat.h" -#include "Container.h" //************************************************************************** // @@ -163,9 +162,6 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ); BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ); -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_FIND_DATA *pFind ); - - // CompareSGPFileTimes() returns... // -1 if the First file time is less than second file time. ( first file is older ) diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index b3fe6e6d..e5f601ee 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -453,9 +453,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow) return FALSE; } - FastDebugMsg("Initializing Containers Manager"); - InitializeContainers(); - FastDebugMsg("Initializing Input Manager"); // Initialize the Input Manager if (InitializeInputManager() == FALSE) @@ -656,7 +653,6 @@ void ShutdownStandardGamingPlatform(void) ShutdownVideoManager(); ShutdownInputManager(); - ShutdownContainers(); ShutdownFileManager(); #ifdef EXTREME_MEMORY_DEBUGGING diff --git a/Standard Gaming Platform/vobject.h b/Standard Gaming Platform/vobject.h index c4964899..40a59f03 100644 --- a/Standard Gaming Platform/vobject.h +++ b/Standard Gaming Platform/vobject.h @@ -2,7 +2,6 @@ #define __VOBJECT_H #include "types.h" -#include "container.h" #include "himage.h" // ************************************************************************************ diff --git a/Standard Gaming Platform/vsurface.h b/Standard Gaming Platform/vsurface.h index 8564aab5..b6a7fa0c 100644 --- a/Standard Gaming Platform/vsurface.h +++ b/Standard Gaming Platform/vsurface.h @@ -2,7 +2,6 @@ #define __VSURFACE_H #include "types.h" -#include "container.h" #include "himage.h" #include "vobject.h" #include diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index a1647353..4759b4ac 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -8,7 +8,6 @@ #include "vsurface.h" #include "Render Dirty.h" #include "sysutil.h" - #include "container.h" #include "wcheck.h" #include "video.h" #include "vobject_blitters.h" diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index c8543b59..9bc43579 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -18,7 +18,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" - #include "container.h" #include "interface.h" #include diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index d99e31bd..dacb8dfc 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -12,7 +12,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" -#include "container.h" #define _USE_MATH_DEFINES // for C #include #include "pathai.h" diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp index 4a3d7037..6b994eac 100644 --- a/Tactical/Soldier Tile.cpp +++ b/Tactical/Soldier Tile.cpp @@ -10,7 +10,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" - #include "container.h" #include "pathai.h" #include "Random.h" #include "worldman.h" diff --git a/Tactical/bullets.cpp b/Tactical/bullets.cpp index 3548b30c..3d1e62a3 100644 --- a/Tactical/bullets.cpp +++ b/Tactical/bullets.cpp @@ -7,7 +7,6 @@ #include "renderworld.h" #include "vsurface.h" #include "sysutil.h" - #include "container.h" #include "wcheck.h" #include "video.h" #include "vobject_blitters.h" diff --git a/Utils/Event Pump.cpp b/Utils/Event Pump.cpp index c0567777..74576ef5 100644 --- a/Utils/Event Pump.cpp +++ b/Utils/Event Pump.cpp @@ -1,7 +1,6 @@ #include #include #include "sgp.h" -#include "container.h" #include "wcheck.h" #include "Event Pump.h" #include "Timer.h" diff --git a/Utils/Utils All.h b/Utils/Utils All.h index dd77c717..208f4990 100644 --- a/Utils/Utils All.h +++ b/Utils/Utils All.h @@ -30,7 +30,6 @@ #include #include #include -#include "container.h" #include "wcheck.h" #include "Event Manager.h" #include "Event Pump.h" @@ -108,4 +107,4 @@ //#include //#include //#include -#endif \ No newline at end of file +#endif diff --git a/aniviewscreen.cpp b/aniviewscreen.cpp index 8f05104d..638e67a2 100644 --- a/aniviewscreen.cpp +++ b/aniviewscreen.cpp @@ -11,7 +11,6 @@ #include "input.h" #include "font.h" #include "screenids.h" - #include "container.h" #include "overhead.h" #include "sysutil.h" #include "Font Control.h"