- Fix: possible crash if enemy forces arrive via non-group (enemy heli)

- Fix: possible crash when ordering militia to move if previous path was not properly cleared

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8541 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-03-08 21:49:26 +00:00
parent 1e38e07ad9
commit d6db35f000
5 changed files with 129 additions and 41 deletions
+9 -9
View File
@@ -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
+1 -3
View File
@@ -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;
+100 -9
View File
@@ -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 );
+3
View File
@@ -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 );
+16 -20
View File
@@ -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