From 6f253e7e49db020f09671f7b1b07c09f5081f416 Mon Sep 17 00:00:00 2001 From: Wanne Date: Mon, 19 May 2014 18:49:20 +0000 Subject: [PATCH] Driveable vehicle update (by anv) - Vehicles can now exit sector in tactical screen. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7216 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/strategicmap.cpp | 17 +++++++++++++++-- Tactical/Overhead.cpp | 12 +++++++++--- Tactical/Strategic Exit GUI.cpp | 18 ++++++++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index ddd8e722..b6974037 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -4089,7 +4089,12 @@ void JumpIntoAdjacentSector( UINT8 ubTacticalDirection, UINT8 ubJumpCode, INT32 curr = pGroup->pPlayerList; while( curr ) { - if ( OK_CONTROLLABLE_MERC( curr->pSoldier) ) + // anv: passengers can't move anyway + if( curr->pSoldier->bAssignment == VEHICLE ) + { + curr->pSoldier->ubWaitActionToDo = 0; + } + else if ( OK_CONTROLLABLE_MERC( curr->pSoldier ) ) { if ( ubTacticalDirection != 255 ) { @@ -4784,6 +4789,12 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu return FALSE; } + // anv: vehicles can't use inner exit grids + if( bExitDirection == (-1) && MercPtrs[gusSelectedSoldier]->bAssignment == VEHICLE ) + { + return FALSE; + } + /* //Exception code for the two sectors in San Mona that are separated by a cliff. We want to allow strategic //traversal, but NOT tactical traversal. The only way to tactically go from D4 to D5 (or viceversa) is to enter @@ -4812,7 +4823,9 @@ BOOLEAN OKForSectorExit( INT8 bExitDirection, INT32 usAdditionalData, UINT32 *pu for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++,pSoldier++) { // If we are controllable - if ( OK_CONTROLLABLE_MERC( pSoldier) && pSoldier->bAssignment == CurrentSquad( ) ) + //if ( OK_CONTROLLABLE_MERC( pSoldier) && pSoldier->bAssignment == CurrentSquad( ) ) + if ( OK_CONTROLLABLE_MERC( pSoldier) && ( pSoldier->bAssignment == CurrentSquad( ) || + ( pSoldier->bAssignment == VEHICLE && GetSoldierStructureForVehicle(pSoldier->iVehicleId)->bAssignment == CurrentSquad( ) ) ) ) { //Need to keep a copy of a good soldier, so we can access it later, and //not more than once. diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 7c927af4..bafbdd79 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -4557,9 +4557,15 @@ UINT8 FindNextActiveAndAliveMerc( SOLDIERTYPE *pSoldier, BOOLEAN fGoodForLessOKL SOLDIERTYPE *FindNextActiveSquad( SOLDIERTYPE *pSoldier ) { INT32 cnt, cnt2; + + // anv: soldier's "assignment" can be a vehicle, not a proper squad, causing out-of-range in second loop + INT8 bMaxSquad = pSoldier->bAssignment; + if( bMaxSquad >= NUMBER_OF_SQUADS ) + { + bMaxSquad = NUMBER_OF_SQUADS - 1; + } - - for( cnt = pSoldier->bAssignment + 1 ; cnt < NUMBER_OF_SQUADS; cnt++ ) + for( cnt = bMaxSquad + 1 ; cnt < NUMBER_OF_SQUADS; cnt++ ) { for( cnt2 =0; cnt2 < NUMBER_OF_SOLDIERS_PER_SQUAD; cnt2++ ) { @@ -4572,7 +4578,7 @@ SOLDIERTYPE *FindNextActiveSquad( SOLDIERTYPE *pSoldier ) // none found, // Now loop back - for( cnt = 0; cnt <= pSoldier->bAssignment; cnt++ ) + for( cnt = 0; cnt <= bMaxSquad; cnt++ ) { for( cnt2 =0; cnt2 < NUMBER_OF_SOLDIERS_PER_SQUAD; cnt2++ ) { diff --git a/Tactical/Strategic Exit GUI.cpp b/Tactical/Strategic Exit GUI.cpp index c97d0022..368383ed 100644 --- a/Tactical/Strategic Exit GUI.cpp +++ b/Tactical/Strategic Exit GUI.cpp @@ -181,6 +181,17 @@ BOOLEAN InternalInitSectorExitMenu( UINT8 ubDirection, INT32 sAdditionalData )// gExitDialog.fAllMove = TRUE; } + // anv: vehicle always move with all passengers inside + if( MercPtrs[gusSelectedSoldier]->bAssignment == VEHICLE ) + { + gExitDialog.fSingleMoveDisabled = TRUE; + gExitDialog.fSingleMoveOn = FALSE; + gExitDialog.fSingleMove = FALSE; + gExitDialog.fAllMoveDisabled = FALSE; + gExitDialog.fAllMoveOn = TRUE; + gExitDialog.fAllMove = TRUE; + } + if ( gTacticalStatus.uiFlags & INCOMBAT ) { INT32 i, cnt = 0; @@ -224,11 +235,14 @@ BOOLEAN InternalInitSectorExitMenu( UINT8 ubDirection, INT32 sAdditionalData )// if( !pSoldier->flags.fBetweenSectors && pSoldier->sSectorX == gWorldSectorX && pSoldier->sSectorY == gWorldSectorY && pSoldier->bSectorZ == gbWorldSectorZ && pSoldier->stats.bLife >= OKLIFE && - pSoldier->bAssignment != MercPtrs[ gusSelectedSoldier ]->bAssignment && - pSoldier->bAssignment != ASSIGNMENT_POW && pSoldier->bAssignment != IN_TRANSIT && pSoldier->bAssignment != ASSIGNMENT_DEAD ) + ( pSoldier->bAssignment != MercPtrs[ gusSelectedSoldier ]->bAssignment || + ( pSoldier->bAssignment == VEHICLE && pSoldier->iVehicleId != MercPtrs[ gusSelectedSoldier ]->iVehicleId ) ) && + pSoldier->bAssignment != ASSIGNMENT_POW && pSoldier->bAssignment != IN_TRANSIT && pSoldier->bAssignment != ASSIGNMENT_DEAD + && !(pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) ) { //KM: We need to determine if there are more than one squad (meaning other concious mercs in a different squad or assignment) // These conditions were done to the best of my knowledge, so if there are other situations that require modification, // then feel free to do so. + // anv: added skipping vehicles and checking if soldiers on the same assignment aren't just in two different vehicles gExitDialog.fMultipleSquadsInSector = TRUE; break; }