From 9e92cefbfad1cddafb752751f3ef0c2e23aaf60c Mon Sep 17 00:00:00 2001 From: lalien Date: Fri, 20 Jul 2007 18:16:54 +0000 Subject: [PATCH] - fixed some variables not being initialized git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1089 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/BobbyRMailOrder.cpp | 2 ++ Laptop/email.cpp | 1 + SaveLoadGame.cpp | 4 ++- Standard Gaming Platform/Button System.cpp | 10 +++++++ Standard Gaming Platform/Font.cpp | 2 ++ Standard Gaming Platform/himage.cpp | 31 ++++++++++++++-------- Tactical/Turn Based Input.cpp | 2 +- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Laptop/BobbyRMailOrder.cpp b/Laptop/BobbyRMailOrder.cpp index be3f4687..ac1a4d8a 100644 --- a/Laptop/BobbyRMailOrder.cpp +++ b/Laptop/BobbyRMailOrder.cpp @@ -2424,6 +2424,8 @@ BOOLEAN NewWayOfLoadingBobbyRMailOrdersToSaveGameFile( HWFILE hFile ) { //Allocate memory for the list gpNewBobbyrShipments = (NewBobbyRayOrderStruct *) MemAlloc( sizeof( NewBobbyRayOrderStruct ) * giNumberOfNewBobbyRShipment ); + memset(gpNewBobbyrShipments, 0, (sizeof( NewBobbyRayOrderStruct ) * giNumberOfNewBobbyRShipment) ); + if( gpNewBobbyrShipments == NULL ) { Assert(0); diff --git a/Laptop/email.cpp b/Laptop/email.cpp index 29230943..2a01823e 100644 --- a/Laptop/email.cpp +++ b/Laptop/email.cpp @@ -777,6 +777,7 @@ void AddEmailMessage(INT32 iMessageOffset, INT32 iMessageLength,STR16 pSubject, // add new element onto list pTempEmail = (EmailPtr) MemAlloc(sizeof(Email)); + memset( pTempEmail, 0, sizeof(Email) ); // add in strings //while(pMessage !=NULL) //{ diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 927dd6e2..dd8c096c 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -3495,7 +3495,7 @@ BOOLEAN LoadFilesFromSavedGame( STR pSrcFileName, HWFILE hFile ) FileClose( hSrcFile ); return( FALSE ); } - + memset( pData, 0, uiFileSize); // Read into the buffer FileRead( hFile, pData, uiFileSize, &uiNumBytesRead ); @@ -5409,6 +5409,8 @@ void HandleOldBobbyRMailOrders() Assert(0); return; } + + memset( gpNewBobbyrShipments, 0, (sizeof( NewBobbyRayOrderStruct )* LaptopSaveInfo.usNumberOfBobbyRayOrderUsed) ); giNumberOfNewBobbyRShipment = LaptopSaveInfo.usNumberOfBobbyRayOrderUsed; diff --git a/Standard Gaming Platform/Button System.cpp b/Standard Gaming Platform/Button System.cpp index 1b0ba415..45e676e9 100644 --- a/Standard Gaming Platform/Button System.cpp +++ b/Standard Gaming Platform/Button System.cpp @@ -1578,6 +1578,8 @@ INT32 CreateIconButton(INT16 Icon,INT16 IconIndex,INT16 GenImg,INT16 xloc,INT16 return(-1); } + memset(b, 0, sizeof(GUI_BUTTON)); + // Init the values in the struct b->uiFlags = BUTTON_DIRTY; b->uiOldFlags = 0; @@ -1706,6 +1708,8 @@ INT32 CreateTextButton(STR16 string, UINT32 uiFont, INT16 sForeColor, INT16 sSha return(-1); } + memset(b, 0, sizeof(GUI_BUTTON)); + // Allocate memory for the button's text string... b->string = NULL; if ( string && wcslen( string ) ) @@ -1836,6 +1840,8 @@ INT32 CreateHotSpot(INT16 xloc, INT16 yloc, INT16 Width, INT16 Height,INT16 Prio return(-1); } + memset(b, 0, sizeof(GUI_BUTTON)); + // Init the structure values b->uiFlags = 0; b->uiOldFlags = 0; @@ -1955,6 +1961,8 @@ INT32 QuickCreateButton(UINT32 Image,INT16 xloc,INT16 yloc,INT32 Type,INT16 Prio return(-1); } + memset(b, 0, sizeof(GUI_BUTTON)); + // Set the values for this buttn b->uiFlags = BUTTON_DIRTY; b->uiOldFlags = 0; @@ -2149,6 +2157,8 @@ INT32 CreateIconAndTextButton( INT32 Image, const STR16 string, UINT32 uiFont, return(-1); } + memset(b, 0, sizeof(GUI_BUTTON)); + // Set the values for this button b->uiFlags = BUTTON_DIRTY; b->uiOldFlags = 0; diff --git a/Standard Gaming Platform/Font.cpp b/Standard Gaming Platform/Font.cpp index 10d82beb..8b0d15ae 100644 --- a/Standard Gaming Platform/Font.cpp +++ b/Standard Gaming Platform/Font.cpp @@ -1283,6 +1283,8 @@ FontTranslationTable *CreateEnglishTransTable( ) UINT16 *temp; pTable = (FontTranslationTable *)MemAlloc(sizeof(FontTranslationTable)); + memset(pTable, 0, sizeof(FontTranslationTable) ); + #ifdef JA2 // ha ha, we have more than Wizardry now (again) pTable->usNumberOfSymbols = 255; diff --git a/Standard Gaming Platform/himage.cpp b/Standard Gaming Platform/himage.cpp index dcbc133d..0fc9a86e 100644 --- a/Standard Gaming Platform/himage.cpp +++ b/Standard Gaming Platform/himage.cpp @@ -348,6 +348,7 @@ BOOLEAN Copy8BPPCompressedImageTo8BPPBuffer( HIMAGE hImage, BYTE *pDestBuf, UINT // Allocate memory for one scanline pScanLine = (UINT8*) MemAlloc( hImage->usWidth ); CHECKF( pScanLine ); + memset( pScanLine, 0, hImage->usWidth ); // go past all the scanlines we don't need to process for (uiCnt = 0; uiCnt < (UINT32) srcRect->iTop; uiCnt++) @@ -436,6 +437,7 @@ BOOLEAN Copy8BPPCompressedImageTo16BPPBuffer( HIMAGE hImage, BYTE *pDestBuf, UIN // Allocate memory for one scanline pScanLine = MemAlloc( hImage->usWidth ); CHECKF( pScanLine ); + memset( pScanLine, 0, hImage->usWidth ); // go past all the scanlines we don't need to process for (uiLine = 0; uiLine < (UINT32) srcRect->iTop; uiLine++) @@ -650,6 +652,7 @@ UINT16 *Create16BPPPalette( SGPPaletteEntry *pPalette ) Assert( pPalette != NULL ); p16BPPPalette = (UINT16 *) MemAlloc( sizeof( UINT16 ) * 256 ); + memset( p16BPPPalette, 0, sizeof( UINT16 ) * 256 ); for ( cnt = 0; cnt < 256; cnt++ ) { @@ -723,6 +726,7 @@ UINT16 *Create16BPPPaletteShaded( SGPPaletteEntry *pPalette, UINT32 rscale, UINT Assert( pPalette != NULL ); p16BPPPalette = (UINT16 *) MemAlloc( sizeof( UINT16 ) * 256 ); + memset( p16BPPPalette, 0, sizeof( UINT16 ) * 256 ); for ( cnt = 0; cnt < 256; cnt++ ) { @@ -870,21 +874,24 @@ UINT32 GetRGBColor( UINT16 Value16BPP ) SGPPaletteEntry *ConvertRGBToPaletteEntry(UINT8 sbStart, UINT8 sbEnd, UINT8 *pOldPalette) { UINT16 Index; - SGPPaletteEntry *pPalEntry; + SGPPaletteEntry *pPalEntry; SGPPaletteEntry *pInitEntry; pPalEntry = (SGPPaletteEntry *)MemAlloc(sizeof(SGPPaletteEntry) * 256); + memset( pPalEntry, 0, sizeof(SGPPaletteEntry) * 256 ); pInitEntry = pPalEntry; - DbgMessage(TOPIC_HIMAGE, DBG_LEVEL_0, "Converting RGB palette to SGPPaletteEntry"); - for(Index=0; Index <= (sbEnd-sbStart);Index++) - { - pPalEntry->peRed = *(pOldPalette + (Index*3)); - pPalEntry->peGreen = *(pOldPalette + (Index*3) + 1); - pPalEntry->peBlue = *(pOldPalette + (Index*3) + 2); - pPalEntry->peFlags = 0; - pPalEntry++; - } - return pInitEntry; + + DbgMessage(TOPIC_HIMAGE, DBG_LEVEL_0, "Converting RGB palette to SGPPaletteEntry"); + + for(Index=0; Index <= (sbEnd-sbStart);Index++) + { + pPalEntry->peRed = *(pOldPalette + (Index*3)); + pPalEntry->peGreen = *(pOldPalette + (Index*3) + 1); + pPalEntry->peBlue = *(pOldPalette + (Index*3) + 2); + pPalEntry->peFlags = 0; + pPalEntry++; + } + return pInitEntry; } BOOLEAN GetETRLEImageData( HIMAGE hImage, ETRLEData *pBuffer ) @@ -899,6 +906,7 @@ BOOLEAN GetETRLEImageData( HIMAGE hImage, ETRLEData *pBuffer ) // Create buffer for objects pBuffer->pETRLEObject = (ETRLEObject *) MemAlloc( sizeof( ETRLEObject ) * pBuffer->usNumberOfObjects ); CHECKF( pBuffer->pETRLEObject != NULL ); + memset( pBuffer->pETRLEObject, 0, sizeof( ETRLEObject ) * pBuffer->usNumberOfObjects ); // Copy into buffer memcpy( pBuffer->pETRLEObject, hImage->pETRLEObject, sizeof( ETRLEObject ) * pBuffer->usNumberOfObjects ); @@ -906,6 +914,7 @@ BOOLEAN GetETRLEImageData( HIMAGE hImage, ETRLEData *pBuffer ) // Allocate memory for pixel data pBuffer->pPixData = MemAlloc( hImage->uiSizePixData ); CHECKF( pBuffer->pPixData != NULL ); + memset( pBuffer->pPixData, 0, hImage->uiSizePixData ); pBuffer->uiSizePixData = hImage->uiSizePixData; diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 205f4e3a..05476c99 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -2982,7 +2982,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) { if ( (gWorldItems[ uiLoop ].bVisible == TRUE) && (gWorldItems[ uiLoop ].fExists) && (gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_REACHABLE) && !(gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_ARMED_BOMB) && (gWorldItems[ uiLoop ].sGridNo != pSoldier->sGridNo) )//item exists and is reachable and is not already on soldiers tile { - MoveItemPools(gWorldItems[ uiLoop ].sGridNo, pSoldier->sGridNo, gWorldItems[ uiLoop ].ubLevel, pSoldier->bLevel); + MoveItemPools(gWorldItems[ uiLoop ].sGridNo, pSoldier->sGridNo, gWorldItems[ uiLoop ].ubLevel, pSoldier->bLevel); } }