Fixed incorrect vehicle group id after reloading the game and vehicle movement plot issues. (#207)

This commit is contained in:
Andrzej Fałkowski
2023-08-28 16:26:34 +03:00
committed by GitHub
parent 3ddacf1a44
commit d56288e313
2 changed files with 48 additions and 9 deletions
+26
View File
@@ -4582,6 +4582,28 @@ void HandleSettingTheSelectedListOfMercs( void )
INT8 pbErrorNumber = -1; INT8 pbErrorNumber = -1;
pSoldier = MercPtrs[gCharactersList[GetSelectedDestChar()].usSolID]; pSoldier = MercPtrs[gCharactersList[GetSelectedDestChar()].usSolID];
INT8 bSquadValue = pSoldier->bAssignment; INT8 bSquadValue = pSoldier->bAssignment;
if (bSquadValue == VEHICLE)
{
for (INT8 bCounter = 0; bCounter < NUMBER_OF_SQUADS; ++bCounter)
{
if (Squad[bCounter][0] != NULL && IsVehicle(Squad[bCounter][0]) &&
Squad[bCounter][0]->bVehicleID == pSoldier->iVehicleId)
{
bSquadValue = bCounter;
break;
}
}
}
if (bSquadValue >= NUMBER_OF_SQUADS)
{
if (pbErrorNumber != -1)
{
ReportMapScreenMovementError(pbErrorNumber);
}
SetSelectedDestChar(-1);
giDestHighLine = -1;
return;
}
// find number of characters in particular squad. // find number of characters in particular squad.
for (INT8 bCounter = 0; bCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; ++bCounter) for (INT8 bCounter = 0; bCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; ++bCounter)
@@ -4692,6 +4714,9 @@ INT8 FindSquadThatSoldierCanJoin( SOLDIERTYPE *pSoldier )
// run through the list of squads // run through the list of squads
for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ ) for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ )
{
// anv: don't automatically put people in vehicle squads
if (Squad[bCounter][0] == NULL || !IsVehicle(Squad[bCounter][0]))
{ {
// is this squad in this sector // is this squad in this sector
if (IsThisSquadInThisSector(pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter)) if (IsThisSquadInThisSector(pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter))
@@ -4708,6 +4733,7 @@ INT8 FindSquadThatSoldierCanJoin( SOLDIERTYPE *pSoldier )
} }
} }
} }
}
return( -1 ); return( -1 );
} }
+13
View File
@@ -1699,9 +1699,22 @@ void CheckSquadMovementGroups( void )
// Bob: propagate the group id to the squad members // Bob: propagate the group id to the squad members
for (INT8 iSoldier = 0; iSoldier < NUMBER_OF_SOLDIERS_PER_SQUAD; iSoldier++) { for (INT8 iSoldier = 0; iSoldier < NUMBER_OF_SOLDIERS_PER_SQUAD; iSoldier++) {
if (Squad[iSquad][iSoldier] != NULL) if (Squad[iSquad][iSoldier] != NULL)
{
if (IsVehicle(Squad[iSquad][iSoldier]))
{
INT32 iCounter = 0;
for (iCounter = 0; iCounter < ubNumberOfVehicles; iCounter++)
{
if (pVehicleList[iCounter].ubProfileID == Squad[iSquad][iSoldier]->ubProfile)
break;
}
Squad[iSquad][iSoldier]->ubGroupID = pVehicleList[iCounter].ubMovementGroup;
}
else
{ {
Squad[iSquad][iSoldier]->ubGroupID = pGroup->ubGroupID; Squad[iSquad][iSoldier]->ubGroupID = pGroup->ubGroupID;
} }
} }
} }
} }
}