Initialized many variables

Fix for enemy invasions and reinforcements


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1192 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-08-13 03:39:54 +00:00
parent ca8cb7b89a
commit 6ec2c5da7d
79 changed files with 2621 additions and 2584 deletions
+1
View File
@@ -548,6 +548,7 @@ void MapInfoEntryPointsCallback( GUI_BUTTON *btn, INT32 reason )
case MAPINFO_SOUTH_POINT: sGridNo = gMapInformation.sSouthGridNo; break;
case MAPINFO_CENTER_POINT: sGridNo = gMapInformation.sCenterGridNo; break;
case MAPINFO_ISOLATED_POINT: sGridNo = gMapInformation.sIsolatedGridNo; break;
default: AssertMsg( 0, "Invalid mapinfo point"); sGridNo = -1; break;
}
if( sGridNo != -1 )
{
+1 -1
View File
@@ -227,7 +227,7 @@ void CopyBuilding( INT32 iMapIndex )
//This will prevent overlapping problems.
void SortBuildingLayout( INT32 iMapIndex )
{
BUILDINGLAYOUTNODE *head, *curr, *prev, *prevBest, *best;
BUILDINGLAYOUTNODE *head, *curr, *prev, *prevBest = NULL, *best = NULL;
INT32 iBestIndex;
head = NULL;
if( iMapIndex < gsBuildingLayoutAnchorGridNo )
+1 -1
View File
@@ -80,7 +80,7 @@ ITEM_POOL *gpItemPool = NULL;
void BuildItemPoolList()
{
ITEM_POOL *temp;
IPListNode *tail;
IPListNode *tail = NULL;
UINT16 i;
KillItemPoolList();
for( i = 0; i < WORLD_MAX; i++ )
+9 -4
View File
@@ -1182,9 +1182,7 @@ void EditMercIncDifficultyCallback(GUI_BUTTON *btn,INT32 reason)
//
void ShowEditMercPalettes( SOLDIERTYPE *pSoldier )
{
UINT8 ubPaletteRep;
if( !pSoldier )
ubPaletteRep = 0xff;
UINT8 ubPaletteRep = 0xff;
if( pSoldier )
{
@@ -2020,7 +2018,13 @@ void ChangeBodyType( INT8 bOffset ) //+1 or -1 only
pbArray = bCivArray;
iMax = MAX_CIVTYPES;
break;
default:
AssertMsg( 0, "Unknown team");
return;
}
iIndex = -1;
//find the matching bodytype index within the array.
for( x = 0; x < iMax; x++ )
{
@@ -3423,7 +3427,7 @@ void UpdateScheduleAction( UINT8 ubNewAction )
// 0:1A, 1:1B, 2:2A, 3:2B, ...
void FindScheduleGridNo( UINT8 ubScheduleData )
{
INT32 iMapIndex;
INT32 iMapIndex = 0xffff;
switch( ubScheduleData )
{
case 0: //1a
@@ -3452,6 +3456,7 @@ void FindScheduleGridNo( UINT8 ubScheduleData )
break;
default:
AssertMsg( 0, "FindScheduleGridNo passed incorrect dataID." );
return;
}
if( iMapIndex != 0xffff )
{
+2 -1
View File
@@ -46,8 +46,9 @@
RuntimeLibrary="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
WarningLevel="4"
DebugInformationFormat="4"
DisableSpecificWarnings="4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
+4 -2
View File
@@ -1256,7 +1256,7 @@ void ToggleAttachment( GUI_BUTTON *btn, INT32 reason )
if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
{
INT32 i;
UINT16 usAttachment;
UINT16 usAttachment = 0;
OBJECTTYPE temp;
for( i = 0; i < NUM_ATTACHMENT_BUTTONS; i++ )
{ //Loop through and find the button that was just modified
@@ -1268,6 +1268,7 @@ void ToggleAttachment( GUI_BUTTON *btn, INT32 reason )
case 3: usAttachment = BIPOD; break;
case 4: usAttachment = DUCKBILL; break;
case 5: usAttachment = UNDER_GLAUNCHER; break;
default: Assert(0); continue;
}
if( guiAttachmentButton[ i ] != -1 && btn == ButtonList[ guiAttachmentButton[ i ] ] )
{ //Found it, now check the state of the button.
@@ -1515,7 +1516,7 @@ void UpdateActionItem( INT8 bActionItemIndex )
void ReEvaluateAttachmentStatii()
{
INT32 i;
UINT16 usAttachment;
UINT16 usAttachment = 0;
for( i = 0; i < NUM_ATTACHMENT_BUTTONS; i++ )
{
if( guiAttachmentButton[ i ] != -1 && !( ButtonList[ guiAttachmentButton[ i ] ]->uiFlags & BUTTON_CLICKED_ON ) )
@@ -1528,6 +1529,7 @@ void ReEvaluateAttachmentStatii()
case 3: usAttachment = BIPOD; break;
case 4: usAttachment = DUCKBILL; break;
case 5: usAttachment = UNDER_GLAUNCHER; break;
default: Assert(0); continue;
}
if( ValidItemAttachment( gpItem, usAttachment, TRUE ) )
EnableButton( guiAttachmentButton[ i ] );
+7 -25
View File
@@ -1067,31 +1067,13 @@ BOOLEAN ExtractFilenameFromFields()
BOOLEAN ValidCoordinate()
{
if( gzFilename[0] >= 'A' && gzFilename[0] <= 'P' ||
gzFilename[0] >= 'a' && gzFilename[0] <='p' )
{
UINT16 usTotal;
if( gzFilename[1] == '1' && gzFilename[2] >= '0' && gzFilename[2] <= '6' )
{
usTotal = ( gzFilename[1] - 0x30 ) * 10 + ( gzFilename[2] - 0x30 );
}
else if( gzFilename[1] >= '1' && gzFilename[1] <= '9')
{
if( gzFilename[2] < '0' || gzFilename[2] > '9' )
{
usTotal = ( gzFilename[1] - 0x30 );
}
else
{
return FALSE;
}
}
if( usTotal >= 1 && usTotal <= 16 )
{
return TRUE;
}
}
return FALSE;
CHAR16 sectorY = 0;
UINT16 sectorX = 0;
swscanf( gzFilename, L"%c%2hd", &sectorY, &sectorX);
sectorY = towupper( sectorY);
return ( sectorY >= 'A' && sectorY <= 'P' &&
sectorX >= 1 && sectorX <= 16);
}
BOOLEAN ValidFilename()
+2 -2
View File
@@ -541,7 +541,7 @@ void PasteStructure2( UINT32 iMapIndex )
//
void PasteStructureCommon( UINT32 iMapIndex )
{
BOOLEAN fDoPaste = FALSE;
// BOOLEAN fDoPaste = FALSE;
UINT32 fHeadType;
UINT16 usUseIndex;
UINT16 usUseObjIndex;
@@ -1181,13 +1181,13 @@ void RaiseWorldLand( )
if (pTileElement->fType==FIRSTCLIFF)
{
fSomethingRaised = TRUE;
usIndex=pStruct->usIndex;
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff found at count=%d",cnt));
if( pTileElement->ubNumberOfTiles > 1 )
{
// DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("Cliff has %d children", pTileElement->ubNumberOfTiles));
for (ubLoop = 0; ubLoop < pTileElement->ubNumberOfTiles; ubLoop++)
{
usIndex=pStruct->usIndex;
// need means to turn land raising on and off based on the tile ID and the offset in the
// tile database when reading into the mapsystem
// turning off of land raising can only be done
+3 -3
View File
@@ -2809,9 +2809,9 @@ BOOLEAN RemoveLight( INT16 iMapX, INT16 iMapY )
SOLDIERTYPE *pSoldier;
BOOLEAN fSoldierLight;
BOOLEAN fRemovedLight;
INT32 iMapIndex;
UINT32 uiLastLightType;
UINT8 *pLastLightName;
INT32 iMapIndex = 0;
UINT32 uiLastLightType = 0;
UINT8 *pLastLightName = NULL;
fRemovedLight = FALSE;
+13 -4
View File
@@ -217,6 +217,9 @@ UINT16 GetCaveTileIndexFromPerimeterValue( UINT8 ubTotal )
case 0xff:
usIndex = 60 + (UINT16)Random( 6 );
break;
default:
AssertMsg(0, "Invalid total given");
return 0xffff;
}
GetTileIndexFromTypeSubIndex( usType, usIndex, &usTileIndex );
return usTileIndex;
@@ -447,6 +450,7 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
switch( ubWallPiece )
{
case EXTERIOR_TOP:
ubWallClass = EXTERIOR_L;
iMapIndex -= WORLD_COLS;
//exterior bottom left corner generated
if ( !gfBasement && GetVerticalWall( iMapIndex - 1) && !GetVerticalWall( iMapIndex + WORLD_COLS - 1) )
@@ -464,7 +468,6 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
GetTileIndexFromTypeSubIndex( usWallType, sIndex, &usTileIndex );
ReplaceStructIndex( iMapIndex, pStruct->usIndex, usTileIndex );
}
ubWallClass = EXTERIOR_L;
if( !gfBasement )
{
//All exterior_l walls have shadows.
@@ -483,8 +486,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
}
break;
case EXTERIOR_LEFT:
iMapIndex--;
ubWallClass = EXTERIOR_R;
iMapIndex--;
if( GetHorizontalWall( iMapIndex ) )
{ //Special case where placing the new wall will generate a corner. This piece
//becomes an exterior bottomend, but nothing else is effected.
@@ -510,8 +513,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
}
break;
case INTERIOR_TOP:
iMapIndex -= WORLD_COLS;
ubWallClass = INTERIOR_L;
iMapIndex -= WORLD_COLS;
//check for a lower left corner.
if( pStruct = GetVerticalWall( iMapIndex + WORLD_COLS - 1 ) )
{ //Replace the piece with an extended piece.
@@ -554,8 +557,8 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
}
break;
case INTERIOR_LEFT:
iMapIndex--;
ubWallClass = INTERIOR_R;
iMapIndex--;
if( GetHorizontalWall( iMapIndex ) )
{
ubWallClass = INTERIOR_BOTTOMEND;
@@ -595,6 +598,10 @@ void BuildWallPiece( UINT32 iMapIndex, UINT8 ubWallPiece, UINT16 usWallType )
AddExclusiveShadow( iMapIndex, usTileIndex );
}
break;
default:
AssertMsg( 0, "Invalid wall piece");
return;
}
sIndex = PickAWallPiece( ubWallClass );
GetTileIndexFromTypeSubIndex( usWallType, sIndex, &usTileIndex );
@@ -980,6 +987,8 @@ void AddBuildingSectionToWorld( SGPRect *pSelectRegion )
//change the floor for say a kitchen which might have a different floor type.
usWallType = GetRandomIndexByRange( FIRSTWALL, LASTWALL );
usFloorType = GetRandomIndexByRange( FIRSTFLOOR, LASTFLOOR );
usRoofType = 0xffff;
if( usWallType == 0xffff && usFloorType != 0xffff )
{ //allow user to place floors
for( y = top; y <= bottom; y++ ) for( x = left; x <= right; x++ )
+3
View File
@@ -125,6 +125,9 @@ void InitPopupMenu( INT32 iButtonID, UINT8 ubPopupMenuID, UINT8 ubDirection )
usX = button->Area.RegionBottomRightX;
usY = button->Area.RegionBottomRightY;
break;
default:
AssertMsg(0, "Invalid direction given");
return;
}
//Decipher the popupMenuID
+15 -14
View File
@@ -346,6 +346,10 @@ void CreateJA2SelectionWindow( INT16 sWhat )
pSelList = SelRoom;
pNumSelList = &iNumRoomsSelected;
break;
default:
// If none of these, don't create anything!
AssertMsg( 0, "Unknown window creation type");
return;
}
BuildDisplayWindow( pDSpec, usNSpecs, &pDispList, &SelWinStartPoint, &SelWinEndPoint,
@@ -1086,21 +1090,19 @@ void DisplaySelectionWindowGraphicalInformation()
//
void AddToSelectionList( DisplayList *pNode )
{
INT32 iIndex, iUseIndex;
BOOLEAN fDone;
INT32 iIndex, iUseIndex = -1;
fDone = FALSE;
for (iIndex = 0; iIndex < (*pNumSelList) && !fDone; iIndex++ )
for (iIndex = 0; iIndex < (*pNumSelList); iIndex++ )
{
if ( pNode->uiObjIndx == pSelList[ iIndex ].uiObject &&
pNode->uiIndex == pSelList[ iIndex ].usIndex )
{
fDone = TRUE;
iUseIndex = iIndex;
break;
}
}
if ( fDone )
if ( iUseIndex >= 0 )
{
// Was already in the list, so bump up the count
pSelList[ iUseIndex ].sCount++;
@@ -1158,26 +1160,25 @@ BOOLEAN ClearSelectionList( void )
//
BOOLEAN RemoveFromSelectionList( DisplayList *pNode )
{
INT32 iIndex, iUseIndex;
BOOLEAN fDone, fRemoved;
INT32 iIndex, iUseIndex = -1;
BOOLEAN fRemoved;
// Abort if no entries in list (pretend we removed a node)
if ( (*pNumSelList) <= 0 )
return( TRUE );
fRemoved = FALSE;
fDone = FALSE;
for (iIndex = 0; iIndex < (*pNumSelList) && !fDone; iIndex++ )
for (iIndex = 0; iIndex < (*pNumSelList); iIndex++ )
{
if ( pNode->uiObjIndx == pSelList[ iIndex ].uiObject &&
pNode->uiIndex == pSelList[ iIndex ].usIndex )
{
fDone = TRUE;
iUseIndex = iIndex;
break;
}
}
if ( fDone )
if ( iUseIndex >= 0 )
{
// Was already in the list, so bump up the count
pSelList[ iUseIndex ].sCount--;
@@ -1613,7 +1614,7 @@ BOOLEAN DisplayWindowFunc( DisplayList *pNode, INT16 iTopCutOff, INT16 iBottomCu
fReturnVal = FALSE;
if (DisplayWindowFunc(pNode->pNext, iTopCutOff, iBottomCutOff, pUpperLeft, fFlags))
{
iCurrY = pUpperLeft->iY + pNode->iY - iTopCutOff;
iCurrY = (INT16) pUpperLeft->iY + pNode->iY - iTopCutOff;
if ( iCurrY > iBottomCutOff )
return(TRUE);