mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Fix: determining a militia path in strategic map could cause the sector militia size to be cut to MAX_STRATEGIC_ENEMY_GROUP_SIZE
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8243 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2146,11 +2146,16 @@ void RetreatAllInvolvedMilitiaGroups()
|
|||||||
if ( !pSector )
|
if ( !pSector )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pGroup = CreateNewMilitiaGroupDepartingFromSector( SECTOR( sBattleSectorX, sBattleSectorY ), pSector->ubNumberOfCivsAtLevel[0], pSector->ubNumberOfCivsAtLevel[1], pSector->ubNumberOfCivsAtLevel[2] );
|
// as group size will be cut to MAX_STRATEGIC_ENEMY_GROUP_SIZE, see how many troops are allowed and reduce sector count accordingly
|
||||||
|
UINT8 greens = pSector->ubNumberOfCivsAtLevel[0];
|
||||||
|
UINT8 regulars = pSector->ubNumberOfCivsAtLevel[1];
|
||||||
|
UINT8 elites = pSector->ubNumberOfCivsAtLevel[2];
|
||||||
|
|
||||||
pSector->ubNumberOfCivsAtLevel[0] = 0;
|
pGroup = CreateNewMilitiaGroupDepartingFromSector( SECTOR( sBattleSectorX, sBattleSectorY ), greens, regulars, elites );
|
||||||
pSector->ubNumberOfCivsAtLevel[1] = 0;
|
|
||||||
pSector->ubNumberOfCivsAtLevel[2] = 0;
|
pSector->ubNumberOfCivsAtLevel[0] -= greens;
|
||||||
|
pSector->ubNumberOfCivsAtLevel[1] -= regulars;
|
||||||
|
pSector->ubNumberOfCivsAtLevel[2] -= elites;
|
||||||
|
|
||||||
// if we haven't found a good direction yet, we have to pick the best adjacent sector we can find
|
// if we haven't found a good direction yet, we have to pick the best adjacent sector we can find
|
||||||
if ( !found )
|
if ( !found )
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmin
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites )
|
GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8& arusNumAdmins, UINT8& arusNumTroops, UINT8& arusNumElites )
|
||||||
{
|
{
|
||||||
GROUP *pNew;
|
GROUP *pNew;
|
||||||
AssertMsg( uiSector >= 0 && uiSector <= 255, String( "CreateNewMilitiaGroupDepartingFromSector with out of range value of %d", uiSector ) );
|
AssertMsg( uiSector >= 0 && uiSector <= 255, String( "CreateNewMilitiaGroupDepartingFromSector with out of range value of %d", uiSector ) );
|
||||||
@@ -798,19 +798,19 @@ GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdm
|
|||||||
memset( pNew->pEnemyGroup, 0, sizeof(ENEMYGROUP) );
|
memset( pNew->pEnemyGroup, 0, sizeof(ENEMYGROUP) );
|
||||||
|
|
||||||
// Make sure group is not bigger than allowed!
|
// Make sure group is not bigger than allowed!
|
||||||
while ( ubNumAdmins + ubNumTroops + ubNumElites > gGameExternalOptions.iMaxEnemyGroupSize )
|
while ( arusNumAdmins + arusNumTroops + arusNumElites > gGameExternalOptions.iMaxEnemyGroupSize )
|
||||||
{
|
{
|
||||||
if ( ubNumTroops )
|
if ( arusNumTroops )
|
||||||
{
|
{
|
||||||
ubNumTroops--;
|
arusNumTroops--;
|
||||||
}
|
}
|
||||||
else if ( ubNumAdmins )
|
else if ( arusNumAdmins )
|
||||||
{
|
{
|
||||||
ubNumAdmins--;
|
arusNumAdmins--;
|
||||||
}
|
}
|
||||||
else if ( ubNumElites )
|
else if ( arusNumElites )
|
||||||
{
|
{
|
||||||
ubNumElites--;
|
arusNumElites--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,10 +823,10 @@ GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdm
|
|||||||
pNew->ubNextWaypointID = 0;
|
pNew->ubNextWaypointID = 0;
|
||||||
pNew->ubFatigueLevel = 100;
|
pNew->ubFatigueLevel = 100;
|
||||||
pNew->ubRestAtFatigueLevel = 0;
|
pNew->ubRestAtFatigueLevel = 0;
|
||||||
pNew->pEnemyGroup->ubNumAdmins = ubNumAdmins;
|
pNew->pEnemyGroup->ubNumAdmins = arusNumAdmins;
|
||||||
pNew->pEnemyGroup->ubNumTroops = ubNumTroops;
|
pNew->pEnemyGroup->ubNumTroops = arusNumTroops;
|
||||||
pNew->pEnemyGroup->ubNumElites = ubNumElites;
|
pNew->pEnemyGroup->ubNumElites = arusNumElites;
|
||||||
pNew->ubGroupSize = (UINT8)(ubNumAdmins + ubNumTroops + ubNumElites);
|
pNew->ubGroupSize = (UINT8)(arusNumAdmins + arusNumTroops + arusNumElites);
|
||||||
pNew->ubTransportationMask = FOOT;
|
pNew->ubTransportationMask = FOOT;
|
||||||
pNew->fVehicle = FALSE;
|
pNew->fVehicle = FALSE;
|
||||||
pNew->ubCreatedSectorID = pNew->ubOriginalSector;
|
pNew->ubCreatedSectorID = pNew->ubOriginalSector;
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ BOOLEAN SetGroupPatrolParameters( UINT8 ubGroupID, UINT8 ubRestAtFL, UINT8 ubRes
|
|||||||
//............................................................
|
//............................................................
|
||||||
GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanksm, UINT8 ubNumJeeps );
|
GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanksm, UINT8 ubNumJeeps );
|
||||||
|
|
||||||
GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites );
|
GROUP* CreateNewMilitiaGroupDepartingFromSector( UINT32 uiSector, UINT8& arusNumAdmins, UINT8& arusNumTroops, UINT8& arusNumElites );
|
||||||
|
|
||||||
#ifdef JA2UB
|
#ifdef JA2UB
|
||||||
GROUP* CreateNewEnemyGroupDepartingFromSectorUsingZLevel( UINT32 uiSector, UINT8 ubSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks );
|
GROUP* CreateNewEnemyGroupDepartingFromSectorUsingZLevel( UINT32 uiSector, UINT8 ubSectorZ, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumTanks );
|
||||||
|
|||||||
+10
-5
@@ -16794,12 +16794,17 @@ BOOLEAN MilitiaPlotStart( )
|
|||||||
if ( !pSector )
|
if ( !pSector )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// when we start plotting, the group is still empty - we add militia later
|
// as group size will be cut to MAX_STRATEGIC_ENEMY_GROUP_SIZE, see how many troops are allowed and reduce sector count accordingly
|
||||||
GROUP* pGroup = CreateNewMilitiaGroupDepartingFromSector( SECTOR( sSelMapX, sSelMapY ), pSector->ubNumberOfCivsAtLevel[0], pSector->ubNumberOfCivsAtLevel[1], pSector->ubNumberOfCivsAtLevel[2] );
|
UINT8 greens = pSector->ubNumberOfCivsAtLevel[0];
|
||||||
|
UINT8 regulars = pSector->ubNumberOfCivsAtLevel[1];
|
||||||
|
UINT8 elites = pSector->ubNumberOfCivsAtLevel[2];
|
||||||
|
|
||||||
pSector->ubNumberOfCivsAtLevel[0] = 0;
|
// when we start plotting, the group is still empty - we add militia later
|
||||||
pSector->ubNumberOfCivsAtLevel[1] = 0;
|
GROUP* pGroup = CreateNewMilitiaGroupDepartingFromSector( SECTOR( sSelMapX, sSelMapY ), greens, regulars, elites );
|
||||||
pSector->ubNumberOfCivsAtLevel[2] = 0;
|
|
||||||
|
pSector->ubNumberOfCivsAtLevel[0] -= greens;
|
||||||
|
pSector->ubNumberOfCivsAtLevel[1] -= regulars;
|
||||||
|
pSector->ubNumberOfCivsAtLevel[2] -= elites;
|
||||||
|
|
||||||
gMilitiaPath[gMilitiaGroupId].sGroupid = pGroup->ubGroupID;
|
gMilitiaPath[gMilitiaGroupId].sGroupid = pGroup->ubGroupID;
|
||||||
gNewMilitiaGroupId = pGroup->ubGroupID;
|
gNewMilitiaGroupId = pGroup->ubGroupID;
|
||||||
|
|||||||
Reference in New Issue
Block a user