From b25a4be4e76abef83f0bb62d0a9a00165e366bc2 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 30 May 2020 14:26:16 +0000 Subject: [PATCH] Fix: compiler warnings git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8814 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/DropDown.cpp | 4 +-- Laptop/DynamicDialogueWidget.cpp | 6 ++-- Laptop/Intelmarket.cpp | 10 ++---- Standard Gaming Platform/FileMan.cpp | 2 -- Strategic/Assignments.cpp | 5 +-- Strategic/Creature Spreading.cpp | 1 - Strategic/Map Screen Interface Map.cpp | 44 ++++++++++++-------------- Strategic/Town Militia.cpp | 2 +- Tactical/Handle Items.cpp | 2 +- Tactical/Interface Enhanced.cpp | 4 +-- Tactical/Overhead.cpp | 3 +- Tactical/Soldier Control.cpp | 27 ++++++---------- Tactical/Soldier Control.h | 4 +-- Tactical/Soldier Init List.cpp | 1 - screenids.h | 2 +- 15 files changed, 49 insertions(+), 68 deletions(-) diff --git a/Laptop/DropDown.cpp b/Laptop/DropDown.cpp index 3cb70c46..3502c20f 100644 --- a/Laptop/DropDown.cpp +++ b/Laptop/DropDown.cpp @@ -95,8 +95,8 @@ DropDownBase::Init( UINT16 sX, UINT16 sY ) mFirstShownEntry = max( 0, min( mFirstShownEntry, mEntryVector.size( ) - 1 - mNumDisplayedEntries ) ); musWidth = 0; - UINT16 size = mEntryVector.size( ); - for ( UINT16 i = 0; i < size; ++i ) + size_t size = mEntryVector.size(); + for ( size_t i = 0; i < size; ++i ) { musWidth = max( musWidth, StringPixLength( mEntryVector[i].second, DEF_DROPDOWN_FONT ) ); } diff --git a/Laptop/DynamicDialogueWidget.cpp b/Laptop/DynamicDialogueWidget.cpp index f7395443..0b8d44d9 100644 --- a/Laptop/DynamicDialogueWidget.cpp +++ b/Laptop/DynamicDialogueWidget.cpp @@ -439,8 +439,7 @@ IMPDialogueChooseBox::Init( UINT16 sX, UINT16 sY ) musWidth = 0; - UINT16 size = mEntryVector.size( ); - for ( UINT16 i = 0; i < size; ++i ) + for ( size_t i = 0, size = mEntryVector.size(); i < size; ++i ) { musWidth = max( musWidth, StringPixLength( mEntryVector[i].second, MYBOX_FONT_DEF ) ); } @@ -463,8 +462,7 @@ IMPDialogueChooseBox::Create( UINT16 sX, UINT16 sY ) sY += IMPDIALOGUECHOOSEBOX_BAR_Y_OFFSET; - UINT16 size = mEntryVector.size( ); - for ( UINT16 i = 0; i < size; ++i ) + for ( size_t i = 0, size = mEntryVector.size(); i < size; ++i ) { if ( !mChoiceRegionDefined[i] ) { diff --git a/Laptop/Intelmarket.cpp b/Laptop/Intelmarket.cpp index 6cb40877..f4568cca 100644 --- a/Laptop/Intelmarket.cpp +++ b/Laptop/Intelmarket.cpp @@ -132,11 +132,7 @@ void DisplayDefaults_IM() GetVideoObject( &hPixHandle, guiMercCompareLogoImage ); SetFontShadow( MERCOMP_FONT_SHADOW ); - - CHAR16 sText[800]; - UINT16 usPosX = CAMPAIGN_HISTORY_LINK_START_X; - UINT16 usPosY = CAMPAIGN_HISTORY_LINK_START_Y; - + WebPageTileBackground( 4, 4, BACKGROUND_WIDTH, CAMPAIGN_HISTORY_BACKGROUND_HEIGHT, guiInsuranceBackGround ); //Display the title slogan @@ -145,8 +141,8 @@ void DisplayDefaults_IM() //Display the subtitle slogan DrawTextToScreen( szIntelWebsiteText[TEXT_INTEL_SUBTITLE], CAMPAIGN_HISTORY_SUBTITLE_X, CAMPAIGN_HISTORY_SUBTITLE_Y, 0, CAMPHIS_FONT_BIG, MERCOMP_FONT_COLOR, FONT_MCOLOR_BLACK, FALSE, 0 ); - usPosX = CAMPAIGN_HISTORY_LINK_START_X; - usPosY = CAMPAIGN_HISTORY_LINK_START_Y; + UINT16 usPosX = CAMPAIGN_HISTORY_LINK_START_X; + UINT16 usPosY = CAMPAIGN_HISTORY_LINK_START_Y; for ( int i = 0; i 0 ) - AddTransactionToPlayersBook( WORKERS_TRAINED, 0, GetWorldTotalMin( ), -(totalworkersadded * gGameExternalOptions.usWorkerTrainingCost) ); + INT32 totalcost = totalworkersadded * gGameExternalOptions.usWorkerTrainingCost; + if ( totalcost > 0 ) + AddTransactionToPlayersBook( WORKERS_TRAINED, 0, GetWorldTotalMin( ), -totalcost ); } // Flugente: fortification diff --git a/Strategic/Creature Spreading.cpp b/Strategic/Creature Spreading.cpp index 432d01d7..167cfc6b 100644 --- a/Strategic/Creature Spreading.cpp +++ b/Strategic/Creature Spreading.cpp @@ -771,7 +771,6 @@ void AddCreaturesToBattle( UINT8 ubNumYoungMales, UINT8 ubNumYoungFemales, UINT8 void AddCreaturesToBattle_Other( UINT8 ubNum ) { - INT32 iRandom; SOLDIERTYPE *pSoldier; MAPEDGEPOINTINFO MapEdgepointInfo = {}; UINT8 bDesiredDirection = 0; diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index af0f6939..2767bf8c 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -876,9 +876,9 @@ UINT32 DrawMap( void ) if ( DoesSamCoverSector( i, SECTOR( cnt, cnt2 ), &samworking ) && samworking ) { if ( i == 0 ) a = TRUE; - if ( i == 1 ) b = TRUE; - if ( i == 2 ) c = TRUE; - if ( i == 3 ) d = TRUE; + else if ( i == 1 ) b = TRUE; + else if ( i == 2 ) c = TRUE; + else if ( i == 3 ) d = TRUE; } } @@ -1016,14 +1016,11 @@ UINT32 DrawMap( void ) DrawTownMilitiaForcesOnMap( ); } - if ( ( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE || gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE_COLOURED_SAMS ) && !gfInChangeArrivalSectorMode ) + if ( is_networked //haydent (allow client to see map deployment bullseye) + || (( gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE || gusMapDisplayColourMode == MAP_DISPLAY_AIRSPACE_COLOURED_SAMS ) && !gfInChangeArrivalSectorMode ) ) { DrawBullseye(); } - else if(is_networked) - { - DrawBullseye();//haydent (allow client to see map deployment bullseye) - } } else { @@ -5924,8 +5921,9 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen4"); INT32 iCounter = 0, iNumberUnderControl = 0, iNumberOfGreens = 0, iNumberOfRegulars = 0, iNumberOfElites = 0, iTotalNumberOfTroops = 0; INT32 iNumberLeftOverGreen = 0, iNumberLeftOverRegular = 0, iNumberLeftOverElite = 0; INT16 sBaseSectorValue = 0, sCurrentSectorValue = 0; - INT16 sSectorX = 0, sSectorY = 0, sSector = 0; + INT16 sSectorX = 0, sSectorY = 0; INT16 sTotalSoFar = 0; + UINT8 usSector = 0; // how many sectors in the selected town do we control? iNumberUnderControl = GetTownSectorsUnderControl( ( INT8 ) sSelectedMilitiaTown ); @@ -6007,17 +6005,17 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen4"); if( !StrategicMap[ pTownLocationsList[ iCounter ] ].fEnemyControlled && !NumHostilesInSector( sSectorX, sSectorY, 0 ) ) { - sSector = SECTOR( sSectorX, sSectorY ); + usSector = SECTOR( sSectorX, sSectorY ); // distribute here - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ GREEN_MILITIA ] = ( UINT8 )( iNumberOfGreens / iNumberUnderControl ); - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] = ( UINT8 )( iNumberOfRegulars / iNumberUnderControl ); - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ ELITE_MILITIA ] = ( UINT8 )( iNumberOfElites / iNumberUnderControl ); + SectorInfo[usSector].ubNumberOfCivsAtLevel[ GREEN_MILITIA ] = ( UINT8 )( iNumberOfGreens / iNumberUnderControl ); + SectorInfo[usSector].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ] = ( UINT8 )( iNumberOfRegulars / iNumberUnderControl ); + SectorInfo[usSector].ubNumberOfCivsAtLevel[ ELITE_MILITIA ] = ( UINT8 )( iNumberOfElites / iNumberUnderControl ); // Flugente: indivdual militia - DropIndividualMilitia( sSector, GREEN_MILITIA, (UINT8)(iNumberOfGreens / iNumberUnderControl) ); - DropIndividualMilitia( sSector, REGULAR_MILITIA, (UINT8)(iNumberOfRegulars / iNumberUnderControl) ); - DropIndividualMilitia( sSector, ELITE_MILITIA, (UINT8)(iNumberOfElites / iNumberUnderControl) ); + DropIndividualMilitia( usSector, GREEN_MILITIA, (UINT8)(iNumberOfGreens / iNumberUnderControl) ); + DropIndividualMilitia( usSector, REGULAR_MILITIA, (UINT8)(iNumberOfRegulars / iNumberUnderControl) ); + DropIndividualMilitia( usSector, ELITE_MILITIA, (UINT8)(iNumberOfElites / iNumberUnderControl) ); // Flugente: as we do not move the group militia, we have to make sure we don't accidentally overfill a sector sTotalSoFar = NumNonPlayerTeamMembersInSector( sSectorX, sSectorY, MILITIA_TEAM ); @@ -6025,38 +6023,38 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Map Screen4"); // add leftovers that weren't included in the div operation if( ( iNumberLeftOverGreen ) && ( sTotalSoFar < iMaxMilitiaPerSector ) ) { - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ GREEN_MILITIA ]++; + SectorInfo[usSector].ubNumberOfCivsAtLevel[ GREEN_MILITIA ]++; ++sTotalSoFar; --iNumberLeftOverGreen; // Flugente: indivdual militia - DropIndividualMilitia( sSector, GREEN_MILITIA, 1 ); + DropIndividualMilitia( usSector, GREEN_MILITIA, 1 ); } if( ( iNumberLeftOverRegular )&&( sTotalSoFar < iMaxMilitiaPerSector ) ) { - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ]++; + SectorInfo[usSector].ubNumberOfCivsAtLevel[ REGULAR_MILITIA ]++; ++sTotalSoFar; --iNumberLeftOverRegular; // Flugente: indivdual militia - DropIndividualMilitia( sSector, REGULAR_MILITIA, 1 ); + DropIndividualMilitia( usSector, REGULAR_MILITIA, 1 ); } if( ( iNumberLeftOverElite )&&( sTotalSoFar < iMaxMilitiaPerSector ) ) { - SectorInfo[ sSector ].ubNumberOfCivsAtLevel[ ELITE_MILITIA ]++; + SectorInfo[usSector].ubNumberOfCivsAtLevel[ ELITE_MILITIA ]++; ++sTotalSoFar; --iNumberLeftOverElite; // Flugente: indivdual militia - DropIndividualMilitia( sSector, ELITE_MILITIA, 1 ); + DropIndividualMilitia( usSector, ELITE_MILITIA, 1 ); } // if this sector is currently loaded if( (gWorldSectorX != 0) && (gWorldSectorY != 0) && - (sSector == SECTOR( gWorldSectorX, gWorldSectorY )) ) + ( usSector == SECTOR( gWorldSectorX, gWorldSectorY )) ) { gfStrategicMilitiaChangesMade = TRUE; } diff --git a/Strategic/Town Militia.cpp b/Strategic/Town Militia.cpp index bd09a5fb..787543bb 100644 --- a/Strategic/Town Militia.cpp +++ b/Strategic/Town Militia.cpp @@ -2079,7 +2079,7 @@ UINT32 CalcMilitiaUpkeep( void ) { if ( militia_static[i] > militia_individual[i] ) { - uiTotalPayment += ( militia_static[i] + -militia_individual[i] ) * gGameExternalOptions.usDailyCostTown[i]; + uiTotalPayment += ( militia_static[i] - militia_individual[i] ) * gGameExternalOptions.usDailyCostTown[i]; } } diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 0a2edfe0..49ea6b63 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -4563,7 +4563,7 @@ void HandleFlashingItems( ) { UINT32 cnt; ITEM_POOL *pItemPool; - LEVELNODE *pObject; + //LEVELNODE *pObject; ITEM_POOL_LOCATOR *pLocator; BOOLEAN fDoLocator = FALSE; diff --git a/Tactical/Interface Enhanced.cpp b/Tactical/Interface Enhanced.cpp index f2916431..7ea6426f 100644 --- a/Tactical/Interface Enhanced.cpp +++ b/Tactical/Interface Enhanced.cpp @@ -14198,13 +14198,13 @@ void DrawAdvancedValues( OBJECTTYPE *gpItemDescObject ) { SetFontForeground( a ? ITEMDESC_FONTPOSITIVE : ITEMDESC_FONTNEGATIVE ); - swprintf( pStr, L"%s/%s", a ? "Y" : "N", b ? "Y" : "N" ); + swprintf( pStr, L"%s/%s", a ? L"Y" : L"N", b ? L"Y" : L"N" ); } else { SetFontForeground( 5 ); - swprintf( pStr, L"%s", a ? "Y" : "N" ); + swprintf( pStr, L"%s", a ? L"Y" : L"N" ); } FindFontCenterCoordinates( sLeft, sTop, sWidth, sHeight, pStr, BLOCKFONT2, &usX, &usY ); diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 569b61b1..10167cd6 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -10678,11 +10678,10 @@ void HandleTurncoatAttempt( SOLDIERTYPE* pSoldier ) // remember the target's ID prisonerdialoguetargetID = pSoldier->ubID; - CHAR16 buf[256]; UINT8 ubCurrentProgress = CurrentPlayerProgressPercentage(); std::vector > dropdownvector_1; - int cnt = 1; + INT16 cnt = 1; UINT8 chance = MercPtrs[gusSelectedSoldier]->GetTurncoatConvinctionChance( prisonerdialoguetargetID, cnt ); swprintf( gTurncoatDropdownText[cnt-1], szTurncoatText[3], chance ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 1860d1e6..bfc8c5f1 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -19921,10 +19921,8 @@ FLOAT SOLDIERTYPE::GetConstructionPoints( ) UINT32 val = EffectiveStrength( this, FALSE ); ReducePointsForFatigue( this, &val ); - - FLOAT dval = val; - - dval = dval * (100 + this->GetBackgroundValue( BG_FORTIFY_ASSIGNMENT )) / 100.0f; + + FLOAT dval = val * (100 + this->GetBackgroundValue( BG_FORTIFY_ASSIGNMENT )) / 100.0f; dval = (dval * this->stats.bLife / this->stats.bLifeMax); @@ -19935,8 +19933,7 @@ FLOAT SOLDIERTYPE::GetConstructionPoints( ) BOOLEAN SOLDIERTYPE::HasItem(UINT16 usItem) { - INT8 invsize = (INT8)inv.size( ); - for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) + for ( size_t bLoop = 0, invsize = inv.size(); bLoop < invsize; ++bLoop ) { if ( inv[bLoop].exists( ) == true && inv[bLoop].usItem == usItem ) return TRUE; @@ -19951,8 +19948,7 @@ BOOLEAN SOLDIERTYPE::SelfDetonate( ) if ( !(this->flags.uiStatusFlags & SOLDIER_UNDERAICONTROL) ) return FALSE; - INT8 invsize = (INT8)inv.size( ); - for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) + for ( size_t bLoop = 0, invsize = inv.size(); bLoop < invsize; ++bLoop ) { if ( inv[bLoop].exists( ) == true && inv[bLoop].usItem == this->aiData.usActionData ) { @@ -19980,8 +19976,7 @@ UINT8 SOLDIERTYPE::GetWaterSnakeDefenseChance() val += this->GetBackgroundValue( BG_SNAKEDEFENSE ); // bonus if we have a knife, extra if it is in our hands - INT8 invsize = (INT8)inv.size( ); // remember inventorysize, so we don't call size() repeatedly - for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) + for ( size_t bLoop = 0, invsize = inv.size(); bLoop < invsize; ++bLoop ) { if ( inv[bLoop].exists( ) ) { @@ -20026,9 +20021,7 @@ UINT16 SOLDIERTYPE::GetInteractiveActionSkill( INT32 sGridNo, UINT8 usLevel, UIN OBJECTTYPE* pObj = NULL; - INT8 invsize = (INT8)inv.size( ); // remember inventorysize, so we don't call size() repeatedly - - for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) // ... for all items in our inventory ... + for ( size_t bLoop = 0, invsize = inv.size(); bLoop < invsize; ++bLoop ) { if ( inv[bLoop].exists( ) == true && Item[inv[bLoop].usItem].usHackingModifier ) { @@ -20191,7 +20184,7 @@ BOOLEAN SOLDIERTYPE::CanDragInPrinciple() return TRUE; } -BOOLEAN SOLDIERTYPE::CanDragPerson( UINT8 usID ) +BOOLEAN SOLDIERTYPE::CanDragPerson( UINT16 usID ) { if ( !CanDragInPrinciple() ) return FALSE; @@ -20288,7 +20281,7 @@ void SOLDIERTYPE::SetDragOrderPerson( UINT16 usID ) { // sevenfm: if someone is dragging this soldier, cancel drag SOLDIERTYPE *pSoldier; - for (UINT32 uiLoop = 0; uiLoop < guiNumMercSlots; uiLoop++) + for (UINT32 uiLoop = 0; uiLoop < guiNumMercSlots; ++uiLoop) { pSoldier = MercPtrs[uiLoop]; if (pSoldier && pSoldier->usDragPersonID == usID) @@ -20813,7 +20806,7 @@ BOOLEAN SOLDIERTYPE::InPositionForTurncoatAttempt( UINT16 usID ) return FALSE; } -UINT8 SOLDIERTYPE::GetTurncoatConvinctionChance( UINT16 usID, UINT8 usApproach ) +UINT8 SOLDIERTYPE::GetTurncoatConvinctionChance( UINT16 usID, INT16 sApproach ) { if ( usID >= NOBODY ) return 0; @@ -20875,7 +20868,7 @@ UINT8 SOLDIERTYPE::GetTurncoatConvinctionChance( UINT16 usID, UINT8 usApproach ReducePointsForFatigue( pSoldier, &enemyresistancerating ); - switch ( usApproach ) + switch ( sApproach ) { // base approach case 1: diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index a4d88f2b..606cfcd6 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -2004,7 +2004,7 @@ public: // Flugente: drag people BOOLEAN CanDragInPrinciple(); - BOOLEAN CanDragPerson( UINT8 usID ); + BOOLEAN CanDragPerson( UINT16 usID ); BOOLEAN CanDragCorpse( UINT16 usCorpseNum ); BOOLEAN IsDraggingSomeone(); void SetDragOrderPerson( UINT16 usID ); @@ -2034,7 +2034,7 @@ public: // Flugente: turncoats BOOLEAN InPositionForTurncoatAttempt( UINT16 usID ); - UINT8 GetTurncoatConvinctionChance( UINT16 usID, UINT8 usApproach ); + UINT8 GetTurncoatConvinctionChance( UINT16 usID, INT16 usApproach ); void AttemptToCreateTurncoat( UINT16 usID ); BOOLEAN OrderTurnCoatToSwitchSides( UINT16 usID ); void OrderAllTurnCoatToSwitchSides(); diff --git a/Tactical/Soldier Init List.cpp b/Tactical/Soldier Init List.cpp index ffbaf7c2..80f715bd 100644 --- a/Tactical/Soldier Init List.cpp +++ b/Tactical/Soldier Init List.cpp @@ -2074,7 +2074,6 @@ void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT8 ubNumLarvae, UINT8 ubNum void AddSoldierInitListOtherCreatures( UINT8 usNum ) { SOLDIERINITNODE *curr; - INT32 iRandom; UINT8 ubFreeSlots; BOOLEAN fDoPlacement; UINT8 ubNumCreatures = usNum; diff --git a/screenids.h b/screenids.h index 35dfa95c..148168d5 100644 --- a/screenids.h +++ b/screenids.h @@ -1,7 +1,7 @@ #ifndef __SCREEN_IDS #define __SCREEN_IDS -typedef enum ScreenTypes +enum ScreenTypes { EDIT_SCREEN, SAVING_SCREEN,