diff --git a/lib/framework/block.c b/lib/framework/block.c index 16382ad0b..87a81ba8d 100644 --- a/lib/framework/block.c +++ b/lib/framework/block.c @@ -62,7 +62,7 @@ void blkShutDown(void) if (psBlockList) { - DBPRINTF(("blkShutDown: blocks still allocated:\n")); + debug( LOG_NEVER, "blkShutDown: blocks still allocated:\n" ); while (psBlockList) { psNext = psBlockList->psNext; @@ -77,39 +77,42 @@ void blkCallPos(STRING *pFileName, SDWORD line) { pCallFileName = pFileName; callLine = line; -} +} // Create a new block heap BOOL blkCreate(BLOCK_HEAP **ppsHeap, SDWORD init, SDWORD ext) { - - DBPRINTF(("BLKCREATE CALLED !!!!!!!!!!!!!!!!!!!!!!\n")); + + debug( LOG_NEVER, "BLKCREATE CALLED !!!!!!!!!!!!!!!!!!!!!!\n" ); *ppsHeap = (BLOCK_HEAP*)RMALLOC(sizeof(BLOCK_HEAP)); if (!*ppsHeap) { - DBERROR(("blkCreate: Out of memory")); + debug( LOG_ERROR, "blkCreate: Out of memory" ); + abort(); return FALSE; } (*ppsHeap)->psBlocks = (BLOCK_HEAP_MEM*)RMALLOC(sizeof(BLOCK_HEAP_MEM)); if (!(*ppsHeap)->psBlocks) { - DBERROR(("blkCreate: Out of memory")); + debug( LOG_ERROR, "blkCreate: Out of memory" ); + abort(); return FALSE; } (*ppsHeap)->psBlocks->pMem = (UBYTE*)RMALLOC(init); if (!(*ppsHeap)->psBlocks->pMem) { - DBERROR(("blkCreate: Out of memory")); + debug( LOG_ERROR, "blkCreate: Out of memory" ); + abort(); return FALSE; } - + (*ppsHeap)->init = init; (*ppsHeap)->ext = ext; (*ppsHeap)->psBlocks->size = init; (*ppsHeap)->psBlocks->pFree = (*ppsHeap)->psBlocks->pMem; (*ppsHeap)->psBlocks->psNext = NULL; - + #ifdef DEBUG_BLOCK (*ppsHeap)->pFileName = pCallFileName; (*ppsHeap)->line = callLine; @@ -131,8 +134,7 @@ void blkDestroy(BLOCK_HEAP *psHeap) #ifdef DEBUG_BLOCK if (psHeap->psMemTreap != NULL) { - DBPRINTF(("blkDestroy: %s at %d: memory allocated :\n", - psHeap->pFileName, psHeap->line)); + debug( LOG_NEVER, "blkDestroy: %s at %d: memory allocated :\n", psHeap->pFileName, psHeap->line ); memRecReport(psHeap->psMemTreap); } #endif @@ -157,17 +159,17 @@ void blkPrintDetails(BLOCK_HEAP *psHeap) { #ifdef DEBUG_BLOCK - UDWORD Left=(UDWORD)((psHeap->psBlocks->pMem)+(psHeap->psBlocks->size)-(psHeap->psBlocks->pFree)); - DBPRINTF(("ptr=%p init=%d ext=%d used=%d (Start=$%p Free=$%p Left=%d)\n",psHeap,psHeap->init,psHeap->ext,psHeap->TotalAllocated,psHeap->psBlocks->pMem,psHeap->psBlocks->pFree,Left)); + UDWORD Left = (UDWORD)((psHeap->psBlocks->pMem)+(psHeap->psBlocks->size)-(psHeap->psBlocks->pFree)); + debug( LOG_NEVER, "ptr=%p init=%d ext=%d used=%d (Start=$%p Free=$%p Left=%d)\n", psHeap,psHeap->init, psHeap->ext,psHeap->TotalAllocated, psHeap->psBlocks->pMem, psHeap->psBlocks->pFree, Left ); memMemoryDump(psHeap->psMemTreap); #else - DBPRINTF(("ptr=%p init=%d ext=%d\n",psHeap,psHeap->init,psHeap->ext)); + debug( LOG_NEVER, "ptr=%p init=%d ext=%d\n", psHeap, psHeap->init, psHeap->ext ); #endif } else { - DBPRINTF(("NULL POINTER IN BLOCK LIST\n")); + debug( LOG_NEVER, "NULL POINTER IN BLOCK LIST\n" ); } } @@ -177,24 +179,24 @@ void blkReport(void) { - + #ifdef DEBUG UDWORD BlockNumber=0; BLOCK_HEAP *psCurHeap; - DBPRINTF(("\n\nBlock Report. Current Block=%p:\n",memGetBlockHeap() )); + debug( LOG_NEVER, "\n\nBlock Report. Current Block=%p:\n", memGetBlockHeap() ); psCurHeap=psBlockList; while (psCurHeap) { - DBPRINTF(("Block %d) ",BlockNumber++)); + debug( LOG_NEVER, "Block %d)",BlockNumber++ ); blkPrintDetails(psCurHeap); psCurHeap = psCurHeap->psNext; } - DBPRINTF(("\n\n")); -#endif + debug( LOG_NEVER, "\n\n" ); +#endif } #if(0) // no longer used - uploaded in small chunks @@ -203,7 +205,7 @@ void blkReport(void) // // This can be used for scratch memory ... Critical on the Playstation where memory is so tight // -// - e.g. The sound data must be stored as one 400k file. This must be loaded into scratch memory +// - e.g. The sound data must be stored as one 400k file. This must be loaded into scratch memory // we clearly do not have 400k of spare memory around. // // @@ -221,9 +223,9 @@ BOOL blkSpecialFree(BLOCK_HEAP *psHeap, void *Ptr) if ((UDWORD)psCurr->pLastAllocated == RequestedFreeMem) { #ifdef DEBUG_BLOCK - + UDWORD BlockSize=((UDWORD)psCurr->pFree)-RequestedFreeMem; -DBPRINTF(("FREED %d block bytes\n",BlockSize)); // /// del me now ! + debug( LOG_NEVER, "FREED %d block bytes\n", BlockSize ); // del me now ! psHeap->TotalAllocated-=BlockSize; #endif @@ -235,7 +237,7 @@ DBPRINTF(("FREED %d block bytes\n",BlockSize)); // /// del me now ! } } return(FALSE); // unable to free mem - + } #endif @@ -267,9 +269,7 @@ void *blkAlloc(BLOCK_HEAP *psHeap, SDWORD size) // see if free has been called for this block if (psHeap->free) { - DBPRINTF(("Block Heap: %s at %d: Alloc after free:\n free %s at %d\n alloc %s at %d\n", - psHeap->pFileName, psHeap->line, psHeap->pFreeFile, psHeap->freeLine, - pCallFileName, callLine)); + debug( LOG_NEVER, "Block Heap: %s at %d: Alloc after free:\n free %s at %d\n alloc %s at %d\n", psHeap->pFileName, psHeap->line, psHeap->pFreeFile, psHeap->freeLine, pCallFileName, callLine ); psHeap->free = FALSE; } @@ -346,7 +346,7 @@ void *blkAlloc(BLOCK_HEAP *psHeap, SDWORD size) psNode->pFile = pCallFileName; psNode->line = callLine; psNode->size = allocSize; - + /* Store the new entry in the memory treap */ psNode->priority = (UDWORD)rand(); psNode->key = (UDWORD)psNode; @@ -454,7 +454,7 @@ void blkFree(BLOCK_HEAP *psHeap, void *pMemToFree) #if(1) - //DBPRINTF(("UNABLE TO FREE MEMORY\n")); + //DBPRINTF(("UNABLE TO FREE MEMORY\n")); #else @@ -462,17 +462,17 @@ void blkFree(BLOCK_HEAP *psHeap, void *pMemToFree) #ifdef DEBUG if (bRes==TRUE) { - DBPRINTF(("blkFree called - memory successfully released\n")); + debug( LOG_NEVER, "blkFree called - memory successfully released\n" ); } else { -// DBPRINTF(("blkFree called - memory NOT released\n")); +// debug( LOG_NEVER, "blkFree called - memory NOT released\n" ); } #endif #endif - } + } } @@ -490,8 +490,7 @@ void blkReset(BLOCK_HEAP *psHeap) #ifdef DEBUG_BLOCK if (psHeap->psMemTreap != NULL) { - DBPRINTF(("blkReset: %s at %d: memory allocated :\n", - psHeap->pFileName, psHeap->line)); + debug( LOG_NEVER, "blkReset: %s at %d: memory allocated :\n", psHeap->pFileName, psHeap->line ); memRecReport(psHeap->psMemTreap); } psHeap->psMemTreap = NULL; @@ -499,10 +498,9 @@ void blkReset(BLOCK_HEAP *psHeap) psHeap->TotalAllocated=0; - DBP0(("blkReset: %s at %d: memory usage:\n", - psHeap->pFileName, psHeap->line)); + debug( LOG_NEVER, "blkReset: %s at %d: memory usage:\n", psHeap->pFileName, psHeap->line ); #else - DBP0(("blkReset: memory usage:\n")); + debug( LOG_NEVER, "blkReset: memory usage:\n" ); #endif psCurr = psHeap->psBlocks; @@ -519,8 +517,7 @@ void blkReset(BLOCK_HEAP *psHeap) psCurr = psCurr->psNext; } - DBP0((" Blocks allocated %dk, Memory allocated %dk\n", - block/1024, alloc/1024)); + debug( LOG_NEVER, " Blocks allocated %dk, Memory allocated %dk\n", block/1024, alloc/1024 ); } @@ -619,7 +616,7 @@ void blockSuspendUsage(void) psSuspendedHeap = memGetBlockHeap(); memSetBlockHeap(NULL); - + } // restore the current block - if there is one @@ -640,13 +637,13 @@ void blockCurrentBlockInfo(void) psCurHeap=memGetBlockHeap(); if (psCurHeap==NULL) { - DBPRINTF(("*** No current block defined\n")); + debug( LOG_NEVER, "*** No current block defined\n" ); } else { UDWORD Left=(UDWORD)((psCurHeap->psBlocks->pMem)+(psCurHeap->psBlocks->size)-(psCurHeap->psBlocks->pFree)); - - DBPRINTF(("ptr=%p init=%d ext=%d used=%d (Start=$%p Free=$%p Left=%d)\n",psCurHeap,psCurHeap->init,psCurHeap->ext,psCurHeap->TotalAllocated,psCurHeap->psBlocks->pMem,psCurHeap->psBlocks->pFree,Left)); + + debug( LOG_NEVER, "ptr=%p init=%d ext=%d used=%d (Start=$%p Free=$%p Left=%d)\n", psCurHeap, psCurHeap->init, psCurHeap->ext, psCurHeap->TotalAllocated, psCurHeap->psBlocks->pMem, psCurHeap->psBlocks->pFree, Left ); } #endif } diff --git a/lib/framework/debug.c b/lib/framework/debug.c index 57eb99a5d..c4a106440 100644 --- a/lib/framework/debug.c +++ b/lib/framework/debug.c @@ -299,6 +299,3 @@ void debug( code_part part, const char *str, ... ) } useInputBuffer1 = !useInputBuffer1; // Swap buffers } - - - diff --git a/lib/framework/debug.h b/lib/framework/debug.h index 6f31baeb0..9c560bde2 100644 --- a/lib/framework/debug.h +++ b/lib/framework/debug.h @@ -29,6 +29,7 @@ #endif /* DBMB used to be 'show message box' */ +/* #ifndef _MSC_VER #define DBMB(x) _db_debug x #define DBPRINTF(x) _db_debug x @@ -37,6 +38,7 @@ #define DBMB(x) #define DBPRINTF(x) #endif +*/ /* * @@ -79,7 +81,7 @@ do { \ * * Arguments as for printf */ - +/* #ifndef _MSC_VER #define DBERROR(x) _debug_error x #define _debug_error(...) \ @@ -90,6 +92,7 @@ do { \ #else #define DBERROR(x) #endif +*/ /**************************************************************************************** diff --git a/lib/framework/frameresource.c b/lib/framework/frameresource.c index 4e3f62ebc..9cca0b4dc 100644 --- a/lib/framework/frameresource.c +++ b/lib/framework/frameresource.c @@ -162,7 +162,8 @@ static BOOL resAlloc(STRING *pType, RES_TYPE **ppsFunc) psT = (RES_TYPE *)MALLOC(sizeof(RES_TYPE)); if (!psT) { - DBERROR(("resAlloc: Out of memory")); + debug( LOG_ERROR, "resAlloc: Out of memory" ); + abort(); return FALSE; } diff --git a/lib/framework/heap.c b/lib/framework/heap.c index ee1750d19..db9730469 100644 --- a/lib/framework/heap.c +++ b/lib/framework/heap.c @@ -136,7 +136,8 @@ BOOL heapCreate(OBJ_HEAP **ppsHeap, UDWORD size, UDWORD init, UDWORD ext) *ppsHeap = (OBJ_HEAP *)MALLOC(sizeof(OBJ_HEAP)); if (*ppsHeap == NULL) { - DBERROR(("heapCreate: Out of memory")); + debug( LOG_ERROR, "heapCreate: Out of memory" ); + abort(); return FALSE; } // memset(*ppsHeap,0,sizeof(OBJ_HEAP)); //setting everything to 0 first (debug test)-Q @@ -155,7 +156,8 @@ BOOL heapCreate(OBJ_HEAP **ppsHeap, UDWORD size, UDWORD init, UDWORD ext) if ((*ppsHeap)->pMemory == NULL) { - DBERROR(("heapCreate: Out of memory")); + debug( LOG_ERROR, "heapCreate: Out of memory" ); + abort(); return FALSE; } @@ -183,7 +185,8 @@ BOOL heapCreate(OBJ_HEAP **ppsHeap, UDWORD size, UDWORD init, UDWORD ext) } if (HeapDebugList[Heap]!=*ppsHeap) { - DBERROR(("heapCreate: MAXDEBUGHEAPS too small")); + debug( LOG_ERROR, "heapCreate: MAXDEBUGHEAPS too small" ); + abort(); } #endif @@ -440,8 +443,7 @@ void heapDestroy(OBJ_HEAP *psHeap) /* Warn about any unfreed objects */ if (psHeap->currUsage > 0) { - DBPRINTF(("heapDestroy: %s, line %d : %d objects in use\n", - psHeap->pFile, psHeap->line, psHeap->currUsage)); + debug( LOG_NEVER, "heapDestroy: %s, line %d : %d objects in use\n", psHeap->pFile, psHeap->line, psHeap->currUsage ); } /* Print out where the unfreed objects were allocated */ @@ -473,9 +475,7 @@ void heapDestroy(OBJ_HEAP *psHeap) ASSERT((clean, "heapDestroy: unallocated memory has been overwritten")); #if HEAP_USAGE_REPORT - DBPRINTF(("heapDestory: %s, line %d : Max usage %d (Init %d Ext %d)\n", - psHeap->pFile, psHeap->line, psHeap->maxUsage, - psHeap->initAlloc, psHeap->extAlloc)); + debug( LOG_NEVER, "heapDestory: %s, line %d : Max usage %d (Init %d Ext %d)\n", psHeap->pFile, psHeap->line, psHeap->maxUsage, psHeap->initAlloc, psHeap->extAlloc ); #endif #if COPY_FILE_STRING @@ -551,21 +551,17 @@ void heapReport(void) OBJ_HEAP *psHeap; - DBPRINTF(("\nheapReport\n==========\n")); + debug( LOG_NEVER, "\nheapReport\n==========\n" ); for (Heap=0;HeappFile, psHeap->line, psHeap->objSize, psHeap->objSize*psHeap->initAlloc)); - - DBPRINTF((" Current Usage=%d ",psHeap->currUsage)); - - DBPRINTF((" Max usage %d (Init %d Ext %d)\n", - psHeap->maxUsage, - psHeap->initAlloc, psHeap->extAlloc)); + debug( LOG_NEVER, "Heap: %s, line %d size=%d mem taken=%d\n", psHeap->pFile, psHeap->line, psHeap->objSize, psHeap->objSize*psHeap->initAlloc ); + + debug( LOG_NEVER, " Current Usage=%d ", psHeap->currUsage ); + debug( LOG_NEVER, " Max usage %d (Init %d Ext %d)\n", psHeap->maxUsage, psHeap->initAlloc, psHeap->extAlloc ); } } diff --git a/lib/framework/mem.c b/lib/framework/mem.c index a70f968d6..c45324f93 100644 --- a/lib/framework/mem.c +++ b/lib/framework/mem.c @@ -166,7 +166,7 @@ void *memMalloc(STRING *pFileName, SDWORD LineNumber, size_t Size) ASSERT((FALSE, "Warning: malloc returning NULL - [%s - %d]",pFileName,LineNumber)); - DBPRINTF(("[%s - %d] %d bytes\n",pFileName,LineNumber,Size)); + debug( LOG_NEVER, "[%s - %d] %d bytes\n", pFileName, LineNumber, Size ); return NULL; } @@ -176,7 +176,7 @@ void *memMalloc(STRING *pFileName, SDWORD LineNumber, size_t Size) if (!psNode->pFile) { RFREE(pMemBase); - DBMB(("Warning: malloc returning NULL")); + debug( LOG_NEVER, "Warning: malloc returning NULL" ); return NULL; } strcpy(psNode->pFile, pFileName); diff --git a/lib/framework/resource_lexer.l b/lib/framework/resource_lexer.l index e10804a09..c2a620bf2 100644 --- a/lib/framework/resource_lexer.l +++ b/lib/framework/resource_lexer.l @@ -124,7 +124,8 @@ int res_wrap(void) { if (inComment) { - DBERROR(("Warning: reached end of file in a comment")); + debug( LOG_ERROR, "Warning: reached end of file in a comment" ); + abort(); } return 1; } diff --git a/lib/framework/resource_parser.y b/lib/framework/resource_parser.y index 9883b8d16..dedfa1451 100644 --- a/lib/framework/resource_parser.y +++ b/lib/framework/resource_parser.y @@ -31,8 +31,8 @@ void res_error(const char *pMessage,...) char *pText; resGetErrorData(&line, &pText); - DBERROR(("RES file parse error:\n%s at line %d\nText: '%s'\n", - pMessage, line, pText)); + debug( LOG_ERROR, "RES file parse error:\n%s at line %d\nText: '%s'\n", pMessage, line, pText ); + abort(); } %} @@ -65,7 +65,7 @@ dir_line: DIRECTORY QTEXT_T { UDWORD len; // set a new input directory - DBP0(("directory: %s\n", $2)); + debug( LOG_NEVER, "directory: %s\n", $2 ); if ($2[1] == ':' || $2[0] == '\\') { diff --git a/lib/framework/strres.c b/lib/framework/strres.c index 702953f04..4b828fe0f 100644 --- a/lib/framework/strres.c +++ b/lib/framework/strres.c @@ -32,14 +32,16 @@ static BOOL strresAllocBlock(STR_BLOCK **ppsBlock, UDWORD size) *ppsBlock = (STR_BLOCK*)MALLOC(sizeof(STR_BLOCK)); if (!*ppsBlock) { - DBERROR(("strresAllocBlock: Out of memory - 1")); + debug( LOG_ERROR, "strresAllocBlock: Out of memory - 1" ); + abort(); return FALSE; } (*ppsBlock)->apStrings = (STRING**)MALLOC(sizeof(STRING *) * size); if (!(*ppsBlock)->apStrings) { - DBERROR(("strresAllocBlock: Out of memory - 2")); + debug( LOG_ERROR, "strresAllocBlock: Out of memory - 2" ); + abort(); FREE(*ppsBlock); return FALSE; } @@ -62,7 +64,8 @@ BOOL strresCreate(STR_RES **ppsRes, UDWORD init, UDWORD ext) psRes = (STR_RES*)MALLOC(sizeof(STR_RES)); if (!psRes) { - DBERROR(("strresCreate: Out of memory")); + debug( LOG_ERROR, "strresCreate: Out of memory" ); + abort(); return FALSE; } psRes->init = init; @@ -71,7 +74,8 @@ BOOL strresCreate(STR_RES **ppsRes, UDWORD init, UDWORD ext) if (!TREAP_CREATE(&psRes->psIDTreap, treapStringCmp, init, ext)) { - DBERROR(("strresCreate: Out of memory")); + debug( LOG_ERROR, "strresCreate: Out of memory" ); + abort(); FREE(psRes); return FALSE; } @@ -148,7 +152,7 @@ void strresDestroy(STR_RES *psRes) #ifdef DEBUG else if (i < psRes->nextID) { - DBPRINTF(("strresDestroy: No string loaded for id %d\n", i)); + debug( LOG_NEVER, "strresDestroy: No string loaded for id %d\n", i ); } #endif } @@ -182,7 +186,8 @@ BOOL strresLoadFixedID(STR_RES *psRes, STR_ID *psID, UDWORD numID) // Store the ID string if (!TREAP_ADD(psRes->psIDTreap, (UDWORD)psID->pIDStr, psID)) { - DBERROR(("strresLoadFixedID: Out of memory")); + debug( LOG_ERROR, "strresLoadFixedID: Out of memory" ); + abort(); return FALSE; } @@ -261,13 +266,15 @@ BOOL strresStoreString(STR_RES *psRes, STRING *pID, STRING *pString) psID = (STR_ID*)MALLOC(sizeof(STR_ID)); if (!psID) { - DBERROR(("strresStoreString: Out of memory")); + debug( LOG_ERROR, "strresStoreString: Out of memory" ); + abort(); return FALSE; } psID->pIDStr = (STRING*)MALLOC(sizeof(STRING) * (stringLen(pID) + 1)); if (!psID->pIDStr) { - DBERROR(("strresStoreString: Out of memory")); + debug( LOG_ERROR, "strresStoreString: Out of memory" ); + abort(); FREE(psID); return FALSE; } @@ -298,7 +305,8 @@ BOOL strresStoreString(STR_RES *psRes, STRING *pID, STRING *pString) // Put the new string in the string block if (psBlock->apStrings[psID->id - psBlock->idStart] != NULL) { - DBERROR(("strresStoreString: Duplicate string for id: %s", psID->pIDStr)); + debug( LOG_ERROR, "strresStoreString: Duplicate string for id: %s", psID->pIDStr ); + abort(); return FALSE; } @@ -306,7 +314,8 @@ BOOL strresStoreString(STR_RES *psRes, STRING *pID, STRING *pString) pNew = (STRING*)MALLOC(sizeof(STRING) * (stringLen(pString) + 1)); if (!pNew) { - DBERROR(("strresStoreString: Out of memory")); + debug( LOG_ERROR, "strresStoreString: Out of memory" ); + abort(); return FALSE; } stringCpy(pNew, pString); diff --git a/lib/framework/strres_lexer.l b/lib/framework/strres_lexer.l index f0f2a9121..9236aac67 100644 --- a/lib/framework/strres_lexer.l +++ b/lib/framework/strres_lexer.l @@ -116,7 +116,8 @@ int strres_wrap(void) { if (inComment) { - DBERROR(("Warning: reched end of file in a comment")); + debug( LOG_ERROR, "Warning: reched end of file in a comment" ); + abort(); } return 1; diff --git a/lib/framework/strres_parser.y b/lib/framework/strres_parser.y index 2e06e0b11..898008d20 100644 --- a/lib/framework/strres_parser.y +++ b/lib/framework/strres_parser.y @@ -28,8 +28,8 @@ void strres_error(const char *pMessage,...) char *pText; strresGetErrorData(&line, &pText); - DBERROR(("STRRES file parse error:\n%s at line %d\nText: '%s'\n", - pMessage, line, pText)); + debug( LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'\n", pMessage, line, pText ); + abort(); } %} diff --git a/lib/framework/treap.c b/lib/framework/treap.c index 023dbec62..8aa6b7301 100644 --- a/lib/framework/treap.c +++ b/lib/framework/treap.c @@ -77,13 +77,15 @@ BOOL treapCreate(TREAP **ppsTreap, TREAP_CMP cmp, UDWORD init, UDWORD ext) *ppsTreap = (TREAP*)MALLOC(sizeof(TREAP)); if (!(*ppsTreap)) { - DBERROR(("treapCreate: Out of memory")); + debug( LOG_ERROR, "treapCreate: Out of memory" ); + abort(); return FALSE; } if (!HEAP_CREATE(&((*ppsTreap)->psNodes), sizeof(TREAP_NODE), init, ext)) { - DBERROR(("treapCreate: Out of memory")); + debug( LOG_ERROR, "treapCreate: Out of memory" ); + abort(); FREE(*ppsTreap); return FALSE; } @@ -147,7 +149,7 @@ void treapAddNode(TREAP_NODE **ppsRoot, TREAP_NODE *psNew, TREAP_CMP cmp) { // Node less than root, insert to the left of the tree treapAddNode(&(*ppsRoot)->psLeft, psNew, cmp); - + // Sort the priority if ((*ppsRoot)->priority > (*ppsRoot)->psLeft->priority) { @@ -159,7 +161,7 @@ void treapAddNode(TREAP_NODE **ppsRoot, TREAP_NODE *psNew, TREAP_CMP cmp) { // Node greater than root, insert to the right of the tree treapAddNode(&(*ppsRoot)->psRight, psNew, cmp); - + // Sort the priority if ((*ppsRoot)->priority > (*ppsRoot)->psRight->priority) { @@ -330,7 +332,7 @@ static void treapReportRec(TREAP_NODE *psRoot) { if (psRoot) { - DBPRINTF((" %s, line %d\n", psRoot->pFile, psRoot->line)); + debug( LOG_NEVER, ((" %s, line %d\n", psRoot->pFile, psRoot->line ); treapReportRec(psRoot->psLeft); treapReportRec(psRoot->psRight); } @@ -369,8 +371,7 @@ void treapDestroy(TREAP *psTreap) #if DEBUG_TREAP if (psTreap->psRoot) { - DBPRINTF(("treapDestroy: %s, line %d : nodes still in the tree\n", - psTreap->pFile, psTreap->line)); + debug( LOG_NEVER, "treapDestroy: %s, line %d : nodes still in the tree\n", psTreap->pFile, psTreap->line ); treapReportRec(psTreap->psRoot); } FREE(psTreap->pFile); @@ -388,11 +389,9 @@ void treapDisplayRec(TREAP_NODE *psRoot, UDWORD indent) // Display the root #if DEBUG_TREAP - DBPRINTF(("%s, line %d : %d,%d\n", - psRoot->pFile, psRoot->line, - psRoot->key, psRoot->priority)); + debug( LOG_NEVER, "%s, line %d : %d,%d\n", psRoot->pFile, psRoot->line, psRoot->key, psRoot->priority ); #else - DBPRINTF(("%d,%d\n", psRoot->key, psRoot->priority)); + debug( LOG_NEVER, "%d,%d\n", psRoot->key, psRoot->priority ); #endif // Display the left of the tree @@ -400,9 +399,9 @@ void treapDisplayRec(TREAP_NODE *psRoot, UDWORD indent) { for(i=0; ipsLeft, indent+1); } @@ -411,9 +410,9 @@ void treapDisplayRec(TREAP_NODE *psRoot, UDWORD indent) { for(i=0; ipsRight, indent+1); } } diff --git a/lib/gamelib/anim.c b/lib/gamelib/anim.c index 3554ca6d2..76f3efc08 100644 --- a/lib/gamelib/anim.c +++ b/lib/gamelib/anim.c @@ -46,7 +46,8 @@ anim_Init( GETSHAPEFUNC pGetShapeFunc ) /* ensure ANIM2D and ANIM3D structs same size */ if ( iSizeAnim2D != iSizeAnim3D ) { - DBERROR( ("anim_Init: ANIM2D and ANIM3D structs not same size in anim.h!") ); + debug( LOG_ERROR, "anim_Init: ANIM2D and ANIM3D structs not same size in anim.h!" ); + abort(); } /* init globals */ @@ -91,7 +92,7 @@ anim_Shutdown( void ) if (g_animGlobals.psAnimList != NULL) { - DBPRINTF(("anim_Shutdown: warning anims still allocated")); + debug( LOG_NEVER, "anim_Shutdown: warning: anims still allocated" ); } /* empty anim list */ @@ -161,8 +162,9 @@ anim_Create3D( char szPieFileName[], UWORD uwStates, /* check frame count matches script */ if ( ubType == ANIM_3D_TRANS && uwObj != uwFrames ) { - DBERROR( ("anim_Create3D: frames in pie %s != script objects %i\n", - szPieFileName, uwObj ) ); + debug( LOG_ERROR, "anim_Create3D: frames in pie %s != script objects %i\n", + szPieFileName, uwObj ); + abort(); return FALSE; } @@ -211,7 +213,8 @@ anim_EndScript( void ) if ( g_animGlobals.uwCurState != psAnim->uwStates ) { - DBERROR( ("anim_End3D: states in current anim not consistent with header\n") ); + debug( LOG_ERROR, "anim_End3D: states in current anim not consistent with header\n" ); + abort(); return FALSE; } @@ -296,7 +299,8 @@ anim_SetVals( char szFileName[], UWORD uwAnimID ) if ( psAnim == NULL ) { - DBERROR( ("anim_SetVals: can't find anim %s\n", szFileName) ); + debug( LOG_ERROR, "anim_SetVals: can't find anim %s\n", szFileName ); + abort(); return ; } @@ -312,7 +316,8 @@ BASEANIM *anim_LoadFromBuffer(char *pBuffer, UDWORD size) { if ( ParseResourceFile( pBuffer, size ) == FALSE ) { - DBERROR( ("anim_LoadFromBuffer: couldn't parse file\n") ); + debug( LOG_ERROR, "anim_LoadFromBuffer: couldn't parse file\n" ); + abort(); return NULL; } @@ -330,7 +335,8 @@ anim_GetAnimID( char *szName ) if ( cPos == NULL ) { - DBERROR( ("anim_GetAnimID: %s isn't .ani file\n", szName)); + debug( LOG_ERROR, "anim_GetAnimID: %s isn't .ani file\n", szName ); + abort(); return NO_ANIM; } diff --git a/lib/gamelib/animobj.c b/lib/gamelib/animobj.c index a0e0cc477..56a91efb8 100644 --- a/lib/gamelib/animobj.c +++ b/lib/gamelib/animobj.c @@ -161,7 +161,8 @@ animObj_Update( void ) if ( hashTable_RemoveElement( g_pAnimObjTable, psObj, (int) psObj->psParent, psObj->psAnim->uwID ) == FALSE ) { - DBERROR( ("animObj_Update: couldn't remove anim obj\n") ); + debug( LOG_ERROR, "animObj_Update: couldn't remove anim obj\n" ); + abort(); } } @@ -195,7 +196,8 @@ animObj_Add( void *pParentObj, int iAnimID, if (psObj==NULL) { - DBERROR( ("animObj_Add: No room in hash table\n") ); + debug( LOG_ERROR, "animObj_Add: No room in hash table\n" ); + abort(); return(NULL); } @@ -221,7 +223,8 @@ animObj_Add( void *pParentObj, int iAnimID, if ( uwObj > ANIM_MAX_COMPONENTS ) { - DBERROR( ("animObj_Add: number of components too small\n") ); + debug( LOG_ERROR, "animObj_Add: number of components too small\n" ); + abort(); } /* set parent pointer and shape pointer */ diff --git a/lib/gamelib/audp_parser.y b/lib/gamelib/audp_parser.y index b1482bf8c..1972f1d5c 100644 --- a/lib/gamelib/audp_parser.y +++ b/lib/gamelib/audp_parser.y @@ -195,13 +195,12 @@ void audp_error(char *pMessage,...) va_list args; va_start(args, pMessage); - vsprintf(aTxtBuf, pMessage, args); - parseGetErrorData( &line, &pText ); - DBERROR(("RES file parse error:\n%s at line %d\nToken: %d, Text: '%s'\n", - aTxtBuf, line, audp_char, pText)); - va_end(args); + + parseGetErrorData( &line, &pText ); + debug( LOG_ERROR, "RES file parse error:\n%s at line %d\nToken: %d, Text: '%s'\n", aTxtBuf, line, audp_char, pText ); + abort(); } /***************************************************************************/ diff --git a/lib/gamelib/pqueue.c b/lib/gamelib/pqueue.c index 2b1a6cc62..f705c4a65 100644 --- a/lib/gamelib/pqueue.c +++ b/lib/gamelib/pqueue.c @@ -29,7 +29,8 @@ queue_Init( QUEUE ** ppQueue, int iMaxElements, int iElementSize, if ( (*ppQueue) == NULL ) { - DBERROR( ("queue_Init: couldn't allocate memory for queue") ); + debug( LOG_ERROR, "queue_Init: couldn't allocate memory for queue" ); + abort(); return FALSE; } @@ -42,7 +43,8 @@ queue_Init( QUEUE ** ppQueue, int iMaxElements, int iElementSize, if ( (*ppQueue) == NULL ) { - DBERROR( ("queue_Init: couldn't allocate memory for queue node") ); + debug( LOG_ERROR, "queue_Init: couldn't allocate memory for queue node" ); + abort(); return FALSE; } @@ -154,7 +156,7 @@ queue_Enqueue( QUEUE * pQueue, void * psElement, int iPriority ) /* check list not empty */ if ( pQueue->psFreeNodeList == NULL ) { - DBPRINTF( ("queue_GetFreeElement: all nodes allocated: flushing queue.\n") ); + debug( LOG_NEVER, "queue_GetFreeElement: all nodes allocated: flushing queue.\n" ); queue_Clear( pQueue ); } diff --git a/lib/gamelib/ptrlist.c b/lib/gamelib/ptrlist.c index 937a04cc8..7e8c9ef8b 100644 --- a/lib/gamelib/ptrlist.c +++ b/lib/gamelib/ptrlist.c @@ -161,7 +161,7 @@ ptrList_FreeElement( PTRLIST *ptrList, void *psElement ) if ( HEAP_FREE( ptrList->psElementHeap, psElement ) == FALSE ) { - DBPRINTF( ("ptrList_FreeElement: couldn't free element\n") ); + debug( LOG_NEVER, "ptrList_FreeElement: couldn't free element\n" ); } } diff --git a/lib/ivis_common/bug.c b/lib/ivis_common/bug.c index 274622d71..2215898e2 100644 --- a/lib/ivis_common/bug.c +++ b/lib/ivis_common/bug.c @@ -41,7 +41,7 @@ void iV_DisplayLogFile(void) if (fp) { while ((c = getc(fp)) != EOF) - DBPRINTF(("%c",c)); + debug( LOG_NEVER, "%c", c ); fclose(fp); } } diff --git a/lib/ivis_common/imd.c b/lib/ivis_common/imd.c index 2abd0dc67..49d9ce883 100644 --- a/lib/ivis_common/imd.c +++ b/lib/ivis_common/imd.c @@ -5,17 +5,17 @@ #include // we need BSPIMD defined if we want to read & use the BSP imd files - + // Define this if we are compile ivis for the BSP generating tool, also for PIEBIN tool //#define PIETOOL #ifdef PIETOOL -#define BSPIMD +#define BSPIMD #define SAVEIMD #endif #include "ivisdef.h" -#include "imd.h" +#include "imd.h" #include "bug.h" #include "tex.h" #include "ivispatch.h" @@ -46,7 +46,7 @@ // most of them are in ptrlist.c which is no longer included in ivis. See the source for BSPIMD // for this file. Becareful not to confuse this with the same named file in deliverance/src which // might or might not be the same. -// +// #ifdef PIETOOL // Prototypes for the linked list handling @@ -66,8 +66,8 @@ void OutputTriangleList(FILE *fp, PSBSPPTRLIST TriList) int d; if (TriList == NULL) return; - - Triangle = list_GetFirst(TriList); + + Triangle = list_GetFirst(TriList); while (Triangle != NULL) { fprintf(fp,"\t%8x %d",Triangle->flags,Triangle->npnts); @@ -77,7 +77,7 @@ void OutputTriangleList(FILE *fp, PSBSPPTRLIST TriList) if (Triangle->flags & iV_IMD_TEXANIM) { if (Triangle->pTexAnim == NULL) { - DBPRINTF(("No TexAnim pointer!\n")); + debug( LOG_NEVER, "No TexAnim pointer!\n" ); } else { fprintf(fp," %d %d %d %d", Triangle->pTexAnim->nFrames, @@ -86,7 +86,7 @@ void OutputTriangleList(FILE *fp, PSBSPPTRLIST TriList) Triangle->pTexAnim->textureHeight); } } - + // if textured write texture uv's if (Triangle->flags & (iV_IMD_TEX | iV_IMD_PSXTEX)) { for (d = 0; d < Triangle->npnts; d++) { @@ -107,8 +107,8 @@ void CountTriangleList(PSBSPPTRLIST TriList) if (TriList == NULL) return; if (TriList->iNumNodes == 0) return; - - Triangle=list_GetFirst(TriList); + + Triangle=list_GetFirst(TriList); while (Triangle != NULL) { BSPPolyTable[BSPPolys] = Triangle; @@ -127,7 +127,7 @@ void CountBSPPolys(PSBSPTREENODE psNode) BSPNodeTable[BSPNodes] = psNode; BSPNodes++; - + CountBSPPolys(psNode->link[LEFT]); CountTriangleList(psNode->psTriSameDir); CountTriangleList(psNode->psTriOppoDir); @@ -175,7 +175,7 @@ int HuntPolyList(iIMDPoly *Poly) void DumpTriangleList(FILE *fp,PSBSPPTRLIST TriList) { - + iIMDPoly *Triangle; assert(BSPPolysnconnectors); p = s->connectors; for (i=0; inconnectors; i++, p++) { - fprintf(fp,"\t%d %d %d\n", p->x,p->y,p->z); + fprintf(fp,"\t%d %d %d\n", p->x,p->y,p->z); } } } @@ -298,7 +298,7 @@ iBool iV_IMDSave(STRING *filename, iIMDShape *s, BOOL PieIMD) #ifdef PIETOOL if (sp->BSPNode==NULL) #endif - { + { fprintf(fp,"POLYGONS %d\n",sp->npolys); for (poly = sp->polys, j=0; jnpolys; j++, poly++) { fprintf(fp,"\t%8x %d",poly->flags,poly->npnts); @@ -309,7 +309,7 @@ iBool iV_IMDSave(STRING *filename, iIMDShape *s, BOOL PieIMD) if (poly->flags & iV_IMD_TEXANIM) { if (poly->pTexAnim == NULL) { - printf("No TexAnim pointer!\n"); + printf("No TexAnim pointer!\n"); } else { fprintf(fp," %d %d %d %d", poly->pTexAnim->nFrames, @@ -330,11 +330,11 @@ iBool iV_IMDSave(STRING *filename, iIMDShape *s, BOOL PieIMD) } #ifdef PIETOOL else - { + { int NodeCount; fprintf(fp,"POLYGONS %d\n",GetBSPPolyCount(sp->BSPNode,&NodeCount) ); - OutputBSPPolys(fp,sp->BSPNode); // + OutputBSPPolys(fp,sp->BSPNode); // fprintf(fp,"BSP %d\n",NodeCount ); OutputBSPNodes(fp,sp->BSPNode); diff --git a/lib/ivis_common/imdload.c b/lib/ivis_common/imdload.c index 242df6ddc..c94329135 100644 --- a/lib/ivis_common/imdload.c +++ b/lib/ivis_common/imdload.c @@ -153,11 +153,11 @@ static UDWORD IMDConnectors = 0; void DumpIMDInfo(void) { - DBPRINTF(("imds loaded =%d - using %d bytes\n",IMDcount,IMDcount*sizeof(iIMDShape))); - DBPRINTF(("polys loaded =%d - using %d bytes\n",IMDPolycount,IMDPolycount*sizeof(iIMDPoly))); - DBPRINTF(("vertices loaded=%d - using %d bytes\n",IMDVertexcount,IMDVertexcount*(sizeof(VERTEXID)+sizeof(iVertex)))); - DBPRINTF(("points loaded =%d - using %d bytes\n",IMDPoints,IMDPoints*sizeof(iVector))); - DBPRINTF(("connectors =%d - using %d bytes\n",IMDConnectors,IMDConnectors*sizeof(iVector) )); + debug( LOG_NEVER, "imds loaded =%d - using %d bytes\n", IMDcount, IMDcount*sizeof(iIMDShape) ); + debug( LOG_NEVER, "polys loaded =%d - using %d bytes\n", IMDPolycount, IMDPolycount*sizeof(iIMDPoly) ); + debug( LOG_NEVER, "vertices loaded=%d - using %d bytes\n", IMDVertexcount, IMDVertexcount*(sizeof(VERTEXID)+sizeof(iVertex)) ); + debug( LOG_NEVER, "points loaded =%d - using %d bytes\n", IMDPoints, IMDPoints*sizeof(iVector) ); + debug( LOG_NEVER, "connectors =%d - using %d bytes\n", IMDConnectors, IMDConnectors*sizeof(iVector) ); } static STRING texfile[64]; //Last loaded texture page filename @@ -415,7 +415,7 @@ static iBool _imd_load_polys(STRING **ppFileData, STRING *FileDataEnd, iIMDShape int NewID; if (sscanf(pFileData, "%d%n", &NewID,&cnt) != 1) { - DBPRINTF(("failed poly %d. point %d [%s]\n",i,j,_IMD_NAME)); + debug( LOG_NEVER, "failed poly %d. point %d [%s]\n", i, j, _IMD_NAME ); iV_Error(0xff,"(_load_polys) [poly %d] error reading poly indices",i); return FALSE; } diff --git a/lib/ivis_opengl/piepalette.c b/lib/ivis_opengl/piepalette.c index 1a06aa62e..2ce82ce05 100644 --- a/lib/ivis_opengl/piepalette.c +++ b/lib/ivis_opengl/piepalette.c @@ -56,7 +56,8 @@ int pal_AddNewPalette(iColour *pal) psGamePal = (iColour*) MALLOC(PALETTE_SIZE * sizeof(iColour)); if (psGamePal == NULL) { - DBERROR(("pal_AddNewPalette - Out of memory")); + debug( LOG_ERROR, "pal_AddNewPalette - Out of memory" ); + abort(); return FALSE; } } @@ -65,7 +66,8 @@ int pal_AddNewPalette(iColour *pal) psWinPal = (PALETTEENTRY*) MALLOC(PALETTE_SIZE * sizeof(PALETTEENTRY)); if (psGamePal == NULL) { - DBERROR(("pal_AddNewPalette - Out of memory")); + debug( LOG_ERROR, "pal_AddNewPalette - Out of memory" ); + abort(); return FALSE; } } diff --git a/lib/ivis_opengl/tex.c b/lib/ivis_opengl/tex.c index 530148e5a..6eeda8728 100644 --- a/lib/ivis_opengl/tex.c +++ b/lib/ivis_opengl/tex.c @@ -231,7 +231,7 @@ void pie_TexShutDown(void) { i++; } - DBPRINTF(("pie_TexShutDown successful - freed %d texture pages\n",j)); + debug( LOG_NEVER, "pie_TexShutDown successful - freed %d texture pages\n", j ); } void pie_TexInit(void) { diff --git a/lib/netplay/netcrypt.c b/lib/netplay/netcrypt.c index 997ef8557..45e43dd06 100644 --- a/lib/netplay/netcrypt.c +++ b/lib/netplay/netcrypt.c @@ -195,7 +195,8 @@ NETMSG *NETmanglePacket(NETMSG *msg) if(msg->size > MaxMsgSize-NIBBLELENGTH) { - DBERROR(("NETmanglePacket: can't encrypt huge packets. returning unencrypted packet")); + debug( LOG_ERROR, "NETmanglePacket: can't encrypt huge packets. returning unencrypted packet" ); + abort(); return msg; } @@ -234,7 +235,8 @@ VOID NETunmanglePacket(NETMSG *msg) if(msg->size%NIBBLELENGTH !=0) { - DBERROR(("NETunmanglePacket: Incoming msg wrong length")); + debug( LOG_ERROR, "NETunmanglePacket: Incoming msg wrong length" ); + abort(); NETlogEntry("NETunmanglePacket failure",msg->type,msg->size); return; } @@ -266,7 +268,8 @@ BOOL NETmangleData(long *input,long *result, UDWORD dataSize) if(dataSize%8 != 0) //if message not multiple of 8 bytes, { - DBERROR(("NETmangleData: msg not a multiple of 8 bytes")); + debug( LOG_ERROR, "NETmangleData: msg not a multiple of 8 bytes" ); + abort(); return FALSE; } @@ -290,7 +293,8 @@ BOOL NETunmangleData(long *input, long *result, UDWORD dataSize) if(dataSize%8 != 0) //if message not multiple of 8 bytes, { - DBERROR(("NETunmangleData: msg not a multiple of 8 bytes")); + debug( LOG_ERROR, "NETunmangleData: msg not a multiple of 8 bytes" ); + abort(); return FALSE; } diff --git a/lib/netplay/netjoin_stub.c b/lib/netplay/netjoin_stub.c index e9a843445..7d96fbd85 100644 --- a/lib/netplay/netjoin_stub.c +++ b/lib/netplay/netjoin_stub.c @@ -23,7 +23,8 @@ DWORD NETgetGameFlagsUnjoined(UDWORD gameid, UDWORD flag) return NetPlay.games[gameid].desc.dwUser4; break; default: - DBERROR(("Invalid flag for getgameflagsunjoined in netplay lib")); + debug( LOG_ERROR, "Invalid flag for NETgetGameFlagsUnjoined in netplay lib" ); + abort(); break; } return 0; diff --git a/lib/netplay/netplay.c b/lib/netplay/netplay.c index 2258c1cec..c8ef067eb 100644 --- a/lib/netplay/netplay.c +++ b/lib/netplay/netplay.c @@ -463,7 +463,7 @@ BOOL NETinit(BOOL bFirstCall) if(bFirstCall) { - DBPRINTF(("NETPLAY: Init called, MORNIN' \n ")); + debug( LOG_NEVER, "NETPLAY: Init called, MORNIN'\n" ); NetPlay.bLobbyLaunched = FALSE; // clean up NetPlay.dpidPlayer = 0; diff --git a/lib/script/codeprint.c b/lib/script/codeprint.c index 996342cf7..4d72e7e5b 100644 --- a/lib/script/codeprint.c +++ b/lib/script/codeprint.c @@ -25,25 +25,25 @@ void cpPrintType(INTERP_TYPE type) switch(type) { case VAL_BOOL: - DBPRINTF(("BOOL")); + debug( LOG_NEVER, "BOOL" ); break; case VAL_INT: - DBPRINTF(("INT")); + debug( LOG_NEVER, "INT" ); break; /* case VAL_FLOAT: - DBPRINTF(("FLOAT")); + debug( LOG_NEVER, "FLOAT" ); break;*/ case VAL_STRING: - DBPRINTF(("STRING")); + debug( LOG_NEVER, "STRING" ); break; case VAL_TRIGGER: - DBPRINTF(("TRIGGER")); + debug( LOG_NEVER, "TRIGGER" ); break; case VAL_EVENT: - DBPRINTF(("EVENT")); + debug( LOG_NEVER, "EVENT" ); break; case VAL_VOID: - DBPRINTF(("VOID")); + debug( LOG_NEVER, "VOID" ); break; default: // See if it is a user defined type @@ -53,7 +53,7 @@ void cpPrintType(INTERP_TYPE type) { if (asScrTypeTab[i].typeID == type) { - DBPRINTF(("%s", asScrTypeTab[i].pIdent )); + debug( LOG_NEVER, "%s", asScrTypeTab[i].pIdent ); return; } } @@ -64,7 +64,7 @@ void cpPrintType(INTERP_TYPE type) if (ref) { - DBPRINTF((" REF")); + debug( LOG_NEVER, " REF" ); } } @@ -76,32 +76,31 @@ void cpPrintVal(INTERP_VAL *psVal) if (psVal->type & VAL_REF) { - DBPRINTF(("type: ")); + debug( LOG_NEVER, "type: " ); cpPrintType(psVal->type); - DBPRINTF((" value: %x", psVal->v.ival)); + debug( LOG_NEVER, " value: %x", psVal->v.ival ); return; } switch(psVal->type) { case VAL_BOOL: - DBPRINTF(("type: BOOL value: %s", - psVal->v.bval ? "true" : "false")); + debug( LOG_NEVER, "type: BOOL value: %s", psVal->v.bval ? "true" : "false" ); break; case VAL_INT: - DBPRINTF(("type: INT value: %d", psVal->v.ival )); + debug( LOG_NEVER, "type: INT value: %d", psVal->v.ival ); break; /* case VAL_FLOAT: - DBPRINTF(("type: FLOAT value: %f", psVal->v.fval )); + debug( LOG_NEVER, "type: FLOAT value: %f", psVal->v.fval ); break;*/ case VAL_STRING: - DBPRINTF(("type: STRING value: %s", psVal->v.sval )); + debug( LOG_NEVER, "type: STRING value: %s", psVal->v.sval ); break; case VAL_TRIGGER: - DBPRINTF(("type: TRIGGER value: %d", psVal->v.ival )); + debug( LOG_NEVER, "type: TRIGGER value: %d", psVal->v.ival ); break; case VAL_EVENT: - DBPRINTF(("type: EVENT value: %d", psVal->v.ival )); + debug( LOG_NEVER, "type: EVENT value: %d", psVal->v.ival ); break; default: // See if it is a user defined type @@ -111,8 +110,7 @@ void cpPrintVal(INTERP_VAL *psVal) { if (asScrTypeTab[i].typeID == psVal->type) { - DBPRINTF(("type: %s value: %x", - asScrTypeTab[i].pIdent, psVal->v.ival )); + debug( LOG_NEVER, "type: %s value: %x", asScrTypeTab[i].pIdent, psVal->v.ival ); return; } } @@ -132,32 +130,31 @@ void cpPrintPackedVal(UDWORD *ip) if (type & VAL_REF) { - DBPRINTF(("type: ")); + debug( LOG_NEVER, "type: " ); cpPrintType(type); - DBPRINTF((" value: %x", data)); + debug( LOG_NEVER, " value: %x", data ); return; } switch(type) { case VAL_BOOL: - DBPRINTF(("BOOL : %s", - ((BOOL)data) ? "true" : "false")); + debug( LOG_NEVER, "BOOL : %s", ((BOOL)data) ? "true" : "false" ); break; case VAL_INT: - DBPRINTF(("INT : %d", (SDWORD)data )); + debug( LOG_NEVER, "INT : %d", (SDWORD)data ); break; /* case VAL_FLOAT: - DBPRINTF(("FLOAT : %f", (float)data )); + debug( LOG_NEVER, "FLOAT : %f", (float)data ); break;*/ case VAL_STRING: - DBPRINTF(("STRING : %s", (STRING *)data )); + debug( LOG_NEVER, "STRING : %s", (STRING *)data ); break; case VAL_TRIGGER: - DBPRINTF(("TRIGGER : %d", (SDWORD)data )); + debug( LOG_NEVER, "TRIGGER : %d", (SDWORD)data ); break; case VAL_EVENT: - DBPRINTF(("EVENT : %d", (SDWORD)data )); + debug( LOG_NEVER, "EVENT : %d", (SDWORD)data ); break; default: // See if it is a user defined type @@ -167,8 +164,7 @@ void cpPrintPackedVal(UDWORD *ip) { if (asScrTypeTab[i].typeID == type) { - DBPRINTF(("type: %s value: %x", - asScrTypeTab[i].pIdent, data )); + debug( LOG_NEVER, "type: %s value: %x", asScrTypeTab[i].pIdent, data ); return; } } @@ -185,46 +181,46 @@ void cpPrintMathsOp(UDWORD opcode) switch (opcode) { case OP_ADD: - DBPRINTF(("ADD ")); + debug( LOG_NEVER, "ADD" ); break; case OP_SUB: - DBPRINTF(("SUB ")); + debug( LOG_NEVER, "SUB" ); break; case OP_MUL: - DBPRINTF(("MUL ")); + debug( LOG_NEVER, "MUL" ); break; case OP_DIV: - DBPRINTF(("DIV ")); + debug( LOG_NEVER, "DIV" ); break; case OP_NEG: - DBPRINTF(("NEG ")); + debug( LOG_NEVER, "NEG" ); break; case OP_AND: - DBPRINTF(("AND ")); + debug( LOG_NEVER, "AND" ); break; case OP_OR: - DBPRINTF(("OR ")); + debug( LOG_NEVER, "OR" ); break; case OP_NOT: - DBPRINTF(("NOT ")); + debug( LOG_NEVER, "NOT" ); break; case OP_EQUAL: - DBPRINTF(("EQUAL ")); + debug( LOG_NEVER, "EQUAL" ); break; case OP_NOTEQUAL: - DBPRINTF(("NOT_EQUAL ")); + debug( LOG_NEVER, "NOT_EQUAL" ); break; case OP_GREATEREQUAL: - DBPRINTF(("GRT_EQUAL ")); + debug( LOG_NEVER, "GRT_EQUAL" ); break; case OP_LESSEQUAL: - DBPRINTF(("LESS_EQUAL ")); + debug( LOG_NEVER, "LESS_EQUAL" ); break; case OP_GREATER: - DBPRINTF(("GREATER ")); + debug( LOG_NEVER, "GREATER" ); break; case OP_LESS: - DBPRINTF(("LESS ")); + debug( LOG_NEVER, "LESS" ); break; default: ASSERT((FALSE, "cpPrintMathsOp: unknown operator")); @@ -244,7 +240,7 @@ void cpPrintFunc(SCRIPT_FUNC pFunc) { if (asScrInstinctTab[i].pFunc == pFunc) { - DBPRINTF(("%s", asScrInstinctTab[i].pIdent)); + debug( LOG_NEVER, "%s", asScrInstinctTab[i].pIdent ); return; } } @@ -257,7 +253,7 @@ void cpPrintFunc(SCRIPT_FUNC pFunc) { if (asScrCallbackTab[i].pFunc == pFunc) { - DBPRINTF(("%s", asScrCallbackTab[i].pIdent)); + debug( LOG_NEVER, "%s", asScrCallbackTab[i].pIdent ); return; } } @@ -278,13 +274,13 @@ void cpPrintVarFunc(SCRIPT_VARFUNC pFunc, UDWORD index) if (asScrExternalTab[i].set == pFunc && asScrExternalTab[i].index == index) { - DBPRINTF(("%s (set)", asScrExternalTab[i].pIdent)); + debug( LOG_NEVER, "%s (set)", asScrExternalTab[i].pIdent ); return; } else if (asScrExternalTab[i].get == pFunc && asScrExternalTab[i].index == index) { - DBPRINTF(("%s (get)", asScrExternalTab[i].pIdent)); + debug( LOG_NEVER, "%s (get)", asScrExternalTab[i].pIdent ); return; } } @@ -298,13 +294,13 @@ void cpPrintVarFunc(SCRIPT_VARFUNC pFunc, UDWORD index) if (asScrObjectVarTab[i].set == pFunc && asScrObjectVarTab[i].index == index) { - DBPRINTF(("%s (set)", asScrObjectVarTab[i].pIdent)); + debug( LOG_NEVER, "%s (set)", asScrObjectVarTab[i].pIdent ); return; } else if (asScrObjectVarTab[i].get == pFunc && asScrObjectVarTab[i].index == index) { - DBPRINTF(("%s (get)", asScrObjectVarTab[i].pIdent)); + debug( LOG_NEVER, "%s (get)", asScrObjectVarTab[i].pIdent ); return; } } @@ -336,10 +332,10 @@ void cpPrintArrayInfo(UDWORD **pip, SCRIPT_CODE *psProg) pElem += 1; }*/ - DBPRINTF(("%d->", base)); + debug( LOG_NEVER, "%d->", base ); for(i=0; ipsArrayInfo[base].dimensions; i+= 1) { - DBPRINTF(("[%d]", psProg->psArrayInfo[base].elements[i])); + debug( LOG_NEVER, "[%d]", psProg->psArrayInfo[base].elements[i] ); } // calculate the number of DWORDs needed to store the number of elements for each dimension of the array // elementDWords = (dimensions - 1)/4 + 1; @@ -372,43 +368,39 @@ void cpPrintProgram(SCRIPT_CODE *psProg) // Print out the global variables if (psProg->numGlobals > 0) { - DBPRINTF(("index storage type variable name\n")); + debug( LOG_NEVER, "index storage type variable name\n" ); psCurrVar = psProg->psVarDebug; for(i=0; inumGlobals; i++) { - DBPRINTF(("%-6d %s %-4d %s\n", psCurrVar - psProg->psVarDebug, - psCurrVar->storage == ST_PUBLIC ? "Public " : "Private", - psProg->pGlobals[i], psCurrVar->pIdent)); + debug( LOG_NEVER, "%-6d %s %-4d %s\n", psCurrVar - psProg->psVarDebug, psCurrVar->storage == ST_PUBLIC ? "Public " : "Private", psProg->pGlobals[i], psCurrVar->pIdent ); psCurrVar++; } } if (psProg->numArrays > 0) { - DBPRINTF(("\narrays\n")); + debug( LOG_NEVER, "\narrays\n" ); psCurrArray = psProg->psArrayInfo; psCurrArrayDebug = psProg->psArrayDebug; for(i=0; inumArrays; i++) { - DBPRINTF(("%-6d %s %-4d %s", i, - psCurrArrayDebug->storage == ST_PUBLIC ? "Public " : "Private", - psCurrArray->type, psCurrArrayDebug->pIdent)); + debug( LOG_NEVER, "%-6d %s %-4d %s", i, psCurrArrayDebug->storage == ST_PUBLIC ? "Public " : "Private", psCurrArray->type, psCurrArrayDebug->pIdent ); for(dim=0; dim < psCurrArray->dimensions; dim += 1) { - DBPRINTF(("[%d]", psCurrArray->elements[dim])); + debug( LOG_NEVER, "[%d]", psCurrArray->elements[dim] ); } - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); psCurrArray++; psCurrArrayDebug++; } } - DBPRINTF(("\nindex line offset\n")); + debug( LOG_NEVER, "\nindex line offset\n" ); psCurrDebug = psProg->psDebug; } else { - DBPRINTF(("index offset\n")); + debug( LOG_NEVER, "index offset\n" ); } // Find the first trigger with code @@ -433,7 +425,7 @@ void cpPrintProgram(SCRIPT_CODE *psProg) if ((UDWORD)(ip - psProg->pCode) == psCurrDebug->offset && psCurrDebug->pLabel != NULL) { - DBPRINTF(("%s\n", psCurrDebug->pLabel)); + debug( LOG_NEVER, "%s\n", psCurrDebug->pLabel ); } } @@ -442,7 +434,7 @@ void cpPrintProgram(SCRIPT_CODE *psProg) { if (ip - psProg->pCode == psProg->pTriggerTab[jumpOffset]) { - DBPRINTF(("%-6d ", jumpOffset)); + debug( LOG_NEVER, "%-6d", jumpOffset ); jumpOffset+= 1; // Find the next trigger with code while(jumpOffset < psProg->numTriggers) @@ -462,19 +454,19 @@ void cpPrintProgram(SCRIPT_CODE *psProg) } else { - DBPRINTF((" ")); + debug( LOG_NEVER, "" ); } } else { if (ip - psProg->pCode == psProg->pEventTab[jumpOffset]) { - DBPRINTF(("%-6d ", jumpOffset)); + debug( LOG_NEVER, "%-6d", jumpOffset ); jumpOffset+= 1; } else { - DBPRINTF((" ")); + debug( LOG_NEVER, "" ); } } @@ -483,92 +475,89 @@ void cpPrintProgram(SCRIPT_CODE *psProg) { if ((UDWORD)(ip - psProg->pCode) == psCurrDebug->offset) { - DBPRINTF(("%-6d ", psCurrDebug->line)); + debug( LOG_NEVER, "%-6d", psCurrDebug->line ); psCurrDebug++; } else { - DBPRINTF((" ")); + debug( LOG_NEVER, "" ); } } // Display the code offset - DBPRINTF(("%-6d ", ip - psProg->pCode)); + debug( LOG_NEVER, "%-6d", ip - psProg->pCode ); switch (opcode) { case OP_PUSH: - DBPRINTF(("PUSH ")); + debug( LOG_NEVER, "PUSH" ); cpPrintPackedVal(ip); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); ip += aOpSize[opcode]; break; case OP_PUSHREF: - DBPRINTF(("PUSHREF ")); + debug( LOG_NEVER, "PUSHREF" ); cpPrintPackedVal(ip); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); ip += aOpSize[opcode]; break; case OP_POP: - DBPRINTF(("POP\n")); + debug( LOG_NEVER, "POP\n" ); ip += aOpSize[opcode]; break; case OP_PUSHGLOBAL: - DBPRINTF(("PUSHGLOBAL %d\n", data)); + debug( LOG_NEVER, "PUSHGLOBAL %d\n", data ); ip += aOpSize[opcode]; break; case OP_POPGLOBAL: - DBPRINTF(("POPGLOBAL %d\n", data)); + debug( LOG_NEVER, "POPGLOBAL %d\n", data ); ip += aOpSize[opcode]; break; case OP_PUSHARRAYGLOBAL: - DBPRINTF(("PUSHARRAYGLOBAL ")); + debug( LOG_NEVER, "PUSHARRAYGLOBAL" ); cpPrintArrayInfo(&ip, psProg); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); break; case OP_POPARRAYGLOBAL: - DBPRINTF(("POPARRAYGLOBAL ")); + debug( LOG_NEVER, "POPARRAYGLOBAL" ); cpPrintArrayInfo(&ip, psProg); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); break; case OP_CALL: - DBPRINTF(("CALL ")); + debug( LOG_NEVER, "CALL" ); cpPrintFunc( (SCRIPT_FUNC)(*(ip+1)) ); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); ip += aOpSize[opcode]; break; case OP_VARCALL: - DBPRINTF(("VARCALL ")); + debug( LOG_NEVER, "VARCALL" ); cpPrintVarFunc( (SCRIPT_VARFUNC)(*(ip+1)), data); - DBPRINTF(("(%d)\n", data)); + debug( LOG_NEVER, "(%d)\n", data ); ip += aOpSize[opcode]; break; case OP_JUMP: - DBPRINTF(("JUMP %d (%d)\n", - (SWORD)data, ip - psProg->pCode + (SWORD)data)); + debug( LOG_NEVER, "JUMP %d (%d)\n", (SWORD)data, ip - psProg->pCode + (SWORD)data ); ip += aOpSize[opcode]; break; case OP_JUMPTRUE: - DBPRINTF(("JUMPTRUE %d (%d)\n", - (SWORD)data, ip - psProg->pCode + (SWORD)data)); + debug( LOG_NEVER, "JUMPTRUE %d (%d)\n", (SWORD)data, ip - psProg->pCode + (SWORD)data ); ip += aOpSize[opcode]; break; case OP_JUMPFALSE: - DBPRINTF(("JUMPFALSE %d (%d)\n", - (SWORD)data, ip - psProg->pCode + (SWORD)data)); + debug( LOG_NEVER, "JUMPFALSE %d (%d)\n", (SWORD)data, ip - psProg->pCode + (SWORD)data ); ip += aOpSize[opcode]; break; case OP_BINARYOP: case OP_UNARYOP: cpPrintMathsOp(data); - DBPRINTF(("\n")); + debug( LOG_NEVER, "\n" ); ip += aOpSize[opcode]; break; case OP_EXIT: - DBPRINTF(("EXIT\n")); + debug( LOG_NEVER, "EXIT\n" ); ip += aOpSize[opcode]; break; case OP_PAUSE: - DBPRINTF(("PAUSE %d\n", data)); + debug( LOG_NEVER, "PAUSE %d\n", data ); ip += aOpSize[opcode]; break; default: diff --git a/lib/script/event.c b/lib/script/event.c index c6f6aeb64..0afb2b49e 100644 --- a/lib/script/event.c +++ b/lib/script/event.c @@ -60,7 +60,7 @@ static SDWORD eventTraceLevel=3; #ifdef DEBUG #define DB_TRACE(x, level) \ if (eventTraceLevel >= (level)) \ - DBPRINTF(x) + debug( LOG_NEVER, x) #else #define DB_TRACE(x,level) #endif @@ -166,7 +166,7 @@ void eventReset(void) #ifdef DEBUG if (count>0) { - DBPRINTF(("eventReset: %d contexts still allocated at shutdown\n", count)); + debug( LOG_NEVER, "eventReset: %d contexts still allocated at shutdown\n", count ); } #endif } @@ -295,11 +295,10 @@ void eventPrintTriggerInfo(ACTIVE_TRIGGER *psTrigger) // find the debug info for the event pEventLab = eventGetEventID(psCode, psTrigger->event); - DBPRINTF(("trigger %s at %d -> %s", - pTrigLab, psTrigger->testTime, pEventLab)); + debug( LOG_NEVER, "trigger %s at %d -> %s", pTrigLab, psTrigger->testTime, pEventLab ); if (psTrigger->offset != 0) { - DBPRINTF((" %d", psTrigger->offset)); + debug( LOG_NEVER, " %d", psTrigger->offset ); } } @@ -337,7 +336,8 @@ BOOL eventAddValueCreate(INTERP_TYPE type, VAL_CREATE_FUNC create) { if (type >= numFuncs) { - debug(LOG_ERROR, "eventAddValueCreate: type out of range"); + debug( LOG_ERROR, "eventAddValueCreate: type out of range" ); + abort(); return FALSE; } @@ -351,8 +351,8 @@ BOOL eventAddValueRelease(INTERP_TYPE type, VAL_RELEASE_FUNC release) { if (type >= numFuncs) { - debug(LOG_ERROR, "eventAddValueRelease: type out of range"); - DBERROR(("eventAddValueRelease: type out of range")); + debug( LOG_ERROR, "eventAddValueRelease: type out of range" ); + abort(); return FALSE; } @@ -399,7 +399,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release, //prepare local variables (initialize, store type) //------------------------------- - psCode->ppsLocalVarVal = (INTERP_VAL **)MALLOC(sizeof(INTERP_VAL*) * psCode->numEvents); //allocate space for array of local var arrays for each event + psCode->ppsLocalVarVal = (INTERP_VAL **)MALLOC(sizeof(INTERP_VAL*) * psCode->numEvents); //allocate space for array of local var arrays for each event debug(LOG_SCRIPT,"allocated space for %d events", psCode->numEvents); @@ -446,13 +446,13 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release, } //debug(LOG_SCRIPT,"------"); - + } else //this event has no local vars { psCode->ppsLocalVarVal[i] = NULL; } - + } while (val >= 0) @@ -878,7 +878,8 @@ BOOL eventLoadTrigger(UDWORD time, SCRIPT_CONTEXT *psContext, // Get a trigger object if (!HEAP_ALLOC(psTrigHeap, (void*) &psNewTrig)) { - DBERROR(("eventLoadTrigger: out of memory")); + debug( LOG_ERROR, "eventLoadTrigger: out of memory" ); + abort(); return FALSE; } @@ -1401,10 +1402,10 @@ BOOL eventSetTraceLevel(void) //reset local vars BOOL resetLocalVars(SCRIPT_CODE *psCode, UDWORD EventIndex) { - + SDWORD i; - if(EventIndex >= psCode->numEvents) + if(EventIndex >= psCode->numEvents) { if(psCode->psDebug != NULL) debug(LOG_ERROR, "resetLocalVars: wrong event index: %d (Event name: %s, total events count = %d, stack depth = %d)", EventIndex, eventGetEventID(psCode, EventIndex), psCode->numEvents, GetCallDepth()); @@ -1433,7 +1434,7 @@ BOOL resetLocalVars(SCRIPT_CODE *psCode, UDWORD EventIndex) if (psCode->ppsLocalVarVal[EventIndex][i].type == ST_GROUP) { debug(LOG_SCRIPT, "resetLocalVars - created"); - + if (!asCreateFuncs[psCode->ppsLocalVarVal[EventIndex][i].type](&(psCode->ppsLocalVarVal[EventIndex][i]) )) { debug(LOG_ERROR, "asCreateFuncs failed for local var (re-init)"); diff --git a/lib/script/evntsave.c b/lib/script/evntsave.c index 04c0f3414..818107a62 100644 --- a/lib/script/evntsave.c +++ b/lib/script/evntsave.c @@ -53,7 +53,8 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize) //nothashed if (!resGetIDfromData("SCRIPT", psCCont->psCode, &hashedName)) if (!resGetHashfromData("SCRIPT", psCCont->psCode, &hashedName)) { - DBERROR(("eventSaveContext: couldn't find script resource id")); + debug( LOG_ERROR, "eventSaveContext: couldn't find script resource id" ); + abort(); return FALSE; } numVars = psCCont->psCode->numGlobals + psCCont->psCode->arraySize; @@ -122,7 +123,8 @@ static BOOL eventSaveContext(char *pBuffer, UDWORD *pSize) if (!saveFunc(psVal->type, (UDWORD)psVal->v.ival, pPos, &valSize)) { - DBERROR(("eventSaveContext: couldn't get variable value size")); + debug( LOG_ERROR, "eventSaveContext: couldn't get variable value size" ); + abort(); return FALSE; } @@ -192,7 +194,8 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize) numVars = psCode->numGlobals + psCode->arraySize; if (numVars != *((SWORD*)pPos)) { - DBERROR(("eventLoadContext: number of context variables does not match the script code")); + debug( LOG_ERROR, "eventLoadContext: number of context variables does not match the script code" ); + abort(); return FALSE; } pPos += sizeof(SWORD); @@ -230,7 +233,8 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize) // set the value in the context if (!eventSetContextVar(psCCont, (UDWORD)i, type, data)) { - DBERROR(("eventLoadContext: couldn't set variable value")); + debug( LOG_ERROR, "eventLoadContext: couldn't set variable value" ); + abort(); return FALSE; } } @@ -250,13 +254,15 @@ static BOOL eventLoadContext(SDWORD version, char *pBuffer, UDWORD *pSize) // into the variables data space. if (!eventGetContextVal(psCCont, (UDWORD)i, &psVal)) { - DBERROR(("eventLoadContext: couldn't find variable in context")); + debug( LOG_ERROR, "eventLoadContext: couldn't find variable in context" ); + abort(); return FALSE; } if (!loadFunc(version, type, pPos, valSize, (UDWORD *)&(psVal->v.ival))) { - DBERROR(("eventLoadContext: couldn't get variable value")); + debug( LOG_ERROR, "eventLoadContext: couldn't get variable value" ); + abort(); return FALSE; } @@ -310,7 +316,8 @@ static BOOL eventLoadContextHashed(SDWORD version, char *pBuffer, UDWORD *pSize) numVars = psCode->numGlobals + psCode->arraySize; if (numVars != *((SWORD*)pPos)) { - DBERROR(("eventLoadContext: number of context variables does not match the script code")); + debug( LOG_ERROR, "eventLoadContext: number of context variables does not match the script code" ); + abort(); return FALSE; } pPos += sizeof(SWORD); @@ -348,7 +355,8 @@ static BOOL eventLoadContextHashed(SDWORD version, char *pBuffer, UDWORD *pSize) // set the value in the context if (!eventSetContextVar(psCCont, (UDWORD)i, type, data)) { - DBERROR(("eventLoadContext: couldn't set variable value")); + debug( LOG_ERROR, "eventLoadContext: couldn't set variable value" ); + abort(); return FALSE; } } @@ -368,13 +376,15 @@ static BOOL eventLoadContextHashed(SDWORD version, char *pBuffer, UDWORD *pSize) // into the variables data space. if (!eventGetContextVal(psCCont, (UDWORD)i, &psVal)) { - DBERROR(("eventLoadContext: couldn't find variable in context")); + debug( LOG_ERROR, "eventLoadContext: couldn't find variable in context" ); + abort(); return FALSE; } if (!loadFunc(version, type, pPos, valSize, (UDWORD *)&(psVal->v.ival))) { - DBERROR(("eventLoadContext: couldn't get variable value")); + debug( LOG_ERROR, "eventLoadContext: couldn't get variable value" ); + abort(); return FALSE; } @@ -455,7 +465,8 @@ BOOL eventSaveTriggerList(ACTIVE_TRIGGER *psList, char *pBuffer, UDWORD *pSize) pPos += sizeof(UDWORD); if (!eventGetContextIndex(psCurr->psContext, &context)) { - DBERROR(("eventSaveTriggerList: couldn't find context")); + debug( LOG_ERROR, "eventSaveTriggerList: couldn't find context" ); + abort(); return FALSE; } *((SWORD*)pPos) = (SWORD)context; @@ -509,7 +520,8 @@ static BOOL eventLoadTriggerList(SDWORD version, char *pBuffer, UDWORD *pSize) pPos += sizeof(SWORD); if (!eventFindContext(context, &psContext)) { - DBERROR(("eventLoadTriggerList: couldn't find context")); + debug( LOG_ERROR, "eventLoadTriggerList: couldn't find context" ); + abort(); return FALSE; } @@ -575,7 +587,8 @@ BOOL eventSaveState(SDWORD version, char **ppBuffer, UDWORD *pFileSize) pBuffer = MALLOC(totalSize); if (pBuffer == NULL) { - DBERROR(("eventSaveState: out of memory")); + debug( LOG_ERROR, "eventSaveState: out of memory" ); + abort(); return FALSE; } pPos = pBuffer; @@ -635,7 +648,8 @@ BOOL eventLoadState(char *pBuffer, UDWORD fileSize, BOOL bHashed) psHdr = (EVENT_SAVE_HDR *)pPos; if (strncmp(psHdr->aFileType, "evnt", 4) != 0) { - DBERROR(("eventLoadState: invalid file header")); + debug( LOG_ERROR, "eventLoadState: invalid file header" ); + abort(); return FALSE; } /* if ((psHdr->version != 1) && @@ -686,7 +700,8 @@ BOOL eventLoadState(char *pBuffer, UDWORD fileSize, BOOL bHashed) if (totalSize != fileSize) { - DBERROR(("eventLoadState: corrupt save file")); + debug( LOG_ERROR, "eventLoadState: corrupt save file" ); + abort(); return FALSE; } diff --git a/lib/script/interp.c b/lib/script/interp.c index 340188910..bb0fb3c29 100644 --- a/lib/script/interp.c +++ b/lib/script/interp.c @@ -12,7 +12,7 @@ #include "stack.h" #include "codeprint.h" #include "script.h" -#include "event.h" //needed for eventGetEventID() +#include "event.h" //needed for eventGetEventID() // the maximum number of instructions to execute before assuming @@ -60,7 +60,7 @@ BOOL interpTrace; /* Print out trace info if tracing is turned on */ #define TRCPRINTF(x) \ if (interpTrace) \ - DBPRINTF(x) + debug( LOG_NEVER, x) #define TRCPRINTVAL(x) \ if (interpTrace) \ @@ -169,12 +169,12 @@ BOOL interpGetArrayVarData(UDWORD **pip, VAL_CHUNK *psGlobals, SCRIPT_CODE *psPr // print out the debug trace if (interpTrace) { - DBPRINTF(("%d->", base)); + debug( LOG_NEVER, "%d->", base ); for(i=0; i psProg->numEvents) { @@ -364,7 +364,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i //debug( LOG_SCRIPT, "OP_PUSHLOCAL"); //debug( LOG_SCRIPT, "OP_PUSHLOCAL, (CurEvent=%d, data =%d) num loc vars: %d; pushing: %d", CurEvent, data, psContext->psCode->numLocalVars[CurEvent], psContext->psCode->ppsLocalVarVal[CurEvent][data].v.ival); - + if (data >= psContext->psCode->numLocalVars[CurEvent]) { debug(LOG_ERROR, "interpRunScript: OP_PUSHLOCAL: variable index out of range"); @@ -374,7 +374,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i //debug( LOG_SCRIPT, "OP_PUSHLOCAL 2"); //debug(LOG_SCRIPT, "OP_PUSHLOCAL type: %d", psContext->psCode->ppsLocalVarVal[CurEvent][data].type); - + if (!stackPush( &(psContext->psCode->ppsLocalVarVal[CurEvent][data]) )) { debug(LOG_ERROR, "interpRunScript: OP_PUSHLOCAL: push failed"); @@ -382,11 +382,11 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i } //debug( LOG_SCRIPT, "OP_PUSHLOCAL 3"); - + ip += 1;//aOpSize[opcode]; break; case OP_POPLOCAL: - + //debug( LOG_SCRIPT, "OP_POPLOCAL, event index: '%d', data: '%d'", CurEvent, data); //debug( LOG_SCRIPT, "OP_POPLOCAL, numLocalVars: '%d'", psContext->psCode->numLocalVars[CurEvent]); @@ -418,7 +418,7 @@ BOOL interpRunScript(SCRIPT_CONTEXT *psContext, INTERP_RUNTYPE runType, UDWORD i sVal.type = (*ip) & OPCODE_DATAMASK; /* get local var index */ - data = *(ip + 1); + data = *(ip + 1); if (data >= psContext->psCode->numLocalVars[CurEvent]) { @@ -973,7 +973,7 @@ BOOL PopRetStack(UDWORD *psVal) } *psVal = retStack[retStackPos]; - + retStackPos = retStackPos - 1; //debug( LOG_SCRIPT, "PopRetStack: val=%d", *psVal); diff --git a/lib/script/script_lexer.l b/lib/script/script_lexer.l index 6cdec0763..4786962b4 100644 --- a/lib/script/script_lexer.l +++ b/lib/script/script_lexer.l @@ -377,7 +377,7 @@ NOT return _NOT; else { //debug(LOG_SCRIPT, "'%s' is an ident", scr_text); - + strcpy(aText[currText], scr_text); scr_lval.sval = aText[currText]; currText = (currText + 1) % TEXT_BUFFERS; @@ -436,7 +436,8 @@ int scr_wrap(void) { if (inComment) { - DBERROR(("Warning: reached end of file in a comment")); + debug( LOG_ERROR, "Warning: reached end of file in a comment" ); + abort(); } return 1; } diff --git a/lib/script/script_parser.y b/lib/script/script_parser.y index 628322f86..f4136e41b 100644 --- a/lib/script/script_parser.y +++ b/lib/script/script_parser.y @@ -629,7 +629,7 @@ static UDWORD _baseOffset; } \ (psFinal)->debugEntries = (UWORD)((psFinal)->debugEntries + (psBlock)->debugEntries); \ } - + /* Macro to store a label in the debug info */ #define DEBUG_LABEL(psBlock, offset, pString) \ @@ -663,10 +663,10 @@ static UDWORD _baseOffset; else if ((error) == CE_PARSE) \ { \ YYERROR; \ - } + } + - /* Generate the code for a function call, checking the parameter * types match. */ @@ -732,7 +732,7 @@ CODE_ERROR scriptCodeFunction(FUNC_SYMBOL *psFSymbol, // The function being ca { size += sizeof(OPCODE); } - + ALLOC_BLOCK(*ppsCBlock, size); ip = (*ppsCBlock)->pCode; (*ppsCBlock)->type = psFSymbol->type; @@ -772,7 +772,7 @@ UDWORD checkFuncParamTypes(EVENT_SYMBOL *psFSymbol, // The function being call UDWORD size, i, *ip; BOOL typeError = FALSE; STRING aErrorString[255]; - + //debug(LOG_SCRIPT,"checkFuncParamTypes"); /* Check the parameter types match what the function needs */ @@ -788,12 +788,12 @@ UDWORD checkFuncParamTypes(EVENT_SYMBOL *psFSymbol, // The function being call } //} } - + //debug(LOG_SCRIPT,"END checkFuncParamTypes"); return 0; //all ok } - + /* * function call */ @@ -804,7 +804,7 @@ CODE_ERROR scriptCodeCallFunction(FUNC_SYMBOL *psFSymbol, // The function being UDWORD size, i, *ip; BOOL typeError = FALSE; STRING aErrorString[255]; - + //debug(LOG_SCRIPT, "scriptCodeCallFunction"); ASSERT((psFSymbol != NULL, "ais_CodeFunction: Invalid function symbol pointer")); @@ -817,7 +817,7 @@ CODE_ERROR scriptCodeCallFunction(FUNC_SYMBOL *psFSymbol, // The function being size = psPBlock->size + sizeof(OPCODE) + sizeof(SCRIPT_FUNC); - + ALLOC_BLOCK(*ppsCBlock, size); ip = (*ppsCBlock)->pCode; (*ppsCBlock)->type = psFSymbol->type; @@ -829,7 +829,7 @@ CODE_ERROR scriptCodeCallFunction(FUNC_SYMBOL *psFSymbol, // The function being /* Make the function call */ PUT_OPCODE(ip, OP_CALL); PUT_FUNC(ip, psFSymbol->pFunc); - + //debug(LOG_SCRIPT, "END scriptCodeCallFunction"); return CE_OK; @@ -891,7 +891,7 @@ CODE_ERROR scriptCodeCallbackParams( } size = psPBlock->size + sizeof(OPCODE) + sizeof(SCRIPT_FUNC); - + ALLOC_TSUBDECL(*ppsTDecl, psCBSymbol->type, size, 0); ip = (*ppsTDecl)->pCode; @@ -996,7 +996,7 @@ CODE_ERROR scriptCodeObjAssignment(OBJVAR_BLOCK *psVariable,// The variable to a return CE_PARSE; } - ALLOC_BLOCK(*ppsBlock, psVariable->size + psValue->size + + ALLOC_BLOCK(*ppsBlock, psVariable->size + psValue->size + sizeof(OPCODE) + sizeof(SCRIPT_VARFUNC)); ip = (*ppsBlock)->pCode; @@ -1038,7 +1038,7 @@ CODE_ERROR scriptCodeObjGet(OBJVAR_BLOCK *psVariable,// The variable to get from return CE_PARSE; } - ALLOC_BLOCK(*ppsBlock, psVariable->size + + ALLOC_BLOCK(*ppsBlock, psVariable->size + sizeof(OPCODE) + sizeof(SCRIPT_VARFUNC)); ip = (*ppsBlock)->pCode; @@ -1232,7 +1232,7 @@ CODE_ERROR scriptCodeParameter(CODE_BLOCK *psParam, // Code for the parameter /* Copy in the code for the parameter */ PUT_BLOCK(ip, psParam); FREE_BLOCK(psParam); - + (*ppsBlock)->aParams[0] = type; return CE_OK; @@ -1303,7 +1303,7 @@ BOOL checkFuncParamType(SDWORD argIndex, SDWORD argType) debug(LOG_ERROR, "checkFuncParamType() - argument %d has wrong argument index, event: '%s'", argIndex, psCurEvent->pIdent); return FALSE; } - + return FALSE; } @@ -1487,7 +1487,7 @@ CODE_ERROR scriptCodeVarRef(VAR_SYMBOL *psVariable, // The object variable symb { case ST_PUBLIC: case ST_PRIVATE: - + PUT_PKOPCODE(ip, OP_PUSHREF, (*ppsBlock)->aParams[0]); PUT_DATA(ip, psVariable->index); break; @@ -1537,7 +1537,7 @@ CODE_ERROR scriptCodeTrigger(STRING *pIdent, CODE_BLOCK *psCode) /* Add debugging info for the EXIT instruction */ scriptGetErrorData((SDWORD *)&line, &pDummy); psNewBlock->psDebug[psNewBlock->debugEntries].line = line; - psNewBlock->psDebug[psNewBlock->debugEntries].offset = + psNewBlock->psDebug[psNewBlock->debugEntries].offset = ip - psNewBlock->pCode; psNewBlock->debugEntries ++; } @@ -1574,7 +1574,7 @@ CODE_ERROR scriptCodeEvent(EVENT_SYMBOL *psEvent, TRIGGER_SYMBOL *psTrig, CODE_B /* Add debugging info for the EXIT instruction */ scriptGetErrorData((SDWORD *)&line, &pDummy); psNewBlock->psDebug[psNewBlock->debugEntries].line = line; - psNewBlock->psDebug[psNewBlock->debugEntries].offset = + psNewBlock->psDebug[psNewBlock->debugEntries].offset = ip - psNewBlock->pCode; psNewBlock->debugEntries ++; } @@ -1744,7 +1744,7 @@ static void scriptStoreVarTypes(VAR_SYMBOL *psVar) %type boolexp %type stringexp %type return_exp -%type return_statement +%type return_statement %type objexp %type objexp_dot %type userexp @@ -1795,7 +1795,7 @@ static void scriptStoreVarTypes(VAR_SYMBOL *psVar) %% -script: header var_list +script: header var_list { /* stop parsing here if we are just getting */ /* the variables in the script */ @@ -1864,7 +1864,7 @@ script: header var_list if(numEventLocalVars[i] > 0) { pCurEvLocalVars = (INTERP_TYPE*)MALLOC(sizeof(INTERP_TYPE) * numEventLocalVars[i]); - + j=0; for(psCurr =psLocalVarsB[i]; psCurr != NULL; psCurr = psCurr->psNext) { @@ -2095,7 +2095,7 @@ var_line: variable_decl ';' variable_decl_head: STORAGE TYPE { //debug(LOG_SCRIPT, "variable_decl_head: STORAGE TYPE"); - + ALLOC_VARDECL(psCurrVDecl); psCurrVDecl->storage = $1; psCurrVDecl->type = $2; @@ -2112,7 +2112,7 @@ variable_decl_head: STORAGE TYPE } | STORAGE TRIGGER { - + ALLOC_VARDECL(psCurrVDecl); psCurrVDecl->storage = $1; psCurrVDecl->type = VAL_TRIGGER; @@ -2322,7 +2322,7 @@ event_subdecl: EVENT IDENT psCurEvent = $2; $$ = $2; - + //debug(LOG_SCRIPT, "END EVENT EVENT_SYM"); } ; @@ -2463,7 +2463,7 @@ argument_decl_head: TYPE variable_ident debug(LOG_ERROR, "argument_decl_head 0: - psCurEvent == NULL"); psCurEvent->numParams = psCurEvent->numParams + 1; /* remember a parameter was declared */ - + /* remember parameter type */ psCurEvent->aParams[0] = $1; @@ -2477,7 +2477,7 @@ argument_decl_head: TYPE variable_ident ALLOC_VARDECL(psCurrVDecl); psCurrVDecl->storage =ST_LOCAL; /* can only be local */ psCurrVDecl->type = $3; - + /* remember parameter type */ psCurEvent->aParams[psCurEvent->numParams] = $3; //debug(LOG_SCRIPT, "argument_decl_head 10 "); @@ -2642,7 +2642,7 @@ event_decl: event_subdecl ';' { YYABORT; } - + /* end of event */ psCurEvent = NULL; @@ -2654,7 +2654,7 @@ event_decl: event_subdecl ';' /* function that was NOT declared before (atleast must look like this)!!! */ /* | func_subdecl '(' argument_decl_head ')' '{' var_list statement_list '}' */ - | function_declaration '{' var_list statement_list return_statement '}' + | function_declaration '{' var_list statement_list return_statement '}' { UDWORD line; STRING *pDummy; @@ -2664,14 +2664,14 @@ event_decl: event_subdecl ';' /* stays the same if no params (just gets copied) */ ALLOC_BLOCK(psCurrBlock, $4->size + $5->size + sizeof(OPCODE) + (sizeof(OPCODE) * $1->numParams)); /* statement_list + expression + EXIT + numParams */ ip = psCurrBlock->pCode; - + /* pop required number of paramerets passed to this event (if any) */ popArguments(&ip, $1->numParams); - + /* Copy the two code blocks */ PUT_BLOCK(ip, $4); - + PUT_BLOCK(ip, $5); PUT_OPCODE(ip, OP_EXIT); /* must exit after return */ @@ -2693,7 +2693,7 @@ event_decl: event_subdecl ';' FREE_BLOCK($5); - + /* end of event */ psCurEvent = NULL; @@ -2746,7 +2746,7 @@ event_decl: event_subdecl ';' /* FREE_DEBUG($8); */ FREE_BLOCK($7); FREE_BLOCK($8); - + /* end of event */ psCurEvent = NULL; @@ -2768,14 +2768,14 @@ return_statement: return_statement_void if(!psCurEvent->bFunction) { - + scr_error("return statement inside of an event '%s'", psCurEvent->pIdent); YYABORT; } if(psCurEvent->retType != VAL_VOID) { - + scr_error("wrong return statement syntax for a non-void function '%s'", psCurEvent->pIdent); YYABORT; } @@ -2792,7 +2792,7 @@ return_statement: return_statement_void | RET return_exp ';' { //debug(LOG_SCRIPT, "RET return_exp ';'"); - + if(psCurEvent == NULL) /* no events declared or defined yet */ { debug(LOG_ERROR, "return statement outside of function"); @@ -2813,7 +2813,7 @@ return_statement: return_statement_void debug(LOG_ERROR, "wrong return statement syntax for function '%s' (%d - %d)", psCurEvent->pIdent, psCurEvent->retType, $2->type); YYABORT; } - + } /* Allocate code block for exit instruction */ @@ -2829,7 +2829,7 @@ return_statement: return_statement_void psCurrBlock->type = $2->type; $$ = psCurrBlock; - + //debug(LOG_SCRIPT, "END RET return_exp ';'"); } ; @@ -2896,7 +2896,7 @@ statement: assignment ';' UDWORD line; STRING *pDummy; - + /* Put in debugging info */ if (genDebugInfo) @@ -2929,7 +2929,7 @@ statement: assignment ';' scr_error("Wrong number of arguments for function call: '%s'. Expected %d parameters instead of %d.", $1->pIdent, $1->numParams, $3->numParams); return CE_PARSE; } - + /* check if right parameters were passed */ paramNumber = checkFuncParamTypes($1, $3); if(paramNumber > 0) @@ -3325,7 +3325,7 @@ assignment: NUM_VAR '=' expression */ func_call: NUM_FUNC '(' param_list ')' { - + /* Generate the code for the function call */ codeRet = scriptCodeFunction($1, $3, FALSE, &psCurrBlock); @@ -3336,7 +3336,7 @@ func_call: NUM_FUNC '(' param_list ')' } | BOOL_FUNC '(' param_list ')' { - + /* Generate the code for the function call */ codeRet = scriptCodeFunction($1, $3, FALSE, &psCurrBlock); @@ -3347,7 +3347,7 @@ func_call: NUM_FUNC '(' param_list ')' } | USER_FUNC '(' param_list ')' { - + /* Generate the code for the function call */ codeRet = scriptCodeFunction($1, $3, FALSE, &psCurrBlock); @@ -3358,7 +3358,7 @@ func_call: NUM_FUNC '(' param_list ')' } | OBJ_FUNC '(' param_list ')' { - + /* Generate the code for the function call */ codeRet = scriptCodeFunction($1, $3, FALSE, &psCurrBlock); @@ -3369,7 +3369,7 @@ func_call: NUM_FUNC '(' param_list ')' } | FUNC '(' param_list ')' { - + /* Generate the code for the function call */ codeRet = scriptCodeFunction($1, $3, FALSE, &psCurrBlock); CHECK_CODE_ERROR(codeRet); @@ -3405,7 +3405,7 @@ param_list: /* NULL token */ } | param_list ',' parameter { - + ALLOC_PBLOCK(psCurrPBlock, $1->size + $3->size, $1->numParams + $3->numParams); @@ -3414,7 +3414,7 @@ param_list: /* NULL token */ /* Copy in the code for the parameters */ PUT_BLOCK(ip, $1); PUT_BLOCK(ip, $3); - + /* Copy the parameter types */ memcpy(psCurrPBlock->aParams, $1->aParams, $1->numParams * sizeof(INTERP_TYPE)); @@ -3425,7 +3425,7 @@ param_list: /* NULL token */ /* Free the old pblocks */ FREE_PBLOCK($1); FREE_PBLOCK($3); - + //if(psCurrPBlock->numParams > 0) // debug(LOG_SCRIPT, "param_list:param %d type: %d", psCurrPBlock->numParams, $3->aParams[0]); @@ -3472,7 +3472,7 @@ parameter: expression | objexp { //debug(LOG_SCRIPT, "objexp, scriptCodeParameter"); - + /* Generate the code for the parameter */ codeRet = scriptCodeParameter($1, $1->type, &psCurrPBlock); CHECK_CODE_ERROR(codeRet); @@ -3646,7 +3646,7 @@ cond_clause: IF '(' boolexp ')' { /* Allocate the block */ ALLOC_CONDBLOCK(psCondBlock, 1, - $3->size + $7->size + + $3->size + $7->size + sizeof(OPCODE)*2); ALLOC_DEBUG(psCondBlock, $7->debugEntries + 1); ip = psCondBlock->pCode; @@ -3840,7 +3840,7 @@ expression: expression '+' expression scr_error("assignment type conflict"); return CE_PARSE; } - + /* check if right parameters were passed */ paramNumber = checkFuncParamTypes($1, $3); if(paramNumber > 0) @@ -3920,23 +3920,23 @@ expression: expression '+' expression $$ = psCurrBlock; } ; - - + + /*************************************************************************************** - * + * * String expressions */ stringexp: stringexp '&' stringexp //CHANGED: OP_CANC { //debug(LOG_SCRIPT, "stringexp: stringexp '&' stringexp"); - + codeRet = scriptCodeBinaryOperator($1, $3, OP_CANC, &psCurrBlock); CHECK_CODE_ERROR(codeRet); /* Return the code block */ $$ = psCurrBlock; - + //debug(LOG_SCRIPT, "END stringexp: stringexp '&' stringexp"); } | stringexp '&' expression //CHANGED: OP_CANC @@ -3955,7 +3955,7 @@ stringexp: /* Return the code block */ $$ = psCurrBlock; } - + | '(' stringexp ')' { //debug(LOG_SCRIPT, "'(' stringexp ')'"); @@ -4020,15 +4020,15 @@ stringexp: | STRING_VAR { - + //debug(LOG_SCRIPT, "STRING_VAR"); - + codeRet = scriptCodeVarGet($1, &psCurrBlock); CHECK_CODE_ERROR(codeRet); /* Return the code block */ $$ = psCurrBlock; - + //debug(LOG_SCRIPT, "END STRING_VAR (%s)", $1->pIdent); } | NUM_VAR @@ -4042,7 +4042,7 @@ stringexp: | QTEXT { //debug(LOG_SCRIPT, "QTEXT found (%s)", yyvsp[0].sval); - + ALLOC_BLOCK(psCurrBlock, sizeof(OPCODE) + sizeof(UDWORD)); ip = psCurrBlock->pCode; @@ -4061,7 +4061,7 @@ stringexp: *STRSTACK[CURSTACKSTR] = (char)MALLOC(MAXSTRLEN); widgCopyString(STRSTACK[CURSTACKSTR],yyvsp[0].sval); CURSTACKSTR = CURSTACKSTR + 1; /* Increment 'pointer' to the top of the string stack */ - + //debug(LOG_SCRIPT, "END QTEXT found"); } | INTEGER @@ -4077,8 +4077,8 @@ stringexp: $$ = psCurrBlock; } ; - - + + /*************************************************************************************** * * Boolean expressions @@ -4173,7 +4173,7 @@ boolexp: boolexp _AND boolexp scr_error("assignment type conflict"); return CE_PARSE; } - + /* check if right parameters were passed */ paramNumber = checkFuncParamTypes($1, $3); if(paramNumber > 0) @@ -4499,7 +4499,7 @@ objexp: OBJ_VAR scr_error("'%s' does not return an object value (%d )", $1->pIdent, $1->retType); return CE_PARSE; } - + /* check if right parameters were passed */ paramNumber = checkFuncParamTypes($1, $3); if(paramNumber > 0) @@ -4849,18 +4849,16 @@ void scr_error(char *pMessage, ...) va_end(args); scriptGetErrorData(&line, &text); #ifdef DEBUG - debug(LOG_ERROR, "script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n", - aBuff, GetLastResourceFilename(), line, scr_char, text); + debug( LOG_ERROR, "script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n", + aBuff, GetLastResourceFilename(), line, scr_char, text ); ASSERT((FALSE, "script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n", aBuff, GetLastResourceFilename(), line, scr_char, text)); #else //DBERROR(("script parse error:\n%s at line %d\nToken: %d, Text: '%s'\n", // pMessage, line, scr_char, text)); - debug(LOG_ERROR, "script parse error:\n'%s' at %s:%d\nToken: %d, Text: '%s'\n", - aBuff, GetLastResourceFilename(), line, scr_char, text); - DBERROR(("script parse error:\n%s at %s:%d\nToken: %d, Text: '%s'\n", - aBuff, GetLastResourceFilename(), line, scr_char, text)); - + debug( LOG_ERROR, "script parse error:\n'%s' at %s:%d\nToken: %d, Text: '%s'\n", + aBuff, GetLastResourceFilename(), line, scr_char, text ); + abort(); #endif } @@ -4871,7 +4869,7 @@ BOOL scriptLookUpType(STRING *pIdent, INTERP_TYPE *pType) UDWORD i; //debug(LOG_SCRIPT, "scriptLookUpType"); - + if (asScrTypeTab) { for(i=0; asScrTypeTab[i].typeID != 0; i++) @@ -4883,7 +4881,7 @@ BOOL scriptLookUpType(STRING *pIdent, INTERP_TYPE *pType) } } } - + //debug(LOG_SCRIPT, "END scriptLookUpType"); return FALSE; @@ -5033,7 +5031,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) { VAR_SYMBOL *psCurr; UDWORD i; - + //debug(LOG_SCRIPT, "scriptLookUpVariable"); /* See if the symbol is an object variable */ @@ -5050,7 +5048,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) } } } - + //debug(LOG_SCRIPT, "scriptLookUpVariable 1"); /* See if the symbol is an external variable */ @@ -5066,7 +5064,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) } } } - + //debug(LOG_SCRIPT, "scriptLookUpVariable 2"); /* See if the symbol is in the local variable list */ @@ -5079,7 +5077,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) return TRUE; } } - + //debug(LOG_SCRIPT, "scriptLookUpVariable 3"); /* check local vars if we are inside of an event */ @@ -5121,7 +5119,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) } } } - + //debug(LOG_SCRIPT, "scriptLookUpVariable 4"); @@ -5151,7 +5149,7 @@ BOOL scriptLookUpVariable(STRING *pIdent, VAR_SYMBOL **ppsSym) /* Failed to find the variable */ *ppsSym = NULL; - + //debug(LOG_SCRIPT, "END scriptLookUpVariable"); return FALSE; } @@ -5234,7 +5232,7 @@ BOOL scriptAddTrigger(STRING *pIdent, TRIGGER_DECL *psDecl, UDWORD line) BOOL scriptLookUpTrigger(STRING *pIdent, TRIGGER_SYMBOL **ppsTrigger) { TRIGGER_SYMBOL *psCurr; - + //debug(LOG_SCRIPT, "scriptLookUpTrigger"); for(psCurr = psTriggers; psCurr; psCurr=psCurr->psNext) @@ -5246,7 +5244,7 @@ BOOL scriptLookUpTrigger(STRING *pIdent, TRIGGER_SYMBOL **ppsTrigger) return TRUE; } } - + //debug(LOG_SCRIPT, "END scriptLookUpTrigger"); return FALSE; @@ -5257,7 +5255,7 @@ BOOL scriptLookUpTrigger(STRING *pIdent, TRIGGER_SYMBOL **ppsTrigger) BOOL scriptLookUpCallback(STRING *pIdent, CALLBACK_SYMBOL **ppsCallback) { CALLBACK_SYMBOL *psCurr; - + //debug(LOG_SCRIPT, "scriptLookUpCallback"); if (!asScrCallbackTab) @@ -5274,7 +5272,7 @@ BOOL scriptLookUpCallback(STRING *pIdent, CALLBACK_SYMBOL **ppsCallback) return TRUE; } } - + //debug(LOG_SCRIPT, "END scriptLookUpCallback: found"); return FALSE; } @@ -5356,7 +5354,7 @@ BOOL scriptDefineEvent(EVENT_SYMBOL *psEvent, CODE_BLOCK *psCode, SDWORD trigger psEvent->size = psCode->size; psEvent->trigger = trigger; - + // Add debug info if (genDebugInfo) @@ -5413,7 +5411,7 @@ BOOL scriptLookUpEvent(STRING *pIdent, EVENT_SYMBOL **ppsEvent) BOOL scriptLookUpConstant(STRING *pIdent, CONST_SYMBOL **ppsSym) { CONST_SYMBOL *psCurr; - + //debug(LOG_SCRIPT, "scriptLookUpConstant"); /* Scan the Constant list */ @@ -5428,7 +5426,7 @@ BOOL scriptLookUpConstant(STRING *pIdent, CONST_SYMBOL **ppsSym) } } } - + //debug(LOG_SCRIPT, "END scriptLookUpConstant"); return FALSE; @@ -5440,7 +5438,7 @@ BOOL scriptLookUpFunction(STRING *pIdent, FUNC_SYMBOL **ppsSym) { UDWORD i; FUNC_SYMBOL *psCurr; - + //debug(LOG_SCRIPT, "scriptLookUpFunction"); /* See if the function is defined as an instinct function */ @@ -5468,7 +5466,7 @@ BOOL scriptLookUpFunction(STRING *pIdent, FUNC_SYMBOL **ppsSym) /* Failed to find the indentifier */ *ppsSym = NULL; - + //debug(LOG_SCRIPT, "END scriptLookUpFunction"); return FALSE; } @@ -5478,7 +5476,7 @@ BOOL scriptLookUpCustomFunction(STRING *pIdent, EVENT_SYMBOL **ppsSym) { UDWORD i; EVENT_SYMBOL *psCurr; - + //debug(LOG_SCRIPT, "scriptLookUpCustomFunction"); /* See if the function is defined as a script function */ @@ -5497,7 +5495,7 @@ BOOL scriptLookUpCustomFunction(STRING *pIdent, EVENT_SYMBOL **ppsSym) /* Failed to find the indentifier */ *ppsSym = NULL; - + //debug(LOG_SCRIPT, "END scriptLookUpCustomFunction"); return FALSE; } diff --git a/lib/script/stack.c b/lib/script/stack.c index eafd26a83..3ed7c609e 100644 --- a/lib/script/stack.c +++ b/lib/script/stack.c @@ -331,7 +331,7 @@ BOOL stackPopParams(SDWORD numParams, ...) sprintf(tempstr, "%d", psVal->v.ival); *pData = tempstr; - + //itoa(psVal->v.ival,tmpstr,10); } } @@ -424,7 +424,7 @@ void stackPrintTop(void) } else { - DBPRINTF(("STACK EMPTY")); + debug( LOG_NEVER, "STACK EMPTY" ); } } @@ -647,15 +647,15 @@ BOOL stackInitialise(void) psStackBase = (STACK_CHUNK *)MALLOC(sizeof(STACK_CHUNK)); if (psStackBase == NULL) { - debug(LOG_ERROR, "Out of memory"); - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } psStackBase->aVals = MALLOC(sizeof(INTERP_VAL) * INIT_SIZE); if (!psStackBase->aVals) { - debug(LOG_ERROR, "Out of memory"); - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -679,7 +679,7 @@ void stackShutDown(void) if ((psCurrChunk != psStackBase) && (currEntry != 0)) { - DBPRINTF(("stackShutDown: stack is not empty on shutdown")); + debug( LOG_NEVER, "stackShutDown: stack is not empty on shutdown" ); } for(psCurr = psStackBase; psCurr != NULL; psCurr = psNext) diff --git a/lib/sequence/rpl_reader.c b/lib/sequence/rpl_reader.c index 076b6dc24..9317bb2a3 100644 --- a/lib/sequence/rpl_reader.c +++ b/lib/sequence/rpl_reader.c @@ -98,12 +98,12 @@ rpl_open(char* filename) { rpl->f = f; if (strcmp(readline(f, buf, len), "ARMovie") != 0) - DBPRINTF(("%s missing RPL magic number\n", filename)); + debug( LOG_NEVER, "%s missing RPL magic number\n", filename ); readline(f, buf, len); /* discard filename */ readline(f, buf, len); /* discard copyright */ if (strcmp(readline(f, buf, len), "ESCAPE 2.0") != 0) /* This field is really "author", but.. */ - DBPRINTF(("%s not in \"ESCAPE 2.0\" format?\n", filename)); + debug( LOG_NEVER, "%s not in \"ESCAPE 2.0\" format?\n", filename ); tmp = readint(f, buf, len); @@ -113,7 +113,7 @@ rpl_open(char* filename) { break; default: rpl->video_decoder = rpl_decode_video_unknown; - printf("Unknown video format %i\n", tmp); + debug( LOG_NEVER, "Unknown video format %i\n", tmp); break; } diff --git a/lib/sound/audio.c b/lib/sound/audio.c index 96850976e..83fafdad3 100644 --- a/lib/sound/audio.c +++ b/lib/sound/audio.c @@ -80,7 +80,8 @@ BOOL audio_Init( AUDIO_CALLBACK pStopTrackCallback ) // allocate sample heap if ( !HEAP_CREATE(&g_psSampleHeap, AUDIO_SAMPLE_HEAP_INIT, AUDIO_SAMPLE_HEAP_EXT, sizeof(AUDIO_SAMPLE)) ) { - DBERROR( ("audio_Init: couldn't create sample queue\n") ); + debug( LOG_ERROR, "audio_Init: couldn't create sample queue\n" ); + abort(); return FALSE; } @@ -546,7 +547,7 @@ void audio_UpdateQueue( void ) } else { - DBPRINTF( ("audio_UpdateQueue: couldn't play sample\n") ); + debug( LOG_NEVER, "audio_UpdateQueue: couldn't play sample\n" ); HEAP_FREE( g_psSampleHeap, psSample ); } } @@ -705,7 +706,7 @@ BOOL audio_SetTrackVals psTrack = resGetData( "WAV", szFileName ); //at this point we have 4 valid entries, and 8 invalid -Q if ( psTrack == NULL ) { - DBPRINTF( ("audio_SetTrackVals: track %s resource not found\n", szFileName) ); + debug( LOG_NEVER, "audio_SetTrackVals: track %s resource not found\n", szFileName ); return FALSE; } else @@ -718,7 +719,7 @@ BOOL audio_SetTrackVals if ( *piID == SAMPLE_NOT_ALLOCATED ) { - DBPRINTF( ("audio_SetTrackVals: couldn't get spare track ID\n") ); + debug( LOG_NEVER, "audio_SetTrackVals: couldn't get spare track ID\n" ); return FALSE; } else @@ -883,7 +884,7 @@ static BOOL audio_Play3DTrack( SDWORD iX, SDWORD iY, SDWORD iZ, int iTrack, void } else { - DBPRINTF( ("audio_Play3DTrack: couldn't play sample\n") ); + debug( LOG_NEVER, "audio_Play3DTrack: couldn't play sample\n" ); HEAP_FREE( g_psSampleHeap, psSample ); return FALSE; } @@ -1072,7 +1073,7 @@ void audio_PlayTrack( int iTrack ) } else { - DBPRINTF( ("audio_PlayTrack: couldn't play sample\n") ); + debug( LOG_NEVER, "audio_PlayTrack: couldn't play sample\n" ); HEAP_FREE( g_psSampleHeap, psSample ); } } @@ -1203,7 +1204,7 @@ void audio_StopAll( void ) return; } - DBPRINTF( ("audio_StopAll called\n") ); + debug( LOG_NEVER, "audio_StopAll called\n" ); g_bStopAll = TRUE; // @@ -1228,7 +1229,7 @@ void audio_StopAll( void ) g_psSampleQueue = NULL; g_bStopAll = FALSE; - DBPRINTF( ("audio_StopAll done\n") ); + debug( LOG_NEVER, "audio_StopAll done\n" ); } //* diff --git a/lib/sound/track.c b/lib/sound/track.c index b65d1c93c..e87b1d2be 100644 --- a/lib/sound/track.c +++ b/lib/sound/track.c @@ -91,7 +91,7 @@ BOOL sound_Init( SDWORD iMaxSameSamples ) 0, NULL ); - DBPRINTF( ("sound_Init: couldn't load compression manager MSACM32.DLL\n") ); + debug( LOG_NEVER, "sound_Init: couldn't load compression manager MSACM32.DLL\n" ); } if ( !LoadLibrary("MSADP32.ACM") ) @@ -106,12 +106,12 @@ BOOL sound_Init( SDWORD iMaxSameSamples ) 0, NULL ); - DBPRINTF( ("sound_Init: couldn't load ADPCM codec MSADP32.ACM\n") ); + debug( LOG_NEVER, "sound_Init: couldn't load ADPCM codec MSADP32.ACM\n" ); } #endif if ( sound_InitLibrary() == FALSE ) { - DBPRINTF( ("Cannot init sound library\n") ); + debug( LOG_NEVER, "Cannot init sound library\n" ); return FALSE; } @@ -182,7 +182,8 @@ BOOL sound_SetTrackVals { if ( g_apTrack[iTrack] != NULL ) { - DBERROR( ("sound_SetTrackVals: track %i already set\n", iTrack) ); + debug( LOG_ERROR, "sound_SetTrackVals: track %i already set\n", iTrack ); + abort(); return FALSE; } @@ -229,7 +230,8 @@ BOOL sound_AddTrack( TRACK *pTrack ) } else { - DBERROR( ("sound_AddTrack: all tracks used: increase MAX_TRACKS\n") ); + debug( LOG_ERROR, "sound_AddTrack: all tracks used: increase MAX_TRACKS\n" ); + abort(); return FALSE; } } @@ -249,7 +251,8 @@ void *sound_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize) memset(pTrack, 0, sizeof(TRACK)); if ( pTrack == NULL ) { - DBERROR( ("sound_LoadTrackFromBuffer: couldn't allocate memory\n") ); + debug( LOG_ERROR, "sound_LoadTrackFromBuffer: couldn't allocate memory\n" ); + abort(); return NULL; } else @@ -258,7 +261,8 @@ void *sound_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize) pTrack->pName = MALLOC( strlen(GetLastResourceFilename()) + 1 ); if ( pTrack->pName == NULL ) { - DBERROR( ("sound_LoadTrackFromBuffer: couldn't allocate memory\n") ); + debug( LOG_ERROR, "sound_LoadTrackFromBuffer: couldn't allocate memory\n" ); + abort(); FREE( pTrack ); return NULL; } @@ -275,7 +279,7 @@ void *sound_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize) // flag compressed audio load if ( pTrack->bCompressed == TRUE ) { - DBPRINTF( ("sound_LoadTrackFromBuffer: %s is compressed!\n", pTrack->pName) ); + debug( LOG_NEVER, "sound_LoadTrackFromBuffer: %s is compressed!\n", pTrack->pName ); } #endif return pTrack; @@ -301,7 +305,8 @@ BOOL sound_LoadTrackFromFile(char szFileName[]) pTrack->pName = MALLOC( strlen((char*) szFileName) + 1 ); if ( pTrack->pName == NULL ) { - DBERROR( ("sound_LoadTrackFromFile: Out of memory") ); + debug( LOG_ERROR, "sound_LoadTrackFromFile: Out of memory" ); + abort(); return FALSE; } @@ -420,13 +425,13 @@ BOOL sound_CheckTrack( SDWORD iTrack ) { if ( iTrack < 0 || iTrack > g_iCurTracks - 1 ) { - DBPRINTF( ("sound_CheckTrack: track number %i outside max %i\n", iTrack, g_iCurTracks) ); + debug( LOG_NEVER, "sound_CheckTrack: track number %i outside max %i\n", iTrack, g_iCurTracks ); return FALSE; } if ( g_apTrack[iTrack] == NULL ) { - DBPRINTF( ("sound_CheckTrack: track %i NULL\n", iTrack) ); + debug( LOG_NEVER, "sound_CheckTrack: track %i NULL\n", iTrack ); return FALSE; } diff --git a/src/action.c b/src/action.c index 2ea303c14..77cc36001 100644 --- a/src/action.c +++ b/src/action.c @@ -762,7 +762,7 @@ void actionAddVtolAttackRun( DROID *psDroid ) iX>(SDWORD)(GetWidthOfMap()<(SDWORD)(GetHeightOfMap()<MAX_PLAYERS || col >MAX_PLAYERS) { - DBERROR(("setplayercolour: wrong values")); + debug( LOG_ERROR, "setplayercolour: wrong values" ); + abort(); return FALSE; } PlayerColour[(UBYTE)player] = (UBYTE)col; @@ -203,7 +204,7 @@ UDWORD getComponentRadius(BASE_STATS *psComponent) if ( (StatIsComponent(psComponent) != COMP_WEAPON) || ((WEAPON_STATS *)psComponent)->weaponSubClass != WSC_BOMB ) { - DBPRINTF(("ComponentPIE == NULL : File : %s Line : %d\n",__FILE__,__LINE__)); + debug( LOG_NEVER, "ComponentPIE == NULL : File : %s Line : %d\n", __FILE__, __LINE__ ); } return COMPONENT_RADIUS; @@ -219,7 +220,7 @@ UDWORD getResearchRadius(BASE_STATS *Stat) } // DBERROR(("Null IMD in getResearchRadius()")); - DBPRINTF(("ResearchPIE == NULL : File : %s Line : %d\n",__FILE__,__LINE__)); + debug( LOG_NEVER, "ResearchPIE == NULL : File : %s Line : %d\n", __FILE__, __LINE__ ); return 100; } @@ -521,7 +522,7 @@ void displayComponentButton(BASE_STATS *Stat, iVector *Rotation,iVector *Positio ((StatIsComponent(Stat) != COMP_WEAPON) || ((WEAPON_STATS *)Stat)->weaponSubClass != WSC_BOMB) ) { - DBPRINTF(("ComponentPIE == NULL : File : %s Line : %d\n",__FILE__,__LINE__)); + debug( LOG_NEVER, "ComponentPIE == NULL : File : %s Line : %d\n", __FILE__, __LINE__ ); // DBERROR(("ComponentIMD == NULL")); } diff --git a/src/configuration.c b/src/configuration.c index bc2e38d6b..36e1528ba 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -545,7 +545,7 @@ BOOL saveConfig() } else { - DBPRINTF(("Writing multiplay prefs to registry\n")); + debug( LOG_NEVER, "Writing multiplay prefs to registry\n" ); if(NetPlay.bHost && ingame.localJoiningInProgress) { setWarzoneKeyString("gameName", game.name); // last hosted game diff --git a/src/console.c b/src/console.c index d2ca45e23..bf0acf633 100644 --- a/src/console.c +++ b/src/console.c @@ -230,7 +230,8 @@ CONSOLE_MESSAGE *psMessage; break; /* Gone tits up by the looks of it */ default: - DBERROR(("Weirdy type of text justification for console print")); + debug( LOG_ERROR, "Weirdy type of text justification for console print" ); + abort(); break; } @@ -647,7 +648,8 @@ void setDefaultConsoleJust(CONSOLE_TEXT_JUSTIFICATION defJ) defJustification = defJ; break; default: - DBERROR(("Weird default text justification for console")); + debug( LOG_ERROR, "Weird default text justification for console" ); + abort(); break; } } diff --git a/src/data.c b/src/data.c index 060bb059e..03a5a9138 100644 --- a/src/data.c +++ b/src/data.c @@ -710,7 +710,8 @@ BOOL dataIMDBufferLoad(char *pBuffer, UDWORD size, void **ppData) psIMD = iV_ProcessIMD(&pBufferPosition, pBufferPosition + size, "", "", FALSE); if (psIMD == NULL) { - DBERROR(("IMD load failed - %s", GetLastResourceFilename())); + debug( LOG_ERROR, "IMD load failed - %s", GetLastResourceFilename() ); + abort(); return FALSE; } diff --git a/src/design.c b/src/design.c index 6820c2553..b5b1c5343 100644 --- a/src/design.c +++ b/src/design.c @@ -1364,7 +1364,8 @@ intChooseSystemStats( DROID_TEMPLATE *psTemplate ) psTemplate->asWeaps[0]); break; default: - DBERROR( ("intSetDesignStats: unrecognised droid type") ); + debug( LOG_ERROR, "intSetDesignStats: unrecognised droid type" ); + abort(); return NULL; } @@ -1455,7 +1456,7 @@ STRING *GetDefaultTemplateName(DROID_TEMPLATE *psTemplate) if ( strlen( aCurrName ) + strlen( pStr ) > WIDG_MAXSTR ) { - DBPRINTF( ("GetDefaultTemplateName: name string too long %s+%s\n",aCurrName,pStr) ); + debug( LOG_NEVER, "GetDefaultTemplateName: name string too long %s+%s\n", aCurrName, pStr ); return NULL; } @@ -1471,7 +1472,7 @@ STRING *GetDefaultTemplateName(DROID_TEMPLATE *psTemplate) if ( strlen( aCurrName ) + strlen( pStr ) > WIDG_MAXSTR ) { - DBPRINTF( ("GetDefaultTemplateName: name string too long %s+%s\n",aCurrName,pStr) ); + debug( LOG_NEVER, "GetDefaultTemplateName: name string too long %s+%s\n", aCurrName, pStr ); return NULL; } @@ -2695,7 +2696,7 @@ static BOOL intAddComponentButtons(COMP_BASE_STATS *psStats, UDWORD size, sButInit.majorID += 1; if (sButInit.majorID >= WFORM_MAXMAJOR) { - DBPRINTF(("Too many buttons for component form")); + debug( LOG_NEVER, "Too many buttons for component form" ); return FALSE; } } @@ -2714,7 +2715,7 @@ static BOOL intAddComponentButtons(COMP_BASE_STATS *psStats, UDWORD size, sButInit.minorID += 1; if (sButInit.minorID >= WFORM_MAXMINOR) { - DBPRINTF(("Too many buttons for component form")); + debug( LOG_NEVER, "Too many buttons for component form" ); return FALSE; } } @@ -5106,7 +5107,7 @@ BOOL saveTemplate(void) /* The design needs a new template in the list */ if (!HEAP_ALLOC(psTemplateHeap, (void**) &psTempl)) { - DBPRINTF( ("saveTemplate: heap alloc failed\n") ); + debug( LOG_NEVER, "saveTemplate: heap alloc failed\n" ); return FALSE; } diff --git a/src/difficulty.c b/src/difficulty.c index 852324834..cbdd028cf 100644 --- a/src/difficulty.c +++ b/src/difficulty.c @@ -60,7 +60,8 @@ void setDifficultyLevel(DIFFICULTY_LEVEL lev) fDifEnemyModifier = FRACTCONST(50,100); // they do less damage! break; default: - DBERROR(("Invalid difficulty level selected - forcing NORMAL")); + debug( LOG_ERROR, "Invalid difficulty level selected - forcing NORMAL" ); + abort(); break; } diff --git a/src/disp2d.c b/src/disp2d.c index b5bd818a5..6aec805b4 100644 --- a/src/disp2d.c +++ b/src/disp2d.c @@ -6,11 +6,11 @@ */ #ifdef DISP2D -/* +/* * In order to reintroduce the 2D map editor, we will have to rewrite the * graphics code almost completely. It used a previous iteration of their * graphics interface. Although portions of it may still be in commented - * out portions of the original source release, it is of doubtful value. + * out portions of the original source release, it is of doubtful value. * Better to port it to the new interface and OpenGL. - Per */ @@ -635,7 +635,7 @@ removed cos types are different - am sStructPos.y = ((worldY + TILE_UNITS/2) >> TILE_SHIFT) - sStructPos.height/2; } else - { + { sStructPos.y = (worldY >> TILE_SHIFT) - sStructPos.height/2; } //check for valid location @@ -960,8 +960,8 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) NULL, &sDDSDSrc, DDLOCK_WAIT, NULL); if (ddrval != DD_OK) { - DBERROR(("Lock failed for tile blit:\n%s", - DDErrorToString(ddrval))); + debug( LOG_ERROR, "Lock failed for tile blit:\n%s", DDErrorToString(ddrval) ); + abort(); return; } @@ -972,8 +972,8 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) NULL, &sDDSDDest, DDLOCK_WAIT, NULL); if (ddrval != DD_OK) { - DBERROR(("Lock failed for tile blit:\n%s", - DDErrorToString(ddrval))); + debug( LOG_ERROR, "Lock failed for tile blit:\n%s", DDErrorToString(ddrval) ); + abort(); return; } @@ -986,7 +986,7 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) /* P1 -> P2 is horizontal */ xDir = (psP1->x > psP2->x) ? -1 : 1; yDir = (psP1->y > psP4->y) ? -1 : 1; - p8Dest = (UBYTE *)sDDSDDest.lpSurface + + p8Dest = (UBYTE *)sDDSDDest.lpSurface + sDDSDDest.lPitch * psDestRect->top + psDestRect->left; destInc = sDDSDDest.lPitch - (psDestRect->right - psDestRect->left); @@ -1026,7 +1026,7 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) /* P1 -> P2 is vertical */ xDir = (psP1->x > psP4->x) ? -1 : 1; yDir = (psP1->y > psP2->y) ? -1 : 1; - p8Dest = (UBYTE *)sDDSDDest.lpSurface + + p8Dest = (UBYTE *)sDDSDDest.lpSurface + sDDSDDest.lPitch * psDestRect->top + psDestRect->left; destInc = sDDSDDest.lPitch - (psDestRect->right - psDestRect->left); @@ -1059,7 +1059,7 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) /* P1 -> P2 is horizontal */ xDir = (psP1->x > psP2->x) ? -1 : 1; yDir = (psP1->y > psP4->y) ? -1 : 1; - p16Dest = (UWORD *)((UBYTE *)sDDSDDest.lpSurface + + p16Dest = (UWORD *)((UBYTE *)sDDSDDest.lpSurface + sDDSDDest.lPitch * psDestRect->top + (psDestRect->left << 1)); destInc = sDDSDDest.lPitch - ((psDestRect->right - psDestRect->left) << 1); @@ -1099,7 +1099,7 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) /* P1 -> P2 is vertical */ xDir = (psP1->x > psP4->x) ? -1 : 1; yDir = (psP1->y > psP2->y) ? -1 : 1; - p16Dest = (UWORD *)((UBYTE *)sDDSDDest.lpSurface + + p16Dest = (UWORD *)((UBYTE *)sDDSDDest.lpSurface + sDDSDDest.lPitch * psDestRect->top + (psDestRect->left << 1)); destInc = sDDSDDest.lPitch - ((psDestRect->right - psDestRect->left) << 1); @@ -1130,21 +1130,22 @@ void blitTile(RECT *psDestRect, RECT *psSrcRect, UDWORD texture) case 32: break; default: - DBERROR(("blitTile: Unknown pixel format")); + debug( LOG_ERROR, "blitTile: Unknown pixel format" ); + abort(); } ddrval = psBack->lpVtbl->Unlock(psBack, NULL); if (ddrval != DD_OK) { - DBERROR(("Unlock failed for tileBlit:\n%s", - DDErrorToString(ddrval))); + debug( LOG_ERROR, "Unlock failed for tileBlit:\n%s", DDErrorToString(ddrval) ); + abort(); } ddrval = psVidTiles->lpVtbl->Unlock(psTiles, NULL); if (ddrval != DD_OK) { - DBERROR(("Unlock failed for tileBlit:\n%s", - DDErrorToString(ddrval))); + debug( LOG_ERROR, "Unlock failed for tileBlit:\n%s", DDErrorToString(ddrval) ); + abort(); } } @@ -1329,7 +1330,7 @@ static void display2DMap(void) (((psDroid->x + TILE_SIZE2D/2) >> TILE_SHIFT) < (viewX + TILES_ACROSS)) && (((psDroid->y - TILE_SIZE2D/2) >> TILE_SHIFT) >= (viewY)) && (((psDroid->y + TILE_SIZE2D/2) >> TILE_SHIFT) < (viewY + TILES_DOWN))) - + { if (psDroid->sMove.Status != MOVEINACTIVE) { @@ -1375,7 +1376,7 @@ static void display2DMap(void) bmpDir = psDroid->direction + 180; bmpDir = bmpDir >= 360 ? bmpDir - 360 : bmpDir; bmpDir = (360 - bmpDir)/45; - screenBlitTile(scrX, scrY, psVidDroids, + screenBlitTile(scrX, scrY, psVidDroids, 32,32, bmpDir); /* switch (psDroid->action) { @@ -1458,7 +1459,7 @@ static void display2DMap(void) >= (viewY)) && (((psStructure->y + breadth * TILE_SIZE2D/2) >> TILE_SHIFT) < (viewY + TILES_DOWN))) - + { scrX = (((psStructure->x - (viewX << TILE_SHIFT)) * TILE_SIZE2D) >> TILE_SHIFT) - TILE_SIZE2D/2; @@ -1482,7 +1483,7 @@ static void display2DMap(void) { for (k = 0; k < width; k++) { - screenBlitTile(scrX, scrY, psVidStructures, + screenBlitTile(scrX, scrY, psVidStructures, 32,32, psStructure->status); scrX += TILE_SIZE2D; } @@ -1516,7 +1517,7 @@ static void display2DMap(void) >= (viewY)) && (((psFeature->y + breadth * TILE_SIZE2D/2) >> TILE_SHIFT) < (viewY + TILES_DOWN))) - + { scrX = (((psFeature->x - (viewX << TILE_SHIFT)) * TILE_SIZE2D) >> TILE_SHIFT) - TILE_SIZE2D/2; @@ -1540,7 +1541,7 @@ static void display2DMap(void) { for (k = 0; k < width; k++) { - screenBlitTile(scrX, scrY, psVidStructures, + screenBlitTile(scrX, scrY, psVidStructures, 32,32, 3); scrX += TILE_SIZE2D; } @@ -1622,7 +1623,7 @@ static void display2DBullets(void) bmpDir = psCurr->psSource->direction + 180; bmpDir = bmpDir >= 360 ? bmpDir - 360 : bmpDir; bmpDir = (360 - bmpDir)/45; - flashFrame = ((gameTime >> 7) & 1) + + flashFrame = ((gameTime >> 7) & 1) + (bmpDir << 1); screenBlitTile(scrX1 - FLASH_SIZE/2, scrY1 - FLASH_SIZE/2, psVidFlash, FLASH_SIZE,FLASH_SIZE, @@ -1724,7 +1725,7 @@ DROID *psCurr; STRUCTURE *psStruct; UDWORD Count; - + screenTextOut(0,0,"Current Player: %d",selectedPlayer); screenTextOut(200,0,"Current Frame Rate: %d",frameGetFrameRate()); @@ -1759,7 +1760,7 @@ UDWORD Count; } screenTextOut(400, 16, "Player has %d Structures",Count); screenTextOut(400,0,"Game Ticks: %d",gameTime); - + // if(apsDroidLists[0]) // { // screenTextOut(400,48,"Droid Direction : %d",apsDroidLists[0]->direction); @@ -1774,10 +1775,10 @@ void showDroidRange(DROID *psDroid) { UDWORD radius; SDWORD x0,y0,x1,y1; - + /* Get the droid's sensor range */ radius = psDroid->sensorRange; - + /* Convert droid's coordinates to screen coords */ disp2DFromWorld(psDroid->x-radius, psDroid->y-radius, &x0, &y0); disp2DFromWorld(psDroid->x+radius, psDroid->y+radius, &x1, &y1); diff --git a/src/display.c b/src/display.c index 13c24582a..3c164f214 100644 --- a/src/display.c +++ b/src/display.c @@ -790,7 +790,7 @@ void CheckStartWallDrag(void) wallDrag.x1 = wallDrag.x2 = mouseTileX; wallDrag.y1 = wallDrag.y2 = mouseTileY; wallDrag.status = DRAG_PLACING; - DBPRINTF(("Start Wall Drag\n")); + debug( LOG_NEVER, "Start Wall Drag\n" ); } } else if (intBuildSelectMode())//if we were in build select mode @@ -837,7 +837,7 @@ BOOL CheckFinishedFindPosition(void) wallDrag.status = DRAG_RELEASED; } - DBPRINTF(("BUILD3D_FINISHED\n")); + debug( LOG_NEVER, "BUILD3D_FINISHED\n" ); buildState = BUILD3D_FINISHED; return TRUE; } else { diff --git a/src/display3d.c b/src/display3d.c index 01c2eb03e..ad5ef41c0 100644 --- a/src/display3d.c +++ b/src/display3d.c @@ -4733,7 +4733,8 @@ SDWORD shift; break; default: - DBERROR(("Weirdy direction for a structure in renderWall")); + debug( LOG_ERROR, "Weirdy direction for a structure in renderWall" ); + abort(); break; } /* diff --git a/src/drive.c b/src/drive.c index 7d40564c8..221afb652 100644 --- a/src/drive.c +++ b/src/drive.c @@ -114,7 +114,7 @@ void driveInitVars(BOOL Restart) { if(WasDriving && !Restart) { - DBPRINTF(("driveInitVars: WasDriving\n")); + debug( LOG_NEVER, "driveInitVars: WasDriving\n" ); DrivingAudioTrack=-1; psDrivenDroid = NULL; DoFollowRangeCheck = TRUE; @@ -127,7 +127,7 @@ void driveInitVars(BOOL Restart) TargetFeatures = FALSE; } else { - DBPRINTF(("driveInitVars: Driving\n")); + debug( LOG_NEVER, "driveInitVars: Driving\n" ); DrivingAudioTrack=-1; psDrivenDroid = NULL; DoFollowRangeCheck = TRUE; @@ -193,7 +193,7 @@ BOOL StartDriverMode(DROID *psOldDroid) // psDroid->sMove.Status = MOVEDRIVE; } psDrivenDroid = psDroid; - DBPRINTF(("New driven droid\n")); + debug( LOG_NEVER, "New driven droid\n" ); } else if(psDroid != psDrivenDroid) { // All the others become followers of the driven droid. // psDroid->sMove.Status = MOVEDRIVEFOLLOW; @@ -232,14 +232,14 @@ BOOL StartDriverMode(DROID *psOldDroid) setDrivingStatus(TRUE); if(DriveInterfaceEnabled) { - DBPRINTF(("Interface enabled1 ! Disabling drive control\n")); + debug( LOG_NEVER, "Interface enabled1 ! Disabling drive control\n" ); DriveControlEnabled = FALSE; } else { DriveControlEnabled = TRUE; } if(psLastDriven != psDrivenDroid) { -DBPRINTF(("camAllignWithTarget\n")); + debug( LOG_NEVER, "camAllignWithTarget\n" ); camAllignWithTarget((BASE_OBJECT*)psDrivenDroid); } @@ -264,7 +264,7 @@ void ChangeDriver(void) DROID *psDroid; if(psDrivenDroid != NULL) { - DBPRINTF(("Driver Changed\n")); + debug( LOG_NEVER, "Driver Changed\n" ); // audio_StopObjTrack(psDrivenDroid,ID_SOUND_SMALL_DROID_RUN); @@ -294,7 +294,7 @@ void StopDriverMode(void) DROID *psDroid; if(psDrivenDroid != NULL) { - DBPRINTF(("Drive mode canceled\n")); + debug( LOG_NEVER, "Drive mode canceled\n" ); // audio_StopObjTrack(psDrivenDroid,ID_SOUND_SMALL_DROID_RUN); @@ -882,7 +882,7 @@ void driveEnableTactical(void) StartTacticalScroll(TRUE); TacticalActive = TRUE; - DBPRINTF(("Tactical Mode Activated\n")); + debug( LOG_NEVER, "Tactical Mode Activated\n" ); } @@ -897,7 +897,7 @@ void driveDisableTactical(void) // SetMouseRange(0,16,16,639-16,479-16); // SetMousePos(0,320,160); TacticalActive = FALSE; - DBPRINTF(("Tactical Mode Canceled\n")); + debug( LOG_NEVER, "Tactical Mode Canceled\n" ); } } @@ -915,7 +915,7 @@ void driveTacticalSelectionChanged(void) { if(TacticalActive && psDrivenDroid) { StartTacticalScrollObj(TRUE,(BASE_OBJECT *)psDrivenDroid); - DBPRINTF(("driveTacticalSelectionChanged\n")); + debug( LOG_NEVER, "driveTacticalSelectionChanged\n" ); } } diff --git a/src/droid.c b/src/droid.c index 5d1ef37e8..ffabe97fe 100644 --- a/src/droid.c +++ b/src/droid.c @@ -702,7 +702,7 @@ void removeDroidFX(DROID *psDel) #if defined(PSX) && defined(LIBPAD) if(EnableVibration) { - DBPRINTF(("SetVibro1\n")); + debug( LOG_NEVER, "SetVibro1\n" ); SetVibro1(0,100,512); } #endif @@ -831,7 +831,7 @@ void destroyDroid(DROID *psDel) #if defined(PSX) && defined(LIBPAD) if(EnableVibration) { - DBPRINTF(("SetVibro1\n")); + debug( LOG_NEVER, "SetVibro1\n" ); SetVibro1(0,100,512); } #endif @@ -1044,7 +1044,8 @@ void droidBurntCallback( ANIM_OBJECT * psObj ) ID_ANIM_DROIDFLAMEFALL, 0, 1 ); if ( psDroid->psCurAnim == NULL ) { - DBERROR( ("unitBurntCallback: couldn't add fall over anim\n") ); + debug( LOG_ERROR, "unitBurntCallback: couldn't add fall over anim\n" ); + abort(); return; } @@ -1060,7 +1061,8 @@ void droidBurn( DROID * psDroid ) if ( psDroid->droidType != DROID_PERSON ) { - DBERROR( ("unitBurn: can't burn anything except babarians currently!\n") ); + debug( LOG_ERROR, "unitBurn: can't burn anything except babarians currently!\n" ); + abort(); return; } @@ -1085,7 +1087,8 @@ void droidBurn( DROID * psDroid ) ID_ANIM_DROIDBURN, 0, 3 ); if ( psDroid->psCurAnim == NULL ) { - DBERROR( ("unitBurn: couldn't add burn anim\n") ); + debug( LOG_ERROR, "unitBurn: couldn't add burn anim\n" ); + abort(); return; } @@ -1093,7 +1096,7 @@ void droidBurn( DROID * psDroid ) animObj_SetDoneFunc( psDroid->psCurAnim, droidBurntCallback ); /* add scream */ -DBPRINTF(("baba burn\n")); + debug( LOG_NEVER, "baba burn\n" ); audio_PlayObjDynamicTrack( psDroid, ID_SOUND_BARB_SCREAM+(rand()%3), NULL ); @@ -1795,7 +1798,7 @@ BOOL droidStartBuild(DROID *psDroid) if (!droidNextToStruct(psDroid, (BASE_OBJECT *)psStruct)) { /* Nope - stop building */ - DBPRINTF(("unitStartBuild: not next to structure\n")); + debug( LOG_NEVER, "unitStartBuild: not next to structure\n" ); } } @@ -2854,7 +2857,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) { if (!HEAP_ALLOC(psTemplateHeap, (void*) &pDroidDesign)) { - DBERROR(("Out of memory - Droid Templates")); + debug( LOG_ERROR, "Out of memory - Droid Templates" ); + abort(); return FALSE; } memset(pDroidDesign, 0, sizeof(DROID_TEMPLATE)); @@ -2912,7 +2916,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) of STORE_RESOURCE_ID or RESOURCE_NAMES! - 25/06/98 AB*/ if (!strresGetIDNum(psStringRes, componentName, &id)) { - DBERROR(("Unable to find string resource for %s", componentName)); + debug( LOG_ERROR, "Unable to find string resource for %s", componentName ); + abort(); return FALSE; } @@ -2966,7 +2971,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("Body component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "Body component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); return FALSE; } } @@ -3010,7 +3016,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("Brain component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "Brain component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); // DBERROR(("Brain component not found for droid %s", pDroidDesign->pName)); return FALSE; } @@ -3055,7 +3062,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("Construct component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "Construct component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); return FALSE; } } @@ -3099,7 +3107,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("ECM component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "ECM component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); return FALSE; } } @@ -3150,7 +3159,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("Propulsion component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "Propulsion component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); return FALSE; } } @@ -3194,7 +3204,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) } if (!found) { - DBERROR(("Repair component not found for droid %s", getTemplateName(pDroidDesign))); + debug( LOG_ERROR, "Repair component not found for droid %s", getTemplateName(pDroidDesign) ); + abort(); return FALSE; } } @@ -3276,10 +3287,11 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) if (!found) { #ifdef HASH_NAMES - DBERROR(("Sensor not found for droid Template: %s",strresGetString(NULL,pDroidDesign->NameHash))); + debug( LOG_ERROR, "Sensor not found for droid Template: %s", strresGetString( NULL, pDroidDesign->NameHash ) ); #else - DBERROR(("Sensor not found for droid Template: %s",pDroidDesign->aName)); + debug( LOG_ERROR, "Sensor not found for droid Template: %s", pDroidDesign->aName ); #endif + abort(); return FALSE; } } @@ -3294,10 +3306,11 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) pDroidDesign->numWeaps > DROID_MAXWEAPS) { #ifdef HASH_NAMES - DBERROR(("Too many weapons have been allocated for droid Template: %s (%x)",strresGetString(NULL,pDroidDesign->NameHash),pDroidDesign->NameHash)); + debug( LOG_ERROR, "Too many weapons have been allocated for droid Template: %s (%x)", strresGetString( NULL, pDroidDesign->NameHash ), pDroidDesign->NameHash ); #else - DBERROR(("Too many weapons have been allocated for droid Template: %s",pDroidDesign->aName)); + debug( LOG_ERROR, "Too many weapons have been allocated for droid Template: %s", pDroidDesign->aName ); #endif + abort(); return FALSE; } @@ -3345,7 +3358,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) if ( bDefaultTemplateFound == FALSE ) { - DBERROR( ("loadUnitTemplates: default template not found\n") ); + debug( LOG_ERROR, "loadUnitTemplates: default template not found\n" ); + abort(); return FALSE; } @@ -3588,7 +3602,8 @@ BOOL loadDroidWeapons(char *pWeaponData, UDWORD bufferSize) if ( strcmp(TemplateName, pTemplate->aName) ) #endif { - DBERROR(("Unable to find Template - %s", TemplateName)); + debug( LOG_ERROR, "Unable to find Template - %s", TemplateName ); + abort(); return FALSE; } } @@ -3597,8 +3612,8 @@ BOOL loadDroidWeapons(char *pWeaponData, UDWORD bufferSize) //if weapon not found - error if (incW == -1) { - DBERROR(("Unable to find Weapon %s for template %s", - WeaponName, TemplateName)); + debug( LOG_ERROR, "Unable to find Weapon %s for template %s", WeaponName, TemplateName ); + abort(); return FALSE; } else @@ -3609,15 +3624,16 @@ BOOL loadDroidWeapons(char *pWeaponData, UDWORD bufferSize) if (pTemplate->storeCount > (SDWORD)pTemplate->numWeaps) { - DBERROR(("Trying to allocate more weapons than allowed for Template - %s", - TemplateName)); + debug( LOG_ERROR, "Trying to allocate more weapons than allowed for Template - %s", TemplateName ); + abort(); return FALSE; } //check valid weapon/propulsion if (!checkValidWeaponForProp(pTemplate)) { // ffs - DBERROR(("Weapon is invalid for air propulsion for template %s",pTemplate->aName)); + debug( LOG_ERROR, "Weapon is invalid for air propulsion for template %s", pTemplate->aName ); + abort(); return FALSE; } @@ -3637,7 +3653,8 @@ BOOL loadDroidWeapons(char *pWeaponData, UDWORD bufferSize) if (SkippedWeaponCount > 0) { - DBERROR(("Illegal player number in %d droid weapons",SkippedWeaponCount)); + debug( LOG_ERROR, "Illegal player number in %d droid weapons", SkippedWeaponCount ); + abort(); } @@ -4151,7 +4168,7 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player, //allocate memory if (!createDroid(player, &psDroid)) { - DBPRINTF(("unit build: unable to create\n")); + debug( LOG_NEVER, "unit build: unable to create\n" ); ASSERT((FALSE,"Cannot get the memory for the unit")); return NULL; } @@ -4213,7 +4230,7 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player, { if (!grpCreate(&psGrp)) { - DBPRINTF(("unit build: unable to create group\n")); + debug( LOG_NEVER, "unit build: unable to create group\n" ); ASSERT((FALSE,"Can't create unit because can't create group")); HEAP_FREE(psDroidHeap, psDroid); return NULL; @@ -5829,13 +5846,13 @@ UDWORD passes; } //same as orig, but with threat check -BOOL pickATileGenThreat(UDWORD *x, UDWORD *y, UBYTE numIterations, SDWORD threatRange, +BOOL pickATileGenThreat(UDWORD *x, UDWORD *y, UBYTE numIterations, SDWORD threatRange, SDWORD player, BOOL (*function)(UDWORD x, UDWORD y)) { SDWORD i,j; SDWORD startX,endX,startY,endY; UDWORD passes; - + ASSERT((*x>=0 AND *x=0 AND *y> TILE_SHIFT; dragEY = worldY >> TILE_SHIFT; - + /* Make sure selSX,selSY is always the top left of the box */ if (dragSX < dragEX) { @@ -439,7 +439,8 @@ BOOL ed2dProcessInput(void) /* Get the new undo data */ if (!getBox(&sUndoBox, selSX, selSY, sPasteBox.width,sPasteBox.height)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); break; } @@ -608,7 +609,7 @@ BOOL ed2dProcessInput(void) { if ((currTile & TILE_ROTMASK) < (3 << TILE_ROTSHIFT)) { - currTile = (currTile & ~TILE_ROTMASK) | ((currTile & TILE_ROTMASK) + currTile = (currTile & ~TILE_ROTMASK) | ((currTile & TILE_ROTMASK) + (1 << TILE_ROTSHIFT)); } else @@ -770,7 +771,8 @@ static BOOL getBox(PASTE_BOX *psBox, UDWORD x, UDWORD y, UDWORD width, UDWORD he psBox->width * psBox->height); if (psBox->psTiles == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -821,7 +823,8 @@ static void flipBoxX(PASTE_BOX *psBox) psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height); if (psNew == NULL) { - DBERROR(("Out of memory, couldn't do flip\n")); + debug( LOG_ERROR, "Out of memory, couldn't do flip\n" ); + abort(); return; } @@ -870,7 +873,8 @@ static void flipBoxY(PASTE_BOX *psBox) psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height); if (psNew == NULL) { - DBERROR(("Out of memory, couldn't do flip\n")); + debug( LOG_ERROR, "Out of memory, couldn't do flip\n" ); + abort(); return; } @@ -921,7 +925,8 @@ static void rotBox(PASTE_BOX *psBox) psNew = (MAPTILE *)MALLOC(sizeof(MAPTILE) * psBox->width * psBox->height); if (psNew == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return; } @@ -981,7 +986,7 @@ BOOL ed2dLoadMapFile(void) goto error; } - /* Load the data into the map - + /* Load the data into the map - don't check the return code as we do the same thing either way */ (void)mapLoad(pFileData, fileSize); FREE(pFileData); diff --git a/src/effects.c b/src/effects.c index eb504972e..7f6762bbe 100644 --- a/src/effects.c +++ b/src/effects.c @@ -666,7 +666,8 @@ void updateEffect(EFFECT *psEffect) if(!gamePaused()) updateFirework(psEffect); break; default: - DBERROR(("Weirdy class of effect passed to updateEffect")); + debug( LOG_ERROR, "Weirdy class of effect passed to updateEffect" ); + abort(); break; } } @@ -1626,7 +1627,8 @@ void renderEffect(EFFECT *psEffect) renderFirework(psEffect); break; default: - DBERROR(("Weirdy class of effect passed to renderEffect")); + debug( LOG_ERROR, "Weirdy class of effect passed to renderEffect" ); + abort(); break; } } @@ -2929,7 +2931,8 @@ iIMDShape *psOrig; if(!pFileData) { /* Nope, so do one */ - DBERROR(("Saving FX data : Cannot get the memory! (%d)",fileSize)); + debug( LOG_ERROR, "Saving FX data : Cannot get the memory! (%d)", fileSize ); + abort(); return(FALSE); } @@ -3021,7 +3024,8 @@ EFFECT *pFXData; if(fileSize!=expectedFileSize) { /* No, so bomb out */ - DBERROR(("Read FX data : Weird file size!")); + debug( LOG_ERROR, "Read FX data : Weird file size!" ); + abort(); return(FALSE); } diff --git a/src/environ.c b/src/environ.c index c9458f6fb..3381e971d 100644 --- a/src/environ.c +++ b/src/environ.c @@ -70,7 +70,8 @@ BOOL environInit( void ) pEnvironData = MALLOC(sizeof(struct environ_data) * MAP_MAXWIDTH * MAP_MAXHEIGHT); if(!pEnvironData) { - DBERROR(("Can't get memory for the environment data")); + debug( LOG_ERROR, "Can't get memory for the environment data" ); + abort(); return FALSE; } return TRUE; @@ -192,7 +193,8 @@ FRACT fraction; increment = ((MAKEFRACT(ENVIRON_LAND_SPEED)*pEnvironData[index].vec) * fraction); break; default: - DBERROR(("Weird environment type found")); + debug( LOG_ERROR, "Weird environment type found" ); + abort(); break; } diff --git a/src/feature.c b/src/feature.c index ca84905ff..e73aa91f7 100644 --- a/src/feature.c +++ b/src/feature.c @@ -155,7 +155,8 @@ BOOL loadFeatureStats(char *pFeatureData, UDWORD bufferSize) if (asFeatureStats == NULL) { - DBERROR(("Feature Stats - Out of memory")); + debug( LOG_ERROR, "Feature Stats - Out of memory" ); + abort(); return FALSE; } @@ -220,10 +221,11 @@ BOOL loadFeatureStats(char *pFeatureData, UDWORD bufferSize) if (psFeature->psImd == NULL) { #ifdef HASH_NAMES - DBERROR(("Cannot find the feature PIE for record %s", strresGetString(NULL,psFeature->NameHash))); + debug( LOG_ERROR, "Cannot find the feature PIE for record %s", strresGetString( NULL, psFeature->NameHash ) ); #else - DBERROR(("Cannot find the feature PIE for record %s", getName(psFeature->pName))); + debug( LOG_ERROR, "Cannot find the feature PIE for record %s", getName( psFeature->pName ) ); #endif + abort(); return FALSE; } @@ -749,7 +751,7 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave) if ((psStats->subType == FEAT_OIL_RESOURCE) && !gwZoneReachable(gwGetZone(startX,startY))) { - DBPRINTF(("Oil resource at (%d,%d) is unreachable", startX,startY)); + debug( LOG_NEVER, "Oil resource at (%d,%d) is unreachable", startX, startY ); } if(FromSave == TRUE) { diff --git a/src/formation.c b/src/formation.c index a98bdfb7e..a29a1896b 100644 --- a/src/formation.c +++ b/src/formation.c @@ -73,7 +73,7 @@ void formationShutDown(void) while (psFormationList) { - DBPRINTF(("formation with %d units still attached\n",psFormationList->refCount)); + debug( LOG_NEVER, "formation with %d units still attached\n", psFormationList->refCount ); psNext = psFormationList->psNext; HEAP_FREE(psFHeap, psFormationList); psFormationList = psNext; diff --git a/src/fpath.c b/src/fpath.c index 2ff54e6ae..ccb05b19a 100644 --- a/src/fpath.c +++ b/src/fpath.c @@ -18,7 +18,7 @@ BOOL fpathDoMessage; #undef DBP2 #define DBP2( x ) \ if (fpathDoMessage) \ - DBPRINTF( x ) + debug( LOG_NEVER, x ) #include "objects.h" #include "map.h" diff --git a/src/frontend.c b/src/frontend.c index 0a507dd26..52e66c625 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -334,7 +334,8 @@ VOID changeTitleMode(tMode mode) break; default: - DBERROR(("Unknown title mode requested")); + debug( LOG_ERROR, "Unknown title mode requested" ); + abort(); break; } @@ -1573,7 +1574,7 @@ VOID addText(int FontID,UDWORD FormID,UDWORD id, UDWORD PosX, UDWORD PosY, STRI { W_LABINIT sLabInit; -DBPRINTF(("addText : %s\n",txt)); + debug( LOG_NEVER, "addText : %s\n", txt ); memset(&sLabInit, 0, sizeof(W_LABINIT)); sLabInit.formID = FormID; diff --git a/src/function.c b/src/function.c index d713c998a..5feee1099 100644 --- a/src/function.c +++ b/src/function.c @@ -46,7 +46,7 @@ static BOOL loadUpgradeFunction(char *pData, UBYTE type); //array of functions pointers for each load function -BOOL (*pLoadFunction[NUMFUNCTIONS])(char *pData) = +BOOL (*pLoadFunction[NUMFUNCTIONS])(char *pData) = { loadProduction, loadProductionUpgradeFunction, @@ -98,7 +98,8 @@ BOOL loadFunctionStats(char *pFunctionData, UDWORD bufferSize) asFunctions = (FUNCTION**) MALLOC(totalFunctions*sizeof(FUNCTION*)); if (!asFunctions) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } pStartList = asFunctions; @@ -284,7 +285,8 @@ BOOL storeName(FUNCTION* pFunction, STRING* pNameToStore) pFunction->pName = (STRING *)MALLOC(strlen(pNameToStore)+1); if (pFunction->pName == NULL) { - DBERROR(("Function Name - Out of memory")); + debug( LOG_ERROR, "Function Name - Out of memory" ); + abort(); return FALSE; } strcpy(pFunction->pName,pNameToStore); @@ -351,7 +353,8 @@ BOOL loadProduction(char *pData) psFunction = (PRODUCTION_FUNCTION *)MALLOC(sizeof(PRODUCTION_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Production Function - Out of memory")); + debug( LOG_ERROR, "Production Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(PRODUCTION_FUNCTION)); @@ -446,7 +449,8 @@ BOOL loadProductionUpgradeFunction(char *pData) (PRODUCTION_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Production Upgrade Function - Out of memory")); + debug( LOG_ERROR, "Production Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(PRODUCTION_UPGRADE_FUNCTION)); @@ -510,7 +514,8 @@ BOOL loadResearchFunction(char *pData) psFunction = (RESEARCH_FUNCTION *)MALLOC(sizeof(RESEARCH_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Research Function - Out of memory")); + debug( LOG_ERROR, "Research Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(RESEARCH_FUNCTION)); @@ -543,7 +548,8 @@ BOOL loadReArmFunction(char *pData) psFunction = (REARM_FUNCTION *)MALLOC(sizeof(REARM_FUNCTION)); if (psFunction == NULL) { - DBERROR(("ReArm Function - Out of memory")); + debug( LOG_ERROR, "ReArm Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(REARM_FUNCTION)); @@ -649,7 +655,8 @@ BOOL loadUpgradeFunction(char *pData, UBYTE type) psFunction = (UPGRADE_FUNCTION *)MALLOC(sizeof(UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Upgrade Function - Out of memory")); + debug( LOG_ERROR, "Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(UPGRADE_FUNCTION)); @@ -694,7 +701,8 @@ BOOL loadDroidBodyUpgradeFunction(char *pData) sizeof(DROIDBODY_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("UnitBody Upgrade Function - Out of memory")); + debug( LOG_ERROR, "UnitBody Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(DROIDBODY_UPGRADE_FUNCTION)); @@ -760,7 +768,8 @@ BOOL loadDroidSensorUpgradeFunction(char *pData) sizeof(DROIDSENSOR_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("UnitSensor Upgrade Function - Out of memory")); + debug( LOG_ERROR, "UnitSensor Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(DROIDSENSOR_UPGRADE_FUNCTION)); @@ -808,7 +817,8 @@ BOOL loadWeaponUpgradeFunction(char *pData) (WEAPON_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Weapon Upgrade Function - Out of memory")); + debug( LOG_ERROR, "Weapon Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(WEAPON_UPGRADE_FUNCTION)); @@ -847,7 +857,8 @@ BOOL loadWeaponUpgradeFunction(char *pData) incenDamage > UWORD_MAX OR radiusHit > UWORD_MAX) { - DBERROR(("A percentage increase for Weapon Upgrade function is too large")); + debug( LOG_ERROR, "A percentage increase for Weapon Upgrade function is too large" ); + abort(); return FALSE; } @@ -877,7 +888,8 @@ BOOL loadStructureUpgradeFunction(char *pData) (STRUCTURE_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Structure Upgrade Function - Out of memory")); + debug( LOG_ERROR, "Structure Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(STRUCTURE_UPGRADE_FUNCTION)); @@ -903,7 +915,8 @@ BOOL loadStructureUpgradeFunction(char *pData) body > UWORD_MAX OR resistance > UWORD_MAX) { - DBERROR(("A percentage increase for Structure Upgrade function is too large")); + debug( LOG_ERROR, "A percentage increase for Structure Upgrade function is too large" ); + abort(); return FALSE; } @@ -926,7 +939,8 @@ BOOL loadWallDefenceUpgradeFunction(char *pData) (WALLDEFENCE_UPGRADE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("WallDefence Upgrade Function - Out of memory")); + debug( LOG_ERROR, "WallDefence Upgrade Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(WALLDEFENCE_UPGRADE_FUNCTION)); @@ -951,7 +965,8 @@ BOOL loadWallDefenceUpgradeFunction(char *pData) if (armour > UWORD_MAX OR body > UWORD_MAX) { - DBERROR(("A percentage increase for WallDefence Upgrade function is too large")); + debug( LOG_ERROR, "A percentage increase for WallDefence Upgrade function is too large" ); + abort(); return FALSE; } @@ -1042,7 +1057,8 @@ BOOL loadPowerGenFunction(char *pData) (POWER_GEN_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Power Gen Function - Out of memory")); + debug( LOG_ERROR, "Power Gen Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(POWER_GEN_FUNCTION)); @@ -1086,7 +1102,8 @@ BOOL loadResourceFunction(char *pData) (RESOURCE_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Resource Function - Out of memory")); + debug( LOG_ERROR, "Resource Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(RESOURCE_FUNCTION)); @@ -1188,7 +1205,8 @@ BOOL loadRepairDroidFunction(char *pData) (REPAIR_DROID_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Repair Droid Function - Out of memory")); + debug( LOG_ERROR, "Repair Droid Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(REPAIR_DROID_FUNCTION)); @@ -1514,7 +1532,8 @@ BOOL loadWallFunction(char *pData) psFunction = (WALL_FUNCTION *)MALLOC(sizeof(WALL_FUNCTION)); if (psFunction == NULL) { - DBERROR(("Wall Function - Out of memory")); + debug( LOG_ERROR, "Wall Function - Out of memory" ); + abort(); return FALSE; } memset(psFunction, 0, sizeof(WALL_FUNCTION)); @@ -1550,7 +1569,8 @@ BOOL loadWallFunction(char *pData) #else if (!allocateName(&psFunction->pStructName, structureName)) { - DBERROR(("Structure Stats Invalid for function - %s", functionName)); + debug( LOG_ERROR, "Structure Stats Invalid for function - %s", functionName ); + abort(); return FALSE; } #endif diff --git a/src/game.c b/src/game.c index 3871df8fb..2db6f954f 100644 --- a/src/game.c +++ b/src/game.c @@ -1301,20 +1301,20 @@ BOOL loadGameInit(STRING *pGameToLoad ) pFileData = DisplayBuffer; if (!loadFileToBuffer(pGameToLoad, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail2\n")); + debug( LOG_NEVER, "loadgame: Fail2\n" ); goto error; } if (!gameLoad(pFileData, fileSize)) { -printf("[loadgameInit]========----------- FIXME!!!!!!!! \n"); - DBPRINTF(("loadgame: Fail4\n")); + // FIXME Probably should never arrive here? + debug( LOG_NEVER, "loadgame: Fail4\n" ); goto error; } return TRUE; error: - DBPRINTF(("loadgame: ERROR\n")); + debug( LOG_NEVER, "loadgame: ERROR\n" ); /* Start the game clock */ gameTimeStart(); @@ -1370,7 +1370,7 @@ BOOL loadMissionExtras(STRING *pGameToLoad, SWORD levelType) { if (!loadSaveProximity(pFileData, fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 2\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 2\n" ); return FALSE; } } @@ -1399,7 +1399,7 @@ BOOL loadMissionExtras(STRING *pGameToLoad, SWORD levelType) { if (!loadSaveMessage(pFileData, fileSize, levelType)) { - DBPRINTF(("loadMissionExtras: Fail 2\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 2\n" ); return FALSE; } } @@ -1426,7 +1426,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave UWORD missionScrollMinX = 0, missionScrollMinY = 0, missionScrollMaxX = 0, missionScrollMaxY = 0; - DBPRINTF(("loadGame\n")); + debug( LOG_NEVER, "loadGame\n" ); /* Stop the game clock */ gameTimeStop(); @@ -1776,7 +1776,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail23\n")); + debug( LOG_NEVER, "loadgame: Fail23\n" ); goto error; } @@ -1786,7 +1786,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadTerrainTypeMap(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail25\n")); + debug( LOG_NEVER, "loadgame: Fail25\n" ); goto error; } } @@ -1840,13 +1840,13 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail20\n")); + debug( LOG_NEVER, "loadgame: Fail20\n" ); goto error; } //load the data into apsTemplates if (!loadSaveTemplate(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail22\n")); + debug( LOG_NEVER, "loadgame: Fail22\n" ); goto error; } //JPS 25 feb (reverse templates moved from here) @@ -1878,7 +1878,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!mapLoad(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail7\n")); + debug( LOG_NEVER, "loadgame: Fail7\n" ); return(FALSE); } } @@ -1895,7 +1895,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!readVisibilityData(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -1918,14 +1918,14 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail14\n")); + debug( LOG_NEVER, "loadgame: Fail14\n" ); goto error; } //load the data into apsFeatureLists if (!loadSaveFeature(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail16\n")); + debug( LOG_NEVER, "loadgame: Fail16\n" ); goto error; } @@ -1936,14 +1936,14 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail17\n")); + debug( LOG_NEVER, "loadgame: Fail17\n" ); goto error; } //load the data into apsStructLists if (!loadSaveStructure(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail19\n")); + debug( LOG_NEVER, "loadgame: Fail19\n" ); goto error; } @@ -1978,7 +1978,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //ppsCurrentDroidLists = mission.apsDroidLists; if (!loadSaveDroid(pFileData, fileSize, apsDroidLists)) { - DBPRINTF(("loadgame: Fail12\n")); + debug( LOG_NEVER, "loadgame: Fail12\n" ); goto error; } } @@ -2011,7 +2011,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 3\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 3\n" ); return FALSE; } @@ -2021,7 +2021,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveFlag(pFileData, fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 4\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 4\n" ); return FALSE; } } @@ -2052,7 +2052,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail5\n")); + debug( LOG_NEVER, "loadgame: Fail5\n" ); goto error; } @@ -2060,7 +2060,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave // well if it is good enough for the PSX it's good enough for the PC - John. if (!mapLoad(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail7\n")); + debug( LOG_NEVER, "loadgame: Fail7\n" ); return(FALSE); } @@ -2121,7 +2121,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail32\n")); + debug( LOG_NEVER, "loadgame: Fail32\n" ); goto error; } //#else @@ -2133,7 +2133,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveResearch(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -2149,14 +2149,14 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail8\n")); + debug( LOG_NEVER, "loadgame: Fail8\n" ); goto error; } if(!loadSaveDroidInit(pFileData,fileSize)) { - DBPRINTF(("loadgame: Fail10\n")); + debug( LOG_NEVER, "loadgame: Fail10\n" ); goto error; } } @@ -2177,7 +2177,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail11\n")); + debug( LOG_NEVER, "loadgame: Fail11\n" ); goto error; } @@ -2185,7 +2185,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //ppsCurrentDroidLists = apsDroidLists; if (!loadSaveDroid(pFileData, fileSize, apsDroidLists)) { - DBPRINTF(("loadgame: Fail12\n")); + debug( LOG_NEVER, "loadgame: Fail12\n" ); goto error; } @@ -2231,7 +2231,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //ppsCurrentDroidLists = mission.apsDroidLists; if (!loadSaveDroid(pFileData, fileSize, mission.apsDroidLists)) { - DBPRINTF(("loadgame: Fail12\n")); + debug( LOG_NEVER, "loadgame: Fail12\n" ); goto error; } } @@ -2256,7 +2256,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //ppsCurrentDroidLists = apsLimboDroids; if (!loadSaveDroid(pFileData, fileSize, apsLimboDroids)) { - DBPRINTF(("loadgame: Fail12\n")); + debug( LOG_NEVER, "loadgame: Fail12\n" ); goto error; } } @@ -2271,7 +2271,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail14\n")); + debug( LOG_NEVER, "loadgame: Fail14\n" ); goto error; } @@ -2279,7 +2279,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //load the data into apsFeatureLists if (!loadSaveFeature(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail16\n")); + debug( LOG_NEVER, "loadgame: Fail16\n" ); goto error; } @@ -2293,13 +2293,13 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail17\n")); + debug( LOG_NEVER, "loadgame: Fail17\n" ); goto error; } //load the data into apsStructLists if (!loadSaveStructure(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail19\n")); + debug( LOG_NEVER, "loadgame: Fail19\n" ); goto error; } @@ -2326,7 +2326,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail26\n")); + debug( LOG_NEVER, "loadgame: Fail26\n" ); goto error; } @@ -2336,7 +2336,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveCompList(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail28\n")); + debug( LOG_NEVER, "loadgame: Fail28\n" ); goto error; } } @@ -2348,7 +2348,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail29\n")); + debug( LOG_NEVER, "loadgame: Fail29\n" ); goto error; } @@ -2358,7 +2358,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveStructTypeList(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail31\n")); + debug( LOG_NEVER, "loadgame: Fail31\n" ); goto error; } } @@ -2385,7 +2385,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!readVisibilityData(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -2416,7 +2416,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveProduction(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -2445,7 +2445,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!readFXData(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -2475,7 +2475,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!readScoreData(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail33\n")); + debug( LOG_NEVER, "loadgame: Fail33\n" ); goto error; } } @@ -2502,7 +2502,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 3\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 3\n"); return FALSE; } @@ -2512,7 +2512,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveFlag(pFileData, fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 4\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 4\n" ); return FALSE; } } @@ -2534,7 +2534,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 5\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 5\n" ); return FALSE; } @@ -2544,7 +2544,7 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave { if (!loadSaveCommandLists(pFileData, fileSize)) { - DBPRINTF(("loadMissionExtras: Fail 6\n")); + debug( LOG_NEVER, "loadMissionExtras: Fail 6\n" ); return FALSE; } } @@ -2562,14 +2562,14 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail17\n")); + debug( LOG_NEVER, "loadgame: Fail17\n" ); goto error; } //load the data into apsStructLists if (!loadSaveStructLimits(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail19\n")); + debug( LOG_NEVER, "loadgame: Fail19\n" ); goto error; } @@ -2753,12 +2753,12 @@ BOOL loadGame(STRING *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL UserSave //put any widgets back on for the missions resetMissionWidgets(); - DBPRINTF(("loadGame: done\n")); + debug( LOG_NEVER, "loadGame: done\n" ); return TRUE; error: - DBPRINTF(("loadgame: ERROR\n")); + debug( LOG_NEVER, "loadgame: ERROR\n" ); /* Clear all the objects off the map and free up the map memory */ freeAllDroids(); @@ -3183,7 +3183,8 @@ BOOL gameLoad(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'g' || psHeader->aFileType[1] != 'a' || psHeader->aFileType[2] != 'm' || psHeader->aFileType[3] != 'e') { - DBERROR(("gameLoad: Incorrect file type")); + debug( LOG_ERROR, "gameLoad: Incorrect file type" ); + abort(); return FALSE; } @@ -3193,7 +3194,7 @@ BOOL gameLoad(char *pFileData, UDWORD filesize) //increment to the start of the data pFileData += GAME_HEADER_SIZE; - DBPRINTF(("gl .gam file is version %d\n",psHeader->version)); + debug( LOG_NEVER, "gl .gam file is version %d\n", psHeader->version ); //set main version Id from game file saveGameVersion = psHeader->version; @@ -3201,7 +3202,8 @@ BOOL gameLoad(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("gameLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "gameLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version < VERSION_9) @@ -3220,7 +3222,8 @@ BOOL gameLoad(char *pFileData, UDWORD filesize) } else { - DBERROR(("gameLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "gameLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -3300,7 +3303,8 @@ BOOL getCampaignV(char *pFileData, UDWORD filesize, UDWORD version) if ((sizeOfSaveGame + GAME_HEADER_SIZE) > filesize) { - DBERROR(("getCampaign: unexpected end of file")); + debug( LOG_ERROR, "getCampaign: unexpected end of file" ); + abort(); return FALSE; } @@ -3459,7 +3463,7 @@ UDWORD getCampaign(STRING *pGameToLoad, BOOL *bSkipCDCheck) pFileData = DisplayBuffer; if (!loadFileToBuffer(pGameToLoad, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail2\n")); + debug( LOG_NEVER, "loadgame: Fail2\n" ); return 0; } @@ -3469,7 +3473,8 @@ UDWORD getCampaign(STRING *pGameToLoad, BOOL *bSkipCDCheck) if (psHeader->aFileType[0] != 'g' || psHeader->aFileType[1] != 'a' || psHeader->aFileType[2] != 'm' || psHeader->aFileType[3] != 'e') { - DBERROR(("getCampaign: Incorrect file type")); + debug( LOG_ERROR, "getCampaign: Incorrect file type" ); + abort(); return 0; } @@ -3479,7 +3484,7 @@ UDWORD getCampaign(STRING *pGameToLoad, BOOL *bSkipCDCheck) //increment to the start of the data pFileData += GAME_HEADER_SIZE; - DBPRINTF(("gl .gam file is version %d\n",psHeader->version)); + debug( LOG_NEVER, "gl .gam file is version %d\n", psHeader->version ); //set main version Id from game file saveGameVersion = psHeader->version; @@ -3514,7 +3519,8 @@ UDWORD getCampaign(STRING *pGameToLoad, BOOL *bSkipCDCheck) else { - DBERROR(("getCampaign: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "getCampaign: undefined save format version %d", psHeader->version ); + abort(); return 0; } @@ -3543,7 +3549,8 @@ BOOL gameLoadV7(char *pFileData, UDWORD filesize) if ((sizeof(SAVE_GAME_V7) + GAME_HEADER_SIZE) > filesize) { - DBERROR(("gameLoad: unexpected end of file")); + debug( LOG_ERROR, "gameLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -3577,7 +3584,8 @@ BOOL gameLoadV7(char *pFileData, UDWORD filesize) // find the level dataset if (!levFindDataSet(pLevelName, &psNewLevel)) { - DBERROR(("gameLoadV6: couldn't find level data")); + debug( LOG_ERROR, "gameLoadV6: couldn't find level data" ); + abort(); return FALSE; } //check to see whether mission automatically starts @@ -3691,7 +3699,8 @@ BOOL gameLoadV(char *pFileData, UDWORD filesize, UDWORD version) if ((sizeOfSaveGame + GAME_HEADER_SIZE) > filesize) { - DBERROR(("gameLoad: unexpected end of file")); + debug( LOG_ERROR, "gameLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -3949,7 +3958,7 @@ BOOL gameLoadV(char *pFileData, UDWORD filesize, UDWORD version) if (strcmp(psSaveGame->buildDate,date) != 0) { // ASSERT((gameType != GTYPE_SAVE_MIDMISSION,"Mid-game save out of date. Continue with caution.")); - DBPRINTF(("saveGame build date differs;/nsavegame %s/n build %s/n",psSaveGame->buildDate,date)); + debug( LOG_NEVER, "saveGame build date differs;\nsavegame %s\n build %s\n", psSaveGame->buildDate, date ); validityKey = validityKey|VALIDITYKEY_DATE; if (gameType == GTYPE_SAVE_MIDMISSION) { @@ -3959,7 +3968,7 @@ BOOL gameLoadV(char *pFileData, UDWORD filesize, UDWORD version) } else { - DBPRINTF(("saveGame build date differs;/nsavegame pre-Version 18 (%s)/n build %s/n",psSaveGame->buildDate,date)); + debug( LOG_NEVER, "saveGame build date differs;\nsavegame pre-Version 18 (%s)\n build %s\n", psSaveGame->buildDate, date ); oldestSaveGameVersion = 1; validityKey = VALIDITYKEY_DATE; } @@ -4166,7 +4175,8 @@ BOOL writeGameFile(STRING *pFileName, SDWORD saveType) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -4464,7 +4474,8 @@ BOOL loadSaveDroidInit(char *pFileData, UDWORD filesize) psHeader = (DROIDINIT_SAVEHEADER *)pFileData; if (psHeader->aFileType[0] != 'd' || psHeader->aFileType[1] != 'i' || psHeader->aFileType[2] != 'n' || psHeader->aFileType[3] != 't') { - DBERROR(("loadSaveUnitInit: Incorrect file type")); + debug( LOG_ERROR, "loadSaveUnitInit: Incorrect file type" ); + abort(); return FALSE; } @@ -4478,7 +4489,8 @@ BOOL loadSaveDroidInit(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("UnitInit; unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "UnitInit; unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version <= CURRENT_VERSION_NUM) @@ -4490,7 +4502,8 @@ BOOL loadSaveDroidInit(char *pFileData, UDWORD filesize) } else { - DBERROR(("UnitInit: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "UnitInit: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -4537,8 +4550,7 @@ BOOL loadSaveDroidInitV2(char *pFileData, UDWORD filesize,UDWORD quantity) if(psTemplate==NULL) { - DBMB(("loadSaveUnitInitV2:\nUnable to find template for %s player %d", - pDroidInit->name,pDroidInit->player)); + debug( LOG_NEVER, "loadSaveUnitInitV2:\nUnable to find template for %s player %d", pDroidInit->name,pDroidInit->player ); #ifdef DEBUG // DumpDroidTemplates(); @@ -4565,7 +4577,8 @@ BOOL loadSaveDroidInitV2(char *pFileData, UDWORD filesize,UDWORD quantity) else { - DBERROR(("This droid cannot be built - %s", pDroidInit->name)); + debug( LOG_ERROR, "This droid cannot be built - %s", pDroidInit->name ); + abort(); } } } @@ -4577,8 +4590,8 @@ BOOL loadSaveDroidInitV2(char *pFileData, UDWORD filesize,UDWORD quantity) if(NumberOfSkippedDroids) { - DBERROR(("unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", - NumberOfSkippedDroids)); + debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids ); + abort(); } return TRUE; } @@ -4607,7 +4620,8 @@ DROID_TEMPLATE *FindDroidTemplate(STRING *name,UDWORD player) //get the name from the resource associated with it if (!strresGetIDNum(psStringRes, name, &id)) { - DBERROR(("Cannot find resource for template - %s", name)); + debug( LOG_ERROR, "Cannot find resource for template - %s", name ); + abort(); return NULL; } //get the string from the id @@ -4649,7 +4663,8 @@ BOOL loadSaveDroid(char *pFileData, UDWORD filesize, DROID **ppsCurrentDroidList if (psHeader->aFileType[0] != 'd' || psHeader->aFileType[1] != 'r' || psHeader->aFileType[2] != 'o' || psHeader->aFileType[3] != 'd') { - DBERROR(("loadSaveUnit: Incorrect file type")); + debug( LOG_ERROR, "loadSaveUnit: Incorrect file type" ); + abort(); return FALSE; } @@ -4663,7 +4678,8 @@ BOOL loadSaveDroid(char *pFileData, UDWORD filesize, DROID **ppsCurrentDroidList /* Check the file version */ if (psHeader->version < VERSION_9) { - DBERROR(("UnitLoad; unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "UnitLoad; unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version == VERSION_11) @@ -4689,7 +4705,8 @@ BOOL loadSaveDroid(char *pFileData, UDWORD filesize, DROID **ppsCurrentDroidList } else { - DBERROR(("UnitLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "UnitLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -4723,7 +4740,8 @@ DROID* buildDroidFromSaveDroidV11(SAVE_DROID_V11* psSaveDroid) if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name ); + abort(); found = FALSE; break;//continue; } @@ -4744,7 +4762,8 @@ DROID* buildDroidFromSaveDroidV11(SAVE_DROID_V11* psSaveDroid) if (psTemplate->asWeaps[i] < 0) { - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[i].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[i].name ); + abort(); found = FALSE; break; } @@ -4837,7 +4856,8 @@ DROID* buildDroidFromSaveDroidV19(SAVE_DROID_V18* psSaveDroid, UDWORD version) if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name ); + abort(); found = FALSE; break;//continue; @@ -4860,7 +4880,8 @@ DROID* buildDroidFromSaveDroidV19(SAVE_DROID_V18* psSaveDroid, UDWORD version) if (psTemplate->asWeaps[0] < 0) { - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[0].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[0].name ); + abort(); found = FALSE; } } @@ -5090,7 +5111,8 @@ DROID* buildDroidFromSaveDroid(SAVE_DROID* psSaveDroid, UDWORD version) else if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asBits[i].name ); + abort(); found = FALSE; break;//continue; @@ -5112,8 +5134,8 @@ DROID* buildDroidFromSaveDroid(SAVE_DROID* psSaveDroid, UDWORD version) if (psTemplate->asWeaps[0] < 0) { - - DBERROR(("This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[0].name)); + debug( LOG_ERROR, "This component no longer exists - %s, the droid will be deleted", psSaveDroid->asWeaps[0].name ); + abort(); found = FALSE; } } @@ -5314,7 +5336,7 @@ BOOL loadDroidSetPointers(void) for(list = 0; list<3; list++) { - DBPRINTF(("List %d\n",list)); + debug( LOG_NEVER, "List %d\n", list ); for(player = 0; player filesize) { - DBERROR(("unitLoad: unexpected end of file")); + debug( LOG_ERROR, "unitLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -5515,7 +5538,8 @@ BOOL loadSaveDroidV11(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD if (psDroid == NULL) { - DBERROR(("unitLoad: Template not found for unit\n")); + debug( LOG_ERROR, "unitLoad: Template not found for unit\n" ); + abort(); } else if (psSaveDroid->saveType == DROID_ON_TRANSPORT) { @@ -5539,7 +5563,7 @@ BOOL loadSaveDroidV11(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD //set current TransPorter group if (!grpCreate(&psGrp)) { - DBPRINTF(("unit build: unable to create group\n")); + debug( LOG_NEVER, "unit build: unable to create group\n" ); return FALSE; } grpJoin(psGrp, psDroid); @@ -5549,8 +5573,8 @@ BOOL loadSaveDroidV11(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD } if (NumberOfSkippedDroids>0) { - DBERROR(("unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", - NumberOfSkippedDroids)); + debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids ); + abort(); } ppsCurrentDroidLists = NULL;//ensure it always gets set @@ -5599,7 +5623,8 @@ BOOL loadSaveDroidV19(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD if ((sizeOfSaveDroid * numDroids + DROID_HEADER_SIZE) > filesize) { - DBERROR(("unitLoad: unexpected end of file")); + debug( LOG_ERROR, "unitLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -5690,7 +5715,7 @@ BOOL loadSaveDroidV19(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD //set current TransPorter group if (!grpCreate(&psGrp)) { - DBPRINTF(("unit build: unable to create group\n")); + debug( LOG_NEVER, "unit build: unable to create group\n" ); return FALSE; } grpJoin(psGrp, psDroid); @@ -5700,8 +5725,8 @@ BOOL loadSaveDroidV19(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD } if (NumberOfSkippedDroids>0) { - DBERROR(("unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", - NumberOfSkippedDroids)); + debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids ); + abort(); } ppsCurrentDroidLists = NULL;//ensure it always gets set @@ -5742,7 +5767,8 @@ BOOL loadSaveDroidV(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD v if ((sizeOfSaveDroid * numDroids + DROID_HEADER_SIZE) > filesize) { - DBERROR(("unitLoad: unexpected end of file")); + debug( LOG_ERROR, "unitLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -5870,8 +5896,8 @@ BOOL loadSaveDroidV(char *pFileData, UDWORD filesize, UDWORD numDroids, UDWORD v } if (NumberOfSkippedDroids>0) { - DBERROR(("unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", - NumberOfSkippedDroids)); + debug( LOG_ERROR, "unitLoad: Bad Player number in %d unit(s)... assigned to the last player!\n", NumberOfSkippedDroids ); + abort(); } ppsCurrentDroidLists = NULL;//ensure it always gets set @@ -6270,7 +6296,8 @@ BOOL writeDroidFile(STRING *pFileName, DROID **ppsCurrentDroidLists) psTrans = psCurr->psGroup->psList; if (((UDWORD)psTrans->psGrpNext) == 0xcdcdcdcd) { - DBERROR(("transporter ->psGrpNext not reset")); + debug( LOG_ERROR, "transporter ->psGrpNext not reset" ); + abort(); } else { @@ -6288,7 +6315,8 @@ BOOL writeDroidFile(STRING *pFileName, DROID **ppsCurrentDroidLists) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -6360,7 +6388,8 @@ BOOL loadSaveStructure(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 's' || psHeader->aFileType[1] != 't' || psHeader->aFileType[2] != 'r' || psHeader->aFileType[3] != 'u') { - DBERROR(("loadSaveStructure: Incorrect file type")); + debug( LOG_ERROR, "loadSaveStructure: Incorrect file type" ); + abort(); return FALSE; } @@ -6374,7 +6403,8 @@ BOOL loadSaveStructure(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("StructLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "StructLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version < VERSION_9) @@ -6400,7 +6430,8 @@ BOOL loadSaveStructure(char *pFileData, UDWORD filesize) } else { - DBERROR(("StructLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "StructLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -6426,7 +6457,8 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures) if ((sizeof(SAVE_STRUCTURE_V2) * numStructures + STRUCT_HEADER_SIZE) > filesize) { - DBERROR(("structureLoad: unexpected end of file")); + debug( LOG_ERROR, "structureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -6487,8 +6519,9 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures) //if haven't found the structure - ignore this record! if (!found) { - DBERROR(("This structure no longer exists - %s",getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure))); - continue; + debug( LOG_ERROR, "This structure no longer exists - %s", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure) ); + abort(); + continue; } /*create the Structure */ //psStructure = buildStructure((asStructureStats + psSaveStructure-> @@ -6502,8 +6535,8 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures) psSaveStructure->y >> TILE_SHIFT); if (psStructure == NULL) { - DBERROR(("No owning structure for module - %s for player - %d", - getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->player)); + debug( LOG_ERROR, "No owning structure for module - %s for player - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->player ); + abort(); //ignore this module continue; } @@ -6520,15 +6553,15 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures) if(((psSaveStructure->x >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->x >> TILE_SHIFT) > (SDWORD)(mapWidth - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, x coord too near the edge of the map. id - %d", - getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } if(((psSaveStructure->y >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->y >> TILE_SHIFT) > (SDWORD)(mapHeight - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, y coord too near the edge of the map. id - %d", - getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } @@ -6632,7 +6665,8 @@ BOOL loadSaveStructureV7(char *pFileData, UDWORD filesize, UDWORD numStructures) if (NumberOfSkippedStructures>0) { - DBERROR(("structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n",NumberOfSkippedStructures)); + debug( LOG_ERROR, "structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n", NumberOfSkippedStructures ); + abort(); } return TRUE; @@ -6654,7 +6688,8 @@ UDWORD getResearchIdFromName(STRING *pName) } } - DBERROR(("Unknown research - %s", pName)); + debug( LOG_ERROR, "Unknown research - %s", pName ); + abort(); return UDWORD_MAX; } @@ -6705,7 +6740,8 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures if ((sizeOfSaveStruture * numStructures + STRUCT_HEADER_SIZE) > filesize) { - DBERROR(("structureLoad: unexpected end of file")); + debug( LOG_ERROR, "structureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -6776,8 +6812,9 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures //if haven't found the structure - ignore this record! if (!found) { - DBERROR(("This structure no longer exists - %s",getSaveStructNameV19(psSaveStructure))); - continue; + debug( LOG_ERROR, "This structure no longer exists - %s", getSaveStructNameV19(psSaveStructure) ); + abort(); + continue; } /*create the Structure */ //for modules - need to check the base structure exists @@ -6787,8 +6824,8 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures psSaveStructure->y >> TILE_SHIFT); if (psStructure == NULL) { - DBERROR(("No owning structure for module - %s for player - %d", - getSaveStructNameV19(psSaveStructure), psSaveStructure->player)); + debug( LOG_ERROR, "No owning structure for module - %s for player - %d", getSaveStructNameV19(psSaveStructure), psSaveStructure->player ); + abort(); //ignore this module continue; } @@ -6803,15 +6840,15 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures if(((psSaveStructure->x >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->x >> TILE_SHIFT) > (SDWORD)(mapWidth - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, x coord too near the edge of the map. id - %d", - getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } if(((psSaveStructure->y >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->y >> TILE_SHIFT) > (SDWORD)(mapHeight - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, y coord too near the edge of the map. id - %d", - getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV19((SAVE_STRUCTURE_V17*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } @@ -7106,7 +7143,8 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures if (NumberOfSkippedStructures>0) { - DBERROR(("structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n",NumberOfSkippedStructures)); + debug( LOG_ERROR, "structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n", NumberOfSkippedStructures ); + abort(); } return TRUE; @@ -7150,7 +7188,8 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures, if ((sizeOfSaveStructure * numStructures + STRUCT_HEADER_SIZE) > filesize) { - DBERROR(("structureLoad: unexpected end of file")); + debug( LOG_ERROR, "structureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -7221,8 +7260,9 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures, //if haven't found the structure - ignore this record! if (!found) { - DBERROR(("This structure no longer exists - %s",getSaveStructNameV(psSaveStructure))); - continue; + debug( LOG_ERROR, "This structure no longer exists - %s", getSaveStructNameV(psSaveStructure) ); + abort(); + continue; } /*create the Structure */ //for modules - need to check the base structure exists @@ -7232,8 +7272,8 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures, psSaveStructure->y >> TILE_SHIFT); if (psStructure == NULL) { - DBERROR(("No owning structure for module - %s for player - %d", - getSaveStructNameV(psSaveStructure), psSaveStructure->player)); + debug( LOG_ERROR, "No owning structure for module - %s for player - %d", getSaveStructNameV(psSaveStructure), psSaveStructure->player ); + abort(); //ignore this module continue; } @@ -7248,15 +7288,15 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures, if(((psSaveStructure->x >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->x >> TILE_SHIFT) > (SDWORD)(mapWidth - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, x coord too near the edge of the map. id - %d", - getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, x coord too near the edge of the map. id - %d", getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } if(((psSaveStructure->y >> TILE_SHIFT) < TOO_NEAR_EDGE) || (( psSaveStructure->y >> TILE_SHIFT) > (SDWORD)(mapHeight - TOO_NEAR_EDGE))) { - DBERROR(("Structure %s, y coord too near the edge of the map. id - %d", - getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id)); + debug( LOG_ERROR, "Structure %s, y coord too near the edge of the map. id - %d", getSaveStructNameV((SAVE_STRUCTURE*)psSaveStructure), psSaveStructure->id ); + abort(); continue; } @@ -7544,7 +7584,8 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures, if (NumberOfSkippedStructures>0) { - DBERROR(("structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n",NumberOfSkippedStructures)); + debug( LOG_ERROR, "structureLoad: invalid player number in %d structures ... assigned to the last player!\n\n", NumberOfSkippedStructures ); + abort(); } return TRUE; @@ -7584,7 +7625,8 @@ BOOL writeStructFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -7948,7 +7990,8 @@ BOOL loadSaveFeature(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'f' || psHeader->aFileType[1] != 'e' || psHeader->aFileType[2] != 'a' || psHeader->aFileType[3] != 't') { - DBERROR(("loadSaveFeature: Incorrect file type")); + debug( LOG_ERROR, "loadSaveFeature: Incorrect file type" ); + abort(); return FALSE; } @@ -7962,7 +8005,8 @@ BOOL loadSaveFeature(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("FeatLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "FeatLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version <= VERSION_19) @@ -7981,7 +8025,8 @@ BOOL loadSaveFeature(char *pFileData, UDWORD filesize) } else { - DBERROR(("FeatLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "FeatLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -8003,7 +8048,8 @@ BOOL loadSaveFeatureV2(char *pFileData, UDWORD filesize, UDWORD numFeatures) if ((sizeof(SAVE_FEATURE_V2) * numFeatures + FEATURE_HEADER_SIZE) > filesize) { - DBERROR(("featureLoad: unexpected end of file")); + debug( LOG_ERROR, "featureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8033,7 +8079,8 @@ BOOL loadSaveFeatureV2(char *pFileData, UDWORD filesize, UDWORD numFeatures) if (statInc < 0 OR statInc > numFeatureStats) { - DBERROR(("This feature no longer exists - %s, it will be deleted", psSaveFeature->name)); + debug( LOG_ERROR, "This feature no longer exists - %s, it will be deleted", psSaveFeature->name ); + abort(); continue; } @@ -8069,7 +8116,8 @@ BOOL loadSaveFeatureV2(char *pFileData, UDWORD filesize, UDWORD numFeatures) if (!found) { - DBERROR(("This feature no longer exists - %s",psSaveFeature->name)); + debug( LOG_ERROR, "This feature no longer exists - %s", psSaveFeature->name ); + abort(); continue; } @@ -8122,7 +8170,8 @@ BOOL loadSaveFeatureV14(char *pFileData, UDWORD filesize, UDWORD numFeatures, UD if ((sizeOfSaveFeature * numFeatures + FEATURE_HEADER_SIZE) > filesize) { - DBERROR(("featureLoad: unexpected end of file")); + debug( LOG_ERROR, "featureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8174,8 +8223,8 @@ BOOL loadSaveFeatureV14(char *pFileData, UDWORD filesize, UDWORD numFeatures, UD if (!found) { - DBERROR(("This feature no longer exists - %s",psSaveFeature->name)); - + debug( LOG_ERROR, "This feature no longer exists - %s", psSaveFeature->name ); + abort(); continue; } //create the Feature @@ -8231,7 +8280,8 @@ BOOL loadSaveFeatureV(char *pFileData, UDWORD filesize, UDWORD numFeatures, UDWO if ((sizeOfSaveFeature * numFeatures + FEATURE_HEADER_SIZE) > filesize) { - DBERROR(("featureLoad: unexpected end of file")); + debug( LOG_ERROR, "featureLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8273,7 +8323,6 @@ BOOL loadSaveFeatureV(char *pFileData, UDWORD filesize, UDWORD numFeatures, UDWO //loop until find the same name if (!strcmp(psStats->pName, psSaveFeature->name)) - { found = TRUE; break; @@ -8283,7 +8332,8 @@ BOOL loadSaveFeatureV(char *pFileData, UDWORD filesize, UDWORD numFeatures, UDWO if (!found) { - DBERROR(("This feature no longer exists - %s",psSaveFeature->name)); + debug( LOG_ERROR, "This feature no longer exists - %s", psSaveFeature->name ); + abort(); continue; } @@ -8341,7 +8391,8 @@ BOOL writeFeatureFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -8421,7 +8472,8 @@ BOOL loadSaveTemplate(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 't' || psHeader->aFileType[1] != 'e' || psHeader->aFileType[2] != 'm' || psHeader->aFileType[3] != 'p') { - DBERROR(("loadSaveTemplate: Incorrect file type")); + debug( LOG_ERROR, "loadSaveTemplate: Incorrect file type" ); + abort(); return FALSE; } @@ -8435,7 +8487,8 @@ BOOL loadSaveTemplate(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("TemplateLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "TemplateLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version < VERSION_14) @@ -8461,7 +8514,8 @@ BOOL loadSaveTemplate(char *pFileData, UDWORD filesize) } else { - DBERROR(("TemplateLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "TemplateLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } return TRUE; @@ -8481,7 +8535,8 @@ BOOL loadSaveTemplateV7(char *pFileData, UDWORD filesize, UDWORD numTemplates) if ((sizeof(SAVE_TEMPLATE_V2) * numTemplates + TEMPLATE_HEADER_SIZE) > filesize) { - DBERROR(("templateLoad: unexpected end of file")); + debug( LOG_ERROR, "templateLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8506,7 +8561,8 @@ BOOL loadSaveTemplateV7(char *pFileData, UDWORD filesize, UDWORD numTemplates) //create the Template if (!HEAP_ALLOC(psTemplateHeap, (void*) &psTemplate)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); goto error; } //copy the values across @@ -8532,7 +8588,8 @@ BOOL loadSaveTemplateV7(char *pFileData, UDWORD filesize, UDWORD numTemplates) if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the template will be deleted",psSaveTemplate->asParts[i])); + debug( LOG_ERROR, "This component no longer exists - %s, the template will be deleted", psSaveTemplate->asParts[i] ); + abort(); found = FALSE; //continue; @@ -8556,8 +8613,8 @@ BOOL loadSaveTemplateV7(char *pFileData, UDWORD filesize, UDWORD numTemplates) if (compInc < 0) { - DBERROR(("This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i])); - + debug( LOG_ERROR, "This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i] ); + abort(); found = FALSE; //continue; @@ -8609,7 +8666,8 @@ BOOL loadSaveTemplateV14(char *pFileData, UDWORD filesize, UDWORD numTemplates) if ((sizeof(SAVE_TEMPLATE_V14) * numTemplates + TEMPLATE_HEADER_SIZE) > filesize) { - DBERROR(("templateLoad: unexpected end of file")); + debug( LOG_ERROR, "templateLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8635,7 +8693,8 @@ BOOL loadSaveTemplateV14(char *pFileData, UDWORD filesize, UDWORD numTemplates) //create the Template if (!HEAP_ALLOC(psTemplateHeap, (void*) &psTemplate)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); goto error; } //copy the values across @@ -8663,7 +8722,8 @@ BOOL loadSaveTemplateV14(char *pFileData, UDWORD filesize, UDWORD numTemplates) if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the template will be deleted",psSaveTemplate->asParts[i])); + debug( LOG_ERROR, "This component no longer exists - %s, the template will be deleted", psSaveTemplate->asParts[i] ); + abort(); found = FALSE; //continue; @@ -8686,9 +8746,8 @@ BOOL loadSaveTemplateV14(char *pFileData, UDWORD filesize, UDWORD numTemplates) if (compInc < 0) { - - DBERROR(("This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i])); - + debug( LOG_ERROR, "This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i] ); + abort(); found = FALSE; //continue; @@ -8769,7 +8828,8 @@ BOOL loadSaveTemplateV(char *pFileData, UDWORD filesize, UDWORD numTemplates) if ((sizeof(SAVE_TEMPLATE) * numTemplates + TEMPLATE_HEADER_SIZE) > filesize) { - DBERROR(("templateLoad: unexpected end of file")); + debug( LOG_ERROR, "templateLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -8796,7 +8856,8 @@ BOOL loadSaveTemplateV(char *pFileData, UDWORD filesize, UDWORD numTemplates) //create the Template if (!HEAP_ALLOC(psTemplateHeap, (void*) &psTemplate)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); goto error; } //copy the values across @@ -8841,7 +8902,8 @@ BOOL loadSaveTemplateV(char *pFileData, UDWORD filesize, UDWORD numTemplates) else if (compInc < 0) { - DBERROR(("This component no longer exists - %s, the template will be deleted",psSaveTemplate->asParts[i])); + debug( LOG_ERROR, "This component no longer exists - %s, the template will be deleted", psSaveTemplate->asParts[i] ); + abort(); found = FALSE; //continue; @@ -8865,7 +8927,8 @@ BOOL loadSaveTemplateV(char *pFileData, UDWORD filesize, UDWORD numTemplates) if (compInc < 0) { - DBERROR(("This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i])); + debug( LOG_ERROR, "This weapon no longer exists - %s, the template will be deleted", psSaveTemplate->asWeaps[i] ); + abort(); found = FALSE; @@ -8961,7 +9024,8 @@ BOOL writeTemplateFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -9064,7 +9128,8 @@ BOOL loadTerrainTypeMap(char *pFileData, UDWORD filesize) if (filesize < TILETYPE_HEADER_SIZE) { - DBERROR(("loadTerrainTypeMap: file too small")); + debug( LOG_ERROR, "loadTerrainTypeMap: file too small" ); + abort(); return FALSE; } @@ -9073,7 +9138,8 @@ BOOL loadTerrainTypeMap(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 't' || psHeader->aFileType[1] != 't' || psHeader->aFileType[2] != 'y' || psHeader->aFileType[3] != 'p') { - DBERROR(("loadTerrainTypeMap: Incorrect file type")); + debug( LOG_ERROR, "loadTerrainTypeMap: Incorrect file type" ); + abort(); return FALSE; } @@ -9098,13 +9164,15 @@ BOOL loadTerrainTypeMap(char *pFileData, UDWORD filesize) { if (i >= MAX_TILE_TEXTURES) { - DBERROR(("loadTerrainTypeMap: too many types")); + debug( LOG_ERROR, "loadTerrainTypeMap: too many types" ); + abort(); return FALSE; } if (*pType > TER_MAX) { - DBERROR(("loadTerrainTypeMap: terrain type out of range")); + debug( LOG_ERROR, "loadTerrainTypeMap: terrain type out of range" ); + abort(); return FALSE; } @@ -9130,7 +9198,8 @@ static BOOL writeTerrainTypeMapFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeTerrainTypeMapFile: Out of memory")); + debug( LOG_ERROR, "writeTerrainTypeMapFile: Out of memory" ); + abort(); return FALSE; } @@ -9175,7 +9244,8 @@ BOOL loadSaveCompList(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'c' || psHeader->aFileType[1] != 'm' || psHeader->aFileType[2] != 'p' || psHeader->aFileType[3] != 'l') { - DBERROR(("loadSaveCompList: Incorrect file type")); + debug( LOG_ERROR, "loadSaveCompList: Incorrect file type" ); + abort(); return FALSE; } @@ -9189,7 +9259,8 @@ BOOL loadSaveCompList(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("CompLoad: unsupported save format version %d", psHeader->version)); + debug( LOG_ERROR, "CompLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version <= VERSION_19) @@ -9208,7 +9279,8 @@ BOOL loadSaveCompList(char *pFileData, UDWORD filesize) } else { - DBERROR(("CompLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "CompLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -9225,7 +9297,8 @@ BOOL loadSaveCompListV9(char *pFileData, UDWORD filesize, UDWORD numRecords, UDW if ((sizeof(SAVE_COMPLIST_V6) * numRecords + COMPLIST_HEADER_SIZE) > filesize) { - DBERROR(("CompListLoad: unexpected end of file")); + debug( LOG_ERROR, "CompListLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -9293,7 +9366,8 @@ BOOL loadSaveCompListV(char *pFileData, UDWORD filesize, UDWORD numRecords, UDWO if ((sizeof(SAVE_COMPLIST) * numRecords + COMPLIST_HEADER_SIZE) > filesize) { - DBERROR(("CompListLoad: unexpected end of file")); + debug( LOG_ERROR, "CompListLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -9353,7 +9427,8 @@ static BOOL writeCompListFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeCompListFile: Out of memory")); + debug( LOG_ERROR, "writeCompListFile: Out of memory" ); + abort(); return FALSE; } @@ -9498,7 +9573,8 @@ BOOL loadSaveStructTypeList(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 's' || psHeader->aFileType[1] != 't' || psHeader->aFileType[2] != 'r' || psHeader->aFileType[3] != 'l') { - DBERROR(("loadSaveStructTypeList: Incorrect file type")); + debug( LOG_ERROR, "loadSaveStructTypeList: Incorrect file type" ); + abort(); return FALSE; } @@ -9512,7 +9588,8 @@ BOOL loadSaveStructTypeList(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("StructTypeLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "StructTypeLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version <= VERSION_19) @@ -9531,7 +9608,8 @@ BOOL loadSaveStructTypeList(char *pFileData, UDWORD filesize) } else { - DBERROR(("StructTypeLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "StructTypeLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -9549,7 +9627,8 @@ BOOL loadSaveStructTypeListV7(char *pFileData, UDWORD filesize, UDWORD numRecord if ((sizeof(SAVE_STRUCTLIST_V6) * numRecords + STRUCTLIST_HEADER_SIZE) > filesize) { - DBERROR(("StructListLoad: unexpected end of file")); + debug( LOG_ERROR, "StructListLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -9607,7 +9686,8 @@ BOOL loadSaveStructTypeListV(char *pFileData, UDWORD filesize, UDWORD numRecords if ((sizeof(SAVE_STRUCTLIST) * numRecords + STRUCTLIST_HEADER_SIZE) > filesize) { - DBERROR(("StructListLoad: unexpected end of file")); + debug( LOG_ERROR, "StructListLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -9672,7 +9752,8 @@ static BOOL writeStructTypeListFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeStructTypeListFile: Out of memory")); + debug( LOG_ERROR, "writeStructTypeListFile: Out of memory" ); + abort(); return FALSE; } @@ -9726,7 +9807,8 @@ BOOL loadSaveResearch(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'r' || psHeader->aFileType[1] != 'e' || psHeader->aFileType[2] != 's' || psHeader->aFileType[3] != 'h') { - DBERROR(("loadSaveResearch: Incorrect file type")); + debug( LOG_ERROR, "loadSaveResearch: Incorrect file type" ); + abort(); return FALSE; } @@ -9740,7 +9822,8 @@ BOOL loadSaveResearch(char *pFileData, UDWORD filesize) /* Check the file version */ if (psHeader->version < VERSION_8) { - DBERROR(("ResearchLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "ResearchLoad: unsupported save format version %d", psHeader->version ); + abort(); return FALSE; } else if (psHeader->version <= VERSION_19) @@ -9759,7 +9842,8 @@ BOOL loadSaveResearch(char *pFileData, UDWORD filesize) } else { - DBERROR(("ResearchLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "ResearchLoad: undefined save format version %d", psHeader->version ); + abort(); return FALSE; } @@ -9778,7 +9862,8 @@ BOOL loadSaveResearchV8(char *pFileData, UDWORD filesize, UDWORD numRecords) if ((sizeof(SAVE_RESEARCH_V8) * numRecords + RESEARCH_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveResearch: unexpected end of file")); + debug( LOG_ERROR, "loadSaveResearch: unexpected end of file" ); + abort(); return FALSE; } @@ -9861,7 +9946,8 @@ BOOL loadSaveResearchV(char *pFileData, UDWORD filesize, UDWORD numRecords) if ((sizeof(SAVE_RESEARCH) * numRecords + RESEARCH_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveResearch: unexpected end of file")); + debug( LOG_ERROR, "loadSaveResearch: unexpected end of file" ); + abort(); return FALSE; } @@ -9943,7 +10029,8 @@ static BOOL writeResearchFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeResearchFile: Out of memory")); + debug( LOG_ERROR, "writeResearchFile: Out of memory" ); + abort(); return FALSE; } @@ -10003,7 +10090,8 @@ BOOL loadSaveMessage(char *pFileData, UDWORD filesize, SWORD levelType) if (psHeader->aFileType[0] != 'm' || psHeader->aFileType[1] != 'e' || psHeader->aFileType[2] != 's' || psHeader->aFileType[3] != 's') { - DBERROR(("loadSaveMessage: Incorrect file type")); + debug( LOG_ERROR, "loadSaveMessage: Incorrect file type" ); + abort(); return FALSE; } @@ -10052,7 +10140,8 @@ BOOL loadSaveMessageV(char *pFileData, UDWORD filesize, UDWORD numMessages, UDWO if ((sizeof(SAVE_MESSAGE) * numMessages + MESSAGE_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveMessage: unexpected end of file")); + debug( LOG_ERROR, "loadSaveMessage: unexpected end of file" ); + abort(); return FALSE; } @@ -10165,7 +10254,8 @@ static BOOL writeMessageFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeMessageFile: Out of memory")); + debug( LOG_ERROR, "writeMessageFile: Out of memory" ); + abort(); return FALSE; } @@ -10259,7 +10349,8 @@ BOOL loadSaveProximity(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'm' || psHeader->aFileType[1] != 'e' || psHeader->aFileType[2] != 's' || psHeader->aFileType[3] != 's') { - DBERROR(("loadSaveProximity: Incorrect file type")); + debug( LOG_ERROR, "loadSaveProximity: Incorrect file type" ); + abort(); return FALSE; } @@ -10292,7 +10383,8 @@ BOOL loadSaveProximityV(char *pFileData, UDWORD filesize, UDWORD numProximitys, if ((sizeof(SAVE_PROXIMITY) * numProximitys + PROXIMITY_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveProximity: unexpected end of file")); + debug( LOG_ERROR, "loadSaveProximity: unexpected end of file" ); + abort(); return FALSE; } @@ -10360,7 +10452,8 @@ static BOOL writeProximityFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeProximityFile: Out of memory")); + debug( LOG_ERROR, "writeProximityFile: Out of memory" ); + abort(); return FALSE; } @@ -10437,7 +10530,8 @@ BOOL loadSaveFlag(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'f' || psHeader->aFileType[1] != 'l' || psHeader->aFileType[2] != 'a' || psHeader->aFileType[3] != 'g') { - DBERROR(("loadSaveflag: Incorrect file type")); + debug( LOG_ERROR, "loadSaveflag: Incorrect file type" ); + abort(); return FALSE; } @@ -10484,7 +10578,8 @@ BOOL loadSaveFlagV(char *pFileData, UDWORD filesize, UDWORD numflags, UDWORD ver if ((sizeOfSaveFlag * numflags + FLAG_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveflag: unexpected end of file")); + debug( LOG_ERROR, "loadSaveflag: unexpected end of file" ); + abort(); return FALSE; } @@ -10656,7 +10751,8 @@ static BOOL writeFlagFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeflagFile: Out of memory")); + debug( LOG_ERROR, "writeflagFile: Out of memory" ); + abort(); return FALSE; } @@ -10791,7 +10887,8 @@ BOOL loadSaveProduction(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'p' || psHeader->aFileType[1] != 'r' || psHeader->aFileType[2] != 'o' || psHeader->aFileType[3] != 'd') { - DBERROR(("loadSaveProduction: Incorrect file type")); + debug( LOG_ERROR, "loadSaveProduction: Incorrect file type" ); + abort(); return FALSE; } @@ -10822,7 +10919,8 @@ BOOL loadSaveProductionV(char *pFileData, UDWORD filesize, UDWORD version) if ((sizeof(SAVE_PRODUCTION) * NUM_FACTORY_TYPES * MAX_FACTORY * MAX_PROD_RUN + PRODUCTION_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveProduction: unexpected end of file")); + debug( LOG_ERROR, "loadSaveProduction: unexpected end of file" ); + abort(); return FALSE; } @@ -10879,7 +10977,8 @@ static BOOL writeProductionFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (!pFileData) { - DBERROR(("writeProductionFile: Out of memory")); + debug( LOG_ERROR, "writeProductionFile: Out of memory" ); + abort(); return FALSE; } @@ -10942,7 +11041,8 @@ BOOL loadSaveStructLimits(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'l' || psHeader->aFileType[1] != 'm' || psHeader->aFileType[2] != 't' || psHeader->aFileType[3] != 's') { - DBERROR(("loadSaveStructLimits: Incorrect file type")); + debug( LOG_ERROR, "loadSaveStructLimits: Incorrect file type" ); + abort(); return FALSE; } @@ -10971,7 +11071,8 @@ BOOL loadSaveStructLimits(char *pFileData, UDWORD filesize) else #endif { - DBERROR(("loadSaveStructLimits: Incorrect file format version")); + debug( LOG_ERROR, "loadSaveStructLimits: Incorrect file format version" ); + abort(); return FALSE; } return TRUE; @@ -10991,14 +11092,16 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits) psSaveLimits = (SAVE_STRUCTLIMITS_V2 *) MALLOC (sizeof(SAVE_STRUCTLIMITS_V2)); if (!psSaveLimits) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } if ((sizeof(SAVE_STRUCTLIMITS_V2) * numLimits + STRUCTLIMITS_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveStructLimits: unexpected end of file")); + debug( LOG_ERROR, "loadSaveStructLimits: unexpected end of file" ); + abort(); return FALSE; } @@ -11023,8 +11126,8 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits) //if haven't found the structure - ignore this record! if (!found) { - DBERROR(("The structure no longer exists. The limits have not been set! - %s", - psSaveLimits->name)); + debug( LOG_ERROR, "The structure no longer exists. The limits have not been set! - %s", psSaveLimits->name ); + abort(); continue; } @@ -11041,7 +11144,8 @@ BOOL loadSaveStructLimitsV19(char *pFileData, UDWORD filesize, UDWORD numLimits) if (SkippedRecords>0) { - DBERROR(("Skipped %d records in structure limits due to bad player number\n",SkippedRecords)); + debug( LOG_ERROR, "Skipped %d records in structure limits due to bad player number\n", SkippedRecords ); + abort(); } FREE(psSaveLimits); return TRUE; @@ -11059,14 +11163,16 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits) psSaveLimits = (SAVE_STRUCTLIMITS*) MALLOC (sizeof(SAVE_STRUCTLIMITS)); if (!psSaveLimits) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } if ((sizeof(SAVE_STRUCTLIMITS) * numLimits + STRUCTLIMITS_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveStructLimits: unexpected end of file")); + debug( LOG_ERROR, "loadSaveStructLimits: unexpected end of file" ); + abort(); return FALSE; } @@ -11091,8 +11197,8 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits) //if haven't found the structure - ignore this record! if (!found) { - DBERROR(("The structure no longer exists. The limits have not been set! - %s", - psSaveLimits->name)); + debug( LOG_ERROR, "The structure no longer exists. The limits have not been set! - %s", psSaveLimits->name ); + abort(); continue; } @@ -11109,7 +11215,8 @@ BOOL loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits) if (SkippedRecords>0) { - DBERROR(("Skipped %d records in structure limits due to bad player number\n",SkippedRecords)); + debug( LOG_ERROR, "Skipped %d records in structure limits due to bad player number\n", SkippedRecords ); + abort(); } FREE(psSaveLimits); return TRUE; @@ -11134,7 +11241,8 @@ BOOL writeStructLimitsFile(STRING *pFileName) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -11184,7 +11292,8 @@ BOOL loadSaveCommandLists(char *pFileData, UDWORD filesize) if (psHeader->aFileType[0] != 'c' || psHeader->aFileType[1] != 'm' || psHeader->aFileType[2] != 'n' || psHeader->aFileType[3] != 'd') { - DBERROR(("loadSaveCommandList: Incorrect file type")); + debug( LOG_ERROR, "loadSaveCommandList: Incorrect file type" ); + abort(); return FALSE; } @@ -11205,7 +11314,8 @@ BOOL loadSaveCommandLists(char *pFileData, UDWORD filesize) } else { - DBERROR(("loadSaveCommandLists: Incorrect file format version")); + debug( LOG_ERROR, "loadSaveCommandLists: Incorrect file format version" ); + abort(); return FALSE; } return TRUE; @@ -11222,7 +11332,8 @@ BOOL loadSaveCommandListsV(char *pFileData, UDWORD filesize, UDWORD numDroids) if ((sizeof(SAVE_COMMAND) * numDroids + COMMAND_HEADER_SIZE) > filesize) { - DBERROR(("loadSaveCommand: unexpected end of file")); + debug( LOG_ERROR, "loadSaveCommand: unexpected end of file" ); + abort(); return FALSE; } @@ -11273,7 +11384,8 @@ BOOL writeCommandLists(STRING *pFileName) pFileData = MALLOC(fileSize); if (pFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -11367,7 +11479,8 @@ BOOL loadScriptState(STRING *pFileName) pFileData = DisplayBuffer; if (!loadFileToBuffer(pFileName, pFileData, displayBufferSize, &fileSize)) { - DBERROR(("loadScriptState: couldn't load %s", pFileName)); + debug( LOG_ERROR, "loadScriptState: couldn't load %s", pFileName ); + abort(); return FALSE; } @@ -11406,12 +11519,12 @@ void setMapScroll() if (scrollMaxX > (SDWORD)mapWidth) { scrollMaxX = mapWidth; - DBMB(("scrollMaxX was too big It has been set to map width")); + debug( LOG_NEVER, "scrollMaxX was too big It has been set to map width" ); } if (scrollMaxY > (SDWORD)mapHeight) { scrollMaxY = mapHeight; - DBMB(("scrollMaxY was too big It has been set to map height")); + debug( LOG_NEVER, "scrollMaxY was too big It has been set to map height" ); } } @@ -11429,7 +11542,8 @@ BOOL getSaveObjectName(STRING *pName) //see if the name has a resource associated with it by trying to get the ID for the string if (!strresGetIDNum(psStringRes, pName, &id)) { - DBERROR(("Cannot find string resource %s", pName)); + debug( LOG_ERROR, "Cannot find string resource %s", pName ); + abort(); return FALSE; } @@ -11507,7 +11621,8 @@ SDWORD getCompFromNamePreV7(UDWORD compType, STRING *pName) break; default: //COMP_UNKNOWN should be an error - DBERROR(("Invalid component type - game.c")); + debug( LOG_ERROR, "Invalid component type - game.c" ); + abort(); } //find the stat with the same name @@ -11517,7 +11632,8 @@ SDWORD getCompFromNamePreV7(UDWORD compType, STRING *pName) //get the translated name from the stat if (!strresGetIDNum(psStringRes, psStats->pName, &id)) { - DBERROR(("Unable to find string resource for %s", getStatName(psStats) )); + debug( LOG_ERROR, "Unable to find string resource for %s", getStatName(psStats) ); + abort(); return -1; } //get the string from the id @@ -11571,7 +11687,8 @@ SDWORD getStatFromNamePreV7(BOOL isFeature, STRING *pName) //get the translated name from the stat if (!strresGetIDNum(psStringRes, psStats->pName, &id)) { - DBERROR(("Unable to find string resource for %s", getStatName(psStats) )); + debug( LOG_ERROR, "Unable to find string resource for %s", getStatName(psStats) ); + abort(); return -1; } @@ -11634,7 +11751,8 @@ static BOOL getNameFromComp(UDWORD compType, STRING *pDest, UDWORD compIndex) psStats = (BASE_STATS*)(asWeaponStats + compIndex); break; default: - DBERROR(("Invalid component type - game.c")); + debug( LOG_ERROR, "Invalid component type - game.c" ); + abort(); return FALSE; } @@ -11673,7 +11791,7 @@ BOOL plotStructurePreview(iSprite *backDropSprite,UBYTE scale,UDWORD offX,UDWORD pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("plotStructurePreview: Fail1\n")); + debug( LOG_NEVER, "plotStructurePreview: Fail1\n" ); } /* Check the file type */ @@ -11681,7 +11799,8 @@ BOOL plotStructurePreview(iSprite *backDropSprite,UBYTE scale,UDWORD offX,UDWORD if (psHeader->aFileType[0] != 's' || psHeader->aFileType[1] != 't' || psHeader->aFileType[2] != 'r' || psHeader->aFileType[3] != 'u') { - DBERROR(("plotStructurePreview: Incorrect file type")); + debug( LOG_ERROR, "plotStructurePreview: Incorrect file type" ); + abort(); return FALSE; } @@ -11807,7 +11926,7 @@ BOOL plotStructurePreview16(unsigned char*backDropSprite,UBYTE scale,UDWORD offX pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("plotStructurePreview16: Fail1\n")); + debug( LOG_NEVER, "plotStructurePreview16: Fail1\n" ); } /* Check the file type */ @@ -11815,7 +11934,8 @@ BOOL plotStructurePreview16(unsigned char*backDropSprite,UBYTE scale,UDWORD offX if (psHeader->aFileType[0] != 's' || psHeader->aFileType[1] != 't' || psHeader->aFileType[2] != 'r' || psHeader->aFileType[3] != 'u') { - DBERROR(("plotStructurePreview16: Incorrect file type")); + debug( LOG_ERROR, "plotStructurePreview16: Incorrect file type" ); + abort(); return FALSE; } diff --git a/src/gateway.c b/src/gateway.c index c6d9d6382..5ae550fbc 100644 --- a/src/gateway.c +++ b/src/gateway.c @@ -163,7 +163,8 @@ BOOL gwNewGateway(SDWORD x1, SDWORD y1, SDWORD x2, SDWORD y2) psNew = MALLOC(sizeof(GATEWAY)); if (!psNew) { - DBERROR(("gwNewGateway: out of memory")); + debug( LOG_ERROR, "gwNewGateway: out of memory" ); + abort(); return FALSE; } @@ -234,7 +235,8 @@ BOOL gwNewLinkGateway(SDWORD x, SDWORD y) psNew = MALLOC(sizeof(GATEWAY)); if (!psNew) { - DBERROR(("gwNewGateway: out of memory")); + debug( LOG_ERROR, "gwNewGateway: out of memory" ); + abort(); return FALSE; } @@ -421,8 +423,7 @@ void gwCheckZoneSizes(void) if (inzone > FPATH_NODEINIT) { - DBPRINTF(("gwCheckZoneSizes: warning zone %d at (%d,%d) is too large %d tiles (max %d)\n", - zone, cx,cy, inzone, FPATH_NODEINIT)); + debug( LOG_ERROR, "gwCheckZoneSizes: warning zone %d at (%d,%d) is too large %d tiles (max %d)\n", zone, cx, cy, inzone, FPATH_NODEINIT ); } } } @@ -437,7 +438,7 @@ BOOL gwGenerateLinkGates(void) ASSERT((apEquivZones != NULL, "gwGenerateLinkGates: no zone equivalence table")); - DBPRINTF(("Generating water link Gateways....")); + debug( LOG_ERROR, "Generating water link Gateways...." ); for(zone=1; zonezone1 == psEnd->zone1) || (psStart->zone1 == psEnd->zone2) ? psStart->zone1 : psStart->zone2; - DBPRINTF(("gwRouteLength: warning only partial route between gateways at %s(%d,%d) and %s(%d,%d) zone %d\n", - psStart->flags & GWR_WATERLINK ? "W" : "", sx,sy, - psStart->flags & GWR_WATERLINK ? "W" : "", ex,ey, - zone)); + debug( LOG_ERROR, "gwRouteLength: warning only partial route between gateways at %s(%d,%d) and %s(%d,%d) zone %d\n", psStart->flags & GWR_WATERLINK ? "W" : "", sx,sy, psStart->flags & GWR_WATERLINK ? "W" : "", ex, ey, zone ); } #endif @@ -710,7 +708,8 @@ BOOL gwLinkGateways(void) aZoneReachable = MALLOC( sizeof(UBYTE) * gwNumZones ); if (aZoneReachable == NULL) { - DBERROR(("gwLinkGateways: out of memory")); + debug( LOG_ERROR, "gwLinkGateways: out of memory" ); + abort(); return FALSE; } memset(aZoneReachable, 0, sizeof(UBYTE) * gwNumZones); @@ -799,7 +798,8 @@ BOOL gwLinkGateways(void) psCurr->psLinks = MALLOC(sizeof(GATEWAY_LINK) * (zone1Links+zone2Links)); if (psCurr->psLinks == NULL) { - DBERROR(("gwLinkGateways: out of memory")); + debug( LOG_ERROR, "gwLinkGateways: out of memory" ); + abort(); return FALSE; } } @@ -917,7 +917,8 @@ BOOL gwNewZoneMap(void) apRLEZones = MALLOC(sizeof(UBYTE *) * gwMapHeight()); if (apRLEZones == NULL) { - DBERROR(("gwNewZoneMap: Out of memory")); + debug( LOG_ERROR, "gwNewZoneMap: Out of memory" ); + abort(); return FALSE; } @@ -943,7 +944,8 @@ UBYTE * gwNewZoneLine(UDWORD Line,UDWORD Size) apRLEZones[Line] = MALLOC(Size); if (apRLEZones[Line] == NULL) { - DBERROR(("gwNewZoneLine: Out of memory")); + debug( LOG_ERROR, "gwNewZoneLine: Out of memory" ); + abort(); return NULL; } @@ -1037,7 +1039,8 @@ BOOL gwNewEquivTable(SDWORD numZones) aNumEquiv = MALLOC(sizeof(UBYTE) * numZones); if (aNumEquiv == NULL) { - DBERROR(("gwNewEquivTable: out of memory")); + debug( LOG_ERROR, "gwNewEquivTable: out of memory" ); + abort(); return FALSE; } for(i=0; i UBYTE_MAX) { - DBERROR(("gwProcessMap: too many zones\n")); + debug( LOG_ERROR, "gwProcessMap: too many zones\n" ); + abort(); return FALSE; } @@ -328,7 +329,8 @@ BOOL gwProcessMap(void) // check the zones havn't overflowed if (currZone > UBYTE_MAX) { - DBERROR(("gwProcessMap: too many zones\n")); + debug( LOG_ERROR, "gwProcessMap: too many zones\n" ); + abort(); return FALSE; } @@ -343,7 +345,8 @@ BOOL gwProcessMap(void) // check the zones havn't overflowed if (currZone > UBYTE_MAX) { - DBERROR(("gwProcessMap: too many zones\n")); + debug( LOG_ERROR, "gwProcessMap: too many zones\n" ); + abort(); return FALSE; } @@ -505,7 +508,8 @@ BOOL gwCreateBlankZoneMap(void) apRLEZones = MALLOC(sizeof(UBYTE *) * gwMapHeight()); if (apRLEZones == NULL) { - DBERROR(("gwCreateBlankZoneMap: Out of memory")); + debug( LOG_ERROR, "gwCreateBlankZoneMap: Out of memory" ); + abort(); return FALSE; } for(i=0; i< gwMapHeight(); i++) @@ -515,7 +519,8 @@ BOOL gwCreateBlankZoneMap(void) if (apRLEZones[i] == NULL) { - DBERROR(("gwCreateBlankZoneMap: Out of memory")); + debug( LOG_ERROR, "gwCreateBlankZoneMap: Out of memory" ); + abort(); return FALSE; } } diff --git a/src/geometry.c b/src/geometry.c index 1210cbc8a..94dc6fbb4 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -452,7 +452,8 @@ UDWORD retVal; /* Check it has a structure - cannot have owner otherwise */ if(!TILE_HAS_STRUCTURE(mapTile(x,y))) { - DBERROR(("Asking for the owner of a tile with no structure on it!!!")); + debug( LOG_ERROR, "Asking for the owner of a tile with no structure on it!!!" ); + abort(); } else { diff --git a/src/hci.c b/src/hci.c index f73eefd17..23f82fb56 100644 --- a/src/hci.c +++ b/src/hci.c @@ -666,7 +666,8 @@ BOOL intInitialise(void) MAXSTRUCTURES); if (!apsStructStatsList) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -674,7 +675,8 @@ BOOL intInitialise(void) ppResearchList = (RESEARCH **) MALLOC(sizeof(RESEARCH *) * MAXRESEARCH); if (ppResearchList == NULL) { - DBERROR(("Unable to allocate memory for research list")); + debug( LOG_ERROR, "Unable to allocate memory for research list" ); + abort(); return FALSE; } @@ -687,12 +689,14 @@ BOOL intInitialise(void) if (pList == NULL) { - DBERROR(("Unable to allocate memory for research list")); + debug( LOG_ERROR, "Unable to allocate memory for research list" ); + abort(); return FALSE; } if (pSList == NULL) { - DBERROR(("Unable to allocate memory for sorted research list")); + debug( LOG_ERROR, "Unable to allocate memory for sorted research list" ); + abort(); return FALSE; } @@ -701,7 +705,8 @@ BOOL intInitialise(void) MAXTEMPLATES); if (apsTemplateList == NULL) { - DBERROR(("Unable to allocate memory for template list")); + debug( LOG_ERROR, "Unable to allocate memory for template list" ); + abort(); return FALSE; } @@ -723,7 +728,8 @@ BOOL intInitialise(void) MAXFEATURES); if (apsFeatureList == NULL) { - DBERROR(("Unable to allocate memory for feature list")); + debug( LOG_ERROR, "Unable to allocate memory for feature list" ); + abort(); return FALSE; } @@ -732,7 +738,8 @@ BOOL intInitialise(void) MAXCOMPONENT); if (apsComponentList == NULL) { - DBERROR(("Unable to allocate memory for component list")); + debug( LOG_ERROR, "Unable to allocate memory for component list" ); + abort(); return FALSE; } @@ -741,7 +748,8 @@ BOOL intInitialise(void) MAXEXTRASYS); if (apsExtraSysList == NULL) { - DBERROR(("Unable to allocate memory for extra systems list")); + debug( LOG_ERROR, "Unable to allocate memory for extra systems list" ); + abort(); return FALSE; } @@ -749,7 +757,8 @@ BOOL intInitialise(void) apsObjectList = (BASE_OBJECT **)MALLOC(sizeof(BASE_OBJECT *) * MAX_OBJECTS); if (!apsObjectList) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -757,7 +766,8 @@ BOOL intInitialise(void) apsListToOrder = (BASE_OBJECT **)MALLOC(sizeof(BASE_OBJECT *) * ORDERED_LIST_SIZE); if (!apsListToOrder) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -796,7 +806,8 @@ BOOL intInitialise(void) if (!widgCreateScreen(&psWScreen)) { - DBERROR(("intInitialise: Couldn't create widget screen (Out of memory ?)")); + debug( LOG_ERROR, "intInitialise: Couldn't create widget screen (Out of memory ?)" ); + abort(); return FALSE; } @@ -806,13 +817,15 @@ BOOL intInitialise(void) if (!intAddReticule()) { - DBERROR(("intInitialise: Couldn't create reticule widgets (Out of memory ?)")); + debug( LOG_ERROR, "intInitialise: Couldn't create reticule widgets (Out of memory ?)" ); + abort(); return FALSE; } if (!intAddPower()) { - DBERROR(("intInitialise: Couldn't create power Bar widget(Out of memory ?)")); + debug( LOG_ERROR, "intInitialise: Couldn't create power Bar widget(Out of memory ?)" ); + abort(); return FALSE; } } @@ -843,7 +856,8 @@ BOOL intInitialise(void) /*Initialise the video playback buffer*/ if (!seq_SetupVideoBuffers()) { - DBERROR(("intInitialise: Unable to initialise video playback buffer")); + debug( LOG_ERROR, "intInitialise: Unable to initialise video playback buffer" ); + abort(); return FALSE; } @@ -1448,7 +1462,7 @@ INT_RETVAL intRunWidgets(void) { if(strlen(sRequestResult)) { - DBPRINTF(("Returned %s",sRequestResult)); + debug( LOG_ERROR, "Returned %s", sRequestResult ); if(bRequestLoad) { // loadGame(sRequestResult,TRUE,FALSE,TRUE); @@ -1951,7 +1965,7 @@ INT_RETVAL intRunWidgets(void) (intMode != INT_MISSIONRES) AND !getDebugMappingStatus()) { - DBPRINTF(("PlayerHasLost Or Won\n")); + debug( LOG_ERROR, "PlayerHasLost Or Won\n" ); intResetScreen(TRUE); retCode = INT_QUIT; quitting = TRUE; @@ -5134,7 +5148,7 @@ static BOOL _intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected, if (sBFormInit.id > IDOBJ_OBJEND) { //can't fit any more on the screen! - DBMB(("This is just a Warning!\n Max buttons have been allocated")); + debug( LOG_NEVER, "This is just a Warning!\n Max buttons have been allocated" ); break; } } else { @@ -5204,7 +5218,7 @@ static BOOL _intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected, // if ((objMode==IOBJ_RESEARCH) && bInTutorial) if (bInTutorial) { - DBPRINTF(("Go with object open callback!\n")); + debug( LOG_NEVER, "Go with object open callback!\n" ); eventFireCallbackTrigger((TRIGGER_TYPE)CALL_OBJECTOPEN); } @@ -5270,7 +5284,7 @@ void intRemoveObject(void) if (bInTutorial) { - DBPRINTF(("Go with object close callback!\n")); + debug( LOG_NEVER, "Go with object close callback!\n" ); eventFireCallbackTrigger((TRIGGER_TYPE)CALL_OBJECTCLOSE); } @@ -6071,7 +6085,7 @@ static BOOL _intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats, if (sBFormInit.id > IDSTAT_END) { //can't fit any more on the screen! - DBMB(("This is just a Warning!\n Max buttons have been allocated")); + debug( LOG_NEVER, "This is just a Warning!\n Max buttons have been allocated" ); break; } @@ -7914,7 +7928,7 @@ BOOL intSelectDroidsInDroidCluster(DROID *psCurDroid) } // intRefreshScreen(); - DBPRINTF(("Selected %d droids\n",NumSelected)); + debug( LOG_NEVER, "Selected %d droids\n", NumSelected ); return TRUE; } @@ -8284,7 +8298,7 @@ void orderDroids(void) SDWORD i,j; BASE_OBJECT *psTemp; - DBPRINTF(("orderUnit\n")); + debug( LOG_NEVER, "orderUnit\n" ); // bubble sort on the ID - first built will always be first in the list for(i=0; ihigherPriority; free( curSearchPath ); curSearchPath = tmpSearchPath; - } + } } // Register searchPath above the path with next lower priority @@ -1017,7 +1017,8 @@ BOOL systemInitialise(void) DisplayBuffer = MALLOC(displayBufferSize); if (DisplayBuffer == NULL) { - DBERROR(("Unable to allocate memory for display buffer")); + debug( LOG_ERROR, "Unable to allocate memory for display buffer" ); + abort(); return FALSE; } @@ -1172,7 +1173,8 @@ init_ObjectDead( void * psObj ) break; default: - DBERROR( ("init_ObjectAnimRemoved: unrecognised object type") ); + debug( LOG_ERROR, "init_ObjectAnimRemoved: unrecognised object type" ); + abort(); } } @@ -1616,7 +1618,8 @@ BOOL stageTwoInitialise(void) if(!initMiscImds()) /* Set up the explosions */ { iV_ShutDown(); - DBERROR(("Can't find all the explosions PCX's")); + debug( LOG_ERROR, "Can't find all the explosions PCX's" ); + abort(); return FALSE; } diff --git a/src/intelmap.c b/src/intelmap.c index 8630afcb5..3bd7f6ba3 100644 --- a/src/intelmap.c +++ b/src/intelmap.c @@ -591,7 +591,7 @@ BOOL intAddMessageView(MESSAGE * psMessage) RESEARCH *psResearch; /* ASSERT((psMessage->type == MSG_RESEARCH, - * "intAddMessageView: invalid message type")); + * "intAddMessageView: invalid message type")); * had to comment out this check, since the 'Fast Play' tutorial triggered it * with psMessage->type=MSG_MISSION and ((VIEWDATA)*psMessage->pViewData)->type=VIEW_RPL, * but which is probably using the wrong function. - Per @@ -1018,7 +1018,7 @@ void StartMessageSequences(MESSAGE *psMessage, BOOL Start) // sprintf(String,"seqadded %d of %d [%s]\n",Sequence,psViewReplay->numSeq,psViewReplay->pSeqList[Sequence].sequenceName); // prnt(1,String,0,0); // } - DBPRINTF(("sequence=%d\n",Sequence)); + debug( LOG_NEVER, "sequence=%d\n", Sequence ); addVideoText(&psViewReplay->pSeqList[Sequence],Sequence); } //play first full screen video @@ -1667,7 +1667,7 @@ void addVideoText(SEQ_DISPLAY *psSeqDisplay, UDWORD sequence) if (psSeqDisplay->numText > 0) { - DBPRINTF(("avt seq=%d [%s]\n",sequence,psSeqDisplay->ppTextMsg[0])); + debug( LOG_NEVER, "avt seq=%d [%s]\n", sequence, psSeqDisplay->ppTextMsg[0] ); //add each message, first at the top x = VIDEO_TEXT_TOP_X; y = VIDEO_TEXT_TOP_Y; diff --git a/src/keyedit.c b/src/keyedit.c index 37593f149..811b2af69 100644 --- a/src/keyedit.c +++ b/src/keyedit.c @@ -539,7 +539,8 @@ BOOL saveKeyMap(void) count++); if(keyMapSaveTable[count] == NULL) { - DBERROR(("can't find keymapped function in the keymap save table!!")); + debug( LOG_ERROR, "can't find keymapped function in the keymap save table!!" ); + abort(); } WRITE(&count, sizeof(count)); } diff --git a/src/keymap.c b/src/keymap.c index 7cf25b2c4..415164885 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -390,7 +390,7 @@ void keyInitMappings( BOOL bForceDefaults ) keyAddMapping(KEYMAP_ALWAYS,KEY_IGNORE,KEY_Z,KEYMAP_PRESSED,kf_SensorDisplayOn, "Sensor display On"); keyAddMapping(KEYMAP_ALWAYS,KEY_IGNORE,KEY_Z,KEYMAP_RELEASED,kf_SensorDisplayOff, "Sensor display Off"); keyAddMapping(KEYMAP_ASSIGNABLE,KEY_LALT,KEY_S,KEYMAP_PRESSED,kf_ToggleShadows, "Toggles shadows"); - keyAddMapping(KEYMAP_ASSIGNABLE,KEY_LCTRL,KEY_TAB,KEYMAP_PRESSED,kf_ToggleRadarTerrain, "Toggle radar terrain"); + keyAddMapping(KEYMAP_ASSIGNABLE,KEY_LCTRL,KEY_TAB,KEYMAP_PRESSED,kf_ToggleRadarTerrain, "Toggle radar terrain"); keyAddMapping(KEYMAP_ASSIGNABLE,KEY_LSHIFT,KEY_TAB,KEYMAP_PRESSED,kf_ToggleRadarAllyEnemy, "Toggle ally-enemy radar view"); // Some extra non QWERTY mappings but functioning in same way @@ -749,7 +749,8 @@ BOOL bKeyProcessed; break; default: - DBERROR(("Weirdy action on keymap processing")); + debug( LOG_ERROR, "Weirdy action on keymap processing" ); + abort(); break; } } diff --git a/src/level_lexer.l b/src/level_lexer.l index 25678e06f..cccc840d1 100644 --- a/src/level_lexer.l +++ b/src/level_lexer.l @@ -128,7 +128,8 @@ int lev_wrap(void) { if (inComment) { - DBERROR(("Warning: reched end of file in a comment")); + debug( LOG_ERROR, "Warning: reched end of file in a comment" ); + abort(); } return 1; } diff --git a/src/levels.c b/src/levels.c index 3a6fdf2b3..f99e8aeb0 100644 --- a/src/levels.c +++ b/src/levels.c @@ -577,7 +577,8 @@ BOOL levLoadBaseData(STRING *pName) // find the level dataset if (!levFindDataSet(pName, &psNewLevel)) { - DBERROR(("levLoadBaseData: couldn't find level data")); + debug( LOG_ERROR, "levLoadBaseData: couldn't find level data" ); + abort(); return FALSE; } @@ -589,7 +590,8 @@ BOOL levLoadBaseData(STRING *pName) psNewLevel->type != LDS_MKEEP_LIMBO ) { - DBERROR(("levLoadBaseData: incorect level type")); + debug( LOG_ERROR, "levLoadBaseData: incorect level type" ); + abort(); return FALSE; } @@ -652,7 +654,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) // find the level dataset if (!levFindDataSet(pName, &psNewLevel)) { - DBMB(("levLoadData: dataset %s not found - trying to load as WRF", pName)); + debug( LOG_NEVER, "levLoadData: dataset %s not found - trying to load as WRF", pName ); return levLoadSingleWRF(pName); } @@ -704,14 +706,14 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) #ifdef DEBUG_GROUP0 if (psNewLevel->psBaseData != NULL) { - DBP0(("levLoadData: Setting base dataset to load: %s\n", psNewLevel->psBaseData->pName)); + debug( LOG_NEVER, "levLoadData: Setting base dataset to load: %s\n", psNewLevel->psBaseData->pName ); } #endif psBaseData = psNewLevel->psBaseData; } else { - DBP0(("levLoadData: No base dataset to load\n")); + debug( LOG_NEVER, "levLoadData: No base dataset to load\n" ); psBaseData = NULL; } } @@ -721,7 +723,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) // reset the old mission data if necessary if (psCurrLevel != NULL) { - DBP0(("levLoadData: reseting old mission data\n")); + debug( LOG_NEVER, "levLoadData: reseting old mission data\n" ); if (!gameReset()) { return FALSE; @@ -744,14 +746,14 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) // basic game data is loaded in the game heap - DBP0(("levLoadData: Setting game heap\n")); + debug( LOG_NEVER, "levLoadData: Setting game heap\n" ); memSetBlockHeap(psGameHeap); // initialise if necessary if (psNewLevel->type == LDS_COMPLETE || //psNewLevel->type >= MULTI_TYPE_START || psBaseData != NULL) { - DBP0(("levLoadData: reset game heap\n")); + debug( LOG_NEVER, "levLoadData: reset game heap\n" ); BLOCK_RESET(psGameHeap); if (!stageOneInitialise()) { @@ -762,7 +764,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) // load up a base dataset if necessary if (psBaseData != NULL) { - DBP0(("levLoadData: loading base dataset %s\n", psBaseData->pName)); + debug( LOG_NEVER, "levLoadData: loading base dataset %s\n", psBaseData->pName ); for(i=0; iapDataFiles[i]) @@ -789,7 +791,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) { ASSERT((psNewLevel->type == LDS_BETWEEN, "levLoadData: only BETWEEN missions do not need a .gam file")); - DBP0(("levLoadData: no .gam file for level: BETWEEN mission\n")); + debug( LOG_NEVER, "levLoadData: no .gam file for level: BETWEEN mission\n" ); if (pSaveName != NULL) { if (psBaseData != NULL) @@ -800,24 +802,24 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) } } - DBP0(("levLoadData: setting map heap\n")); + debug( LOG_NEVER, "levLoadData: setting map heap\n" ); BLOCK_RESET(psMapHeap); memSetBlockHeap(psMapHeap); //set the mission type before the saveGame data is loaded if (saveType == GTYPE_SAVE_MIDMISSION) { - DBP0(("levLoadData: init mission stuff\n")); + debug( LOG_NEVER, "levLoadData: init mission stuff\n" ); if (!startMissionSave(psNewLevel->type)) { return FALSE; } - DBP0(("levLoadData: dataSetSaveFlag\n")); + debug( LOG_NEVER, "levLoadData: dataSetSaveFlag\n" ); dataSetSaveFlag(); } - DBP0(("levLoadData: loading savegame: %s\n", pSaveName)); + debug( LOG_NEVER, "levLoadData: loading savegame: %s\n", pSaveName ); if (!loadGame(pSaveName, FALSE, TRUE,TRUE)) { return FALSE; @@ -832,14 +834,14 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) if ((pSaveName == NULL) || (saveType == GTYPE_SAVE_START)) { - DBP0(("levLoadData: start mission - no .gam\n")); + debug( LOG_NEVER, "levLoadData: start mission - no .gam\n" ); if (!startMission(psNewLevel->type, NULL)) { return FALSE; } } - DBP0(("levLoadData: setting mission heap\n")); + debug( LOG_NEVER, "levLoadData: setting mission heap\n" ); BLOCK_RESET(psMissionHeap); memSetBlockHeap(psMissionHeap); } @@ -847,7 +849,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) //we need to load up the save game data here for a camchange if (bCamChangeSaveGame) { - DBP0(("levLoadData: no .gam file for level: BETWEEN mission\n")); + debug( LOG_NEVER, "levLoadData: no .gam file for level: BETWEEN mission\n" ); if (pSaveName != NULL) { if (psBaseData != NULL) @@ -858,11 +860,11 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) } } - DBP0(("levLoadData: setting map heap\n")); + debug( LOG_NEVER, "levLoadData: setting map heap\n" ); BLOCK_RESET(psMapHeap); memSetBlockHeap(psMapHeap); - DBP0(("levLoadData: loading savegame: %s\n", pSaveName)); + debug( LOG_NEVER, "levLoadData: loading savegame: %s\n", pSaveName ); if (!loadGame(pSaveName, FALSE, TRUE,TRUE)) { return FALSE; @@ -884,7 +886,7 @@ BOOL levLoadData(STRING *pName, STRING *pSaveName, SDWORD saveType) // load the new data - DBP0(("levLoadData: loading mission dataset: %s\n", psNewLevel->pName)); + debug( LOG_NEVER, "levLoadData: loading mission dataset: %s\n", psNewLevel->pName ); psCurrHeap = memGetBlockHeap(); for(i=0; itype)) { return FALSE; } - DBP0(("levLoadData: dataSetSaveFlag\n")); + debug( LOG_NEVER, "levLoadData: dataSetSaveFlag\n" ); dataSetSaveFlag(); } - DBP0(("levLoadData: loading save game %s\n", pSaveName)); + debug( LOG_NEVER, "levLoadData: loading save game %s\n", pSaveName ); if (!loadGame(pSaveName, FALSE, TRUE,TRUE)) { return FALSE; @@ -1022,7 +1024,7 @@ iV_Reset(FALSE);//unload font, to avoid crash on 8th load... ajl 15/sep/99 break; case LDS_MKEEP_LIMBO: debug(LOG_WZ, "levLoadData: LDS_MKEEP_LIMBO"); - DBPRINTF(("MKEEP_LIMBO\n")); + debug( LOG_NEVER, "MKEEP_LIMBO\n" ); //if (!startMission(MISSION_OFFKEEP, psNewLevel->apDataFiles[i])) if (!startMission(LDS_MKEEP_LIMBO, psNewLevel->apDataFiles[i])) { @@ -1058,7 +1060,7 @@ iV_Reset(FALSE);//unload font, to avoid crash on 8th load... ajl 15/sep/99 // set the mission heap now if it isn't already being used if (memGetBlockHeap() != psMissionHeap) { - DBP0(("levLoadData: setting mission heap\n")); + debug( LOG_NEVER, "levLoadData: setting mission heap\n" ); BLOCK_RESET(psMissionHeap); memSetBlockHeap(psMissionHeap); } @@ -1082,7 +1084,7 @@ iV_Reset(FALSE);//unload font, to avoid crash on 8th load... ajl 15/sep/99 // set the mission heap now if it isn't already being used if (memGetBlockHeap() != psMissionHeap) { - DBP0(("levLoadData: setting mission heap\n")); + debug( LOG_NEVER, "levLoadData: setting mission heap\n" ); BLOCK_RESET(psMissionHeap); memSetBlockHeap(psMissionHeap); psCurrHeap = psMissionHeap; @@ -1103,7 +1105,7 @@ iV_Reset(FALSE);//unload font, to avoid crash on 8th load... ajl 15/sep/99 { //load script stuff // load the event system state here for a save game - DBP0(("levLoadData: loading script system state\n")); + debug( LOG_NEVER, "levLoadData: loading script system state\n" ); if (!loadScriptState(pSaveName)) { return FALSE; diff --git a/src/loop.c b/src/loop.c index d4710d86e..9f93b1e19 100644 --- a/src/loop.c +++ b/src/loop.c @@ -560,7 +560,7 @@ GAMECODE gameLoop(void) { if(strlen(sRequestResult)) { - DBPRINTF(("Returned %s",sRequestResult)); + debug( LOG_NEVER, "Returned %s", sRequestResult ); if(bRequestLoad) { loopMissionState = LMS_LOADGAME; diff --git a/src/main.c b/src/main.c index 3417fe0d1..09b8fe97e 100644 --- a/src/main.c +++ b/src/main.c @@ -467,12 +467,14 @@ init://jump here from the end if re_initialising psPaletteBuffer = (iColour*)MALLOC(256 * sizeof(iColour)+1); if (psPaletteBuffer == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return -1; } if (!loadFileToBuffer("palette.bin", (char *)psPaletteBuffer, (256 * sizeof(iColour)+1),&pSize)) { - DBERROR(("Couldn't load palette data")); + debug( LOG_ERROR, "Couldn't load palette data" ); + abort(); return -1; } pal_AddNewPalette(psPaletteBuffer); @@ -543,13 +545,13 @@ init://jump here from the end if re_initialising //after data is loaded check the research stats are valid if (!checkResearchStats()) { - DBERROR(("Invalid Research Stats")); + debug( LOG_ERROR, "Invalid Research Stats" ); goto exit; } //and check the structure stats are valid if (!checkStructureStats()) { - DBERROR(("Invalid Structure Stats")); + debug( LOG_ERROR, "Invalid Structure Stats" ); goto exit; } @@ -558,7 +560,8 @@ init://jump here from the end if re_initialising screen_StopBackDrop(); break; case GS_VIDEO_MODE: - DBERROR(("Video_mode no longer valid")); + debug( LOG_ERROR, "Video_mode no longer valid" ); + abort(); if (introVideoControl == 0) { videoInitialised = TRUE; @@ -566,7 +569,7 @@ init://jump here from the end if re_initialising break; default: - debug(LOG_ERROR, "Unknown game status on shutdown!"); + debug( LOG_ERROR, "Unknown game status on shutdown!" ); } @@ -850,6 +853,7 @@ exit: pal_ShutDown(); frameShutDown(); + debug_exit(); return 1; } diff --git a/src/map.c b/src/map.c index a2bd85731..8588ae9d5 100644 --- a/src/map.c +++ b/src/map.c @@ -223,7 +223,8 @@ BOOL mapNew(UDWORD width, UDWORD height) // if (width > MAP_MAXWIDTH || height > MAP_MAXHEIGHT) if (width*height > MAP_MAXAREA) { - DBERROR(("mapNew: map too large : %d %d\n",width,height)); + debug( LOG_ERROR, "mapNew: map too large : %d %d\n", width, height ); + abort(); return FALSE; } @@ -252,7 +253,8 @@ BOOL mapNew(UDWORD width, UDWORD height) psMapTiles = (MAPTILE *)MALLOC(sizeof(MAPTILE) * width*height); if (psMapTiles == NULL) { - DBERROR(("mapNew: Out of memory")); + debug( LOG_ERROR, "mapNew: Out of memory" ); + abort(); return FALSE; } memset(psMapTiles, 0, sizeof(MAPTILE) * width*height); @@ -347,7 +349,8 @@ BOOL mapLoadV1(char *pFileData, UDWORD fileSize) } if ((char *)psTileData - pFileData > fileSize) { - DBERROR(("mapLoad: unexpected end of file")); + debug( LOG_ERROR, "mapLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -393,7 +396,8 @@ BOOL mapLoadV2(char *pFileData, UDWORD fileSize) if ((char *)psTileData - pFileData > fileSize) { - DBERROR(("mapLoad: unexpected end of file")); + debug( LOG_ERROR, "mapLoad: unexpected end of file" ); + abort(); return FALSE; } @@ -456,7 +460,8 @@ BOOL mapLoadV3(char *pFileData, UDWORD fileSize) for(i=0; inumGateways; i++) { if (!gwNewGateway(psGate->x0,psGate->y0, psGate->x1,psGate->y1)) { - DBERROR(("mapLoadV3: Unable to add gateway")); + debug( LOG_ERROR, "mapLoadV3: Unable to add gateway" ); + abort(); return FALSE; } psGate++; @@ -521,14 +526,16 @@ BOOL mapLoadV3(char *pFileData, UDWORD fileSize) if(psZoneHeader->numEquivZones > 0) { // Load in the zone equivelance lists. if(!gwNewEquivTable(psZoneHeader->numEquivZones)) { - DBERROR(("gwNewEquivTable failed")); + debug( LOG_ERROR, "gwNewEquivTable failed" ); + abort(); return FALSE; } for(i=0; inumEquivZones; i++) { if(*pZone != 0) { if(!gwSetZoneEquiv(i, (SDWORD)*pZone, pZone+1)) { - DBERROR(("gwSetZoneEquiv failed")); + debug( LOG_ERROR, "gwSetZoneEquiv failed" ); + abort(); return FALSE; } } @@ -539,7 +546,8 @@ BOOL mapLoadV3(char *pFileData, UDWORD fileSize) if ((char *)pZone - pFileData > fileSize) { - DBERROR(("mapLoadV3: unexpected end of file")); + debug( LOG_ERROR, "mapLoadV3: unexpected end of file" ); + abort(); return FALSE; } //#endif @@ -587,7 +595,8 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize) if (psHeader->aFileType[0] != 'm' || psHeader->aFileType[1] != 'a' || psHeader->aFileType[2] != 'p' || psHeader->aFileType[3] != ' ') { - DBERROR(("mapLoad: Incorrect file type")); + debug( LOG_ERROR, "mapLoad: Incorrect file type" ); + abort(); FREE(pFileData); return FALSE; } @@ -601,7 +610,8 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize) /* Check the file version */ if (psHeader->version < VERSION_7) { - DBERROR(("MapLoad: unsupported save format version %d",psHeader->version)); + debug( LOG_ERROR, "MapLoad: unsupported save format version %d", psHeader->version ); + abort(); FREE(pFileData); return FALSE; } @@ -615,7 +625,8 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize) } else { - DBERROR(("MapLoad: undefined save format version %d",psHeader->version)); + debug( LOG_ERROR, "MapLoad: undefined save format version %d", psHeader->version ); + abort(); FREE(pFileData); return FALSE; } @@ -627,7 +638,8 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize) // if (width > MAP_MAXWIDTH || height > MAP_MAXHEIGHT) if (width*height > MAP_MAXAREA) { - DBERROR(("mapLoad: map too large : %d %d\n",width,height)); + debug( LOG_ERROR, "mapLoad: map too large : %d %d\n", width, height ); + abort(); return FALSE; } @@ -683,7 +695,8 @@ BOOL mapLoad(char *pFileData, UDWORD fileSize) psMapTiles = (MAPTILE *)MALLOC(sizeof(MAPTILE) * width*height); if (psMapTiles == NULL) { - DBERROR(("mapLoad: Out of memory")); + debug( LOG_ERROR, "mapLoad: Out of memory" ); + abort(); return FALSE; } memset(psMapTiles, 0, sizeof(MAPTILE) * width*height); @@ -783,7 +796,8 @@ BOOL mapSave(char **ppFileData, UDWORD *pFileSize) *ppFileData = MALLOC(*pFileSize); if (*ppFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -921,7 +935,8 @@ BOOL mapSaveMission(char **ppFileData, UDWORD *pFileSize) *ppFileData = MALLOC(*pFileSize); if (*ppFileData == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -1607,7 +1622,8 @@ BOOL writeVisibilityData( STRING *pFileName ) if(!pFileData) { /* Nope, so do one */ - DBERROR(("Saving visibility data : Cannot get the memory! (%d)",fileSize)); + debug( LOG_ERROR, "Saving visibility data : Cannot get the memory! (%d)", fileSize ); + abort(); return(FALSE); } @@ -1677,8 +1693,8 @@ UBYTE *pVisData; if(fileSize!=expectedFileSize) { /* No, so bomb out */ - DBERROR(("Read visibility data : Weird file size for %d by %d sized map?", - mapWidth,mapHeight)); + debug( LOG_ERROR, "Read visibility data : Weird file size for %d by %d sized map?", mapWidth, mapHeight ); + abort(); return(FALSE); } diff --git a/src/mapgrid.c b/src/mapgrid.c index 0f2d4bce2..464e58939 100644 --- a/src/mapgrid.c +++ b/src/mapgrid.c @@ -80,7 +80,7 @@ void gridClear(void) GRID_ARRAY *psCurr, *psNext; SDWORD x,y; - DBPRINTF(("gridClear %d %d\n",gridWidth,gridHeight)); + debug( LOG_NEVER, "gridClear %d %d\n", gridWidth, gridHeight ); // for(x=0; xid)); + debug( LOG_NEVER, "help - %d\n", psObj->id ); return; } @@ -522,8 +522,7 @@ void gridDisplayCoverage(BASE_OBJECT *psObj) SDWORD x,y, i; GRID_ARRAY *psCurr; - DBPRINTF(("Grid coverage for object %d (%d,%d) - range %d\n", - psObj->id, psObj->x,psObj->y, gridObjRange(psObj))); + debug( LOG_NEVER, "Grid coverage for object %d (%d,%d) - range %d\n", psObj->id, psObj->x, psObj->y, gridObjRange(psObj) ); // for (x=0; xapsObjects[i] == psObj) { - DBPRINTF((" %d,%d [ %d,%d -> %d,%d ]\n", - x,y, x*GRID_UNITS,y*GRID_UNITS, - (x+1)*GRID_UNITS,(y+1)*GRID_UNITS)); + debug( LOG_NEVER, " %d,%d [ %d,%d -> %d,%d ]\n", x, y, x*GRID_UNITS, y*GRID_UNITS, (x+1)*GRID_UNITS, (y+1)*GRID_UNITS ); } i += 1; diff --git a/src/mechanics.c b/src/mechanics.c index 1a4c25ca0..c675b97d3 100644 --- a/src/mechanics.c +++ b/src/mechanics.c @@ -168,7 +168,8 @@ BOOL allocComponentList(COMPONENT_TYPE type, SDWORD number) apCompLists[inc][type] = (UBYTE *) MALLOC(sizeof(UBYTE) * number); if (apCompLists[inc][type] == NULL) { - DBERROR(("Out of memory assigning Player Component Lists")); + debug( LOG_ERROR, "Out of memory assigning Player Component Lists" ); + abort(); return FALSE; } @@ -215,7 +216,8 @@ BOOL allocStructLists(void) numStructureStats); if (apStructTypeLists[inc] == NULL) { - DBERROR(("Out of memory assigning Player Structure Lists")); + debug( LOG_ERROR, "Out of memory assigning Player Structure Lists" ); + abort(); return FALSE; } for (stat = 0; stat < (SDWORD)numStructureStats; stat++) diff --git a/src/message.c b/src/message.c index da4acfc6c..96b743bba 100644 --- a/src/message.c +++ b/src/message.c @@ -463,7 +463,8 @@ BOOL initMessage(void) pProximityMsgIMD = (iIMDShape *)resGetData("IMD", "arrow.pie"); if (pProximityMsgIMD == NULL) { - DBERROR(("Unable to load Proximity Message PIE")); + debug( LOG_ERROR, "Unable to load Proximity Message PIE" ); + abort(); return FALSE; } @@ -540,7 +541,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) numData = numCR(pViewMsgData, bufferSize); if (numData > UBYTE_MAX) { - DBERROR(("loadViewData: Didn't expect 256 viewData messages!")); + debug( LOG_ERROR, "loadViewData: Didn't expect 256 viewData messages!" ); + abort(); return NULL; } @@ -548,7 +550,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewData = (VIEWDATA *)MALLOC(numData * sizeof(VIEWDATA)); if (psViewData == NULL) { - DBERROR(("Unable to allocate memory for viewdata")); + debug( LOG_ERROR, "Unable to allocate memory for viewdata" ); + abort(); return NULL; } @@ -574,7 +577,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) //check not loading up too many text strings if (numText > MAX_DATA) { - DBERROR(("loadViewData: too many text strings for %s", psViewData->pName)); + debug( LOG_ERROR, "loadViewData: too many text strings for %s", psViewData->pName ); + abort(); return NULL; } psViewData->numText=(UBYTE)numText; @@ -583,7 +587,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewData->pName = (STRING *)MALLOC((strlen(name))+1); if (psViewData->pName == NULL) { - DBERROR(("ViewData Name - Out of memory")); + debug( LOG_ERROR, "ViewData Name - Out of memory" ); + abort(); return NULL; } strcpy(psViewData->pName,name); @@ -607,7 +612,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) //get the ID for the string if (!strresGetIDNum(psStringRes, name, &id)) { - DBERROR(("Cannot find the view data string id %s ", name)); + debug( LOG_ERROR, "Cannot find the view data string id %s ", name ); + abort(); return NULL; } //get the string from the id @@ -626,7 +632,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewData->pData = (VIEW_RESEARCH *) MALLOC(sizeof(VIEW_RESEARCH)); if (psViewData->pData == NULL) { - DBERROR(("Unable to allocate memory")); + debug( LOG_ERROR, "Unable to allocate memory" ); + abort(); return NULL; } imdName[0] = '\0'; @@ -642,7 +649,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewRes->pIMD = (iIMDShape *) resGetData("IMD", imdName); if (psViewRes->pIMD == NULL) { - DBERROR(("Cannot find the PIE for message %s", name)); + debug( LOG_ERROR, "Cannot find the PIE for message %s", name ); + abort(); return NULL; } if (strcmp(imdName2, "0")) @@ -650,7 +658,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewRes->pIMD2 = (iIMDShape *) resGetData("IMD", imdName2); if (psViewRes->pIMD2 == NULL) { - DBERROR(("Cannot find the 2nd PIE for message %s", name)); + debug( LOG_ERROR, "Cannot find the 2nd PIE for message %s", name ); + abort(); return NULL; } } @@ -666,7 +675,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewRes->pAudio = (STRING *) MALLOC(strlen(audioName) + 1); if (psViewRes->pAudio == NULL) { - DBERROR(("loadViewData - Out of memory")); + debug( LOG_ERROR, "loadViewData - Out of memory" ); + abort(); return NULL; } strcpy(psViewRes->pAudio, audioName); @@ -685,7 +695,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewData->pData = (VIEW_REPLAY *) MALLOC(sizeof(VIEW_REPLAY)); if (psViewData->pData == NULL) { - DBERROR(("Unable to allocate memory")); + debug( LOG_ERROR, "Unable to allocate memory" ); + abort(); return NULL; } psViewReplay = (VIEW_REPLAY *)psViewData->pData; @@ -697,7 +708,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) if (count > MAX_DATA) { - DBERROR(("loadViewData: too many sequence for %s", psViewData->pName)); + debug( LOG_ERROR, "loadViewData: too many sequence for %s", psViewData->pName ); + abort(); return NULL; } @@ -718,7 +730,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) pViewMsgData += cnt; if (count > MAX_DATA) { - DBERROR(("loadViewData: too many strings for %s", psViewData->pName)); + debug( LOG_ERROR, "loadViewData: too many strings for %s", psViewData->pName ); + abort(); return NULL; } psViewReplay->pSeqList[dataInc].numText = (UBYTE)count; @@ -731,16 +744,16 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) pViewMsgData += cnt; if (count > MAX_DATA) { - DBERROR(("loadViewData: invalid video playback flag %s", - psViewData->pName)); + debug( LOG_ERROR, "loadViewData: invalid video playback flag %s", psViewData->pName ); + abort(); return NULL; } psViewReplay->pSeqList[dataInc].flag = (UBYTE)count; //check not loading up too many text strings if (count2 > MAX_DATA) { - DBERROR(("loadViewData: too many text strings for seq for %s", - psViewData->pName)); + debug( LOG_ERROR, "loadViewData: too many text strings for seq for %s", psViewData->pName ); + abort(); return NULL; } psViewReplay->pSeqList[dataInc].numText = (UBYTE)count2; @@ -764,7 +777,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) //get the ID for the string if (!strresGetIDNum(psStringRes, name, &id)) { - DBERROR(("Cannot find the view data string id %s ", name)); + debug( LOG_ERROR, "Cannot find the view data string id %s ", name ); + abort(); return NULL; } @@ -790,7 +804,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) strlen(audioName) + 1); if (psViewReplay->pSeqList[dataInc].pAudio == NULL) { - DBERROR(("loadViewData - Out of memory")); + debug( LOG_ERROR, "loadViewData - Out of memory" ); + abort(); return NULL; } strcpy(psViewReplay->pSeqList[dataInc].pAudio, audioName); @@ -807,7 +822,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) psViewData->pData = (VIEW_PROXIMITY *) MALLOC(sizeof(VIEW_PROXIMITY)); if (psViewData->pData == NULL) { - DBERROR(("Unable to allocate memory")); + debug( LOG_ERROR, "Unable to allocate memory" ); + abort(); return NULL; } @@ -826,16 +842,16 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) { if ( audioID_GetIDFromStr( audioName, &audioID ) == FALSE ) { - DBERROR(("loadViewData: couldn't get ID %d for weapon sound %s", - audioID, audioName)); + debug( LOG_ERROR, "loadViewData: couldn't get ID %d for weapon sound %s", audioID, audioName ); + abort(); return FALSE; } if ( ((audioID < 0) || (audioID >= ID_MAX_SOUND)) && (audioID != NO_SOUND) ) { - DBERROR(("Invalid Weapon Sound ID - %d for weapon %s", - audioID, audioName)); + debug( LOG_ERROR, "Invalid Weapon Sound ID - %d for weapon %s", audioID, audioName ); + abort(); return FALSE; } } @@ -874,7 +890,8 @@ VIEWDATA *loadViewData(char *pViewMsgData, UDWORD bufferSize) ((VIEW_PROXIMITY *)psViewData->pData)->proxType = proxType; break; default: - DBERROR(("Unknown ViewData type")); + debug( LOG_ERROR, "Unknown ViewData type" ); + abort(); return NULL; } //increment the pointer to the start of the next record @@ -911,7 +928,8 @@ VIEWDATA * getViewData(STRING *pName) } } - DBERROR(("Unable to find viewdata for message %s", pName)); + debug( LOG_ERROR, "Unable to find viewdata for message %s", pName ); + abort(); return NULL; } diff --git a/src/miscimd.c b/src/miscimd.c index 6145e683f..2db80ca19 100644 --- a/src/miscimd.c +++ b/src/miscimd.c @@ -83,8 +83,8 @@ char name[15]; // hopefully! if(!miscImds[i].pImd) { /* Say which one and return FALSE */ - DBERROR(("Can't find misselaneous PIE file : %s",miscImds[i].pName)); - ASSERT((0,"NULL PIE")); + debug( LOG_ERROR, "Can't find misselaneous PIE file : %s", miscImds[i].pName ); + ASSERT((FALSE,"NULL PIE")); return(FALSE); } /* If the next one's the end one, then get out now. @@ -157,7 +157,8 @@ BOOL initMiscImds( void ) pAssemblyPointIMDs[FACTORY_FLAG][i] = resGetData("IMD", facName); if (!pAssemblyPointIMDs[FACTORY_FLAG][i]) { - DBERROR(("Can't find assembly point graphic for factory")); + debug( LOG_ERROR, "Can't find assembly point graphic for factory" ); + abort(); return(FALSE); } //#ifndef PSX @@ -165,20 +166,23 @@ BOOL initMiscImds( void ) pAssemblyPointIMDs[CYBORG_FLAG][i] = resGetData("IMD", cybName); if (!pAssemblyPointIMDs[CYBORG_FLAG][i]) { - DBERROR(("Can't find assembly point graphic for cyborg factory")); + debug( LOG_ERROR, "Can't find assembly point graphic for cyborg factory" ); + abort(); return(FALSE); } vtolName[6] = *pieNum; pAssemblyPointIMDs[VTOL_FLAG][i] = resGetData("IMD", vtolName); if (!pAssemblyPointIMDs[VTOL_FLAG][i]) { - DBERROR(("Can't find assembly point graphic for vtol factory")); + debug( LOG_ERROR, "Can't find assembly point graphic for vtol factory" ); + abort(); return(FALSE); } pAssemblyPointIMDs[REPAIR_FLAG][i] = resGetData("IMD", "mirnum1.pie"); if (!pAssemblyPointIMDs[REPAIR_FLAG][i]) { - DBERROR(("Can't find assembly point graphic for repair facility")); + debug( LOG_ERROR, "Can't find assembly point graphic for repair facility" ); + abort(); return(FALSE); } //#else diff --git a/src/mission.c b/src/mission.c index 18bf71cba..aaeceecbb 100644 --- a/src/mission.c +++ b/src/mission.c @@ -309,7 +309,7 @@ void initMission(void) { UDWORD inc; -DBPRINTF(("***Init Mission ***\n")); + debug( LOG_NEVER, "***Init Mission ***\n" ); //mission.type = MISSION_NONE; mission.type = LDS_NONE; for (inc = 0; inc < MAX_PLAYERS; inc++) @@ -518,7 +518,7 @@ BOOL startMission(LEVEL_TYPE missionType, STRING *pGame) { /*mission type gets set to none when you have returned from a mission so don't want to go another mission when already on one! - so ignore*/ - DBMB(("Already on a mission")); + debug( LOG_NEVER, "Already on a mission" ); return TRUE; } @@ -624,14 +624,16 @@ BOOL startMission(LEVEL_TYPE missionType, STRING *pGame) default: { //error! - DBERROR(("Unknown Mission Type")); + debug( LOG_ERROR, "Unknown Mission Type" ); + abort(); loaded = FALSE; } } if (!loaded) { - DBERROR(("Unable to load mission file")); + debug( LOG_ERROR, "Unable to load mission file" ); + abort(); return FALSE; } @@ -1870,7 +1872,7 @@ void endMission(void) if (mission.type == LDS_NONE) { //can't go back any further!! - DBMB(("Already returned from mission")); + debug( LOG_NEVER, "Already returned from mission" ); return; } @@ -1936,7 +1938,8 @@ void endMission(void) default: { //error! - DBERROR(("Unknown Mission Type")); + debug( LOG_ERROR, "Unknown Mission Type" ); + abort(); } } @@ -2558,7 +2561,7 @@ void missionResetDroids() TILE_UNITS) - TILE_UNITS || psDroid->y <= TILE_UNITS || psDroid->y >= (mapHeight * TILE_UNITS) - TILE_UNITS) { - DBMB(("missionResetUnits: unit too close to edge of map - removing")); + debug( LOG_NEVER, "missionResetUnits: unit too close to edge of map - removing" ); vanishDroid(psDroid); continue; } @@ -2798,7 +2801,7 @@ void missionMoveTransporterOffWorld( DROID *psTransporter ) } else { - DBPRINTF( ("missionMoveTransporterOffWorld: droid type not transporter!\n") ); + debug( LOG_NEVER, "missionMoveTransporterOffWorld: droid type not transporter!\n" ); } } @@ -3545,15 +3548,13 @@ void intRunMissionResult() pie_SetMouse(IntImages,IMAGE_CURSOR_DEFAULT); frameSetCursorFromRes(IDC_DEFAULT); - - if(bLoadSaveUp) { if(runLoadSave(FALSE))// check for file name. { if(strlen(sRequestResult)) { - DBPRINTF(("Returned %s",sRequestResult)); + debug( LOG_NEVER, "Returned %s", sRequestResult ); if(bRequestLoad) { @@ -3711,7 +3712,7 @@ void launchMission(void) } else { - DBMB(("Start Mission has not been called")); + debug( LOG_NEVER, "Start Mission has not been called" ); } } @@ -4092,8 +4093,7 @@ void missionSetTransporterEntry( SDWORD iPlayer, SDWORD iEntryTileX, SDWORD iEnt } else { - DBPRINTF( ("missionSetTransporterEntry: entry point x %i outside scroll limits %i->%i\n", - iEntryTileX, scrollMinX, scrollMaxX ) ); + debug( LOG_NEVER, "missionSetTransporterEntry: entry point x %i outside scroll limits %i->%i\n", iEntryTileX, scrollMinX, scrollMaxX ); mission.iTranspEntryTileX[iPlayer] = (UWORD) (scrollMinX + EDGE_SIZE); } @@ -4103,8 +4103,7 @@ void missionSetTransporterEntry( SDWORD iPlayer, SDWORD iEntryTileX, SDWORD iEnt } else { - DBPRINTF( ("missionSetTransporterEntry: entry point y %i outside scroll limits %i->%i\n", - iEntryTileY, scrollMinY, scrollMaxY ) ); + debug( LOG_NEVER, "missionSetTransporterEntry: entry point y %i outside scroll limits %i->%i\n", iEntryTileY, scrollMinY, scrollMaxY ); mission.iTranspEntryTileY[iPlayer] = (UWORD) (scrollMinY + EDGE_SIZE); } } @@ -4119,8 +4118,7 @@ void missionSetTransporterExit( SDWORD iPlayer, SDWORD iExitTileX, SDWORD iExitT } else { - DBPRINTF( ("missionSetTransporterExit: entry point x %i outside scroll limits %i->%i\n", - iExitTileX, scrollMinX, scrollMaxX ) ); + debug( LOG_NEVER, "missionSetTransporterExit: entry point x %i outside scroll limits %i->%i\n", iExitTileX, scrollMinX, scrollMaxX ); mission.iTranspExitTileX[iPlayer] = (UWORD) (scrollMinX + EDGE_SIZE); } @@ -4130,8 +4128,7 @@ void missionSetTransporterExit( SDWORD iPlayer, SDWORD iExitTileX, SDWORD iExitT } else { - DBPRINTF( ("missionSetTransporterExit: entry point y %i outside scroll limits %i->%i\n", - iExitTileY, scrollMinY, scrollMaxY ) ); + debug( LOG_NEVER, "missionSetTransporterExit: entry point y %i outside scroll limits %i->%i\n", iExitTileY, scrollMinY, scrollMaxY ); mission.iTranspExitTileY[iPlayer] = (UWORD) (scrollMinY + EDGE_SIZE); } } @@ -4183,7 +4180,7 @@ void missionDestroyObjects(void) STRUCTURE *psStruct; UBYTE Player; - DBPRINTF(("missionDestroyObjects\n")); + debug( LOG_NEVER, "missionDestroyObjects\n" ); for(Player = 0; Player < MAX_PLAYERS; Player++) { if(Player != selectedPlayer) { diff --git a/src/move.c b/src/move.c index 384445e4f..7227b5c8e 100644 --- a/src/move.c +++ b/src/move.c @@ -28,7 +28,7 @@ BOOL moveDoMessage; #undef DBP6 #define DBP6( x ) \ if (moveDoMessage) \ - DBPRINTF( x ) + debug( LOG_NEVER, x ) #endif @@ -3514,7 +3514,7 @@ void moveUpdateDroidPos( DROID *psDroid, FRACT dx, FRACT dy ) else { /* dreadful last-ditch crash-avoiding hack - sort this! - GJ */ - DBPRINTF( ("**** droid about to go off map - fixed ****\n") ); + debug( LOG_NEVER, "**** droid about to go off map - fixed ****\n" ); destroyDroid( psDroid ); } } @@ -3754,7 +3754,7 @@ void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, SDWORD direction) { // Only add the animation if the droid is on screen, saves memory and time. if(clipXY(psDroid->x,psDroid->y)) { -DBPRINTF(("Added person run anim\n")); + debug( LOG_NEVER, "Added person run anim\n" ); psDroid->psCurAnim = animObj_Add( (BASE_OBJECT *) psDroid, ID_ANIM_DROIDRUN, 0, 0 ); } @@ -3764,7 +3764,7 @@ DBPRINTF(("Added person run anim\n")); bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID ); ASSERT( (bRet == TRUE, "moveUpdatePersonModel : animObj_Remove failed") ); psDroid->psCurAnim = NULL; -DBPRINTF(("Removed person run anim\n")); + debug( LOG_NEVER, "Removed person run anim\n" ); } } } @@ -4029,7 +4029,7 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o { if ( animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->uwID ) == FALSE ) { - DBPRINTF( ("moveUpdateCyborgModel: couldn't remove walk anim\n") ); + debug( LOG_NEVER, "moveUpdateCyborgModel: couldn't remove walk anim\n" ); } psDroid->psCurAnim = NULL; } @@ -4126,7 +4126,7 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o psDroid->psCurAnim->uwID == ID_ANIM_CYBORG_PACK_RUN) && (animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->uwID ) == FALSE) ) { - DBPRINTF( ("moveUpdateCyborgModel: couldn't remove walk anim\n") ); + debug( LOG_NEVER, "moveUpdateCyborgModel: couldn't remove walk anim\n" ); } } @@ -4376,7 +4376,7 @@ if ( oldStatus != newStatus ) char szOldStatus[100], szNewStatus[100]; moveGetStatusStr( oldStatus, szOldStatus ); moveGetStatusStr( newStatus, szNewStatus ); - DBPRINTF( ("oldStatus = %s newStatus = %s\n", szOldStatus, szNewStatus) ); + debug( LOG_NEVER, "oldStatus = %s newStatus = %s\n", szOldStatus, szNewStatus ); } #endif @@ -4595,7 +4595,7 @@ void moveUpdateDroid(DROID *psDroid) if ( psDroid->droidType == DROID_TRANSPORTER ) { - DBPRINTF(("a) dir %g,%g (%g)\n",tx,ty,tangle)); + debug( LOG_NEVER, "a) dir %g,%g (%g)\n", tx, ty, tangle ); } moveSpeed = moveCalcDroidSpeed(psDroid); diff --git a/src/multibot.c b/src/multibot.c index e7c622773..87a4f740e 100644 --- a/src/multibot.c +++ b/src/multibot.c @@ -621,7 +621,7 @@ BOOL recvDroid(NETMSG * m) if(!pT) { NETlogEntry("Couldn't find template to build recvd droid. val = player",0,player ); - DBPRINTF(("Couldn't find template to build recvd droid" )); + debug( LOG_NEVER, "Couldn't find template to build recvd droid" ); sendRequestDroid(id); // request the droid instead. return FALSE; } @@ -1011,11 +1011,13 @@ static VOID ProcessDroidOrder(DROID *psDroid, DROID_ORDER order,UDWORD x, UDWO break; case OBJ_BULLET: // shouldn't be getting this! - DBERROR(("multibot: order specified destination as a bullet. what am i to do??")); + debug( LOG_ERROR, "multibot: order specified destination as a bullet. what am i to do??" ); + abort(); break; default: - DBERROR(("unknown object type")); + debug( LOG_ERROR, "unknown object type" ); + abort(); } if(!psObj) // failed to find it; @@ -1283,7 +1285,7 @@ BOOL sendRequestDroid(UDWORD droidId) NetAdd(msg,0,droidId); NetAdd(msg,4,player2dpid[selectedPlayer] ); - DBPRINTF(("multibot: unknown droid %d, requesting info\n", droidId)); + debug( LOG_NEVER, "multibot: unknown droid %d, requesting info\n", droidId ); msg.type = NET_REQUESTDROID; msg.size = sizeof(DPID)+sizeof(UDWORD); diff --git a/src/multigifts.c b/src/multigifts.c index 8d0a3a79d..319e87008 100644 --- a/src/multigifts.c +++ b/src/multigifts.c @@ -101,7 +101,8 @@ BOOL recvGift(NETMSG *pMsg) giftPower(from,to,FALSE); break; default: - DBERROR(("Unknown Gift recvd")); + debug( LOG_ERROR, "Unknown Gift recvd" ); + abort(); return FALSE; break; } @@ -154,7 +155,8 @@ BOOL sendGift(UDWORD type,UDWORD to) audio_QueueTrack(ID_POWER_TRANSMIT); break; default: - DBERROR(("Unknown Gift sent")); + debug( LOG_ERROR, "Unknown Gift sent" ); + abort(); return FALSE; break; } @@ -566,7 +568,8 @@ BOOL recvAlliance(NETMSG *pMsg,BOOL allowAudio) breakAlliance(from,to,FALSE,allowAudio); break; default: - DBERROR(("Unknown alliance state recvd.")); + debug( LOG_ERROR, "Unknown alliance state recvd." ); + abort(); break; } diff --git a/src/multiint.c b/src/multiint.c index 4239fc910..7aa0d19c5 100644 --- a/src/multiint.c +++ b/src/multiint.c @@ -219,11 +219,11 @@ void loadMapPreview(void) pFileData = DisplayBuffer; if (!loadFileToBuffer(aFileName, pFileData, displayBufferSize, &fileSize)) { - DBPRINTF(("loadgame: Fail5\n")); + debug( LOG_NEVER, "loadgame: Fail5\n" ); } if (!mapLoad(pFileData, fileSize)) { - DBPRINTF(("loadgame: Fail7\n")); + debug( LOG_NEVER, "loadgame: Fail7\n" ); return; } gwShutDown(); @@ -3031,7 +3031,7 @@ VOID runForceSelect(VOID) { if(strlen(sRequestResult)) { - DBPRINTF(("Returned %s",sRequestResult)); + debug( LOG_NEVER, "Returned %s", sRequestResult ); if(bRequestLoad) { loadForce(sRequestResult); @@ -3181,7 +3181,7 @@ BOOL startForceSelect(VOID) strcpy(dir,"multiplay/forces/default.for"); // start with default force. if(!loadForce(dir)) { - DBPRINTF(("Error Loading Force")); + debug( LOG_NEVER, "Error Loading Force" ); } addBackdrop(); diff --git a/src/multiopt.c b/src/multiopt.c index 02fe3df1d..a729a4e4d 100644 --- a/src/multiopt.c +++ b/src/multiopt.c @@ -163,7 +163,8 @@ void recvOptions(NETMSG *pMsg) { #ifndef DEBUG - DBERROR(("Host is running a different version of Warzone2100.")); + debug( LOG_ERROR, "Host is running a different version of Warzone2100." ); + abort(); #endif } if(ingame.numStructureLimits) // free old limits. @@ -181,7 +182,7 @@ void recvOptions(NETMSG *pMsg) NetGet(pMsg,pos,checkval); pos += sizeof(checkval); /* - // This was set to a fixed value in earlier versions of post-Pumpkin code. + // This was set to a fixed value in earlier versions of post-Pumpkin code. // Commenting out to avoid confusion. Should probably be removed. - Per if(checkval != NEThashVal(NetPlay.cryptKey[0])) { @@ -859,7 +860,8 @@ BOOL cleanMap(UDWORD player) case CAMP_WALLS: //everything. break; default: - DBERROR(("Unknown Campaign Style")); + debug( LOG_ERROR, "Unknown Campaign Style" ); + abort(); break; } diff --git a/src/multiplay.c b/src/multiplay.c index 7e7dd88fe..923acdcce 100644 --- a/src/multiplay.c +++ b/src/multiplay.c @@ -143,7 +143,7 @@ BOOL turnOffMultiMsg(BOOL bDoit) { if(bTemp == TRUE) { - DBPRINTF(("\nturnoffmultimsg: multiple calls to turn off msging. \n")); + debug( LOG_NEVER, "\nturnoffmultimsg: multiple calls to turn off msging.\n" ); } if(bMultiPlayer) { @@ -400,7 +400,7 @@ DROID_TEMPLATE *IdToTemplate(UDWORD tempId,UDWORD player) else { // REALLY DANGEROUS!!! ID's are NOT assumed to be unique for TEMPLATES. - DBPRINTF(("Really Dodgy Check performed for a template")); + debug( LOG_NEVER, "Really Dodgy Check performed for a template" ); for(i=0;ibody[8])); strcat(msg,NetPlay.players[sender].name); // name @@ -1346,7 +1346,9 @@ BOOL sendTemplate(DROID_TEMPLATE *pTempl) if(pTempl == NULL) { #ifdef DEBUG - DBERROR(("sendTemplate: TELL ALEXL NOW!!!THIS IS THE BUG THAT ISNT FIXED!!!")); + // FIXME sendTemplate: TELL ALEXL NOW!!!THIS IS THE BUG THAT ISNT FIXED!!! + debug( LOG_ERROR, "sendTemplate: TELL ALEXL NOW!!!THIS IS THE BUG THAT ISNT FIXED!!!" ); + abort(); #endif return TRUE; } @@ -1372,7 +1374,9 @@ BOOL recvTemplate(NETMSG * m) if(m->size < sizeof(DROID_TEMPLATE)) { #ifdef DEBUG - DBERROR(("recvTemplate: invalid template recvd. THIS IS THE BUG THAT ISNT FIXED!!!")); + // FIXME recvTemplate: invalid template recvd. THIS IS THE BUG THAT ISNT FIXED!!! + debug( LOG_ERROR, "recvTemplate: invalid template recvd. THIS IS THE BUG THAT ISNT FIXED!!!" ); + abort(); #endif return TRUE; } @@ -1747,7 +1751,7 @@ BOOL msgStackGetFrom(SDWORD *psVal) } *psVal = msgPlFrom[0]; - + return TRUE; } @@ -1760,7 +1764,7 @@ BOOL msgStackGetTo(SDWORD *psVal) } *psVal = msgPlTo[0]; - + return TRUE; } @@ -1773,7 +1777,7 @@ BOOL msgStackGetCallbackType(SDWORD *psVal) } *psVal = callbackType[0]; - + return TRUE; } @@ -1787,7 +1791,7 @@ BOOL msgStackGetXY(SDWORD *psValx, SDWORD *psValy) *psValx = locx[0]; *psValy = locy[0]; - + return TRUE; } @@ -1802,7 +1806,7 @@ BOOL msgStackGetMsg(STRING *psVal) strcpy(psVal, msgStr[0]); //*psVal = msgPlTo[msgStackPos]; - + return TRUE; } @@ -1914,6 +1918,6 @@ BOOL msgStackFireTop() if(!msgStackPop()) return FALSE; - + return TRUE; } diff --git a/src/multistat.c b/src/multistat.c index edfce223c..fde3f3506 100644 --- a/src/multistat.c +++ b/src/multistat.c @@ -275,7 +275,7 @@ VOID useTheForce(BOOL bAddTempl)//Luke { ASSERT((FALSE, "UseTheForce: Unable to find a free location")); } - DBPRINTF(("force droid dropping at :%d,%d\n",x,y)); + debug( LOG_NEVER, "force droid dropping at :%d,%d\n", x, y ); // copy template psTempl = NameToTemplate(Force.pMembers->pTempl->aName,selectedPlayer); @@ -382,7 +382,8 @@ BOOL saveForce(char *name,FORCE *pfForce) { if (fwrite(pT, sizeof(DROID_TEMPLATE), 1, pFileHandle) != 1) // template { - DBERROR(("Write failed for %s", fileName)); + debug( LOG_ERROR, "Write failed for %s", fileName ); + abort(); return FALSE; } fputc(10,pFileHandle); //seperator. @@ -393,7 +394,8 @@ BOOL saveForce(char *name,FORCE *pfForce) { if (fwrite(&(pMember->pTempl->ref) ,sizeof(pMember->pTempl->ref), 1, pFileHandle) != 1) { - DBERROR(("Write failed for %s", fileName)); // force type + debug( LOG_ERROR, "Write failed for %s", fileName ); // force type + abort(); return FALSE; } } @@ -466,14 +468,16 @@ BOOL loadForce(char *name) for(tcount;tcount!=0;tcount--) // get templates { psTempl = MALLOC(sizeof(DROID_TEMPLATE)); - if (psTempl == NULL) //!HEAP_ALLOC(psTemplateHeap, &psTempl)) + if (psTempl == NULL) // !HEAP_ALLOC(psTemplateHeap, &psTempl)) { - DBERROR(("Couldn't allocate template for %s", fileName)); + debug( LOG_ERROR, "Couldn't allocate template for %s", fileName ); + abort(); return FALSE; } if (fread(psTempl, sizeof(DROID_TEMPLATE), 1, pFileHandle) != 1) // read in a template. { - DBERROR(("read failed for %s", fileName)); + debug( LOG_ERROR, "read failed for %s", fileName ); + abort(); fclose(pFileHandle); return FALSE; } @@ -486,7 +490,8 @@ BOOL loadForce(char *name) { if (fread(&ref, sizeof(ref), 1, pFileHandle) != 1) // read in a template ref code. { - DBERROR(("read failed for %s", fileName)); + debug( LOG_ERROR, "read failed for %s", fileName ); + abort(); fclose(pFileHandle); return FALSE; } @@ -497,7 +502,8 @@ BOOL loadForce(char *name) if(!psTempl) { - DBERROR(("failed to load. invalid file.")); + debug( LOG_ERROR, "failed to load. invalid file." ); + abort(); fclose(pFileHandle); return FALSE; } diff --git a/src/multisync.c b/src/multisync.c index b3300cd3d..9f540e2e6 100644 --- a/src/multisync.c +++ b/src/multisync.c @@ -354,7 +354,7 @@ BOOL recvDroidCheck(NETMSG *m) if ( !(IdToDroid(ref,player,&pD)) ) // find the droid in question { NETlogEntry("Recvd Unknown droid info. val=player",0,player); - DBPRINTF(("Received Checking Info for an unknown (As yet) droid player:%d ref:%d\n",player,ref)); + debug( LOG_NEVER, "Received Checking Info for an unknown (As yet) droid player:%d ref:%d\n", player, ref ); return TRUE; //Recvd checking info for an unknown droid } diff --git a/src/player.c b/src/player.c index b5c7d35f4..36dc655a4 100644 --- a/src/player.c +++ b/src/player.c @@ -116,7 +116,8 @@ BOOL playerInitialise(void) asPlayerAI = (PLAYER_AI *)MALLOC(sizeof(PLAYER_AI) * MAX_PLAYERS); if (!asPlayerAI) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } memset(asPlayerAI, 0, sizeof(PLAYER_AI) * MAX_PLAYERS); diff --git a/src/power.c b/src/power.c index 08143ab65..4989dceb1 100644 --- a/src/power.c +++ b/src/power.c @@ -67,7 +67,8 @@ BOOL allocPlayerPower(void) asPower[player] = (PLAYER_POWER *) MALLOC (sizeof(PLAYER_POWER)); if (asPower[player] == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } } diff --git a/src/projectile.c b/src/projectile.c index 7f55eb4ca..f9ac5e287 100644 --- a/src/projectile.c +++ b/src/projectile.c @@ -648,7 +648,7 @@ proj_InFlightDirectFunc( PROJ_OBJECT *psObj ) if ( worldOnMap( iX, iY ) == FALSE ) { psObj->state = PROJ_IMPACT; - DBPRINTF( ("**** projectile off map - removed ****\n") ); + debug( LOG_NEVER, "**** projectile off map - removed ****\n" ); return; } else @@ -793,7 +793,7 @@ proj_InFlightIndirectFunc( PROJ_OBJECT *psObj ) if ( worldOnMap( iX, iY ) == FALSE ) { psObj->state = PROJ_IMPACT; - DBPRINTF( ("**** projectile off map - removed ****\n") ); + debug( LOG_NEVER, "**** projectile off map - removed ****\n" ); return; } else @@ -1301,7 +1301,7 @@ proj_ImpactFunc( PROJ_OBJECT *psObj ) if ( hashTable_RemoveElement( g_pProjObjTable, psObj, (int) psObj, UNUSED_KEY ) == FALSE ) { - DBPRINTF( ("proj_ImpactFunc: couldn't remove projectile from table\n") ); + debug( LOG_NEVER, "proj_ImpactFunc: couldn't remove projectile from table\n" ); } return; } @@ -1543,7 +1543,7 @@ proj_PostImpactFunc( PROJ_OBJECT *psObj ) if ( hashTable_RemoveElement( g_pProjObjTable, psObj, (int) psObj, UNUSED_KEY ) == FALSE ) { - DBPRINTF( ("proj_PostImpactFunc: couldn't remove projectile from table\n") ); + debug( LOG_NEVER, "proj_PostImpactFunc: couldn't remove projectile from table\n" ); } return; } @@ -1868,7 +1868,7 @@ UDWORD calcDamage(UDWORD baseDamage, WEAPON_EFFECT weaponEffect, BASE_OBJECT *ps damage1 = baseDamage * Mod / 100; - DBPRINTF(("damage1=%d damage=%d baseDamage=%d mod=%d (weaponEffect=%d proptype=%d) \n",damage1,damage,baseDamage,Mod,weaponEffect,PropType); + debug( LOG_NEVER, "damage1=%d damage=%d baseDamage=%d mod=%d (weaponEffect=%d proptype=%d) \n", damage1, damage, baseDamage, Mod, weaponEffect, PropType ); } #endif @@ -1935,7 +1935,8 @@ STRUCTURE *psStructure; return(TRUE); break; default: - DBERROR(("Weird object type in justBeenHitByEW")); + debug( LOG_ERROR, "Weird object type in justBeenHitByEW" ); + abort(); break; } diff --git a/src/research.c b/src/research.c index 5058295d6..638eff19c 100644 --- a/src/research.c +++ b/src/research.c @@ -152,7 +152,8 @@ BOOL researchInitVars(void) asResearch = (RESEARCH *)MALLOC(sizeof(RESEARCH)* MAX_RESEARCH); if (asResearch == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(asResearch, 0, (MAX_RESEARCH * sizeof(RESEARCH))); @@ -164,7 +165,8 @@ BOOL researchInitVars(void) sizeof(PLAYER_RESEARCH)); if (asPlayerResList[i] == NULL) { - DBERROR(("Out of memory assigning Player_Research")); + debug( LOG_ERROR, "Out of memory assigning Player_Research" ); + abort(); return FALSE; } memset(asPlayerResList[i], 0, (MAX_RESEARCH * sizeof(PLAYER_RESEARCH))); @@ -178,7 +180,8 @@ BOOL researchInitVars(void) //pResearchPR = (UBYTE *) MALLOC(sizeof(UBYTE) * MAX_RESEARCH_PR); if (pResearchPR == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } //needs to be UWORD sized for the Patches @@ -188,7 +191,8 @@ BOOL researchInitVars(void) pResearchStructPR = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_PR); if (pResearchStructPR == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchStructPR, 0, (MAX_RESEARCH_STRUCT_PR * sizeof(UWORD))); @@ -196,7 +200,8 @@ BOOL researchInitVars(void) pResearchFunc = (FUNCTION **) MALLOC(sizeof(FUNCTION *) * MAX_RESEARCH_FUNC); if (pResearchFunc == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchFunc, 0, (MAX_RESEARCH_FUNC * sizeof(FUNCTION *))); @@ -204,7 +209,8 @@ BOOL researchInitVars(void) pResearchStructRed = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RED); if (pResearchStructRed == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchStructRed, 0, (MAX_RESEARCH_STRUCT_RED * sizeof(UWORD))); @@ -212,7 +218,8 @@ BOOL researchInitVars(void) pResearchArteRed = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RED); if (pResearchArteRed == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchArteRed, 0, (MAX_RESEARCH_ARTE_RED * sizeof(COMP_BASE_STATS *))); @@ -220,7 +227,8 @@ BOOL researchInitVars(void) pResearchStructRes = (UWORD *) MALLOC(sizeof(UWORD) * MAX_RESEARCH_STRUCT_RES); if (pResearchStructRes == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchStructRes, 0, (MAX_RESEARCH_STRUCT_RES * sizeof(UWORD))); @@ -228,7 +236,8 @@ BOOL researchInitVars(void) pResearchArteRes = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES); if (pResearchArteRes == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchArteRes, 0, (MAX_RESEARCH_ARTE_RES * sizeof(COMP_BASE_STATS *))); @@ -236,7 +245,8 @@ BOOL researchInitVars(void) pResearchArteRep = (COMP_BASE_STATS **) MALLOC(sizeof(COMP_BASE_STATS *) * MAX_RESEARCH_ARTE_RES); if (pResearchArteRep == NULL) { - DBERROR(("Research Stats - Out of memory")); + debug( LOG_ERROR, "Research Stats - Out of memory" ); + abort(); return FALSE; } memset(pResearchArteRep, 0, (MAX_RESEARCH_ARTE_RES * sizeof(COMP_BASE_STATS *))); @@ -440,7 +450,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) if (techCode > 1) //if (pResearch->techCode != TC_MAJOR AND pResearch->techCode != TC_MINOR) { - DBERROR(("Invalid tech code for research topic - %s ", getResearchName(pResearch))); + debug( LOG_ERROR, "Invalid tech code for research topic - %s ", getResearchName(pResearch) ); + abort(); return FALSE; } if (techCode == 0) @@ -478,8 +489,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) } else { - DBERROR(("Cannot find the structure Stat for Research %s", - getResearchName(pResearch))); + debug( LOG_ERROR, "Cannot find the structure Stat for Research %s", getResearchName(pResearch) ); + abort(); return FALSE; } } @@ -493,8 +504,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) } else { - DBERROR(("Cannot find the component Stat for Research %s", - getResearchName(pResearch))); + debug( LOG_ERROR, "Cannot find the component Stat for Research %s", getResearchName(pResearch) ); + abort(); return FALSE; } } @@ -507,7 +518,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) pResearch->pIMD = (iIMDShape *) resGetData("IMD", imdName); if (pResearch->pIMD == NULL) { - DBERROR(("Cannot find the research PIE for record %s", getResearchName(pResearch))); + debug( LOG_ERROR, "Cannot find the research PIE for record %s", getResearchName(pResearch) ); + abort(); return FALSE; } } @@ -521,7 +533,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) pResearch->pIMD2 = (iIMDShape *) resGetData("IMD", imdName2); if (pResearch->pIMD2 == NULL) { - DBERROR(("Cannot find the 2nd research PIE for record %s", getResearchName(pResearch))); + debug( LOG_ERROR, "Cannot find the 2nd research PIE for record %s", getResearchName(pResearch) ); + abort(); return FALSE; } } @@ -536,7 +549,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) //check its a major tech code if (pResearch->techCode != TC_MAJOR) { - DBERROR(("This research should not have a message associated with it, %s the message will be ignored!", getResearchName(pResearch))); + debug( LOG_ERROR, "This research should not have a message associated with it, %s the message will be ignored!", getResearchName(pResearch) ); + abort(); } else { @@ -556,7 +570,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchArteRed >= MAX_RESEARCH_ARTE_RED) { - DBERROR(("Out of memory assigning research artefacts - redundancies")); + debug( LOG_ERROR, "Out of memory assigning research artefacts - redundancies" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -577,7 +592,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchArteRed >= MAX_RESEARCH_ARTE_RES) { - DBERROR(("Out of memory assigning research artefacts - results")); + debug( LOG_ERROR, "Out of memory assigning research artefacts - results" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -599,7 +615,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchArteRep >= MAX_RESEARCH_ARTE_RES) { - DBERROR(("Out of memory assigning research artefacts - replacements")); + debug( LOG_ERROR, "Out of memory assigning research artefacts - replacements" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -621,7 +638,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchFunc >= MAX_RESEARCH_FUNC) { - DBERROR(("Out of memory assigning research functions")); + debug( LOG_ERROR, "Out of memory assigning research functions" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -643,7 +661,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchPR >= MAX_RESEARCH_PR) { - DBERROR(("Out of memory assigning research pre-requisities")); + debug( LOG_ERROR, "Out of memory assigning research pre-requisities" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -668,7 +687,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchStructPR >= MAX_RESEARCH_STRUCT_PR) { - DBERROR(("Out of memory assigning research structures - requirements")); + debug( LOG_ERROR, "Out of memory assigning research structures - requirements" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -690,7 +710,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchStructRed >= MAX_RESEARCH_STRUCT_RED) { - DBERROR(("Out of memory assigning research structures - redundancies")); + debug( LOG_ERROR, "Out of memory assigning research structures - redundancies" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -711,7 +732,8 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) }*/ if (numResearchStructRes >= MAX_RESEARCH_STRUCT_RES) { - DBERROR(("Out of memory assigning research structures - results")); + debug( LOG_ERROR, "Out of memory assigning research structures - results" ); + abort(); return FALSE; } //don't MALLOC - get them from the pre-defined arrays @@ -724,8 +746,9 @@ BOOL loadResearch(char *pResearchData, UDWORD bufferSize) //set the researchPoints if (resPoints > UWORD_MAX) { - DBERROR(("Research Points too high for research topic - %s ", - getResearchName(pResearch))); + debug( LOG_ERROR, "Research Points too high for research topic - %s ", + getResearchName(pResearch) ); + abort(); return FALSE; } pResearch->researchPoints = (UWORD)resPoints; @@ -832,8 +855,8 @@ BOOL loadResearchPR(char *pPRData, UDWORD bufferSize) if ((pResearch[incR].storeCount + 1) > (SDWORD)pResearch[incR].numPRRequired) { - DBERROR(("Trying to allocate more pre-requisites than allowed for research %s", - getResearchName(pResearch))); + debug( LOG_ERROR, "Trying to allocate more pre-requisites than allowed for research %s", getResearchName(pResearch) ); + abort(); return FALSE; } //PRresearch found alloc this to the current Research @@ -849,7 +872,8 @@ BOOL loadResearchPR(char *pPRData, UDWORD bufferSize) //if pre-requisite not found - error if (!recFound) { - DBERROR(("Unable to find Pre-requisite %s for research %s", PRName, ResearchName )); + debug( LOG_ERROR, "Unable to find Pre-requisite %s for research %s", PRName, ResearchName ); + abort(); return FALSE; } else @@ -861,7 +885,8 @@ BOOL loadResearchPR(char *pPRData, UDWORD bufferSize) //if Research not found - error if (!recFound) { - DBERROR(("Unable to find Research %s", ResearchName)); + debug( LOG_ERROR, "Unable to find Research %s", ResearchName ); + abort(); return FALSE; } //quick check that haven't reached maxPR @@ -967,7 +992,8 @@ BOOL loadResearchArtefacts(char *pArteData, UDWORD bufferSize, UDWORD listNumber maxArtefacts = pResearch->numArteResults; break; default: - DBERROR(("Unknown research list")); + debug( LOG_ERROR, "Unknown research list" ); + abort(); return FALSE; } //deal with extra data @@ -999,8 +1025,8 @@ BOOL loadResearchArtefacts(char *pArteData, UDWORD bufferSize, UDWORD listNumber //check the old and new types are the same if (statType(pArtefact->ref) != newType) { - DBERROR(("You are trying to replace one type of component with \ - a different type for research %s in ResultComponents.txt", ResearchName)); + debug( LOG_ERROR, "You are trying to replace one type of component with a different type for research %s in ResultComponents.txt", ResearchName ); + abort(); return FALSE; } //ArtefactResearch found - alloc the artefact to the current Research topic @@ -1009,15 +1035,16 @@ BOOL loadResearchArtefacts(char *pArteData, UDWORD bufferSize, UDWORD listNumber } break; default: - DBERROR(("Unknown research list")); + debug( LOG_ERROR, "Unknown research list" ); + abort(); return FALSE; } //check not allocating more than allowed if (pResearch->storeCount > maxArtefacts) { - DBERROR(("Trying to allocate more artefacts than allowed for research %s", - getResearchName(pResearch))); + debug( LOG_ERROR, "Trying to allocate more artefacts than allowed for research %s", getResearchName(pResearch) ); + abort(); return FALSE; } pResearch->storeCount++; @@ -1152,7 +1179,8 @@ BOOL loadResearchStructures(char *pStructData, UDWORD bufferSize,UDWORD listNumb break; default: /* NO DEFAULT CASE? Alex.... Here ya go - just for you...*/ - DBERROR(("Unknown research list")); + debug( LOG_ERROR, "Unknown research list" ); + abort(); return FALSE; } recFound = TRUE; @@ -1160,7 +1188,8 @@ BOOL loadResearchStructures(char *pStructData, UDWORD bufferSize,UDWORD listNumb if (pResearch[incR].storeCount > (SDWORD)numToFind) { - DBERROR(("Trying to allocate more Structures than allowed for research %s",getResearchName(pResearch))); + debug( LOG_ERROR, "Trying to allocate more Structures than allowed for research %s", getResearchName(pResearch) ); + abort(); return FALSE; } pResearch[incR].storeCount++; @@ -1170,8 +1199,8 @@ BOOL loadResearchStructures(char *pStructData, UDWORD bufferSize,UDWORD listNumb //if Structure not found - error if (!recFound) { - DBERROR(("Unable to find Structure %s for research %s", - StructureName, ResearchName)); + debug( LOG_ERROR, "Unable to find Structure %s for research %s", StructureName, ResearchName ); + abort(); return FALSE; } else @@ -1183,7 +1212,8 @@ BOOL loadResearchStructures(char *pStructData, UDWORD bufferSize,UDWORD listNumb //if Research not found - error if (!recFound) { - DBERROR(("Unable to allocate all Research Structures for %s", ResearchName)); + debug( LOG_ERROR, "Unable to allocate all Research Structures for %s", ResearchName ); + abort(); return FALSE; } @@ -1278,8 +1308,8 @@ BOOL loadResearchFunctions(char *pFunctionData, UDWORD bufferSize) if (pResearch[incR].storeCount > (SDWORD)pResearch[incR].numFunctions) { - DBERROR(("Trying to allocate more Functions than allowed \ - for research %s", ResearchName)); + debug( LOG_ERROR, "Trying to allocate more Functions than allowed for research %s", ResearchName ); + abort(); return FALSE; } pResearch[incR].storeCount++; @@ -1289,8 +1319,8 @@ BOOL loadResearchFunctions(char *pFunctionData, UDWORD bufferSize) //if Function not found - error if (!recFound) { - DBERROR(("Unable to find Function %s for research %s", - FunctionName, ResearchName)); + debug( LOG_ERROR, "Unable to find Function %s for research %s", FunctionName, ResearchName ); + abort(); return FALSE; } else @@ -1302,7 +1332,8 @@ BOOL loadResearchFunctions(char *pFunctionData, UDWORD bufferSize) //if Research not found - error if (!recFound) { - DBERROR(("Unable to allocate all research Functions for %s", ResearchName)); + debug( LOG_ERROR, "Unable to allocate all research Functions for %s", ResearchName ); + abort(); return FALSE; } //quick check that haven't reached maxPR @@ -2279,7 +2310,7 @@ void CancelAllResearch(UDWORD pl) && ( ((RESEARCH_FACILITY *)psCurr->pFunctionality)->psSubject !=NULL ) ) { - DBPRINTF(("canceling research for %p\n",psCurr)); + debug( LOG_NEVER, "canceling research for %p\n", psCurr ); cancelResearch(psCurr); } } @@ -2380,7 +2411,7 @@ static UWORD setIconIDFromHashedName(STRING *pIconName, UDWORD NameHash) //add more names as images are created // ASSERT((FALSE, "Invalid icon graphic %s for topic %s", pIconName, pName)); - DBPRINTF(("Failed to matched research icon %s #%d\n",pIconName,IconHash)); + debug( LOG_NEVER, "Failed to matched research icon %s #%d\n", pIconName, IconHash ); return 0; // Should never get here. } @@ -2717,7 +2748,8 @@ COMP_BASE_STATS * getComponentDetails(STRING *pName, STRING *pCompName) default: { //COMP_UNKNOWN should be an error - DBERROR(("Unknown artefact type - %s",pName)); + debug( LOG_ERROR, "Unknown artefact type - %s", pName ); + abort(); return FALSE; } } @@ -2741,7 +2773,8 @@ COMP_BASE_STATS * getComponentDetails(STRING *pName, STRING *pCompName) pArtefact = (COMP_BASE_STATS*)address; } - DBERROR(("Cannot find component %s",pCompName)); + debug( LOG_ERROR, "Cannot find component %s", pCompName ); + abort(); return NULL; } @@ -2895,7 +2928,8 @@ void replaceComponent(COMP_BASE_STATS *pNewComponent, COMP_BASE_STATS *pOldCompo break; default: //unknown comp type - DBERROR(("Unknown component type - invalid Template")); + debug( LOG_ERROR, "Unknown component type - invalid Template" ); + abort(); return; } } @@ -3440,7 +3474,8 @@ void switchComponent(DROID *psDroid, UDWORD oldType, UDWORD oldCompInc, break; default: //unknown comp type - DBERROR(("Unknown component type - invalid droid")); + debug( LOG_ERROR, "Unknown component type - invalid droid" ); + abort(); return; } } diff --git a/src/scores.c b/src/scores.c index 2c2333eb6..b271ad6da 100644 --- a/src/scores.c +++ b/src/scores.c @@ -148,7 +148,8 @@ void scoreUpdateVar( DATA_INDEX var ) missionData.babasMowedDown++; // Ran over a barbarian break; default: - DBERROR(("Weirdy variable request from scoreUpdateVar")); + debug( LOG_ERROR, "Weirdy variable request from scoreUpdateVar" ); + abort(); break; } } @@ -472,7 +473,8 @@ SCORE_SAVEHEADER *psHeader; // Pointer to the header part of the file if(!pFileData) { /* Nope, so do one */ - DBERROR(("Saving Score data : Cannot get the memory! (%d)",fileSize)); + debug( LOG_ERROR, "Saving Score data : Cannot get the memory! (%d)", fileSize ); + abort(); return(FALSE); } @@ -516,9 +518,8 @@ MISSION_DATA *pScoreData; psHeader = (SCORE_SAVEHEADER *)pFileData; if (psHeader->aFileType[0] != 's' || psHeader->aFileType[1] != 'c' || psHeader->aFileType[2] != 'd' || psHeader->aFileType[3] != 'a') { - DBERROR(("Read Score data : Weird file type found? Has header letters \ - - %c %c %c %c", psHeader->aFileType[0],psHeader->aFileType[1], - psHeader->aFileType[2],psHeader->aFileType[3])); + debug( LOG_ERROR, "Read Score data : Weird file type found? Has header letters - %c %c %c %c", psHeader->aFileType[0],psHeader->aFileType[1], psHeader->aFileType[2],psHeader->aFileType[3] ); + abort(); return FALSE; } @@ -529,7 +530,8 @@ MISSION_DATA *pScoreData; if(fileSize!=expectedFileSize) { /* No, so bomb out */ - DBERROR(("Read Score data : Weird file size!")); + debug( LOG_ERROR, "Read Score data : Weird file size!" ); + abort(); return(FALSE); } diff --git a/src/scriptai.c b/src/scriptai.c index 6a4402610..b509726f7 100644 --- a/src/scriptai.c +++ b/src/scriptai.c @@ -1417,7 +1417,8 @@ BOOL scrSkCanBuildTemplate(void) case DROID_DEFAULT: // Default droid case DROID_ANY: default: - DBERROR(("scrSkCanBuildTemplate: Unhandled template type")); + debug( LOG_ERROR, "scrSkCanBuildTemplate: Unhandled template type" ); + abort(); break; } @@ -1973,8 +1974,8 @@ BOOL scrSkDefenseLocationB(void) BOOL noWater; if (!stackPopParams(6, - VAL_REF|VAL_INT, &pX, - VAL_REF|VAL_INT, &pY, + VAL_REF|VAL_INT, &pX, + VAL_REF|VAL_INT, &pY, ST_STRUCTURESTAT, &statIndex, ST_STRUCTURESTAT, &statIndex2, ST_DROID, &psDroid, @@ -1994,7 +1995,7 @@ BOOL scrSkDefenseLocationB(void) psWStats = (BASE_STATS *)(asStructureStats + statIndex2); // check for wacky coords. - if( *pX < 0 + if( *pX < 0 || *pX > (SDWORD)(mapWidth< (SDWORD)(mapHeight< 2 && noWater) // min 2 tiles - { + { // ok it's free. Is it the nearest one yet? /* Get gateway midpoint */ gX = (psGate->x1 + psGate->x2)/2; @@ -2192,7 +2193,7 @@ BOOL scrSkDefenseLocationB(void) { orderDroidStatsTwoLocAdd(psDroid, DORDER_LINEBUILD, psWStats, x3, y3,x4,y4); } - + return TRUE; failed: @@ -2286,7 +2287,7 @@ BOOL scrInitIterateGroupB(void) return TRUE; } - + //script function - improved version // iterate through a groups members BOOL scrIterateGroupB(void) diff --git a/src/scriptfuncs.c b/src/scriptfuncs.c index 39c0a32f5..5c0fd880b 100644 --- a/src/scriptfuncs.c +++ b/src/scriptfuncs.c @@ -882,7 +882,7 @@ BOOL scrAddDroidToMissionList(void) #ifdef SCRIPT_CHECK_MAX_UNITS // Don't build a new droid if player limit reached, unless it's a transporter. if( IsPlayerDroidLimitReached(player) && (psTemplate->droidType != DROID_TRANSPORTER) ) { - DBPRINTF(("scrAddUnit : Max units reached ,player %d\n",player)); + debug( LOG_NEVER, "scrAddUnit : Max units reached ,player %d\n", player ); psDroid = NULL; } else #endif @@ -934,7 +934,7 @@ BOOL scrAddDroid(void) #ifdef SCRIPT_CHECK_MAX_UNITS // Don't build a new droid if player limit reached, unless it's a transporter. if( IsPlayerDroidLimitReached(player) && (psTemplate->droidType != DROID_TRANSPORTER) ) { - DBPRINTF(("scrAddUnit : Max units reached ,player %d\n",player)); + debug( LOG_NEVER, "scrAddUnit : Max units reached ,player %d\n", player ); psDroid = NULL; } else #endif @@ -1175,7 +1175,7 @@ BOOL scrNumMB(void) /* gameTimeStop(); DBERROR(("scrNumMB: called by script with value: %d", val)); gameTimeStart();*/ - DBPRINTF(("scrNumMB: called by script with value: %d\n", val)); + debug( LOG_NEVER, "scrNumMB: called by script with value: %d\n", val ); return TRUE; } @@ -1687,7 +1687,7 @@ BOOL scrGetFeature(void) // check to see if badly called if(psFeatureStatToFind[bucket] == NULL) { - DBPRINTF(("invalid feature to find. possibly due to save game\n")); + debug( LOG_NEVER, "invalid feature to find. possibly due to save game\n" ); if(!stackPushResult((INTERP_TYPE)ST_FEATURE,(SDWORD)NULL)) { ASSERT((FALSE, "scrGetFeature: Failed to push result")); @@ -3527,7 +3527,8 @@ BOOL scrStartMission(void) // find the level dataset if (!levFindDataSet(pGame, &psNewLevel)) { - DBERROR(("scrStartMission: couldn't find level data")); + debug( LOG_ERROR, "scrStartMission: couldn't find level data" ); + abort(); return FALSE; } @@ -3784,7 +3785,7 @@ BOOL scrRefTest(void) return FALSE; } - DBPRINTF(("scrRefTest: num: %d \n", Num)); + debug( LOG_NEVER, "scrRefTest: num: %d \n", Num ); return TRUE; } @@ -5640,11 +5641,11 @@ BOOL scrGetGameStatus(void) if (result==TRUE) { - DBPRINTF(("battle map active")); + debug( LOG_NEVER, "battle map active" ); } else { - DBPRINTF(("battle map notactive")); + debug( LOG_NEVER, "battle map notactive" ); } @@ -5929,7 +5930,7 @@ BOOL scrTakeOverSingleStructure(void) if (playerToGain == (SDWORD)selectedPlayer AND StructIsFactory(psStructToTake) AND asStructLimits[playerToGain][structureInc].currentQuantity >= MAX_FACTORY) { - DBPRINTF(("scrTakeOverSingleStructure - factory ignored for selectedPlayer\n")); + debug( LOG_NEVER, "scrTakeOverSingleStructure - factory ignored for selectedPlayer\n" ); psNewStruct = NULL; } else @@ -6017,7 +6018,7 @@ BOOL scrTakeOverStructsInArea(void) if (toPlayer == (SDWORD)selectedPlayer AND StructIsFactory(psStruct) AND asStructLimits[toPlayer][structureInc].currentQuantity >= MAX_FACTORY) { - DBPRINTF(("scrTakeOverStructsInArea - factory ignored for selectedPlayer\n")); + debug( LOG_NEVER, "scrTakeOverStructsInArea - factory ignored for selectedPlayer\n" ); } else { @@ -6302,7 +6303,8 @@ BOOL scrTutorialTemplates(void) strcpy(pName,"ViperLtMGWheels"); if (!getResourceName(pName)) { - DBERROR(("tutorial template setup failed")); + debug( LOG_ERROR, "tutorial template setup failed" ); + abort(); return FALSE; } @@ -6336,7 +6338,8 @@ BOOL scrTutorialTemplates(void) } else { - DBERROR(("tutorial template setup failed")); + debug( LOG_ERROR, "tutorial template setup failed" ); + abort(); return FALSE; } return TRUE; diff --git a/src/scriptobj.c b/src/scriptobj.c index 0baa66e32..4f810d80d 100644 --- a/src/scriptobj.c +++ b/src/scriptobj.c @@ -246,8 +246,8 @@ BOOL scrBaseObjGet(UDWORD index) case OBJID_STRUCTSTAT: //droid.stat - now returns the type of structure a truck is building for droids - - + + if (psObj->type == OBJ_STRUCTURE) { type = ST_STRUCTURESTAT; @@ -546,7 +546,8 @@ STRING *scrGetStatName(INTERP_TYPE type, UDWORD data) if (pName == NULL) { - DBERROR(("scrGetStatName: cannot get name for a base stat")); + debug( LOG_ERROR, "scrGetStatName: cannot get name for a base stat" ); + abort(); } return pName; @@ -811,7 +812,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, { if (!scrvGetBaseObj(*((UDWORD*)pBuffer), (BASE_OBJECT **)pData)) { - DBERROR(("scrValDefLoad: couldn't find object id %d", *((UDWORD*)pBuffer))); + debug( LOG_ERROR, "scrValDefLoad: couldn't find object id %d", *((UDWORD*)pBuffer) ); + abort(); } } break; @@ -822,7 +824,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getStructStatFromName((char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find structure stat %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find structure stat %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -831,7 +834,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getFeatureStatFromName((char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find feature stat %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find feature stat %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -840,7 +844,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_BODY, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find body component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find body component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -849,7 +854,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_PROPULSION, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find propulsion component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find propulsion component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -858,7 +864,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_ECM, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find ECM component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find ECM component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -867,7 +874,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_SENSOR, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find sensor component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find sensor component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -876,7 +884,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_CONSTRUCT, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find constructor component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find constructor component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -885,7 +894,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_WEAPON, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find weapon %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find weapon %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -894,7 +904,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_REPAIRUNIT, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find repair component %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find repair component %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -903,7 +914,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = getCompFromResName(COMP_BRAIN, (char *)pBuffer); if (index == -1) { - DBERROR(("scrValDefLoad: couldn't find repair brain %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find repair brain %s", pBuffer ); + abort(); index = 0; } *pData = (UDWORD)index; @@ -919,7 +931,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, *((DROID_TEMPLATE **)pData) = IdToTemplate(id, ANYPLAYER); if (*pData == 0) { - DBERROR(("scrValDefLoad: couldn't find template id %d", *((UDWORD *)pBuffer))); + debug( LOG_ERROR, "scrValDefLoad: couldn't find template id %d", *((UDWORD *)pBuffer) ); + abort(); } } break; @@ -943,7 +956,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, { if (!levFindDataSet((char *)pBuffer, &psLevel)) { - DBERROR(("scrValDefLoad: couldn't find level dataset %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find level dataset %s", pBuffer ); + abort(); } *((STRING **)pData) = psLevel->pName; } @@ -959,7 +973,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, *pData = (UDWORD)getResearch((char *)pBuffer, TRUE); if (*pData == 0) { - DBERROR(("scrValDefLoad: couldn't find research %s", pBuffer)); + debug( LOG_ERROR, "scrValDefLoad: couldn't find research %s", pBuffer ); + abort(); } } break; @@ -968,7 +983,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, { if (!grpCreate((DROID_GROUP **)pData)) { - DBERROR(("scrValDefLoad: out of memory")); + debug( LOG_ERROR, "scrValDefLoad: out of memory" ); + abort(); break; } grpJoin(*((DROID_GROUP **)pData), NULL); @@ -1019,7 +1035,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, { if (!scrvGetBaseObj(*((UDWORD*)pPos), (BASE_OBJECT **)&psCDroid)) { - DBERROR(("scrValDefLoad: couldn't find object id %d", *((UDWORD*)pBuffer))); + debug( LOG_ERROR, "scrValDefLoad: couldn't find object id %d", *((UDWORD*)pBuffer) ); + abort(); } else { @@ -1039,7 +1056,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_TYPE type, char *pBuffer, UDWORD size, index = audio_GetAvailableID(); if (index == SAMPLE_NOT_ALLOCATED) { - DBERROR(("Sound ID not available %s not found", pBuffer)); + debug( LOG_ERROR, "Sound ID not available %s not found", pBuffer ); + abort(); break; } // set track vals diff --git a/src/scriptvals.c b/src/scriptvals.c index 80d55d12f..404eb403d 100644 --- a/src/scriptvals.c +++ b/src/scriptvals.c @@ -83,13 +83,15 @@ BOOL scrvAddContext(STRING *pID, SCRIPT_CONTEXT *psContext, SCRV_TYPE type) psNew = MALLOC(sizeof(SCRV_STORE)); if (!psNew) { - DBERROR(("scrvAddContext: Out of memory")); + debug( LOG_ERROR, "scrvAddContext: Out of memory" ); + abort(); return FALSE; } psNew->pIDString = MALLOC(strlen(pID) + 1); if (!psNew->pIDString) { - DBERROR(("scrvAddContext: Out of memory")); + debug( LOG_ERROR, "scrvAddContext: Out of memory" ); + abort(); return FALSE; } strcpy(psNew->pIDString, pID); @@ -209,7 +211,8 @@ BOOL scrvGetContext(STRING *pID, SCRIPT_CONTEXT **ppsContext) } } - DBERROR(("scrvGetContext: couldn't find context for id: %s", pID)); + debug( LOG_ERROR, "scrvGetContext: couldn't find context for id: %s", pID ); + abort(); return FALSE; } @@ -240,7 +243,8 @@ BOOL scrvGetString(STRING *pStringID, STRING **ppString) //get the ID for the string if (!strresGetIDNum(psStringRes, pStringID, &id)) { - DBERROR(("Cannot find the string id %s ", pStringID)); + debug( LOG_ERROR, "Cannot find the string id %s ", pStringID ); + abort(); return FALSE; } //get the string from the id diff --git a/src/scriptvals_lexer.l b/src/scriptvals_lexer.l index df9975a63..a8633ab4d 100644 --- a/src/scriptvals_lexer.l +++ b/src/scriptvals_lexer.l @@ -152,7 +152,8 @@ int scrv_wrap(void) { if (inComment) { - DBERROR(("Warning: reached end of file in a comment")); + debug( LOG_ERROR, "Warning: reached end of file in a comment" ); + abort(); } return 1; } diff --git a/src/seqdisp.c b/src/seqdisp.c index 8192f0d0c..69b0c714f 100644 --- a/src/seqdisp.c +++ b/src/seqdisp.c @@ -684,7 +684,7 @@ BOOL seq_UpdateFullScreenVideo(CLEAR_MODE *pbClear) } else if (frame < 0) //an ERROR { - DBPRINTF(("VIDEO FRAME ERROR %d\n",frame)); + debug( LOG_NEVER, "VIDEO FRAME ERROR %d\n", frame ); return FALSE; } diff --git a/src/stats.c b/src/stats.c index e81b7da0c..3befc16a2 100644 --- a/src/stats.c +++ b/src/stats.c @@ -144,7 +144,8 @@ static char NotUsedString[50]; // Dummy area for scanf (list) = (type *)MALLOC(sizeof(type) * (numEntries)); \ if ((list) == NULL) \ { \ - DBERROR(("Out of memory")); \ + debug( LOG_ERROR, "Out of memory" ); \ + abort(); \ return FALSE; \ } \ (listSize) = (numEntries); \ @@ -564,7 +565,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) #define DEFAULT_FLIGHTSPEED (500) if (psStats->flightSpeed==0) { - DBPRINTF(("STATS: Zero Flightspeed for %s - using default of %d\n",WeaponName,DEFAULT_FLIGHTSPEED)); + debug( LOG_NEVER, "STATS: Zero Flightspeed for %s - using default of %d\n", WeaponName, DEFAULT_FLIGHTSPEED ); psStats->flightSpeed=DEFAULT_FLIGHTSPEED; } @@ -596,7 +597,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the weapon PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the weapon PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -610,7 +612,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) psStats->pMountGraphic = (iIMDShape *) resGetData("IMD", mountGfx); if (psStats->pMountGraphic == NULL) { - DBERROR(("Cannot find the mount PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the mount PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -625,7 +628,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) psStats->pMuzzleGraphic = (iIMDShape *) resGetData("IMD", muzzleGfx); if (psStats->pMuzzleGraphic == NULL) { - DBERROR(("Cannot find the muzzle PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the muzzle PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } @@ -633,28 +637,32 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) psStats->pInFlightGraphic = (iIMDShape *) resGetData("IMD", flightGfx); if (psStats->pInFlightGraphic == NULL) { - DBERROR(("Cannot find the flight PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the flight PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } psStats->pTargetHitGraphic = (iIMDShape *) resGetData("IMD", hitGfx); if (psStats->pTargetHitGraphic == NULL) { - DBERROR(("Cannot find the target hit PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the target hit PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } psStats->pTargetMissGraphic = (iIMDShape *) resGetData("IMD", missGfx); if (psStats->pTargetMissGraphic == NULL) { - DBERROR(("Cannot find the target miss PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the target miss PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } psStats->pWaterHitGraphic = (iIMDShape *) resGetData("IMD", waterGfx); if (psStats->pWaterHitGraphic == NULL) { - DBERROR(("Cannot find the water hit PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the water hit PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } //trail graphic can be null @@ -663,7 +671,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) psStats->pTrailGraphic = (iIMDShape *) resGetData("IMD", trailGfx); if (psStats->pTrailGraphic == NULL) { - DBERROR(("Cannot find the trail PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the trail PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -688,7 +697,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) } else { - DBERROR(("Invalid fire on move flag for weapon %s", getStatName(psStats))); + debug( LOG_ERROR, "Invalid fire on move flag for weapon %s", getStatName(psStats) ); + abort(); return FALSE; } @@ -713,7 +723,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) } else { - DBERROR(("Invalid weapon class for weapon %s", getStatName(psStats))); + debug( LOG_ERROR, "Invalid weapon class for weapon %s", getStatName(psStats) ); + abort(); return FALSE; } @@ -735,8 +746,8 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) psStats->weaponEffect = getWeaponEffect(weaponEffect); if (psStats->weaponEffect == INVALID_WEAPON_EFFECT) { - DBERROR(("loadWepaonStats: Invalid weapon effect for weapon %s", - getStatName(psStats))); + debug( LOG_ERROR, "loadWepaonStats: Invalid weapon effect for weapon %s", getStatName(psStats) ); + abort(); return FALSE; } @@ -873,13 +884,11 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) } if (psStats->shortRange > longRange) { - DBPRINTF(("%s, flight speed is too low to reach short range (max range %d)\n", - WeaponName, longRange)); + debug( LOG_NEVER, "%s, flight speed is too low to reach short range (max range %d)\n", WeaponName, longRange ); } else if (psStats->longRange > longRange) { - DBPRINTF(("%s, flight speed is too low to reach long range (max range %d)\n", - WeaponName, longRange)); + debug( LOG_NEVER, "%s, flight speed is too low to reach long range (max range %d)\n", WeaponName, longRange ); } //set the weapon sounds to default value @@ -1088,7 +1097,8 @@ BOOL loadBodyStats(char *pBodyData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the body PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the body PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1103,7 +1113,8 @@ BOOL loadBodyStats(char *pBodyData, UDWORD bufferSize) psStats->pFlameIMD = (iIMDShape *) resGetData("IMD", flameIMD); if (psStats->pFlameIMD == NULL) { - DBERROR(("Cannot find the flame PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the flame PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1205,8 +1216,8 @@ BOOL loadBrainStats(char *pBrainData, UDWORD bufferSize) //if weapon not found - error if (incW == -1) { - DBERROR(("Unable to find Weapon %s for brain %s", - weaponName, BrainName)); + debug( LOG_ERROR, "Unable to find Weapon %s for brain %s", weaponName, BrainName ); + abort(); return FALSE; } else @@ -1440,7 +1451,8 @@ BOOL loadPropulsionStats(char *pPropulsionData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", imdName); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the propulsion PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the propulsion PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1453,8 +1465,8 @@ BOOL loadPropulsionStats(char *pPropulsionData, UDWORD bufferSize) psStats->propulsionType = getPropulsionType(type); if (psStats->propulsionType == INVALID_PROP_TYPE) { - DBERROR(("loadPropulsionStats: Invalid Propulsion type for %s", - getStatName(psStats))); + debug( LOG_ERROR, "loadPropulsionStats: Invalid Propulsion type for %s", getStatName(psStats) ); + abort(); return FALSE; } @@ -1625,7 +1637,8 @@ BOOL loadSensorStats(char *pSensorData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the sensor PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the sensor PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1639,7 +1652,8 @@ BOOL loadSensorStats(char *pSensorData, UDWORD bufferSize) psStats->pMountGraphic = (iIMDShape *) resGetData("IMD", mountGfx); if (psStats->pMountGraphic == NULL) { - DBERROR(("Cannot find the mount PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the mount PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1765,7 +1779,8 @@ BOOL loadECMStats(char *pECMData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the ECM PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the ECM PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1779,7 +1794,8 @@ BOOL loadECMStats(char *pECMData, UDWORD bufferSize) psStats->pMountGraphic = (iIMDShape *) resGetData("IMD", mountGfx); if (psStats->pMountGraphic == NULL) { - DBERROR(("Cannot find the mount PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the mount PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1910,7 +1926,8 @@ BOOL loadRepairStats(char *pRepairData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the Repair PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the Repair PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -1924,7 +1941,8 @@ BOOL loadRepairStats(char *pRepairData, UDWORD bufferSize) psStats->pMountGraphic = (iIMDShape *) resGetData("IMD", mountGfx); if (psStats->pMountGraphic == NULL) { - DBERROR(("Cannot find the Repair mount PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the Repair mount PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -2093,7 +2111,8 @@ BOOL loadConstructStats(char *pConstructData, UDWORD bufferSize) psStats->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStats->pIMD == NULL) { - DBERROR(("Cannot find the constructor PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the constructor PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -2107,7 +2126,8 @@ BOOL loadConstructStats(char *pConstructData, UDWORD bufferSize) psStats->pMountGraphic = (iIMDShape *) resGetData("IMD", mountGfx); if (psStats->pMountGraphic == NULL) { - DBERROR(("Cannot find the mount PIE for record %s", getStatName(psStats))); + debug( LOG_ERROR, "Cannot find the mount PIE for record %s", getStatName(psStats) ); + abort(); return FALSE; } } @@ -2155,7 +2175,8 @@ BOOL loadPropulsionTypes(char *pPropTypeData, UDWORD bufferSize) asPropulsionTypes = (PROPULSION_TYPES *)MALLOC(sizeof(PROPULSION_TYPES)*NumTypes); if (asPropulsionTypes == NULL) { - DBERROR(("PropulsionTypes - Out of memory")); + debug( LOG_ERROR, "PropulsionTypes - Out of memory" ); + abort(); return FALSE; } @@ -2186,8 +2207,8 @@ BOOL loadPropulsionTypes(char *pPropTypeData, UDWORD bufferSize) type = getPropulsionType(PropulsionName); if (type == INVALID_PROP_TYPE) { - DBERROR(("loadPropulsionTypes: Invalid Propulsion type - %s", - PropulsionName)); + debug( LOG_ERROR, "loadPropulsionTypes: Invalid Propulsion type - %s", PropulsionName ); + abort(); return FALSE; } @@ -2253,7 +2274,8 @@ BOOL loadTerrainTable(char *pTerrainTableData, UDWORD bufferSize) if (asTerrainTable == NULL) { - DBERROR(("Terrain Types - Out of memory")); + debug( LOG_ERROR, "Terrain Types - Out of memory" ); + abort(); return FALSE; } @@ -2293,7 +2315,8 @@ BOOL loadTerrainTable(char *pTerrainTableData, UDWORD bufferSize) pTerrainTable = asTerrainTable + (i * NUM_PROP_TYPES + j); if (pTerrainTable->speedFactor == 0) { - DBERROR(("loadTerrainTable: Invalid propulsion/terrain table entry")); + debug( LOG_ERROR, "loadTerrainTable: Invalid propulsion/terrain table entry" ); + abort(); return FALSE; } } @@ -2320,7 +2343,8 @@ BOOL loadSpecialAbility(char *pSAbilityData, UDWORD bufferSize) if (asSpecialAbility == NULL) { - DBERROR(("SpecialAbility - Out of memory")); + debug( LOG_ERROR, "SpecialAbility - Out of memory" ); + abort(); return FALSE; } @@ -2338,14 +2362,16 @@ BOOL loadSpecialAbility(char *pSAbilityData, UDWORD bufferSize) //check that the data is ordered in the way it will be stored if (accessID != i) { - DBERROR(("The Special Ability sequence is invalid")); + debug( LOG_ERROR, "The Special Ability sequence is invalid" ); + abort(); return FALSE; } //allocate storage for the name asSpecialAbility->pName = (STRING *)MALLOC((strlen(SAbilityName))+1); if (asSpecialAbility->pName == NULL) { - DBERROR(("Special Ability Name - Out of memory")); + debug( LOG_ERROR, "Special Ability Name - Out of memory" ); + abort(); return FALSE; } strcpy(asSpecialAbility->pName,SAbilityName); @@ -2391,7 +2417,8 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize) NUM_PROP_SIDES * sizeof(iIMDShape *)); if (psBodyStat->ppIMDList == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); } //initialise the pointer space memset(psBodyStat->ppIMDList, 0, (numPropulsionStats * @@ -2443,7 +2470,8 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize) } if (!found) { - DBERROR(("loadBodyPropulsionPIEs: Invalid body name %s", bodyName)); + debug( LOG_ERROR, "loadBodyPropulsionPIEs: Invalid body name %s", bodyName ); + abort(); return FALSE; } @@ -2473,7 +2501,8 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize) } if (!found) { - DBERROR(("Invalid propulsion name %s", propulsionName)); + debug( LOG_ERROR, "Invalid propulsion name %s", propulsionName ); + abort(); return FALSE; } @@ -2485,7 +2514,8 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize) *psBodyStat->ppIMDList = (iIMDShape *) resGetData("IMD", leftIMD); if (*psBodyStat->ppIMDList == NULL) { - DBERROR(("Cannot find the left propulsion PIE for body %s", bodyName)); + debug( LOG_ERROR, "Cannot find the left propulsion PIE for body %s", bodyName ); + abort(); return FALSE; } } @@ -2501,7 +2531,8 @@ BOOL loadBodyPropulsionIMDs(char *pData, UDWORD bufferSize) *psBodyStat->ppIMDList = (iIMDShape *) resGetData("IMD", rightIMD); if (*psBodyStat->ppIMDList == NULL) { - DBERROR(("Cannot find the right propulsion PIE for body %s", bodyName)); + debug( LOG_ERROR, "Cannot find the right propulsion PIE for body %s", bodyName ); + abort(); return FALSE; } } @@ -2534,16 +2565,16 @@ statsGetAudioIDFromString( STRING *szStatName, STRING *szWavName, SDWORD *piWavI { if ( audioID_GetIDFromStr( szWavName, piWavID ) == FALSE ) { - DBERROR(("statsGetAudioIDFromString: couldn't get ID %d for sound %s", - *piWavID, szWavName)); + debug( LOG_ERROR, "statsGetAudioIDFromString: couldn't get ID %d for sound %s", *piWavID, szWavName ); + abort(); return FALSE; } } if ( ((*piWavID < 0) || (*piWavID >= ID_MAX_SOUND)) && (*piWavID != NO_SOUND) ) { - DBERROR(("statsGetAudioIDFromString: Invalid ID - %d for sound %s", - *piWavID, szStatName)); + debug( LOG_ERROR, "statsGetAudioIDFromString: Invalid ID - %d for sound %s", *piWavID, szStatName ); + abort(); return FALSE; } @@ -2621,7 +2652,8 @@ BOOL loadWeaponSounds(char *pSoundData, UDWORD bufferSize) } if (inc == (SDWORD)numWeaponStats) { - DBERROR(("loadWeaponSounds: Weapon stat not found - %s", WeaponName)); + debug( LOG_ERROR, "loadWeaponSounds: Weapon stat not found - %s", WeaponName ); + abort(); Ok = FALSE; // return FALSE; } @@ -2664,23 +2696,23 @@ BOOL loadWeaponModifiers(char *pWeapModData, UDWORD bufferSize) effectInc = getWeaponEffect(weaponEffectName); if (effectInc == INVALID_WEAPON_EFFECT) { - DBERROR(("loadWeaponModifiers: Invalid Weapon Effect - %s", - weaponEffectName)); + debug( LOG_ERROR, "loadWeaponModifiers: Invalid Weapon Effect - %s", weaponEffectName ); + abort(); return FALSE; } //get the propulsion inc propInc = getPropulsionType(propulsionName); if (propInc == INVALID_PROP_TYPE) { - DBERROR(("loadWeaponModifiers: Invalid Propulsion type - %s", - propulsionName)); + debug( LOG_ERROR, "loadWeaponModifiers: Invalid Propulsion type - %s", propulsionName ); + abort(); return FALSE; } if (modifier > UWORD_MAX) { - DBERROR(("loadWeaponModifiers: modifier for effect %s, prop type %s is too large", - weaponEffectName, propulsionName)); + debug( LOG_ERROR, "loadWeaponModifiers: modifier for effect %s, prop type %s is too large", weaponEffectName, propulsionName ); + abort(); return FALSE; } //store in the appropriate index @@ -2751,8 +2783,8 @@ BOOL loadPropulsionSounds(char *pPropSoundData, UDWORD bufferSize) type = getPropulsionType(propulsionName); if (type == INVALID_PROP_TYPE) { - DBERROR(("loadPropulsionSounds: Invalid Propulsion type - %s", - propulsionName)); + debug( LOG_ERROR, "loadPropulsionSounds: Invalid Propulsion type - %s", propulsionName ); + abort(); return FALSE; } pPropType = asPropulsionTypes + type; @@ -3244,7 +3276,8 @@ UDWORD statRefStart(UDWORD stat) default: { //COMP_UNKNOWN should be an error - DBERROR(("Invalid stat type")); + debug( LOG_ERROR, "Invalid stat type" ); + abort(); start = 0; } } @@ -3311,7 +3344,8 @@ BOOL compareYes(STRING *strToCompare, STRING *strOwner) { //set default to FALSE but continue //DBERROR(("Invalid yes/no for record %s", strOwner)); - DBERROR(("Invalid yes/no for record %s", getName(strOwner))); + debug( LOG_ERROR, "Invalid yes/no for record %s", getName(strOwner) ); + abort(); return FALSE; } } @@ -3383,17 +3417,12 @@ void getStatsDetails(UDWORD compType, BASE_STATS **ppsStats, UDWORD *pnumStats, break; default: //COMP_UNKNOWN should be an error - DBERROR(("Invalid component type - game.c")); + debug( LOG_ERROR, "Invalid component type - game.c" ); + abort(); } } - - - - - - //get the component Inc for a stat based on the name and type //returns -1 if record not found SDWORD getCompFromName(UDWORD compType, STRING *pName) @@ -3468,7 +3497,8 @@ BOOL getResourceName(STRING *pName) //see if the name has a resource associated with it by trying to get the ID for the string if (!strresGetIDNum(psStringRes, pName, &id)) { - DBERROR(("Unable to find string resource for %s", pName)); + debug( LOG_ERROR, "Unable to find string resource for %s", pName ); + abort(); return FALSE; } //get the string from the id @@ -3500,7 +3530,8 @@ STRING* getName(STRING *pNameID) the ID for the string*/ if (!strresGetIDNum(psStringRes, pNameID, &id)) { - DBERROR(("Unable to find string resource for %s", pNameID)); + debug( LOG_ERROR, "Unable to find string resource for %s", pNameID ); + abort(); return Unknown; } //get the string from the id @@ -3782,7 +3813,8 @@ BOOL allocateName(STRING **ppStore, STRING *pName) //see if the name has a resource associated with it by trying to get the ID for the string if (!strresGetIDNum(psStringRes, pName, &id)) { - DBERROR(("Unable to find string resource for %s", pName)); + debug( LOG_ERROR, "Unable to find string resource for %s", pName ); + abort(); return FALSE; } @@ -3794,7 +3826,8 @@ BOOL allocateName(STRING **ppStore, STRING *pName) //checks the name has been loaded as a resource and gets the storage pointer if (!strresGetIDString(psStringRes, pName, ppStore)) { - DBERROR(("Unable to find string resource for %s", pName)); + debug( LOG_ERROR, "Unable to find string resource for %s", pName ); + abort(); return FALSE; } return TRUE; @@ -3804,7 +3837,8 @@ BOOL allocateName(STRING **ppStore, STRING *pName) *ppStore = (STRING *)MALLOC((strlen(pName))+1); if (ppStore == NULL) { - DBERROR(("Name - Out of memory")); + debug( LOG_ERROR, "Name - Out of memory" ); + abort(); return FALSE; } strcpy(*ppStore,pName); diff --git a/src/structure.c b/src/structure.c index 2f77a3a86..686229070 100644 --- a/src/structure.c +++ b/src/structure.c @@ -550,8 +550,9 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) GfxFile); if (factoryModuleIMDs[module-1][0] == NULL) { - DBERROR(("Cannot find the PIE for factory module %d - %s", - module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for factory module %d - %s", + module, GfxFile ); + abort(); return;// FALSE; } } @@ -569,8 +570,8 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) GfxFile); if (factoryModuleIMDs[module-1][1] == NULL) { - DBERROR(("Cannot find the PIE for vtol factory module %d - %s", - module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for vtol factory module %d - %s", module, GfxFile ); + abort(); return;// FALSE; } } @@ -589,8 +590,8 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) "IMD", GfxFile); if (researchModuleIMDs[module-1] == NULL) { - DBERROR(("Cannot find the PIE for research module %d - %s", - module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for research module %d - %s", module, GfxFile ); + abort(); return FALSE; } } @@ -605,7 +606,8 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) researchModuleIMDs[0] = (iIMDShape*) resGetData("IMD", GfxFile); if (researchModuleIMDs[0] == NULL) { - DBERROR(("Cannot find the PIE for research module %d - %s", module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for research module %d - %s", module, GfxFile ); + abort(); return;// FALSE; } @@ -631,8 +633,8 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) "IMD", GfxFile); if (powerModuleIMDs[module-1] == NULL) { - DBERROR(("Cannot find the PIE for power module %d - %s", - module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for power module %d - %s", module, GfxFile ); + abort(); return FALSE; } } @@ -646,7 +648,8 @@ void initModulePIEs(char *PIEName,UDWORD i,STRUCTURE_STATS *psStructure) powerModuleIMDs[0] = (iIMDShape*) resGetData("IMD", GfxFile); if (powerModuleIMDs[0] == NULL) { - DBERROR(("Cannot find the PIE for power module %d - %s", module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for power module %d - %s", module, GfxFile ); + abort(); return;// FALSE; } @@ -672,7 +675,8 @@ void initModulePIEsNoMods(char *GfxFile,UDWORD i,STRUCTURE_STATS *psStructure) factoryModuleIMDs[0][0] = (iIMDShape*) resGetData("IMD", GfxFile); if (factoryModuleIMDs[0][0] == NULL) { - DBERROR(("Cannot find the PIE for factory module %d - %s",module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for factory module %d - %s",module, GfxFile ); + abort(); return FALSE; } for (module = 1; module < NUM_FACTORY_MODULES; module++) @@ -687,7 +691,8 @@ void initModulePIEsNoMods(char *GfxFile,UDWORD i,STRUCTURE_STATS *psStructure) factoryModuleIMDs[0][1] = (iIMDShape*) resGetData("IMD", GfxFile); if (factoryModuleIMDs[0][1] == NULL) { - DBERROR(("Cannot find the PIE for vtol factory module %d - %s", module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for vtol factory module %d - %s", module, GfxFile ); + abort(); return FALSE; } for (module = 1; module < NUM_FACTORY_MODULES; module++) @@ -704,7 +709,8 @@ void initModulePIEsNoMods(char *GfxFile,UDWORD i,STRUCTURE_STATS *psStructure) researchModuleIMDs[0] = (iIMDShape*) resGetData("IMD", GfxFile); if (researchModuleIMDs[0] == NULL) { - DBERROR(("Cannot find the PIE for research module %d - %s", module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for research module %d - %s", module, GfxFile ); + abort(); return FALSE; } @@ -724,7 +730,8 @@ void initModulePIEsNoMods(char *GfxFile,UDWORD i,STRUCTURE_STATS *psStructure) powerModuleIMDs[0] = (iIMDShape*) resGetData("IMD", GfxFile); if (powerModuleIMDs[0] == NULL) { - DBERROR(("Cannot find the PIE for power module %d - %s", module, GfxFile)); + debug( LOG_ERROR, "Cannot find the PIE for power module %d - %s", module, GfxFile ); + abort(); return FALSE; } @@ -799,7 +806,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) if (asStructureStats == NULL) { - DBERROR(("Structure Stats - Out of memory")); + debug( LOG_ERROR, "Structure Stats - Out of memory" ); + abort(); return FALSE; } @@ -890,8 +898,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) psStructure->strength = getStructStrength(strength); if (psStructure->strength == INVALID_STRENGTH) { - DBERROR(("loadStructureStats: Unknown structure strength for %s", - getStatName(psStructure))); //->pName)); + debug( LOG_ERROR, "loadStructureStats: Unknown structure strength for %s", getStatName(psStructure) ); //->pName)); + abort(); return FALSE; } @@ -961,8 +969,9 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) //if (psStructure->pSensor->location == LOC_TURRET AND psStructure->numWeaps) if (psStructure->pSensor->location == LOC_TURRET AND numWeaps) { - DBERROR(("loadStructureStats: a Turret Sensor and weapon \ - have been assigned to %s", StructureName)); + debug( LOG_ERROR, "loadStructureStats: a Turret Sensor and weapon \ + have been assigned to %s", StructureName ); + abort(); } } @@ -970,7 +979,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) psStructure->pIMD = (iIMDShape *) resGetData("IMD", GfxFile); if (psStructure->pIMD == NULL) { - DBERROR(("Cannot find the structure PIE for record %s", getStructName(psStructure) )); + debug( LOG_ERROR, "Cannot find the structure PIE for record %s", getStructName(psStructure) ); + abort(); return FALSE; } @@ -979,7 +989,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) psStructure->pBaseIMD = (iIMDShape *) resGetData("IMD", baseIMD); if (psStructure->pIMD == NULL) { - DBERROR(("Cannot find the structure base PIE for record %s", getStructName(psStructure) )); + debug( LOG_ERROR, "Cannot find the structure base PIE for record %s", getStructName(psStructure) ); + abort(); return FALSE; } } @@ -1002,7 +1013,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) if (weapSlots > STRUCT_MAXWEAPS OR numWeaps > weapSlots) { //DBERROR(("Allocated more weapons than allowed in Access DB for Structure")); - DBERROR(("Allocated more weapons than allowed for Structure")); + debug( LOG_ERROR, "Allocated more weapons than allowed for Structure" ); + abort(); return FALSE; } //Don't need to allocate space since thereis only one possible pointer now! AB 24/01/99 @@ -1027,7 +1039,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) sizeof(FUNCTION*)); if (psStructure->asFuncList == NULL) { - DBERROR(("Out of memory assigning structure Functions")); + debug( LOG_ERROR, "Out of memory assigning structure Functions" ); + abort(); return FALSE; } } @@ -1054,7 +1067,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) //if ( iID == -1 ) if (iID > numStructureStats) { - DBERROR( ("intAddObjectStats: destroy structure stat not found\n") ); + debug( LOG_ERROR, "intAddObjectStats: destroy structure stat not found\n" ); + abort(); } g_psStatDestroyStruct = asStructureStats + iID; @@ -1073,7 +1087,8 @@ BOOL loadStructureStats(char *pStructData, UDWORD bufferSize) numStructureStats); if (asStructLimits[player] == NULL) { - DBERROR(("Unable to allocate structure limits")); + debug( LOG_ERROR, "Unable to allocate structure limits" ); + abort(); return FALSE; } } @@ -1237,7 +1252,8 @@ BOOL loadStructureWeapons(char *pWeaponData, UDWORD bufferSize) //see if we have already allocated one if (pStructure[incS].psWeapStat != NULL) { - DBERROR(("Trying to allocate more weapons than allowed for Structure")); + debug( LOG_ERROR, "Trying to allocate more weapons than allowed for Structure" ); + abort(); return FALSE; } pStructure[incS].psWeapStat = &pWeapon[incW]; @@ -1247,8 +1263,8 @@ BOOL loadStructureWeapons(char *pWeaponData, UDWORD bufferSize) //if weapon not found - error if (!weaponFound) { - DBERROR(("Unable to find stats for weapon %s for structure %s", - WeaponName, StructureName)); + debug( LOG_ERROR, "Unable to find stats for weapon %s for structure %s", WeaponName, StructureName ); + abort(); return FALSE; } } @@ -1256,7 +1272,8 @@ BOOL loadStructureWeapons(char *pWeaponData, UDWORD bufferSize) //if structure not found - error if (!structureFound) { - DBERROR(("Unable to find stats for structure %s", StructureName)); + debug( LOG_ERROR, "Unable to find stats for structure %s", StructureName ); + abort(); return FALSE; } //increment the pointer to the start of the next record @@ -1333,7 +1350,8 @@ BOOL loadStructureFunctions(char *pFunctionData, UDWORD bufferSize) if (pStructure[incS].defaultFunc > (SDWORD)pStructure[incS].numFuncs) { - DBERROR(("Trying to allocate more functions than allowed for Structure")); + debug( LOG_ERROR, "Trying to allocate more functions than allowed for Structure" ); + abort(); return FALSE; } pStructure[incS].asFuncList[pStructure[incS].defaultFunc] = @@ -1345,8 +1363,8 @@ BOOL loadStructureFunctions(char *pFunctionData, UDWORD bufferSize) //if function not found - error if (!functionFound) { - DBERROR(("Unable to find stats for function %s for structure %s", - FunctionName, StructureName)); + debug( LOG_ERROR, "Unable to find stats for function %s for structure %s", FunctionName, StructureName ); + abort(); return FALSE; } } @@ -1354,7 +1372,8 @@ BOOL loadStructureFunctions(char *pFunctionData, UDWORD bufferSize) //if structure not found - error if (!structureFound) { - DBERROR(("Unable to find stats for structure %s", StructureName)); + debug( LOG_ERROR, "Unable to find stats for structure %s", StructureName ); + abort(); return FALSE; } //increment the pointer to the start of the next record @@ -1392,10 +1411,11 @@ BOOL loadStructureFunctions(char *pFunctionData, UDWORD bufferSize) if (!((WALL_FUNCTION *)pFunction)->pCornerStat) { #ifdef HASH_NAMES - DBERROR(("Unknown Corner Wall stat for function %x", pFunction->NameHash)); + debug( LOG_ERROR, "Unknown Corner Wall stat for function %x", pFunction->NameHash ); #else - DBERROR(("Unknown Corner Wall stat for function %s", pFunction->pName)); + debug( LOG_ERROR, "Unknown Corner Wall stat for function %s", pFunction->pName ); #endif + abort(); return FALSE; } } @@ -1436,23 +1456,23 @@ BOOL loadStructureStrengthModifiers(char *pStrengthModData, UDWORD bufferSize) effectInc = getWeaponEffect(weaponEffectName); if (effectInc == INVALID_WEAPON_EFFECT) { - DBERROR(("loadStructureStrengthModifiers: Invalid Weapon Effect - %s", - weaponEffectName)); + debug( LOG_ERROR, "loadStructureStrengthModifiers: Invalid Weapon Effect - %s", weaponEffectName ); + abort(); return FALSE; } //get the propulsion inc strengthInc = getStructStrength(strengthName); if (strengthInc == INVALID_STRENGTH) { - DBERROR(("loadStructureStrengthModifiers: Invalid Strength type - %s", - strengthName)); + debug( LOG_ERROR, "loadStructureStrengthModifiers: Invalid Strength type - %s", strengthName ); + abort(); return FALSE; } if (modifier > UWORD_MAX) { - DBERROR(("loadStructureStrengthModifiers: modifier for effect %s, strength %s is too large", - weaponEffectName, strengthName)); + debug( LOG_ERROR, "loadStructureStrengthModifiers: modifier for effect %s, strength %s is too large", weaponEffectName, strengthName ); + abort(); return FALSE; } //store in the appropriate index @@ -2470,8 +2490,9 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, psBuilding = getTileStructure(x>>TILE_SHIFT, y>>TILE_SHIFT); if (psBuilding == NULL) { - //DBERROR(("No owning structure for this module - %s", pStructureType->pName)); - DBERROR(("No owning structure for this module - %s", getStructName(pStructureType))); + //debug( LOG_ERROR, "No owning structure for this module - %s", pStructureType->pName ); + debug( LOG_ERROR, "No owning structure for this module - %s", getStructName(pStructureType) ); + abort(); return FALSE; } if (pStructureType->type == REF_FACTORY_MODULE) @@ -2749,23 +2770,26 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %x", psBuilding)); + debug( LOG_ERROR, "There must be a function assigned to this building - %x", psBuilding ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //allocate the necessary space /*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(FACTORY)); if (psBuilding->pFunctionality == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; }*/ //allocate the necessary space if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -2868,23 +2892,26 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //allocate the necessary space /*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(RESEARCH_FACILITY)); if (psBuilding->pFunctionality == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; }*/ //try and create the Structure if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } //initialise the memory @@ -2935,10 +2962,11 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //allocate the necessary space @@ -2951,7 +2979,8 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) //try and create the Structure if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } @@ -2974,10 +3003,11 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //allocate the necessary space @@ -2990,7 +3020,8 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) //try and create the Structure if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } //initialise the memory @@ -3015,10 +3046,11 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //this function is called once the structure has been built @@ -3031,10 +3063,11 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } break; @@ -3045,10 +3078,11 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } @@ -3056,13 +3090,15 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) /*psBuilding->pFunctionality = (FUNCTIONALITY *) MALLOC(sizeof(REPAIR_FACILITY)); if (psBuilding->pFunctionality == NULL) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; }*/ //try and create the Structure if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } //initialise the memory @@ -3075,7 +3111,7 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if ( !grpCreate(&((REPAIR_FACILITY *) psBuilding->pFunctionality)->psGroup) ) { - DBPRINTF( ("setFunctionality: couldn't create repair facility group") ); + debug( LOG_NEVER, "setFunctionality: couldn't create repair facility group" ); } else { @@ -3108,18 +3144,18 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType) if (psBuilding->pStructureType->numFuncs == 0) { #ifdef HASH_NAMES - DBERROR(("There must be a function assigned to this building - %s", - strresGetString(NULL,psBuilding->pStructureType->NameHash) )); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", strresGetString( NULL, psBuilding->pStructureType->NameHash ) ); #else - DBERROR(("There must be a function assigned to this building - %s", - getName(psBuilding->pStructureType->pName))); + debug( LOG_ERROR, "There must be a function assigned to this building - %s", getName( psBuilding->pStructureType->pName ) ); #endif + abort(); return FALSE; } //try and create the Structure if (!createStructFunc(&psBuilding->pFunctionality)) { - DBERROR(("Out of memory")); + debug( LOG_ERROR, "Out of memory" ); + abort(); return FALSE; } //initialise the memory @@ -4636,7 +4672,7 @@ void aiUpdateStructure(STRUCTURE *psStructure) if ( psDroid->body >= psDroid->originalBody ) { - DBPRINTF( ("aiUpdateStructure: repair completed\n") ); + debug( LOG_NEVER, "aiUpdateStructure: repair completed\n" ); psRepairFac->psObj = NULL; @@ -7180,7 +7216,8 @@ STRUCTURE_STATS * structGetDemolishStat( void ) { if ( g_psStatDestroyStruct == NULL ) { - DBERROR( ("structGetDemolishStat: stat not initialised1\n") ); + debug( LOG_ERROR, "structGetDemolishStat: stat not initialised1\n" ); + abort(); } return g_psStatDestroyStruct; diff --git a/src/visibility.c b/src/visibility.c index ec7f5d318..d4cbd6671 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -186,7 +186,7 @@ static BOOL rayTerrainCallback(SDWORD x, SDWORD y, SDWORD dist) if(dist == 0) { //Complete hack PD.. John what should happen if dist is 0 ??? - DBPRINTF(("rayTerrainCallback: dist == 0, will divide by zero\n")); + debug( LOG_NEVER, "rayTerrainCallback: dist == 0, will divide by zero\n" ); dist = 1; } diff --git a/src/warcam.c b/src/warcam.c index 5ebf9c6b1..33e793625 100644 --- a/src/warcam.c +++ b/src/warcam.c @@ -260,7 +260,8 @@ BOOL Status = TRUE; Status = FALSE; break; default: - DBERROR(("Weirdy status for tracking Camera")); + debug( LOG_ERROR, "Weirdy status for tracking Camera" ); + abort(); break; } /* TBR @@ -284,7 +285,7 @@ BOOL Status = TRUE; /* Flips states for camera active */ void setWarCamActive(BOOL status) { - DBPRINTF(("setWarCamActive(%d)\n",status)); + debug( LOG_NEVER, "setWarCamActive(%d)\n", status ); /* We're trying to switch it on */ if(status == TRUE) diff --git a/src/wrappers.c b/src/wrappers.c index ad72d52be..c95b899b9 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -273,7 +273,8 @@ TITLECODE titleLoop(void) break; default: - DBERROR(("unknown title screen mode ")); + debug( LOG_ERROR, "unknown title screen mode" ); + abort(); } audio_Update(); @@ -314,7 +315,7 @@ void loadingScreenCallback(void) if ((currTick - lastTick) > 500) { currTick -= lastTick; - DBPRINTF(("loadingScreenCallback: pause %d\n", currTick)); + debug( LOG_NEVER, "loadingScreenCallback: pause %d\n", currTick ); } lastTick = GetTickCount(); pie_GlobalRenderBegin();