From 6448b332ecd78dd912793778d5e1fbad15558d3a Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 1 Jun 2014 21:50:14 +0000 Subject: [PATCH] Merged revision(s) 7251 from branches/ja2_source_official_2014: code cleanup & removed some warnings git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7252 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/DropDown.cpp | 6 +- Strategic/Assignments.cpp | 357 +++++++------------------ Strategic/LuaInitNPCs.cpp | 31 +-- Strategic/Map Screen Interface Map.cpp | 2 +- Tactical/Items.cpp | 3 +- Tactical/UI Cursors.cpp | 2 +- Tactical/Weapons.cpp | 6 +- TacticalAI/Movement.cpp | 86 +++--- 8 files changed, 168 insertions(+), 325 deletions(-) diff --git a/Laptop/DropDown.cpp b/Laptop/DropDown.cpp index af2dca437..4a6915581 100644 --- a/Laptop/DropDown.cpp +++ b/Laptop/DropDown.cpp @@ -468,7 +468,7 @@ DropDownBase::SelectDropDownRegionCallBack(MOUSE_REGION * pRegion, INT32 iReason else if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP) { UINT8 ubSelected = (UINT8)MSYS_GetRegionUserData( pRegion, 0 ); - mSelectedEntry = min(ubSelected + mFirstShownEntry, mEntryVector.size() -1) ; + mSelectedEntry = min(ubSelected + mFirstShownEntry, max(0, mEntryVector.size() -1) ); Destroy_Drop(); } @@ -538,10 +538,10 @@ DropDownBase::SelectScrollAreaDropDownMovementCallBack(MOUSE_REGION * pRegion, I } else if( mFirstShownEntry + ubCityNum > mSelectedEntry ) { - mSelectedEntry = min(mFirstShownEntry + ubCityNum, mEntryVector.size() - 1); + mSelectedEntry = min( mFirstShownEntry + ubCityNum, max( 0, mEntryVector.size( ) - 1 ) ); if ( ubCityNum == mNumDisplayedEntries - 1 ) - mFirstShownEntry = min(mFirstShownEntry + 1, mEntryVector.size() - 1); + mFirstShownEntry = min( mFirstShownEntry + 1, max( 0, mEntryVector.size( ) - 1 ) ); } InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY); diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 00dfe2574..4b25eb283 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -3302,13 +3302,13 @@ BOOL HandleSnitchExposition(SOLDIERTYPE *pSoldier) } break; } - } - } - else - { - // he's fine, carry on - return( FALSE ); + } + + return TRUE; } + + // he's fine, carry on + return( FALSE ); } void MakeSoldierKnownAsMercInPrison(SOLDIERTYPE *pSoldier, INT16 sMapX, INT16 sMapY) @@ -3323,18 +3323,10 @@ void MakeSoldierKnownAsMercInPrison(SOLDIERTYPE *pSoldier, INT16 sMapX, INT16 sM BOOLEAN IsSoldierKnownAsMercInSector(SOLDIERTYPE *pSoldier, INT16 sMapX, INT16 sMapY) { - //if( gMercProfiles[pSoldier->ubProfile].ubExposedInSector[ SECTOR(sMapX, sMapY)] ) - //{ - // return( TRUE ); - //} - //else - //{ - // return( FALSE ); - //} if( gMercProfiles[pSoldier->ubProfile].ubSnitchExposedCooldown > 0 ) return( TRUE ); - else - return( FALSE ); + + return( FALSE ); } UINT16 ToolKitPoints(SOLDIERTYPE *pSoldier) @@ -3387,7 +3379,7 @@ void HandleDoctorsInSector( INT16 sX, INT16 sY, INT8 bZ ) // will handle doctor/patient relationship in sector // go through list of characters, find all doctors in sector - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { if(pTeamSoldier->bActive) { @@ -3419,7 +3411,6 @@ void HandleDoctorsInSector( INT16 sX, INT16 sY, INT8 bZ ) } // total healing pts for this sector, now heal people - return; } @@ -3432,7 +3423,7 @@ void UpdatePatientsWhoAreDoneHealing( void ) // set as first in list pSoldier = MercPtrs[0]; - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { // active soldier? if( pTeamSoldier->bActive ) @@ -3440,25 +3431,25 @@ void UpdatePatientsWhoAreDoneHealing( void ) // patient who doesn't need healing or curing if( ( pTeamSoldier->bAssignment == PATIENT ) &&( pTeamSoldier->stats.bLife == pTeamSoldier->stats.bLifeMax ) && ( pTeamSoldier->bPoisonSum == 0 ) ) { - // SANDRO - added check if we can help to heal lost stats to this one - for (UINT8 cnt = 0; cnt < NUM_DAMAGABLE_STATS; ++cnt) + // Flugente: stats can also be damaged + if ( !gGameOptions.fFoodSystem || (gGameOptions.fFoodSystem && pSoldier->bFoodLevel > FoodMoraleMods[FOOD_NORMAL].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_NORMAL].bThreshold) ) { - if (pTeamSoldier->ubCriticalStatDamage[cnt] > 0 ) + if ( pSoldier->usStarveDamageHealth > 0 || pSoldier->usStarveDamageStrength > 0 ) fHasDamagedStat = TRUE; - - // Flugente: stats can also be damaged - if ( !gGameOptions.fFoodSystem || ( gGameOptions.fFoodSystem && pSoldier->bFoodLevel > FoodMoraleMods[FOOD_NORMAL].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_NORMAL].bThreshold ) ) - { - if ( pSoldier->usStarveDamageHealth > 0 || pSoldier->usStarveDamageStrength > 0 ) - fHasDamagedStat = TRUE; - } } + + // SANDRO - added check if we can help to heal lost stats to this one + for ( UINT8 cnt2 = 0; cnt2 < NUM_DAMAGABLE_STATS; ++cnt2 ) + { + if ( pTeamSoldier->ubCriticalStatDamage[cnt2] > 0 ) + fHasDamagedStat = TRUE; + } + if (!fHasDamagedStat )// || !DoctorIsPresent( pTeamSoldier, TRUE )) AssignmentDone( pTeamSoldier, TRUE, TRUE ); } } } - return; } void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) @@ -3474,7 +3465,6 @@ void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) INT32 cnt = 0; UINT16 usOldLeftOvers = 0; - // now find number of healable mercs in sector that are wounded ubTotalNumberOfPatients = GetNumberThatCanBeDoctored( pDoctor, HEALABLE_THIS_HOUR, FALSE, FALSE, FALSE ); @@ -3488,9 +3478,8 @@ void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) // find how many healing points can be evenly distributed to each wounded, healable merc usEvenHealingAmount = usRemainingHealingPts / ubTotalNumberOfPatients; - // heal each of the healable mercs by this equal amount - for ( cnt = 0, pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( cnt = 0, pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { if( pTeamSoldier->bActive ) { @@ -3512,7 +3501,7 @@ void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) // find the worst hurt patient pWorstHurtSoldier = NULL; - for ( cnt = 0, pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( cnt = 0, pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { if( pTeamSoldier->bActive ) { @@ -3550,7 +3539,6 @@ void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) } while( ( usRemainingHealingPts > 0 ) && ( pWorstHurtSoldier != NULL ) ); } - usUsedHealingPts = usAvailableHealingPts - usRemainingHealingPts; // increment skills based on healing pts used @@ -3558,8 +3546,7 @@ void HealCharacters( SOLDIERTYPE *pDoctor, INT16 sX, INT16 sY, INT8 bZ ) StatChange(pDoctor, DEXTAMT, (UINT16) (usUsedHealingPts / 100), FALSE); StatChange(pDoctor, WISDOMAMT, (UINT16) (usUsedHealingPts / 100), FALSE); } - - + // if there's nobody else here who can EVER be helped by this doctor (regardless of whether they got healing this hour) if( GetNumberThatCanBeDoctored( pDoctor, HEALABLE_EVER, FALSE, FALSE, FALSE ) == 0 ) { @@ -3732,11 +3719,9 @@ BOOLEAN CanSoldierBeHealedByDoctor( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pDoctor, return( TRUE ); } - +// get the minimum skill to handle a character under OKLIFE UINT8 GetMinHealingSkillNeeded( SOLDIERTYPE *pPatient ) { - // get the minimum skill to handle a character under OKLIFE - if( pPatient->stats.bLife < OKLIFE ) { // less than ok life, return skill needed @@ -3748,11 +3733,9 @@ UINT8 GetMinHealingSkillNeeded( SOLDIERTYPE *pPatient ) // skill to remove poison needed return( gGameExternalOptions.ubPoisonBaseMedicalSkillToCure ); } - else - { - // only need some skill - return ( 1 ); - } + + // only need some skill + return 1; } @@ -3924,7 +3907,6 @@ UINT16 HealPatient( SOLDIERTYPE *pPatient, SOLDIERTYPE * pDoctor, UINT16 usHealA if (pPatient->iHealableInjury < 0) pPatient->iHealableInjury = 0; } - } // Finaly use all kit points (we are sure, we have that much) @@ -4014,7 +3996,7 @@ void CheckForAndHandleHospitalPatients( void ) pSoldier = MercPtrs[0]; // go through list of characters, find all who are on this assignment - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { if( pTeamSoldier->bActive ) { @@ -4153,7 +4135,7 @@ void HandleRepairmenInSector( INT16 sX, INT16 sY, INT8 bZ ) // will handle doctor/patient relationship in sector // go through list of characters, find all doctors in sector - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt, pTeamSoldier++) { if( pTeamSoldier->bActive ) { @@ -4176,8 +4158,6 @@ void HandleRepairmenInSector( INT16 sX, INT16 sY, INT8 bZ ) } } } - - return; } @@ -4532,7 +4512,7 @@ BOOLEAN RepairObject( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOwner, OBJECTTYPE * ubItemsInPocket = pObj->ubNumberOfObjects; - for ( ubLoop = 0; ubLoop < ubItemsInPocket; ubLoop++ ) + for ( ubLoop = 0; ubLoop < ubItemsInPocket; ++ubLoop ) { // Flugente: if using the new advanced repair system, we can only repair up to the repair threshold INT16 threshold = 100; @@ -4668,7 +4648,7 @@ void HandleRepairBySoldier( SOLDIERTYPE *pSoldier ) if ( ubRepairPtsLeft == 0 ) { AssignmentDone( pSoldier, TRUE, TRUE ); - return; + return; } // remember what we've started off with @@ -4864,7 +4844,6 @@ void HandleRepairBySoldier( SOLDIERTYPE *pSoldier ) StopTimeCompression(); } - // repair items on others RepairItemsOnOthers( pSoldier, &ubRepairPtsLeft ); } @@ -4892,7 +4871,6 @@ void HandleRepairBySoldier( SOLDIERTYPE *pSoldier ) } } - // if he really done if ( HasCharacterFinishedRepairing( pSoldier ) ) { @@ -4915,8 +4893,6 @@ void HandleRepairBySoldier( SOLDIERTYPE *pSoldier ) AssignmentAborted( pSoldier, INSUF_REPAIR_SKILL ); } } - - return; } @@ -5078,7 +5054,6 @@ void RestCharacter( SOLDIERTYPE *pSoldier ) pSoldier->bBreathMax += bMaxBreathRegain; - if( pSoldier->bBreathMax > 100 ) { pSoldier->bBreathMax = 100; @@ -5095,8 +5070,6 @@ void RestCharacter( SOLDIERTYPE *pSoldier ) { pSoldier->flags.fComplainedThatTired = FALSE; } - - return; } @@ -5110,7 +5083,6 @@ void FatigueCharacter( SOLDIERTYPE *pSoldier ) float bMaxBreathLoss = 0; // SANDRO - changed to float INT8 bMaxBreathTaken = 0; - // vehicle or robot? if( ( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) || AM_A_ROBOT( pSoldier ) ) { @@ -5155,8 +5127,7 @@ void FatigueCharacter( SOLDIERTYPE *pSoldier ) else bDivisor -= (2*NUM_SKILL_TRAITS( pSoldier, NIGHTOPS_OT )); } - - + // Re-enforce limits bDivisor = __min(20, __max(6, bDivisor)); @@ -5289,8 +5260,6 @@ void FatigueCharacter( SOLDIERTYPE *pSoldier ) { pSoldier->bBreath = pSoldier->bBreathMax; } - - return; } @@ -5313,7 +5282,6 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) UINT16 usMaxPts; BOOLEAN fTrainingCompleted = FALSE; - // find out if a sam site here BOOLEAN fSamSiteInSector = IsThisSectorASAMSector( sMapX, sMapY, 0 ); @@ -5340,7 +5308,7 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) // sort them from highest to lowest if some form of trainer degradation formula was to be used for multiple trainers. // for each trainable stat - for (ubStat = 0; ubStat < NUM_TRAINABLE_STATS; ubStat++) + for (ubStat = 0; ubStat < NUM_TRAINABLE_STATS; ++ubStat) { sBestTrainingPts = -1; @@ -5366,9 +5334,8 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) } } - // now search team for active self-trainers in this sector - for ( uiCnt = 0, pStudent = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pStudent++) + for ( uiCnt = 0, pStudent = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pStudent++) { // see if this merc is active and in the same sector if( ( pStudent->bActive) && ( pStudent->sSectorX == sMapX ) && ( pStudent->sSectorY == sMapY ) && ( pStudent->bSectorZ == bZ ) ) @@ -5430,7 +5397,6 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) } } - // check if we're doing a sector where militia can be trained if( ( (StrategicMap[ sMapX + ( sMapY * MAP_WORLD_X ) ].bNameId != BLANK_SECTOR ) || ( fSamSiteInSector == TRUE ) ) && (bZ == 0) ) { @@ -5460,7 +5426,6 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) } } - // if we have more than one if (ubTownTrainers > 1) { @@ -5469,7 +5434,7 @@ void HandleTrainingInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) } // for each trainer, in sorted order from the best to the worst - for (uiCnt = 0; uiCnt < ubTownTrainers; uiCnt++) + for (uiCnt = 0; uiCnt < ubTownTrainers; ++uiCnt) { // top trainer has full effect (divide by 1), then divide by 2, 4, 8, etc. //sTownTrainingPts = TownTrainer[ uiCnt ].sTrainingPts / (UINT16) pow(2, uiCnt); @@ -5508,7 +5473,7 @@ void HandleRadioScanInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) // we will count the number of radio operators in this sector that have scanned successfully this hour. The higher this number, the higher the chance to detect enemy patrols! // search team for radio operators in this sector that performed this assignemnt successfully - for ( uiCnt = 0, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pSoldier++) + for ( uiCnt = 0, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pSoldier++) { if( pSoldier->bActive && ( pSoldier->sSectorX == sMapX ) && ( pSoldier->sSectorY == sMapY ) && ( pSoldier->bSectorZ == bZ) ) { @@ -5612,11 +5577,11 @@ void HandleRadioScanInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) } // award experience to all radio operators - for ( uiCnt = 0, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pSoldier++) + for ( uiCnt = 0, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pSoldier++) { if( pSoldier->bActive && ( pSoldier->sSectorX == sMapX ) && ( pSoldier->sSectorY == sMapY ) && ( pSoldier->bSectorZ == bZ) ) { - if( ( pSoldier->bAssignment == RADIO_SCAN ) && ( EnoughTimeOnAssignment( pSoldier ) ) && ( pSoldier->flags.fMercAsleep == FALSE ) ) + if ( !pSoldier->flags.fMercAsleep && (pSoldier->bAssignment == RADIO_SCAN) && EnoughTimeOnAssignment( pSoldier ) ) { StatChange( pSoldier, WISDOMAMT, 5, TRUE ); StatChange( pSoldier, EXPERAMT, 3, TRUE ); @@ -5702,7 +5667,7 @@ void HandleSpreadingPropagandaInSector( INT16 sMapX, INT16 sMapY, INT8 bZ ) IncrementTownLoyalty( ubTownId, uiPropagandaEffect ); // award experience to all snitches - for ( uiCnt = 0, pSnitch = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pSnitch++) + for ( uiCnt = 0, pSnitch = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pSnitch++) { if( pSnitch->bActive && ( pSnitch->sSectorX == sMapX ) && ( pSnitch->sSectorY == sMapY ) && ( pSnitch->bSectorZ == bZ) ) { @@ -5724,7 +5689,7 @@ UINT32 HandlePropagandaBlockingBadNewsInTown( INT8 bTownId, UINT32 uiLoyaltyDecr UINT32 uiNewLoyaltyDecrease = uiLoyaltyDecrease; // search team for snitches in this sector that performed this assignment successfully - for ( uiCnt = 0, pSnitch = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pSnitch++) + for ( uiCnt = 0, pSnitch = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pSnitch++) { if( ( pSnitch->bActive && pSnitch->flags.fMercAsleep == FALSE && EnoughTimeOnAssignment( pSnitch ) ) && ( pSnitch->bAssignment == SNITCH_SPREAD_PROPAGANDA || pSnitch->bAssignment == FACILITY_SPREAD_PROPAGANDA || pSnitch->bAssignment == FACILITY_SPREAD_PROPAGANDA_GLOBAL ) && @@ -5746,6 +5711,7 @@ UINT32 HandlePropagandaBlockingBadNewsInTown( INT8 bTownId, UINT32 uiLoyaltyDecr uiNewLoyaltyDecrease *= ( 1.0 - fPropagandaEffect ); } } + return uiNewLoyaltyDecrease; } @@ -5787,7 +5753,7 @@ void HandleGatheringInformationBySoldier( SOLDIERTYPE* pSoldier ) usNormalGroupSize *= 2; - FLOAT fBaseChance = ( EffectiveLeadership(pSoldier) + EffectiveWisdom(pSoldier) + EffectiveExpLevel(pSoldier) * 10 ) / 3000.0; + FLOAT fBaseChance = ( EffectiveLeadership(pSoldier) + EffectiveWisdom(pSoldier) + EffectiveExpLevel(pSoldier) * 10 ) / 3000.0f; if( gMercProfiles[ pSoldier->ubProfile ].bDisability == DEAF ) { @@ -5860,23 +5826,21 @@ void HandleGatheringInformationBySoldier( SOLDIERTYPE* pSoldier ) StatChange( pSoldier, LDRAMT, 2, TRUE ); StatChange( pSoldier, EXPERAMT, 3, TRUE ); } - } + int TownTrainerQsortCompare(const void *pArg1, const void *pArg2) { if (((TOWN_TRAINER_TYPE *)pArg1)->sTrainingPts > ((TOWN_TRAINER_TYPE *)pArg2)->sTrainingPts) { - return(-1); + return(-1); } else if (((TOWN_TRAINER_TYPE *)pArg1)->sTrainingPts < ((TOWN_TRAINER_TYPE *)pArg2)->sTrainingPts) { - return(1); + return(1); } - else - { + return(0); - } } @@ -5901,7 +5865,6 @@ INT16 GetBonusTrainingPtsDueToInstructor( SOLDIERTYPE *pInstructor, SOLDIERTYPE return ( 0 ); } - switch( bTrainStat ) { case( STRENGTH ): @@ -5948,8 +5911,7 @@ INT16 GetBonusTrainingPtsDueToInstructor( SOLDIERTYPE *pInstructor, SOLDIERTYPE #endif return(0); } - - + // if there's no student if( pStudent == NULL ) { @@ -6019,7 +5981,6 @@ INT16 GetBonusTrainingPtsDueToInstructor( SOLDIERTYPE *pInstructor, SOLDIERTYPE bOpinionFactor += gMercProfiles[ pInstructor->ubProfile ].bMercOpinion[ pStudent->ubProfile ] / 2; } - // check to see if student better than/equal to instructor's effective skill, if so, return 0 // don't use natural skill - if the guy's too doped up to tell what he know, student learns nothing until sobriety returns! ///////////////////////////////////////////////////////////////////////// @@ -6160,7 +6121,6 @@ INT16 GetSoldierTrainingPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, UINT16 *pus return 0; } - // calculate normal training pts - what it would be if his stats were "normal" (ignoring drugs, fatigue) *pusMaxPts = __max( ( ( pSoldier->stats.bWisdom * ( gGameExternalOptions.ubTrainingSkillMax - bSkill ) ) / gGameExternalOptions.ubSelfTrainingDivisor ), 1 ); @@ -6283,7 +6243,6 @@ INT16 GetSoldierStudentPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, UINT16 *pusM return 0; } - // calculate normal training pts - what it would be if his stats were "normal" (ignoring drugs, fatigue) *pusMaxPts = __max( ( ( pSoldier->stats.bWisdom * ( gGameExternalOptions.ubTrainingSkillMax - bSkill ) ) / gGameExternalOptions.ubSelfTrainingDivisor ), 1 ); @@ -6343,15 +6302,14 @@ INT16 GetSoldierStudentPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, UINT16 *pusM ReducePointsForHunger( pSoldier, &uiTrainingPts ); sTrainingPts = (INT16)uiTrainingPts; - - + // now add in stuff for trainer // for each trainable stat sBestTrainingPts = -1; // search team for active instructors in this sector - for ( uiCnt = 0, pTrainer = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; uiCnt++, pTrainer++) + for ( uiCnt = 0, pTrainer = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ MercPtrs[0]->bTeam ].bLastID; ++uiCnt, pTrainer++) { if( pTrainer->bActive && ( pTrainer->sSectorX == pSoldier->sSectorX ) && ( pTrainer->sSectorY == pSoldier->sSectorY ) && ( pTrainer->bSectorZ == pSoldier->bSectorZ) ) { @@ -6442,7 +6400,6 @@ void TrainSoldierWithPts( SOLDIERTYPE *pSoldier, INT16 sTrainPts ) StatChange( pSoldier, ubChangeStat, sTrainPts, FROM_TRAINING ); if (addWis) StatChange( pSoldier, WISDOMAMT, sTrainPts/2, FROM_TRAINING ); - } @@ -7214,7 +7171,6 @@ INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts ) { sTrainingBonus += 5; } - } else { @@ -7250,12 +7206,12 @@ INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts ) } } } + // adjust for teaching bonus (a percentage) sTotalTrainingPts += ( ( sTrainingBonus * sTotalTrainingPts ) / 100 ); // teach bonus is considered "normal" - it's always there *pusMaxPts += ( ( sTrainingBonus * *pusMaxPts ) / 100 ); - // adjust for fatigue of trainer UINT32 uiTrainingPts = (UINT32) sTotalTrainingPts; ReducePointsForFatigue( pTrainer, &uiTrainingPts ); @@ -7266,7 +7222,6 @@ INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts ) sTotalTrainingPts = (INT16)uiTrainingPts; - /* ARM: Decided this didn't make much sense - the guys I'm training damn well BETTER be loyal - and screw the rest! // get town index ubTownId = StrategicMap[ pTrainer->sSectorX + pTrainer->sSectorY * MAP_WORLD_X ].bNameId; @@ -7300,17 +7255,16 @@ void MakeSoldiersTacticalAnimationReflectAssignment( SOLDIERTYPE *pSoldier ) } else { - if ( pSoldier->usAnimState != WKAEUP_FROM_SLEEP && !(pSoldier->bOldAssignment < ON_DUTY ) ) - { - // default: standing - pSoldier->ChangeSoldierState( STANDING, 1, TRUE ); - } + if ( pSoldier->usAnimState != WKAEUP_FROM_SLEEP && !(pSoldier->bOldAssignment < ON_DUTY ) ) + { + // default: standing + pSoldier->ChangeSoldierState( STANDING, 1, TRUE ); + } } } } - void AssignmentAborted( SOLDIERTYPE *pSoldier, UINT8 ubReason ) { AssertLT( ubReason, NUM_ASSIGN_ABORT_REASONS ); @@ -7401,7 +7355,6 @@ void AssignmentDone( SOLDIERTYPE *pSoldier, BOOLEAN fSayQuote, BOOLEAN fMeToo ) } } - AddReasonToWaitingListQueue( ASSIGNMENT_FINISHED_FOR_UPDATE ); AddSoldierToWaitingListQueue( pSoldier ); @@ -7418,14 +7371,10 @@ void AssignmentDone( SOLDIERTYPE *pSoldier, BOOLEAN fSayQuote, BOOLEAN fMeToo ) BOOLEAN CharacterIsBetweenSectors( SOLDIERTYPE *pSoldier ) { // is the character on the move - if( pSoldier == NULL ) - { + if( !pSoldier ) return ( FALSE ); - } - else - { - return( pSoldier->flags.fBetweenSectors ); - } + + return( pSoldier->flags.fBetweenSectors ); } @@ -7438,7 +7387,7 @@ void HandleNaturalHealing( void ) pSoldier = MercPtrs[0]; // go through list of characters, find all who are on this assignment - for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; cnt++,pTeamSoldier++) + for ( pTeamSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID; ++cnt,pTeamSoldier++) { if( pTeamSoldier->bActive ) { @@ -7449,8 +7398,6 @@ void HandleNaturalHealing( void ) } } } - - return; } @@ -7463,7 +7410,6 @@ void HandleHealingByNaturalCauses( SOLDIERTYPE *pSoldier ) UINT16 usFacilityModifier = 100; UINT8 ubAssignmentType = 0; - // check if soldier valid if( pSoldier == NULL ) { @@ -7488,7 +7434,6 @@ void HandleHealingByNaturalCauses( SOLDIERTYPE *pSoldier ) return; } - // not bleeding and injured... if( pSoldier->bAssignment == ASSIGNMENT_POW ) @@ -7540,7 +7485,7 @@ void HandleHealingByNaturalCauses( SOLDIERTYPE *pSoldier ) UINT16 bRegenerationBonus = 0; cnt = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; - for ( pMedic = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; cnt++,pMedic++) + for ( pMedic = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++cnt, pMedic++) { if ( !(pMedic->bActive) || !(pMedic->bInSector) || ( pMedic->flags.uiStatusFlags & SOLDIER_VEHICLE ) || (pMedic->bAssignment == VEHICLE ) ) { @@ -7580,8 +7525,6 @@ void HandleHealingByNaturalCauses( SOLDIERTYPE *pSoldier ) // now update the real life values UpDateSoldierLife( pSoldier ); - - return; } @@ -7647,7 +7590,6 @@ void UpDateSoldierLife( SOLDIERTYPE *pSoldier ) pSoldier->iHealableInjury = 0; // check added by SANDRO } - return; } @@ -7735,8 +7677,6 @@ void CheckIfSoldierUnassigned( SOLDIERTYPE *pSoldier ) pSoldier->ChangeSoldierState( STANDING, 1, TRUE ); } } - - return; } @@ -7754,7 +7694,6 @@ void CreateDestroyMouseRegionsForAssignmentMenu( void ) SGPRect pDimensions; static BOOLEAN fShowRemoveMenu = FALSE; - // will create/destroy mouse regions for the map screen assignment main menu // check if we can only remove character from team..not assign if( ( bSelectedAssignChar != -1 )|| ( fShowRemoveMenu == TRUE ) ) @@ -7779,7 +7718,6 @@ void CreateDestroyMouseRegionsForAssignmentMenu( void ) } } - if( ( fShowAssignmentMenu == TRUE ) && ( fCreated == FALSE ) ) { @@ -7833,7 +7771,6 @@ void CreateDestroyMouseRegionsForAssignmentMenu( void ) SetCurrentBox( ghAssignmentBox ); } - // define regions for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghAssignmentBox ); iCounter++ ) { @@ -7866,7 +7803,6 @@ void CreateDestroyMouseRegionsForAssignmentMenu( void ) // not created fCreated = FALSE; SetRenderFlags( RENDER_FLAG_FULL ); - } } @@ -7886,7 +7822,6 @@ void CreateDestroyMouseRegionForVehicleMenu( void ) SGPRect pDimensions; SOLDIERTYPE *pSoldier = NULL; - if( fShowVehicleMenu ) { GetBoxPosition( ghAssignmentBox, &pPoint); @@ -7900,7 +7835,6 @@ void CreateDestroyMouseRegionForVehicleMenu( void ) SetBoxPosition( ghVehicleBox , VehiclePosition ); } - if( ( fShowVehicleMenu == TRUE ) && ( fCreated == FALSE ) ) { // grab height of font @@ -7944,7 +7878,6 @@ void CreateDestroyMouseRegionForVehicleMenu( void ) } } - // cancel line MSYS_DefineRegion( &gVehicleMenuRegion[ uiMenuLine ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * uiMenuLine ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * ( uiMenuLine + 1 ) ), MSYS_PRIORITY_HIGHEST - 4 , MSYS_NO_CURSOR, VehicleMenuMvtCallback, VehicleMenuBtnCallback ); @@ -7985,19 +7918,15 @@ void CreateDestroyMouseRegionForVehicleMenu( void ) UnHighLightBox( ghAssignmentBox ); } } - - return; } - void HandleShadingOfLinesForVehicleMenu( void ) { SOLDIERTYPE *pSoldier = NULL; INT32 iVehicleId; UINT32 uiMenuLine = 0; - if ( ( fShowVehicleMenu == FALSE ) || ( ghVehicleBox == - 1 ) ) { return; @@ -8032,14 +7961,12 @@ void HandleShadingOfLinesForVehicleMenu( void ) } - void VehicleMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) { // btn callback handler for assignment region INT32 iVehicleID; SOLDIERTYPE * pSoldier; - INT32 iValue = MSYS_GetRegionUserData( pRegion, 0 ); if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP) @@ -8102,7 +8029,7 @@ void VehicleMenuMvtCallback(MOUSE_REGION * pRegion, INT32 iReason ) else { // highlight cancel line - HighLightBoxLine( ghVehicleBox, GetNumberOfLinesOfTextInBox( ghVehicleBox ) - 1 ); + HighLightBoxLine( ghVehicleBox, GetNumberOfLinesOfTextInBox( ghVehicleBox ) - 1 ); } } else if (iReason & MSYS_CALLBACK_REASON_LOST_MOUSE ) @@ -8121,7 +8048,6 @@ BOOLEAN DisplayRepairMenu( SOLDIERTYPE *pSoldier ) INT32 iVehicleIndex=0; INT32 hStringHandle=0; - // run through list of vehicles in sector and add them to pop up box // first, clear pop up box RemoveBox(ghRepairBox); @@ -8162,8 +8088,7 @@ BOOLEAN DisplayRepairMenu( SOLDIERTYPE *pSoldier ) AddMonoString(&hStringHandle, pRepairStrings[ 1 ] ); } */ - - + // is the ROBOT here? if( IsRobotInThisSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) ) { @@ -8171,11 +8096,9 @@ BOOLEAN DisplayRepairMenu( SOLDIERTYPE *pSoldier ) AddMonoString((UINT32 *)&hStringHandle, pRepairStrings[ 3 ] ); } - // items AddMonoString((UINT32 *)&hStringHandle, pRepairStrings[ 0 ] ); - - + // cancel AddMonoString((UINT32 *)&hStringHandle, pRepairStrings[ 2 ] ); @@ -8200,7 +8123,6 @@ void HandleShadingOfLinesForRepairMenu( void ) INT32 iVehicleIndex = 0; INT32 iCount = 0; - if( ( fShowRepairMenu == FALSE ) || ( ghRepairBox == -1 ) ) { return; @@ -8208,13 +8130,12 @@ void HandleShadingOfLinesForRepairMenu( void ) pSoldier = GetSelectedAssignSoldier( FALSE ); - // PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch: // CreateDestroyMouseRegionForRepairMenu(), DisplayRepairMenu(), and HandleShadingOfLinesForRepairMenu(). if ( pSoldier->bSectorZ == 0 ) { - for ( iVehicleIndex = 0; iVehicleIndex < ubNumberOfVehicles; iVehicleIndex++ ) + for ( iVehicleIndex = 0; iVehicleIndex < ubNumberOfVehicles; ++iVehicleIndex ) { if ( pVehicleList[ iVehicleIndex ].fValid == TRUE ) { @@ -8261,7 +8182,6 @@ void HandleShadingOfLinesForRepairMenu( void ) } */ - if( IsRobotInThisSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) ) { // handle shading of repair robot option @@ -8279,7 +8199,6 @@ void HandleShadingOfLinesForRepairMenu( void ) iCount++; } - if ( DoesCharacterHaveAnyItemsToRepair( pSoldier, FINAL_REPAIR_PASS ) ) { // unshade items line @@ -8292,9 +8211,6 @@ void HandleShadingOfLinesForRepairMenu( void ) } iCount++; - - - return; } @@ -8313,7 +8229,6 @@ void CreateDestroyMouseRegionForRepairMenu( void ) SOLDIERTYPE *pSoldier = NULL; INT32 iVehicleIndex = 0; - if( ( fShowRepairMenu == TRUE ) && ( fCreated == FALSE ) ) { // Moa: removed below: repositioning now the same way as for training in AssignmentMenuBtnCB as it caused missplaced box for higher resolutions then 3. @@ -8341,7 +8256,6 @@ void CreateDestroyMouseRegionForRepairMenu( void ) SetCurrentBox( ghRepairBox ); - pSoldier = GetSelectedAssignSoldier( FALSE ); // PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch: @@ -8350,7 +8264,7 @@ void CreateDestroyMouseRegionForRepairMenu( void ) if ( pSoldier->bSectorZ == 0 ) { // vehicles - for ( iVehicleIndex = 0; iVehicleIndex < ubNumberOfVehicles; iVehicleIndex++ ) + for ( iVehicleIndex = 0; iVehicleIndex < ubNumberOfVehicles; ++iVehicleIndex ) { if ( pVehicleList[ iVehicleIndex ].fValid == TRUE ) { @@ -8374,7 +8288,6 @@ void CreateDestroyMouseRegionForRepairMenu( void ) } } - /* No point in allowing SAM site repair any more. Jan/13/99. ARM // SAM site if( ( IsThisSectorASAMSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) == TRUE ) && ( IsTheSAMSiteInSectorRepairable( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) ) ) @@ -8386,8 +8299,7 @@ void CreateDestroyMouseRegionForRepairMenu( void ) iCount++; } */ - - + // robot if( IsRobotInThisSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ ) ) { @@ -8396,18 +8308,16 @@ void CreateDestroyMouseRegionForRepairMenu( void ) MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 0, iCount ); MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 1, REPAIR_MENU_ROBOT ); - iCount++; + ++iCount; } - // items MSYS_DefineRegion( &gRepairMenuRegion[ iCount ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * iCount ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * ( iCount + 1 ) ), MSYS_PRIORITY_HIGHEST - 4 , MSYS_NO_CURSOR, RepairMenuMvtCallback, RepairMenuBtnCallback ); MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 0, iCount ); MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 1, REPAIR_MENU_ITEMS ); - iCount++; - + ++iCount; // cancel MSYS_DefineRegion( &gRepairMenuRegion[ iCount ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * iCount ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghAssignmentBox ) + ( iFontHeight ) * ( iCount + 1 ) ), MSYS_PRIORITY_HIGHEST - 4 , @@ -8415,8 +8325,7 @@ void CreateDestroyMouseRegionForRepairMenu( void ) MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 0, iCount ); MSYS_SetRegionUserData( &gRepairMenuRegion[ iCount ], 1, REPAIR_MENU_CANCEL ); - - + PauseGame( ); // unhighlight all strings in box @@ -8446,19 +8355,15 @@ void CreateDestroyMouseRegionForRepairMenu( void ) UnHighLightBox( ghAssignmentBox ); } } - - return; } - void RepairMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) { // btn callback handler for assignment region SOLDIERTYPE *pSoldier = NULL; INT32 iRepairWhat; - INT32 iValue = MSYS_GetRegionUserData( pRegion, 0 ); // ignore clicks on disabled lines @@ -8470,10 +8375,8 @@ void RepairMenuBtnCallback( MOUSE_REGION * pRegion, INT32 iReason ) // WHAT is being repaired is stored in the second user data argument iRepairWhat = MSYS_GetRegionUserData( pRegion, 1 ); - pSoldier = GetSelectedAssignSoldier( FALSE ); - if ( pSoldier && pSoldier->bActive && ( iReason & MSYS_CALLBACK_REASON_LBUTTON_UP ) ) { if( ( iRepairWhat >= REPAIR_MENU_VEHICLE1 ) && ( iRepairWhat <= REPAIR_MENU_VEHICLE3 ) ) @@ -8740,14 +8643,12 @@ void HandleShadingOfLinesForAssignmentMenus( void ) SOLDIERTYPE *pSoldier = NULL; // updates which menus are selectable based on character status - - + if( ( fShowAssignmentMenu == FALSE ) || ( ghAssignmentBox == - 1 ) ) { return; } - pSoldier = GetSelectedAssignSoldier( FALSE ); if ( pSoldier && pSoldier->bActive ) @@ -8766,7 +8667,6 @@ void HandleShadingOfLinesForAssignmentMenus( void ) ShadeStringInBox( ghEpcBox, EPC_MENU_PATIENT ); } - if( CanCharacterOnDuty( pSoldier ) ) { // unshade on duty line @@ -8810,7 +8710,6 @@ void HandleShadingOfLinesForAssignmentMenus( void ) // shade doctor line ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_DOCTOR ); } - } // repair @@ -8858,7 +8757,6 @@ void HandleShadingOfLinesForAssignmentMenus( void ) ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_PATIENT ); } - if( CanCharacterOnDuty( pSoldier ) ) { // unshade on duty line @@ -8870,7 +8768,6 @@ void HandleShadingOfLinesForAssignmentMenus( void ) ShadeStringInBox( ghAssignmentBox, ASSIGN_MENU_ON_DUTY ); } - if( CanCharacterPractise( pSoldier ) ) { // unshade train line @@ -8953,8 +8850,6 @@ void HandleShadingOfLinesForAssignmentMenus( void ) HandleShadingOfLinesForSnitchMenu( ); HandleShadingOfLinesForSnitchToggleMenu( ); HandleShadingOfLinesForSnitchSectorMenu( ); - - return; } @@ -9011,7 +8906,6 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) // destroy mask, if needed CreateDestroyScreenMaskForAssignmentAndContractMenus( ); - // destroy menu if needed CreateDestroyMouseRegionForVehicleMenu( ); CreateDestroyMouseRegionsForAssignmentMenu( ); @@ -9108,11 +9002,11 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) if( fShowContractMenu == FALSE ) { if ( IsBoxShown( ghRemoveMercAssignBox ) ) - { - HideBox( ghRemoveMercAssignBox ); - fTeamPanelDirty = TRUE; - gfRenderPBInterface = TRUE; - } + { + HideBox( ghRemoveMercAssignBox ); + fTeamPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + } } //HideBox( ghSquadBox ); @@ -9129,7 +9023,6 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) // create mask, if needed CreateDestroyScreenMaskForAssignmentAndContractMenus( ); - // created assignment menu if needed CreateDestroyMouseRegionsForAssignmentMenu( ); CreateDestroyMouseRegionsForTrainingMenu( ); @@ -9157,7 +9050,6 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) else { // show basic assignment menu - ShowBox( ghAssignmentBox ); } } @@ -9230,11 +9122,10 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) { HideBox( ghAttributeBox ); fTeamPanelDirty = TRUE; - fMapPanelDirty = TRUE; - gfRenderPBInterface = TRUE; - // SetRenderFlags(RENDER_FLAG_FULL); + fMapPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + // SetRenderFlags(RENDER_FLAG_FULL); } - } // VEHICLE menu @@ -9248,9 +9139,9 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) { HideBox( ghVehicleBox ); fTeamPanelDirty = TRUE; - fMapPanelDirty = TRUE; - gfRenderPBInterface = TRUE; - // SetRenderFlags(RENDER_FLAG_FULL); + fMapPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + // SetRenderFlags(RENDER_FLAG_FULL); } } @@ -9267,9 +9158,9 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) { HideBox( ghFacilityBox ); fTeamPanelDirty = TRUE; - fMapPanelDirty = TRUE; - gfRenderPBInterface = TRUE; - // SetRenderFlags(RENDER_FLAG_FULL); + fMapPanelDirty = TRUE; + gfRenderPBInterface = TRUE; + // SetRenderFlags(RENDER_FLAG_FULL); } } CreateDestroyMouseRegionForFacilityMenu( ); @@ -9346,14 +9237,11 @@ void DetermineWhichAssignmentMenusCanBeShown( void ) // SetRenderFlags(RENDER_FLAG_FULL); } } - return; } - void CreateDestroyScreenMaskForAssignmentAndContractMenus( void ) { - static BOOLEAN fCreated = FALSE; // will create a screen mask to catch mouse input to disable assignment menus @@ -9380,8 +9268,6 @@ void CreateDestroyScreenMaskForAssignmentAndContractMenus( void ) // not created fCreated = FALSE; } - - return; } @@ -9414,20 +9300,17 @@ void AssignmentScreenMaskBtnCallback(MOUSE_REGION * pRegion, INT32 iReason ) // update mapscreen - fTeamPanelDirty = TRUE; + fTeamPanelDirty = TRUE; fCharacterInfoPanelDirty = TRUE; fMapScreenBottomDirty = TRUE; - gfRenderPBInterface = TRUE; + gfRenderPBInterface = TRUE; SetRenderFlags( RENDER_FLAG_FULL ); - } - return; } void ClearScreenMaskForMapScreenExit( void ) { - // reset show assignment menu fShowAssignmentMenu = FALSE; @@ -9452,8 +9335,6 @@ void ClearScreenMaskForMapScreenExit( void ) CreateDestroyMouseRegionsForSnitchMenu( ); CreateDestroyMouseRegionsForSnitchToggleMenu( ); CreateDestroyMouseRegionsForSnitchSectorMenu( ); - - return; } void CreateDestroyMouseRegions( void ) @@ -9469,7 +9350,6 @@ void CreateDestroyMouseRegions( void ) // will create/destroy mouse regions for the map screen assignment main menu - // do we show the remove menu if( fShowRemoveMenu ) { @@ -9479,7 +9359,6 @@ void CreateDestroyMouseRegions( void ) if( ( fShowAssignmentMenu == TRUE ) && ( fCreated == FALSE ) ) { - // grab height of font iFontHeight = GetLineSpace( ghAssignmentBox ) + GetFontHeight( GetBoxFont( ghAssignmentBox ) ); @@ -9499,7 +9378,7 @@ void CreateDestroyMouseRegions( void ) SetCurrentBox( ghAssignmentBox ); // define regions - for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghAssignmentBox ); iCounter++ ) + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghAssignmentBox ); ++iCounter ) { // add mouse region for each line of text..and set user data @@ -9524,7 +9403,6 @@ void CreateDestroyMouseRegions( void ) // unhighlight all strings in box UnHighLightBox( ghAssignmentBox ); - } else if( ( fShowAssignmentMenu == FALSE ) && ( fCreated == TRUE ) ) { @@ -9539,8 +9417,6 @@ void CreateDestroyMouseRegions( void ) // not created fCreated = FALSE; } - - } @@ -9566,9 +9442,9 @@ void CreateDestroyMouseRegionsForContractMenu( void ) // dead guy handle menu stuff fShowRemoveMenu = fShowContractMenu; - // ATE: Added this setting of global variable 'cause - // it will cause an assert failure in GetSelectedAssignSoldier() - bSelectedAssignChar = bSelectedContractChar; + // ATE: Added this setting of global variable 'cause + // it will cause an assert failure in GetSelectedAssignSoldier() + bSelectedAssignChar = bSelectedContractChar; CreateDestroyMouseRegionsForRemoveMenu( ); @@ -9580,9 +9456,9 @@ void CreateDestroyMouseRegionsForContractMenu( void ) // dead guy handle menu stuff fShowRemoveMenu = fShowContractMenu; - // ATE: Added this setting of global variable 'cause - // it will cause an assert failure in GetSelectedAssignSoldier() - bSelectedAssignChar = bSelectedContractChar; + // ATE: Added this setting of global variable 'cause + // it will cause an assert failure in GetSelectedAssignSoldier() + bSelectedAssignChar = bSelectedContractChar; CreateDestroyMouseRegionsForRemoveMenu( ); @@ -9590,7 +9466,6 @@ void CreateDestroyMouseRegionsForContractMenu( void ) } } - if( ( fShowContractMenu == TRUE ) && ( fCreated == FALSE ) ) { if( bSelectedContractChar == -1 ) @@ -9600,7 +9475,7 @@ void CreateDestroyMouseRegionsForContractMenu( void ) if( fShowContractMenu ) { - SetBoxPosition( ghContractBox , ContractPosition ); + SetBoxPosition( ghContractBox , ContractPosition ); } // grab height of font iFontHeight = GetLineSpace( ghContractBox ) + GetFontHeight( GetBoxFont( ghContractBox ) ); @@ -9621,11 +9496,9 @@ void CreateDestroyMouseRegionsForContractMenu( void ) SetCurrentBox( ghContractBox ); // define regions - for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghContractBox ); iCounter++ ) + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghContractBox ); ++iCounter ) { // add mouse region for each line of text..and set user data - - MSYS_DefineRegion( &gContractMenuRegion[ iCounter ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghContractBox ) + ( iFontHeight ) * iCounter ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghContractBox ) + ( iFontHeight ) * ( iCounter + 1 ) ), MSYS_PRIORITY_HIGHEST - 4 , MSYS_NO_CURSOR, ContractMenuMvtCallback, ContractMenuBtnCallback ); @@ -9641,7 +9514,6 @@ void CreateDestroyMouseRegionsForContractMenu( void ) // unhighlight all strings in box UnHighLightBox( ghContractBox ); - } else if( ( fShowContractMenu == FALSE ) && ( fCreated == TRUE ) ) { @@ -9675,7 +9547,7 @@ void CreateDestroyMouseRegionsForContractMenu( void ) } - +// will create/destroy mouse regions for the map screen assignment main menu void CreateDestroyMouseRegionsForTrainingMenu( void ) { static BOOLEAN fCreated = FALSE; @@ -9686,11 +9558,7 @@ void CreateDestroyMouseRegionsForTrainingMenu( void ) SGPPoint pPosition; INT32 iBoxWidth = 0; SGPRect pDimensions; - - // will create/destroy mouse regions for the map screen assignment main menu - - - + if( ( fShowTrainingMenu == TRUE ) && ( fCreated == FALSE ) ) { // Moa: removed, this missplaces popups when screensize>3. @@ -9723,11 +9591,9 @@ void CreateDestroyMouseRegionsForTrainingMenu( void ) SetCurrentBox( ghTrainingBox ); // define regions - for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghTrainingBox ); iCounter++ ) + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghTrainingBox ); ++iCounter ) { // add mouse region for each line of text..and set user data - - MSYS_DefineRegion( &gTrainingMenuRegion[ iCounter ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghTrainingBox ) + ( iFontHeight ) * iCounter ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghTrainingBox ) + ( iFontHeight ) * ( iCounter + 1 ) ), MSYS_PRIORITY_HIGHEST - 3 , MSYS_NO_CURSOR, TrainingMenuMvtCallBack, TrainingMenuBtnCallback ); @@ -9740,7 +9606,6 @@ void CreateDestroyMouseRegionsForTrainingMenu( void ) // unhighlight all strings in box UnHighLightBox( ghTrainingBox ); - } else if( ( ( fShowAssignmentMenu == FALSE ) || ( fShowTrainingMenu == FALSE ) ) && ( fCreated == TRUE ) ) { @@ -9777,7 +9642,7 @@ void CreateDestroyMouseRegionsForTrainingMenu( void ) } - +// will create/destroy mouse regions for the map screen attribute menu void CreateDestroyMouseRegionsForAttributeMenu( void ) { static BOOLEAN fCreated = FALSE; @@ -9788,11 +9653,7 @@ void CreateDestroyMouseRegionsForAttributeMenu( void ) SGPPoint pPosition; INT32 iBoxWidth = 0; SGPRect pDimensions; - - // will create/destroy mouse regions for the map screen attribute menu - - - + if( ( fShowAttributeMenu == TRUE ) && ( fCreated == FALSE ) ) { // Moa: removed, this missplaces popups when screensize>3. @@ -9823,7 +9684,7 @@ void CreateDestroyMouseRegionsForAttributeMenu( void ) SetCurrentBox( ghAttributeBox ); // define regions - for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghAttributeBox ); iCounter++ ) + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghAttributeBox ); ++iCounter ) { // add mouse region for each line of text..and set user data @@ -9840,7 +9701,6 @@ void CreateDestroyMouseRegionsForAttributeMenu( void ) // unhighlight all strings in box UnHighLightBox( ghAttributeBox ); - } else if( ( ( fShowAssignmentMenu == FALSE ) || ( fShowTrainingMenu == FALSE ) ||( fShowAttributeMenu == FALSE) ) && ( fCreated == TRUE ) ) { @@ -9857,7 +9717,6 @@ void CreateDestroyMouseRegionsForAttributeMenu( void ) gfRenderPBInterface = TRUE; } - RestorePopUpBoxes( ); fMapPanelDirty = TRUE; @@ -9879,7 +9738,6 @@ void CreateDestroyMouseRegionsForAttributeMenu( void ) } - void CreateDestroyMouseRegionsForRemoveMenu( void ) { static BOOLEAN fCreated = FALSE; @@ -9975,10 +9833,6 @@ void CreateDestroyMouseRegionsForRemoveMenu( void ) gfRenderPBInterface = TRUE; } - - - - RestorePopUpBoxes( ); fMapPanelDirty = TRUE; @@ -9994,8 +9848,6 @@ void CreateDestroyMouseRegionsForRemoveMenu( void ) // not created fCreated = FALSE; } - - } @@ -10010,7 +9862,6 @@ void CreateDestroyMouseRegionsForSquadMenu( BOOLEAN fPositionBox ) INT32 iBoxWidth = 0; SGPRect pDimensions; - // will create/destroy mouse regions for the map screen attribute menu if( ( fShowSquadMenu == TRUE ) && ( fCreated == FALSE ) ) @@ -10027,7 +9878,6 @@ void CreateDestroyMouseRegionsForSquadMenu( BOOLEAN fPositionBox ) // get x.y position of box GetBoxPosition( ghSquadBox, &pPosition); - // grab box x and y position iBoxXPosition = pPosition.iX; iBoxYPosition = pPosition.iY; @@ -10041,7 +9891,7 @@ void CreateDestroyMouseRegionsForSquadMenu( BOOLEAN fPositionBox ) SetCurrentBox( ghSquadBox ); // define regions - for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghSquadBox ) - 1; iCounter++ ) + for( iCounter = 0; iCounter < GetNumberOfLinesOfTextInBox( ghSquadBox ) - 1; ++iCounter ) { // add mouse region for each line of text..and set user data MSYS_DefineRegion( &gSquadMenuRegion[ iCounter ], ( INT16 )( iBoxXPosition ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghSquadBox ) + ( iFontHeight ) * iCounter ), ( INT16 )( iBoxXPosition + iBoxWidth ), ( INT16 )( iBoxYPosition + GetTopMarginSize( ghSquadBox ) + ( iFontHeight ) * ( iCounter + 1 ) ), MSYS_PRIORITY_HIGHEST - 2 , @@ -10056,7 +9906,6 @@ void CreateDestroyMouseRegionsForSquadMenu( BOOLEAN fPositionBox ) MSYS_SetRegionUserData( &gSquadMenuRegion[ iCounter ], 0, SQUAD_MENU_CANCEL ); - // created fCreated = TRUE; diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 837b7c338..315c173ad 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -4076,26 +4076,23 @@ static int l_FadeOutGameScreen(lua_State *L) int l_InitMapProfil (lua_State *L) { if ( lua_gettop(L) >= 1 ) - { - - UINT8 prof = lua_tointeger(L,1); - INT16 x = lua_tointeger(L,2); - INT16 y = lua_tointeger(L,3); - INT16 z = lua_tointeger(L,4); - UINT32 gridno = lua_tointeger(L,5); - - gMercProfiles[ prof ].sSectorX = x; - gMercProfiles[ prof ].sSectorY = y; - gMercProfiles[ prof ].bSectorZ = z; - gMercProfiles[ prof ].sGridNo = gridno; - gMercProfiles[ prof ].fUseProfileInsertionInfo = TRUE; - gMercProfiles[ prof ].ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; - gMercProfiles[ prof ].usStrategicInsertionData = gridno; + { + UINT8 prof = lua_tointeger(L,1); + INT16 x = lua_tointeger(L,2); + INT16 y = lua_tointeger(L,3); + INT8 z = lua_tointeger(L,4); + UINT32 gridno = lua_tointeger(L,5); + gMercProfiles[ prof ].sSectorX = x; + gMercProfiles[ prof ].sSectorY = y; + gMercProfiles[ prof ].bSectorZ = z; + gMercProfiles[ prof ].sGridNo = gridno; + gMercProfiles[ prof ].fUseProfileInsertionInfo = TRUE; + gMercProfiles[ prof ].ubStrategicInsertionCode = INSERTION_CODE_GRIDNO; + gMercProfiles[ prof ].usStrategicInsertionData = gridno; } - return 0; - + return 0; } static int l_ProfilesStrategicInsertionData (lua_State *L) diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index 8412887f6..bf04d374d 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -4006,7 +4006,7 @@ void DisplayDistancesForHelicopter( void ) UINT32 uiCostRed = __max(0,gGameExternalOptions.usHelicopterBaseCostPerRedTile + gsSkyriderCostModifier); uiTripCost = ( sNumSafeSectors * uiCostGreen ) + ( sNumUnSafeSectors * uiCostRed ); - if( uiTripCost > LaptopSaveInfo.iCurrentBalance ) + if( (INT32)uiTripCost > LaptopSaveInfo.iCurrentBalance ) SetFontForeground( FONT_LTRED ); swprintf( sString, L"%d", uiTripCost ); diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 6931d841a..7772bee33 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -5756,7 +5756,7 @@ void RemoveProhibitedAttachments(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, UINT16 // put it on the ground //dnl ch75 281013 INT32 sGridNo = NOWHERE; UINT8 ubLevel = 0; - for(int i=0; iusItem ].usItemClass == IC_LAUNCHER ) fModifier = gItemSettings.fAPtoReloadModifierLauncher; - return ( Weapon[ pObj->usItem ].APsToReload * fModifier * - ( 100 - GetPercentReloadTimeAPReduction(pObj) ) ) / 100; - + return ( Weapon[ pObj->usItem ].APsToReload * fModifier * ( 100 - GetPercentReloadTimeAPReduction(pObj) ) ) / 100; } // HEADROCK HAM 3.4: Estimates the number of bullets left in the gun. For use during combat. - CHAR16 gBulletCount[10]; // This is a global containing the bullet count string void EstimateBulletsLeft( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObj ) { - UINT16 usExpLevel; UINT32 usDexterity; UINT32 usWisdom; diff --git a/TacticalAI/Movement.cpp b/TacticalAI/Movement.cpp index 441d00c01..74f48f62d 100644 --- a/TacticalAI/Movement.cpp +++ b/TacticalAI/Movement.cpp @@ -41,14 +41,14 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubPathMode, if ((sGridNo < 0) || (sGridNo >= GRIDSIZE)) { #ifdef RECORDNET - fprintf(NetDebugFile,"LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno %d",GridNo); + fprintf(NetDebugFile,"LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno %d",GridNo); #endif #ifdef BETAVERSION - NumMessage("LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno ",GridNo); + NumMessage("LegalNPC->pathing.sDestination: ERROR - rcvd invalid gridno ",GridNo); #endif - return(FALSE); + return(FALSE); } //dnl ch53 121009 Return false if gridno on different level from merc or inside unvisible area @@ -58,33 +58,32 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubPathMode, // skip mercs if turnbased and adjacent AND not doing an IGNORE_PATH check (which is used almost exclusively by GoAsFarAsPossibleTowards) fSkipTilesWithMercs = (gfTurnBasedAI && ubPathMode != IGNORE_PATH && SpacesAway( pSoldier->sGridNo, sGridNo ) == 1 ); - // if this gridno is an OK destination - // AND the gridno is NOT in a tear-gassed tile when we have no gas mask - // AND someone is NOT already standing there - // AND we're NOT already standing at that gridno - // AND the gridno hasn't been black-listed for us + // if this gridno is an OK destination + // AND the gridno is NOT in a tear-gassed tile when we have no gas mask + // AND someone is NOT already standing there + // AND we're NOT already standing at that gridno + // AND the gridno hasn't been black-listed for us - // Nov 28 98: skip people in destination tile if in turnbased - if ( ( NewOKDestination(pSoldier, sGridNo, fSkipTilesWithMercs, pSoldier->pathing.bLevel ) ) && + // Nov 28 98: skip people in destination tile if in turnbased + if ( ( NewOKDestination(pSoldier, sGridNo, fSkipTilesWithMercs, pSoldier->pathing.bLevel ) ) && ( !InGas( pSoldier, sGridNo ) ) && ( sGridNo != pSoldier->sGridNo ) && ( sGridNo != pSoldier->pathing.sBlackList ) ) - /* - if ( ( NewOKDestination(pSoldier, sGridno, FALSE, pSoldier->pathing.bLevel ) ) && - ( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) && - ( sGridno != pSoldier->sGridNo ) && - ( sGridno != pSoldier->pathing.sBlackList ) )*/ - /* - if ( ( NewOKDestination(pSoldier,sGridno,ALLPEOPLE, pSoldier->pathing.bLevel ) ) && - ( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) && - ( sGridno != pSoldier->sGridNo ) && - ( sGridno != pSoldier->pathing.sBlackList ) ) - */ + /* + if ( ( NewOKDestination(pSoldier, sGridno, FALSE, pSoldier->pathing.bLevel ) ) && + ( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) && + ( sGridno != pSoldier->sGridNo ) && + ( sGridno != pSoldier->pathing.sBlackList ) )*/ + /* + if ( ( NewOKDestination(pSoldier,sGridno,ALLPEOPLE, pSoldier->pathing.bLevel ) ) && + ( !(gpWorldLevelData[ sGridno ].ubExtFlags[0] & (MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) || ( pSoldier->inv[ HEAD1POS ].usItem == GASMASK || pSoldier->inv[ HEAD2POS ].usItem == GASMASK ) ) && + ( sGridno != pSoldier->sGridNo ) && + ( sGridno != pSoldier->pathing.sBlackList ) ) + */ { - - // if water's a problem, and gridno is in a water tile (bridges are OK) + // if water's a problem, and gridno is in a water tile (bridges are OK) if (!ubWaterOK && Water(sGridNo)) - return(FALSE); + return(FALSE); //Madd: added to prevent people from running into gas and fire if ( (gpWorldLevelData[sGridNo].ubExtFlags[pSoldier->pathing.bLevel] & (MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS)) && @@ -97,34 +96,35 @@ int LegalNPCDestination(SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubPathMode, return( FALSE ); } + // passed all checks, now try to make sure we can get there! + switch (ubPathMode) + { + // if finding a path wasn't asked for (could have already been done, + // for example), don't bother + case IGNORE_PATH : return(TRUE); - // passed all checks, now try to make sure we can get there! - switch (ubPathMode) - { - // if finding a path wasn't asked for (could have already been done, - // for example), don't bother - case IGNORE_PATH : return(TRUE); + case ENSURE_PATH : if ( FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, COPYROUTE, fFlags ) ) + { + return(TRUE); // legal destination + } + else // got this far, but found no clear path, + { + // so test fails + return(FALSE); + } - case ENSURE_PATH : if ( FindBestPath( pSoldier, sGridNo, pSoldier->pathing.bLevel, WALKING, COPYROUTE, fFlags ) ) - { - return(TRUE); // legal destination - } - else // got this far, but found no clear path, - { - // so test fails - return(FALSE); - } - // *** NOTE: movement mode hardcoded to WALKING !!!!! + // *** NOTE: movement mode hardcoded to WALKING !!!!! case ENSURE_PATH_COST: return(PlotPath(pSoldier,sGridNo,FALSE,FALSE,FALSE,WALKING,FALSE,FALSE,0)); - default : + default : #ifdef BETAVERSION NumMessage("LegalNPC->pathing.sDestination: ERROR - illegal pathMode = ",ubPathMode); #endif return(FALSE); - } + } } - else // something failed - didn't even have to test path + + // something failed - didn't even have to test path return(FALSE); // illegal destination }