Skip to content

Commit

Permalink
Fixed incorrect vehicle group id after reloading the game and vehicle…
Browse files Browse the repository at this point in the history
… movement plot issues. (#207)
  • Loading branch information
andrzejfalkowski authored Aug 28, 2023
1 parent 3ddacf1 commit d56288e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
42 changes: 34 additions & 8 deletions Strategic/Map Screen Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4582,6 +4582,28 @@ void HandleSettingTheSelectedListOfMercs( void )
INT8 pbErrorNumber = -1;
pSoldier = MercPtrs[gCharactersList[GetSelectedDestChar()].usSolID];
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.
for (INT8 bCounter = 0; bCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; ++bCounter)
Expand Down Expand Up @@ -4693,17 +4715,21 @@ INT8 FindSquadThatSoldierCanJoin( SOLDIERTYPE *pSoldier )
// run through the list of squads
for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ )
{
// is this squad in this sector
if( IsThisSquadInThisSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter ) )
// anv: don't automatically put people in vehicle squads
if (Squad[bCounter][0] == NULL || !IsVehicle(Squad[bCounter][0]))
{
// does it have room?
if( IsThisSquadFull( bCounter ) == FALSE )
// is this squad in this sector
if (IsThisSquadInThisSector(pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter))
{
// is it doing the same thing as the soldier is (staying or going) ?
if( IsSquadSelectedForMovement( bCounter ) == IsSoldierSelectedForMovement( pSoldier ) )
// does it have room?
if (IsThisSquadFull(bCounter) == FALSE)
{
// go ourselves a match, then
return( bCounter );
// is it doing the same thing as the soldier is (staying or going) ?
if (IsSquadSelectedForMovement(bCounter) == IsSoldierSelectedForMovement(pSoldier))
{
// go ourselves a match, then
return(bCounter);
}
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion Tactical/Squads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,20 @@ void CheckSquadMovementGroups( void )
for (INT8 iSoldier = 0; iSoldier < NUMBER_OF_SOLDIERS_PER_SQUAD; iSoldier++) {
if (Squad[iSquad][iSoldier] != NULL)
{
Squad[iSquad][iSoldier]->ubGroupID = pGroup->ubGroupID;
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;
}
}
}
}
Expand Down

0 comments on commit d56288e

Please sign in to comment.