mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
- Fix: wrong final destination displayed for travelling militia
- Fix: when ordering militia movement, data of another group's path can be erased - Fix: a militia groups's path isn't always destroyed if the group is deleted - Fix: unsafe pointer handling can result in a gamecrash when loading strategic AI data from a savegame - Fix: traveltime calculations do not correctly handle waypoints, resulting in possible crashes git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7876 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -7850,7 +7850,7 @@ void DisplayMilitiaGroupBox()
|
|||||||
INT16 finalsector = GetLastSectorIdInMilitiaGroupPath( pGroup->ubGroupID );
|
INT16 finalsector = GetLastSectorIdInMilitiaGroupPath( pGroup->ubGroupID );
|
||||||
if ( finalsector > -1 )
|
if ( finalsector > -1 )
|
||||||
{
|
{
|
||||||
GetShortSectorString( SECTORX( finalsector ), SECTORY( finalsector ), wFinalSectorName );
|
GetShortSectorString( finalsector % MAP_WORLD_X, finalsector / MAP_WORLD_X, wFinalSectorName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2991,6 +2991,8 @@ void DissolveMilitiaGroup( UINT8 uGroupId )
|
|||||||
|
|
||||||
if ( pGroup && pGroup->usGroupTeam == MILITIA_TEAM )
|
if ( pGroup && pGroup->usGroupTeam == MILITIA_TEAM )
|
||||||
{
|
{
|
||||||
|
ClearMercPathsAndWaypointsForAllInGroup( pGroup );
|
||||||
|
|
||||||
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, GREEN_MILITIA, pGroup->pEnemyGroup->ubNumAdmins );
|
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, GREEN_MILITIA, pGroup->pEnemyGroup->ubNumAdmins );
|
||||||
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, REGULAR_MILITIA, pGroup->pEnemyGroup->ubNumTroops );
|
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, REGULAR_MILITIA, pGroup->pEnemyGroup->ubNumTroops );
|
||||||
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, ELITE_MILITIA, pGroup->pEnemyGroup->ubNumElites );
|
StrategicAddMilitiaToSector( pGroup->ubSectorX, pGroup->ubSectorY, ELITE_MILITIA, pGroup->pEnemyGroup->ubNumElites );
|
||||||
|
|||||||
@@ -2120,7 +2120,6 @@ void RetreatAllInvolvedMilitiaGroups()
|
|||||||
GROUP* pDeleteGroup = pGroup;
|
GROUP* pDeleteGroup = pGroup;
|
||||||
pGroup = pGroup->next;
|
pGroup = pGroup->next;
|
||||||
|
|
||||||
ClearMercPathsAndWaypointsForAllInGroup( pDeleteGroup );
|
|
||||||
DissolveMilitiaGroup( pDeleteGroup->ubGroupID );
|
DissolveMilitiaGroup( pDeleteGroup->ubGroupID );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -2295,7 +2295,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Strategic5");
|
|||||||
SetThisSectorAsEnemyControlled( pGroup->ubSectorX, pGroup->ubSectorY, 0, TRUE );
|
SetThisSectorAsEnemyControlled( pGroup->ubSectorX, pGroup->ubSectorY, 0, TRUE );
|
||||||
RemovePGroup( pGroup );
|
RemovePGroup( pGroup );
|
||||||
RecalculateGarrisonWeight( i );
|
RecalculateGarrisonWeight( i );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4198,8 +4198,15 @@ BOOLEAN LoadStrategicAI( HWFILE hFile )
|
|||||||
pGroup->ubSectorY != gWorldSectorY ||
|
pGroup->ubSectorY != gWorldSectorY ||
|
||||||
gbWorldSectorZ )
|
gbWorldSectorZ )
|
||||||
{
|
{
|
||||||
|
UINT8 groupid = pGroup->ubGroupID;
|
||||||
|
|
||||||
RepollSAIGroup( pGroup );
|
RepollSAIGroup( pGroup );
|
||||||
ValidateGroup( pGroup );
|
|
||||||
|
// it is possible that the group gets destroyed inbetween, so recheck on that
|
||||||
|
pGroup = GetGroup( groupid );
|
||||||
|
|
||||||
|
if ( pGroup )
|
||||||
|
ValidateGroup( pGroup );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3185,6 +3185,7 @@ INT32 CalculateTravelTimeOfGroup( GROUP *pGroup )
|
|||||||
{
|
{
|
||||||
INT32 iDelta;
|
INT32 iDelta;
|
||||||
UINT32 uiEtaTime = 0;
|
UINT32 uiEtaTime = 0;
|
||||||
|
INT32 i = 0;
|
||||||
WAYPOINT *pNode = NULL;
|
WAYPOINT *pNode = NULL;
|
||||||
WAYPOINT pCurrent, pDest;
|
WAYPOINT pCurrent, pDest;
|
||||||
// check if valid group
|
// check if valid group
|
||||||
@@ -3197,6 +3198,18 @@ INT32 CalculateTravelTimeOfGroup( GROUP *pGroup )
|
|||||||
// set up next node
|
// set up next node
|
||||||
pNode = pGroup->pWaypoints;
|
pNode = pGroup->pWaypoints;
|
||||||
|
|
||||||
|
// Flugente: start with the next waypoint we travel to, not the first one in the list
|
||||||
|
i = pGroup->ubNextWaypointID;
|
||||||
|
while ( i-- )
|
||||||
|
{
|
||||||
|
//Traverse through the waypoint list to the next waypoint ID
|
||||||
|
if( pNode );
|
||||||
|
pNode = pNode->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !pNode )
|
||||||
|
return uiEtaTime;
|
||||||
|
|
||||||
// now get the delta in current sector and next sector
|
// now get the delta in current sector and next sector
|
||||||
iDelta = ( INT32 )( SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ) - SECTOR( pGroup->ubNextX, pGroup->ubNextY ) );
|
iDelta = ( INT32 )( SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ) - SECTOR( pGroup->ubNextX, pGroup->ubNextY ) );
|
||||||
|
|
||||||
|
|||||||
@@ -16760,7 +16760,7 @@ BOOLEAN MilitiaPlotStart( )
|
|||||||
// if this group exists, is indeed militia but has no members, erase it and its path
|
// if this group exists, is indeed militia but has no members, erase it and its path
|
||||||
if ( pGroup && pGroup->usGroupTeam == MILITIA_TEAM && pGroup->ubGroupSize == 0 )
|
if ( pGroup && pGroup->usGroupTeam == MILITIA_TEAM && pGroup->ubGroupSize == 0 )
|
||||||
{
|
{
|
||||||
gMilitiaPath[groupid].path = ClearStrategicPathList( gMilitiaPath[groupid].path, groupid );
|
gMilitiaPath[groupid].path = ClearStrategicPathList( gMilitiaPath[groupid].path, (UINT8)gMilitiaPath[groupid].sGroupid );
|
||||||
|
|
||||||
RemovePGroup( pGroup );
|
RemovePGroup( pGroup );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user