diff --git a/GameVersion.cpp b/GameVersion.cpp index b9f1e55a..2a226583 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8541 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8541 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8541 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8541 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8541 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,16 +46,16 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8541 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8541 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8537 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8541 (Development Build)" }; #endif #endif -CHAR8 czVersionNumber[16] = { "Build 18.03.04" }; //YY.MM.DD +CHAR8 czVersionNumber[16] = { "Build 18.03.08" }; //YY.MM.DD CHAR16 zTrackingNumber[16] = { L"Z" }; // SAVE_GAME_VERSION is defined in header, change it there diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 9dc63c26..19835ace 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -2442,8 +2442,6 @@ void HandleNonCombatGroupArrival( GROUP *pGroup, BOOLEAN fMainGroup, BOOLEAN fNe } } - //MilitiaFollowPlayer( pGroup->ubPrevX, pGroup->ubPrevY, pGroup->ubSectorX, pGroup->ubSectorY ); - // look for NPCs to stop for, anyone is too tired to keep going, if all OK rebuild waypoints & continue movement // NOTE: Only the main group (first group arriving) will stop for NPCs, it's just too much hassle to stop them all PlayerGroupArrivedSafelyInSector( pGroup, fMainGroup ); @@ -2501,7 +2499,7 @@ void HandleOtherGroupsArrivingSimultaneously( UINT8 ubSectorX, UINT8 ubSectorY, } // Flugente: concealed spies are added if a battle occurs - if ( !IsGroupTheHelicopterGroup( pArrivingGroup ) ) + if ( pArrivingGroup && !IsGroupTheHelicopterGroup( pArrivingGroup ) ) { UINT16 uiCnt = 0; SOLDIERTYPE* pSoldier = NULL; diff --git a/Strategic/Strategic Pathing.cpp b/Strategic/Strategic Pathing.cpp index 854f78e8..5451f1f1 100644 --- a/Strategic/Strategic Pathing.cpp +++ b/Strategic/Strategic Pathing.cpp @@ -911,17 +911,14 @@ PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX PathStPtr pDeleteNode = pHeadOfPath; INT16 sSector = 0; INT16 sCurrentSector = -1; - - - + // is there in fact a path? if( pNode == NULL ) { // no path, leave return ( pNode ); } - - + // get sector value sSector = sX + ( sY * MAP_WORLD_X ); @@ -934,7 +931,6 @@ PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX // move through list while( ( pNode )&&( sSector != sCurrentSector ) ) { - // next value pNode = pNode->pPrev; @@ -951,8 +947,7 @@ PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX // nope, leave return ( pHeadOfPath ); } - - + // we want to KEEP the target sector, not delete it, so advance to the next sector pNode = pNode->pNext; @@ -963,7 +958,6 @@ PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX return ( pHeadOfPath ); } - // if we're NOT about to clear the head (there's a previous entry) if( pNode->pPrev ) { @@ -997,7 +991,104 @@ PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX // delete delete node MemFree( pDeleteNode ); } + + // clear out last node + MemFree( pNode ); + pNode = NULL; + pDeleteNode = NULL; + return( pHeadOfPath ); +} + +PathStPtr ClearStrategicPathListBeforeThisSector( PathStPtr pHeadOfPath, INT16 sX, INT16 sY, INT16 sMvtGroup ) +{ + // will clear out a strategic path and return head of list as NULL + PathStPtr pNode = pHeadOfPath; + PathStPtr pDeleteNode = pHeadOfPath; + INT16 sSector = 0; + INT16 sCurrentSector = -1; + + // is there in fact a path? + if ( pNode == NULL ) + { + // no path, leave + return ( pNode ); + } + + // get sector value + sSector = sX + ( sY * MAP_WORLD_X ); + + // go to end of list + pNode = MoveToBeginningOfPathList( pNode ); + + // get current sector value + sCurrentSector = (INT16)pNode->uiSectorId; + + // move through list + while ( ( pNode ) && ( sSector != sCurrentSector ) ) + { + // next value + pNode = pNode->pNext; + + // get current sector value + if ( pNode != NULL ) + { + sCurrentSector = (INT16)pNode->uiSectorId; + } + } + + // did we find the target sector? + if ( pNode == NULL ) + { + // nope, leave + return ( pHeadOfPath ); + } + + // we want to KEEP the target sector, not delete it, so advance to the next sector + pNode = pNode->pPrev; + + // is nothing left? + if ( pNode == NULL ) + { + // that's it, leave + return ( pHeadOfPath ); + } + + // if we're NOT about to clear the head (there's a previous entry) + if ( pNode->pNext ) + { + // set next for tail to NULL + pNode->pNext->pPrev = NULL; + } + else + { + // clear head, return NULL + pHeadOfPath = ClearStrategicPathList( pHeadOfPath, sMvtGroup ); + + return ( NULL ); + } + + pHeadOfPath = pNode->pNext; + + // clear list + while ( pNode->pPrev ) + { + // set up delete node + pDeleteNode = pNode; + + // move to next node + pNode = pNode->pPrev; + + // check if we are clearing the head of the list + if ( pDeleteNode == pHeadOfPath ) + { + // null out head + pHeadOfPath = NULL; + } + + // delete delete node + MemFree( pDeleteNode ); + } // clear out last node MemFree( pNode ); diff --git a/Strategic/Strategic Pathing.h b/Strategic/Strategic Pathing.h index ff7ce833..a0cde0ab 100644 --- a/Strategic/Strategic Pathing.h +++ b/Strategic/Strategic Pathing.h @@ -67,6 +67,9 @@ PathStPtr RemoveSectorFromStrategicPathList( PathStPtr pList , INT16 sX, INT16 s // clear out path list after/including this sector sX, sY..will start at end of path and work it's way back till sector is found...removes most recent sectors first PathStPtr ClearStrategicPathListAfterThisSector( PathStPtr pHeadOfPath, INT16 sX, INT16 sY, INT16 sMvtGroup ); +// similar to above, clear out the path from the start until the sector is found +PathStPtr ClearStrategicPathListBeforeThisSector( PathStPtr pHeadOfPath, INT16 sX, INT16 sY, INT16 sMvtGroup ); + // get id of last sector in mercs path list INT16 GetLastSectorIdInCharactersPath( SOLDIERTYPE *pCharacter ); diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 583a7cd4..1c3720dc 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -8948,7 +8948,8 @@ void PollLeftButtonInMapView( UINT32 *puiNewEvent ) } else // clicked on a new sector { - gfAllowSkyriderTooFarQuote = TRUE; + if ( fPlotForHelicopter ) + gfAllowSkyriderTooFarQuote = TRUE; // draw new map route *puiNewEvent = MAP_EVENT_PLOT_PATH; @@ -8980,8 +8981,7 @@ void PollRightButtonInMapView( UINT32 *puiNewEvent ) { static BOOLEAN fRBBeenPressedInMapView = FALSE; INT16 sMapX, sMapY; - - + // if the mouse is currently over the MAP area if ( gMapViewRegion.uiFlags & MSYS_MOUSE_IN_AREA ) { @@ -12487,7 +12487,6 @@ BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ) return ( FALSE ); } - void HandleSpontanousTalking( ) { // simply polls if the talking guy is done, if so...send an end command to continue dialogue @@ -12499,19 +12498,15 @@ void HandleSpontanousTalking( ) ContinueDialogue( ( &Menptr[gCharactersList[bSelectedInfoChar].usSolID] ), TRUE ); } } - - return; } - BOOLEAN CheckIfClickOnLastSectorInPath( INT16 sX, INT16 sY ) { PathStPtr *ppMovePath = NULL; BOOLEAN fLastSectorInPath = FALSE; INT32 iVehicleId = -1; PathStPtr pPreviousMercPath = NULL; - - + // see if we have clicked on the last sector in the characters path // check if helicopter @@ -12545,23 +12540,24 @@ BOOLEAN CheckIfClickOnLastSectorInPath( INT16 sX, INT16 sY ) // helicopter route confirmed if ( gMilitiaPath[gMilitiaGroupId].sGroupid > -1 && sX + (sY * MAP_WORLD_X) == GetLastSectorOfMilitiaPath( ) ) { - // if confirm moving to another sector - //if( ( CheckForClickOverHelicopterIcon( sX, sY ) == FALSE ) ) - { - // take off - //TakeOffHelicopter( ); - } + // rebuild waypoints + ppMovePath = &( gMilitiaPath[gMilitiaGroupId].path ); - // rebuild waypoints - helicopter - ppMovePath = &(gMilitiaPath[gMilitiaGroupId].path); + // if our current sector is in our path, and we are not moving, we can obviously delete what came before it from the path + // (this was added as there were occasions where the previous path was not properly cleared even though the group was no longer travelling) + GROUP* pGroup = GetGroup( (UINT8)gMilitiaPath[gMilitiaGroupId].sGroupid ); + + if ( pGroup && pGroup->usGroupTeam == MILITIA_TEAM && !pGroup->fBetweenSectors ) + { + *ppMovePath = ClearStrategicPathListBeforeThisSector( *ppMovePath, pGroup->ubSectorX, pGroup->ubSectorY, gMilitiaPath[gMilitiaGroupId].sGroupid ); + } + RebuildWayPointsForGroupPath( *ppMovePath, (UINT8)gMilitiaPath[gMilitiaGroupId].sGroupid ); - // pointer to previous helicopter path + // pointer to previous path pPreviousMercPath = gpMilitiaPreviousMercPath; fLastSectorInPath = TRUE; - - //gMilitiaPlotStartSector = (INT16)(sX + sY*(MAP_WORLD_X));//SECTOR(sX, sY); } } else // not doing helicopter movement