From bd59b2fcba92c86f1953fc740688ba4a7c81e25a Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 24 Apr 2016 19:59:25 +0000 Subject: [PATCH] - Fix: UB cannot be compiled - Fixed a few compiler warnings git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8176 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/BriefingRoomM.cpp | 5 ++--- MessageBoxScreen.cpp | 2 +- Strategic/Ja25 Strategic Ai.cpp | 16 +++++++--------- Strategic/Ja25 Strategic Ai.h | 6 ++---- Tactical/Civ Quotes.cpp | 1 - Tactical/Interface Items.cpp | 11 +++++------ Tactical/Merc Entering.cpp | 2 +- Tactical/SkillMenu.cpp | 2 +- Tactical/Soldier Control.cpp | 2 +- Tactical/Soldier Create.cpp | 6 ------ Tactical/Turn Based Input.cpp | 4 ++-- Tactical/VehicleMenu.cpp | 2 +- Tactical/XML_Disease.cpp | 2 +- Tactical/merc entering.h | 2 +- TileEngine/Exit Grids.cpp | 11 +++++------ TileEngine/Exit Grids.h | 2 +- 16 files changed, 31 insertions(+), 45 deletions(-) diff --git a/Laptop/BriefingRoomM.cpp b/Laptop/BriefingRoomM.cpp index 7ab81d95..5ee58eef 100644 --- a/Laptop/BriefingRoomM.cpp +++ b/Laptop/BriefingRoomM.cpp @@ -248,7 +248,7 @@ void RenderBriefingRoomEnter() HVOBJECT hContentButtonHandle; UINT16 usWidth=0; - HVOBJECT hHandle; + //HVOBJECT hHandle; DrawBriefingRoomEnterDefaults(); @@ -385,8 +385,7 @@ BOOLEAN DisplayBriefingRoomEnterCopyright() void DisplayPlayerActivationBriefingRoomEnterString( void ) { - -HVOBJECT hHandle; + //HVOBJECT hHandle; // this function will grab the string that the player will enter for activation diff --git a/MessageBoxScreen.cpp b/MessageBoxScreen.cpp index fb13239d..a7a239bf 100644 --- a/MessageBoxScreen.cpp +++ b/MessageBoxScreen.cpp @@ -1144,7 +1144,7 @@ UINT32 ExitMsgBox( INT8 ubExitCode ) { UINT32 uiDestPitchBYTES, uiSrcPitchBYTES; UINT8 *pDestBuf, *pSrcBuf; - SGPPoint pPosition; + //SGPPoint pPosition; // Delete popup! RemoveMercPopupBoxFromIndex( gMsgBox.iBoxId ); diff --git a/Strategic/Ja25 Strategic Ai.cpp b/Strategic/Ja25 Strategic Ai.cpp index 680fdb07..ef6fe149 100644 --- a/Strategic/Ja25 Strategic Ai.cpp +++ b/Strategic/Ja25 Strategic Ai.cpp @@ -124,15 +124,14 @@ JA25_SECTOR_AI_MANAGER gJa25StrategicAi; BOOLEAN AddEnemiesToInitialSectorH7(); UINT32 GetNumberOfJA25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 *pNumAdmins, UINT8 *pNumTroops, UINT8 *pNumElites, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); -void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); +void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubNumJeeps ); -void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); void InitJa25InitialEnemiesInSector(); void InitJa25UnderGroundSectors(); void InitNumberOfEnemiesInAboveGroundSectors( ); void InitNumberOfEnemiesInUnderGroundSectors( ); void SetNumberOfJa25BloodCatsInSector( INT32 iSectorID, INT8 bNumBloodCats, INT8 bBloodCatPlacements ); -void SetNumberJa25EnemiesInUnderGroundSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); +void SetNumberJa25EnemiesInUnderGroundSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubNumJeeps ); void ResetJa25SectorProbabilities(); BOOLEAN InitJa25StrategicSectorAI( BOOLEAN fReset ); @@ -427,16 +426,14 @@ void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ } -void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ) +void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubNumJeeps ) { - SECTORINFO *pSector; - - pSector = &SectorInfo[ iSectorID ]; + SECTORINFO* pSector = &SectorInfo[iSectorID]; pSector->ubNumAdmins = ubNumAdmins; pSector->ubNumTroops = ubNumTroops; pSector->ubNumElites = ubNumElites; pSector->ubNumTanks = ubNumTanks; - pSector->ubNumJeeps = ubJeeps; + pSector->ubNumJeeps = ubNumJeeps; } void SetNumberOfJa25BloodCatsInSector( INT32 iSectorID, INT8 bNumBloodCats, INT8 bBloodCatPlacements ) @@ -449,7 +446,7 @@ void SetNumberOfJa25BloodCatsInSector( INT32 iSectorID, INT8 bNumBloodCats, INT8 pSector->bBloodCatPlacements = bBloodCatPlacements; } -void SetNumberJa25EnemiesInUnderGroundSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks ) +void SetNumberJa25EnemiesInUnderGroundSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubNumJeeps ) { UNDERGROUND_SECTORINFO *pSector=NULL; @@ -461,6 +458,7 @@ void SetNumberJa25EnemiesInUnderGroundSector( INT16 sSectorX, INT16 sSectorY, IN pSector->ubNumTroops = ubNumTroops; pSector->ubNumElites = ubNumElites; pSector->ubNumTanks = ubNumTanks; + pSector->ubNumJeeps = ubNumJeeps; } void InitNumberOfEnemiesInAboveGroundSectors( ) diff --git a/Strategic/Ja25 Strategic Ai.h b/Strategic/Ja25 Strategic Ai.h index 832aa3c2..a329bfdf 100644 --- a/Strategic/Ja25 Strategic Ai.h +++ b/Strategic/Ja25 Strategic Ai.h @@ -188,12 +188,12 @@ BOOLEAN ShouldEnemiesBeAddedToInitialSector(); void InitJa25StrategicAi(); -extern void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); +void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); void InitJa25SaveStruct(); void InitJa25StrategicAiBloodcats( ); -extern void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); +void SetNumberJa25EnemiesInSurfaceSector( INT32 iSectorID, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubNumJeeps ); BOOLEAN SaveJa25SaveInfoToSaveGame( HWFILE hFile ); BOOLEAN LoadJa25SaveInfoFromSavedGame( HWFILE hFile ); @@ -305,7 +305,6 @@ enum extern BOOLEAN gfEnemyShouldImmediatelySeekThePlayer; //extern INT32 giNumJA25Sectors; -extern void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); void SetJa25SectorOwnedStatus( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, BOOLEAN fPlayerOwned ); INT8 GetTheFurthestSectorPlayerOwns(); void Ja25_UpdateTimeOfEndOfLastBattle( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ); @@ -317,7 +316,6 @@ void JA25_HandleUpdateOfStrategicAi(); void SetEnemiesToFindThePlayerMercs(); void HandleSayingDontStayToLongWarningInSectorH8(); -extern void SetNumberJa25EnemiesInSector( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks, UINT8 ubJeeps ); #ifdef JA2BETAVERSION BOOLEAN InitJa25StrategicAiDecisions( BOOLEAN fLoadedGame ); diff --git a/Tactical/Civ Quotes.cpp b/Tactical/Civ Quotes.cpp index 90d95838..eb1befa4 100644 --- a/Tactical/Civ Quotes.cpp +++ b/Tactical/Civ Quotes.cpp @@ -498,7 +498,6 @@ UINT16 DetermineCivQuoteEntry( SOLDIERTYPE *pCiv, UINT16 *pubCivHintToUse, BOOLE BOOLEAN bCivHighLoyalty = FALSE; BOOLEAN bMiners = FALSE; - UINT16 iCounter2; UINT16 FileEDTQUoteID; (*pubCivHintToUse) = 0; diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 49a4f7a7..836bee44 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -4361,7 +4361,6 @@ void INVRenderItem( UINT32 uiBuffer, SOLDIERTYPE * pSoldier, OBJECTTYPE *pObjec void INVRenderSteeringWheel( UINT32 uiBuffer, UINT32 uiSteeringWheelIndex, SOLDIERTYPE *pSoldier, INT16 sX, INT16 sY, INT16 sWidth, INT16 sHeight, UINT8 fDirtyLevel ) { SOLDIERTYPE *pVehicle = NULL; - UINT32 usHeight, usWidth; INT16 sNewY, sNewX; static CHAR16 pStr[ 100 ], pStr2[ 100 ]; @@ -7585,16 +7584,16 @@ void RenderItemDescriptionBox( ) { if ( !Weapon[gpComparedItemDescObject->usItem].NoSemiAuto ) { - UINT8 ubComparedAttackAPs = BaseAPsToShootOrStab( APBPConstants[DEFAULT_APS], APBPConstants[DEFAULT_AIMSKILL], gpComparedItemDescObject, NULL ); - if( ubComparedAttackAPs > ubAttackAPs ) + INT16 sComparedAttackAPs = BaseAPsToShootOrStab( APBPConstants[DEFAULT_APS], APBPConstants[DEFAULT_AIMSKILL], gpComparedItemDescObject, NULL ); + if ( sComparedAttackAPs > ubAttackAPs ) { SetFontForeground( ITEMDESC_FONTNEGATIVE ); - swprintf( pStr, L"+%2d", ubComparedAttackAPs - ubAttackAPs ); + swprintf( pStr, L"+%2d", sComparedAttackAPs - ubAttackAPs ); } - else if( ubComparedAttackAPs < ubAttackAPs ) + else if ( sComparedAttackAPs < ubAttackAPs ) { SetFontForeground( ITEMDESC_FONTPOSITIVE ); - swprintf( pStr, L"%2d", ubComparedAttackAPs - ubAttackAPs ); + swprintf( pStr, L"%2d", sComparedAttackAPs - ubAttackAPs ); } else swprintf( pStr, L"="); diff --git a/Tactical/Merc Entering.cpp b/Tactical/Merc Entering.cpp index 2342e674..69ff0711 100644 --- a/Tactical/Merc Entering.cpp +++ b/Tactical/Merc Entering.cpp @@ -1026,7 +1026,7 @@ void HandleFirstHeliDropOfGame( ) CharacterDialogueWithSpecialEvent( 0, 0, 0, DIALOGUE_TACTICAL_UI , FALSE , FALSE , DIALOGUE_SPECIAL_EVENT_ENABLE_AI ,0, 0 ); } -UINT16 SpawnAirDropElite( INT32 sGridNo ) +UINT8 SpawnAirDropElite( INT32 sGridNo ) { SOLDIERTYPE *pSoldier; diff --git a/Tactical/SkillMenu.cpp b/Tactical/SkillMenu.cpp index a992092e..a42a13ee 100644 --- a/Tactical/SkillMenu.cpp +++ b/Tactical/SkillMenu.cpp @@ -150,7 +150,7 @@ TraitSelection::Setup( UINT32 aVal ) INT16 sX, sY; // sevenfm: changed TraitsMenu position from soldier to mouse //GetSoldierScreenPos( pSoldier, &sX, &sY ); - GetGridNoScreenPos( sTraitsMenuTargetGridNo, gsInterfaceLevel, &sX, &sY ); + GetGridNoScreenPos( sTraitsMenuTargetGridNo, (UINT8)gsInterfaceLevel, &sX, &sY ); if( sX < 0 ) sX = 0; if( sY < 0 ) sY = 0; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 6b6b282b..3575c36e 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -22844,7 +22844,7 @@ void HandleVolunteerRecruitment( SOLDIERTYPE* pRecruiter, SOLDIERTYPE* pTarget ) // bonus for assertive characters if ( DoesMercHavePersonality( pRecruiter, CHAR_TRAIT_ASSERTIVE ) ) - leadershipfactor *= 1.05; + leadershipfactor *= 1.05f; FLOAT recruitmodifier = (100 + pRecruiter->GetBackgroundValue( BG_PERC_APPROACH_RECRUIT )) / 100.0f; diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index f9e810b3..6457f164 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -4161,12 +4161,6 @@ UINT8 GetLocationModifier( UINT8 ubSoldierClass ) { UINT8 ubLocationModifier = 0; INT16 sSectorX, sSectorY, sSectorZ; - #ifdef JA2UB - #else - //INT8 bTownId; - //UINT8 ubPalaceDistance; - #endif - BOOLEAN fSuccess; // Flugente: why do we always crash the game if something does not work? // where is all this taking place? diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 97f6d071..44637192 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -3093,7 +3093,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) GetMouseMapPos( &sGridNo ); // a node to add a structure - AddFortificationPlanNode( sGridNo, gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, TRUE ); + AddFortificationPlanNode( sGridNo, (INT8)gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, TRUE ); } else if ( fAlt ) { @@ -3145,7 +3145,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) GetMouseMapPos( &sGridNo ); // a node to delete a structure - AddFortificationPlanNode( sGridNo, gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, FALSE ); + AddFortificationPlanNode( sGridNo, (INT8)gsInterfaceLevel, gCurrentFortificationStructure, gCurrentFortificationTileLibraryIndex, FALSE ); } else { diff --git a/Tactical/VehicleMenu.cpp b/Tactical/VehicleMenu.cpp index 072baa63..c5cb8e3c 100644 --- a/Tactical/VehicleMenu.cpp +++ b/Tactical/VehicleMenu.cpp @@ -132,7 +132,7 @@ VehicleSelection::Setup( UINT32 aVal ) // grab soldier's x,y screen position INT16 sX, sY; - GetGridNoScreenPos( sVehicleMenuTargetGridNo, gsInterfaceLevel, &sX, &sY ); + GetGridNoScreenPos( sVehicleMenuTargetGridNo, (UINT8)gsInterfaceLevel, &sX, &sY ); if( sX < 0 ) sX = 0; if( sY < 0 ) sY = 0; diff --git a/Tactical/XML_Disease.cpp b/Tactical/XML_Disease.cpp index d4752624..30ee6b28 100644 --- a/Tactical/XML_Disease.cpp +++ b/Tactical/XML_Disease.cpp @@ -154,7 +154,7 @@ diseaseEndElementHandle( void *userData, const XML_Char *name ) else if ( strcmp( name, "uiIndex" ) == 0 ) { pData->curElement = ELEMENT; - pData->curItem.uiIndex = (UINT16)atol( pData->szCharData ); + pData->curItem.uiIndex = (UINT8)atol( pData->szCharData ); } else if ( strcmp( name, "szName" ) == 0 ) { diff --git a/Tactical/merc entering.h b/Tactical/merc entering.h index bb98e971..8043d1b1 100644 --- a/Tactical/merc entering.h +++ b/Tactical/merc entering.h @@ -14,7 +14,7 @@ void StartHelicopterRun(); void HandleHeliDrop( BOOLEAN fPlayer = TRUE ); -UINT16 SpawnAirDropElite( INT32 sGridNo ); +UINT8 SpawnAirDropElite( INT32 sGridNo ); void InitiateEnemyAirDropSoldiers( INT32 sGridNo ); void HandleEnemyAirdrop( ); diff --git a/TileEngine/Exit Grids.cpp b/TileEngine/Exit Grids.cpp index d5cbf429..091ded53 100644 --- a/TileEngine/Exit Grids.cpp +++ b/TileEngine/Exit Grids.cpp @@ -511,7 +511,7 @@ INT32 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT32 sSwee } } -INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadius ) +INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT16 ubRadius ) { INT16 sTop, sBottom; INT16 sLeft, sRight; @@ -522,9 +522,8 @@ INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadiu INT32 leftmost; BOOLEAN fFound = FALSE; EXITGRID ExitGrid; - - - sTop = ubRadius; + + sTop = ubRadius; sBottom = -ubRadius; sLeft = - ubRadius; sRight = ubRadius; @@ -532,11 +531,11 @@ INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadiu //clear the mapelements of potential residue MAPELEMENT_REACHABLE flags uiLowestRange = 999999; - for( cnt1 = sBottom; cnt1 <= sTop; cnt1++ ) + for( cnt1 = sBottom; cnt1 <= sTop; ++cnt1 ) { leftmost = ( ( sSrcGridNo + ( WORLD_COLS * cnt1 ) )/ WORLD_COLS ) * WORLD_COLS; - for( cnt2 = sLeft; cnt2 <= sRight; cnt2++ ) + for( cnt2 = sLeft; cnt2 <= sRight; ++cnt2 ) { sGridNo = sSrcGridNo + ( WORLD_COLS * cnt1 ) + cnt2; if( sGridNo >=0 && sGridNo < WORLD_MAX && sGridNo >= leftmost && sGridNo < ( leftmost + WORLD_COLS ) ) diff --git a/TileEngine/Exit Grids.h b/TileEngine/Exit Grids.h index ce861144..1a35a721 100644 --- a/TileEngine/Exit Grids.h +++ b/TileEngine/Exit Grids.h @@ -51,6 +51,6 @@ extern BOOLEAN gfShowExitGrids;//dnl ch86 190214 // Finds closest ExitGrid of same type as is at gridno, within a radius. Checks // valid paths, destinations, etc. INT32 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT32 sSweetGridNo, INT8 ubRadius, UINT8 *pubDirection ); -INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT8 ubRadius ); +INT32 FindClosestExitGrid( SOLDIERTYPE *pSoldier, INT32 sSrcGridNo, INT16 ubRadius ); #endif