Merged revision(s) 7052 from branches/ja2_source_official_2014:

- Fix: Assertion if groupsize exceeds garrison size
- Fix: mobile militia never decides to move

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7053 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-03-11 22:48:13 +00:00
parent d83ae2a4c8
commit f6ffee0583
2 changed files with 57 additions and 54 deletions
+56 -53
View File
@@ -1583,6 +1583,9 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY )
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Roll %ld", iRandomRes); //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Roll %ld", iRandomRes);
// Flugente: as I once broke this, allow me to explain this part. We've determined the 'urge' to move to an adjacent sector.
// We now see wether an adjacent sector is a worthy target to move to. If we do not find a vali target, we stop the movement function
iRandomRes = 256; iRandomRes = 256;
for( x = 0; x < uiDirNumber; ++x) for( x = 0; x < uiDirNumber; ++x)
@@ -1592,68 +1595,68 @@ void UpdateMilitiaSquads(INT16 sMapX, INT16 sMapY )
iRandomRes = x; iRandomRes = x;
break; break;
} }
}
// "Decided" to stay here // "Decided" to stay here
if(iRandomRes >= uiDirNumber) if(iRandomRes >= uiDirNumber)
return;
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%ld,%ld:Dir count %ld, Rand %ld. Go to %ld,%ld. Have %ld militia men", sMapX, sMapY, uiDirNumber, iRandomRes, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ), uiMilitiaCount);
//Kaiden: if Restricted Sectors List option is turned on,
// militia can't move to any sectors in the list.
// Unless they are following a group of mercs.
///////////////////////////////////////////////////////////////////
// HEADROCK HAM B1: Restrict roamers by XML as normal, but also
// allow them to move through visited sectors.
// Also, there's an option now to use dynamic restriction. The
// AdjustRoamingRestrictions() function is used to dynamically
// define which sectors are restricted, based on city conquest.
///////////////////////////////////////////////////////////////////
// HEADROCK HAM 3.4: Moved the check to a separate function.
if (gGameExternalOptions.gflimitedRoaming)
{
if (!IsSectorRoamingAllowed(pMoveDir[iRandomRes][0]))
return; return;
}
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%ld,%ld:Dir count %ld, Rand %ld. Go to %ld,%ld. Have %ld militia men", sMapX, sMapY, uiDirNumber, iRandomRes, SECTORX( pMoveDir[ iRandomRes ][0] ), SECTORY( pMoveDir[ iRandomRes ][0] ), uiMilitiaCount); // WDS bug fix for moving militia
//Kaiden: if Restricted Sectors List option is turned on, INT16 targetX = SECTORX( pMoveDir[ iRandomRes ][0] );
// militia can't move to any sectors in the list. INT16 targetY = SECTORY( pMoveDir[ iRandomRes ][0] );
// Unless they are following a group of mercs. Assert(targetX >= 0 && targetX < MAP_WORLD_X);
/////////////////////////////////////////////////////////////////// Assert(targetY >= 0 && targetY < MAP_WORLD_Y);
// HEADROCK HAM B1: Restrict roamers by XML as normal, but also MoveMilitiaSquad( sMapX, sMapY, targetX, targetY, FALSE, FALSE );
// allow them to move through visited sectors.
// Also, there's an option now to use dynamic restriction. The
// AdjustRoamingRestrictions() function is used to dynamically
// define which sectors are restricted, based on city conquest.
///////////////////////////////////////////////////////////////////
// HEADROCK HAM 3.4: Moved the check to a separate function. if ( gfStrategicMilitiaChangesMade)
if (gGameExternalOptions.gflimitedRoaming) {
ResetMilitia();
}
if( NumEnemiesInSector( targetX, targetY ) )
{
extern GROUP *gpBattleGroup;
gpBattleGroup = GetGroup( GetEnemyGroupIdInSector( targetX, targetY ) );
/* GROUP* pEnemyGroup = GetGroup( GetEnemyGroupIdInSector( targetX, targetY ) );
if(pEnemyGroup && pEnemyGroup->ubGroupID)
{ {
if (!IsSectorRoamingAllowed(pMoveDir[iRandomRes][0])) //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Attacking from %ld,%ld to %ld,%ld - enemy's group id %ld", sMapX, sMapY, targetX, SECTORY( pMoveDir[ iRandomRes ][0], pEnemyGroup->ubGroupID ));
return; //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Arrival 1, Arrival 2");
}
// WDS bug fix for moving militia pEnemyGroup->ubPrevX = sMapX;
INT16 targetX = SECTORX( pMoveDir[ iRandomRes ][0] ); pEnemyGroup->ubPrevY = sMapY;
INT16 targetY = SECTORY( pMoveDir[ iRandomRes ][0] );
Assert(targetX >= 0 && targetX < MAP_WORLD_X);
Assert(targetY >= 0 && targetY < MAP_WORLD_Y);
MoveMilitiaSquad( sMapX, sMapY, targetX, targetY, FALSE, FALSE );
if ( gfStrategicMilitiaChangesMade) pEnemyGroup->ubNextX = targetX;
{ pEnemyGroup->ubNextY = targetY;
ResetMilitia(); */
} //Moa: handle deserters before moving in hostile territory
MobileMilitiaDeserters( targetX, targetY, TRUE, TRUE );
if( NumEnemiesInSector( targetX, targetY ) ) gfMSBattle = TRUE;
{
extern GROUP *gpBattleGroup;
gpBattleGroup = GetGroup( GetEnemyGroupIdInSector( targetX, targetY ) );
/* GROUP* pEnemyGroup = GetGroup( GetEnemyGroupIdInSector( targetX, targetY ) );
if(pEnemyGroup && pEnemyGroup->ubGroupID) // GroupArrivedAtSector( pEnemyGroup->ubGroupID , TRUE, FALSE );
{ EnterAutoResolveMode( targetX, targetY );
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Attacking from %ld,%ld to %ld,%ld - enemy's group id %ld", sMapX, sMapY, targetX, SECTORY( pMoveDir[ iRandomRes ][0], pEnemyGroup->ubGroupID )); // }
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Arrival 1, Arrival 2");
pEnemyGroup->ubPrevX = sMapX;
pEnemyGroup->ubPrevY = sMapY;
pEnemyGroup->ubNextX = targetX;
pEnemyGroup->ubNextY = targetY;
*/
//Moa: handle deserters before moving in hostile territory
MobileMilitiaDeserters( targetX, targetY, TRUE, TRUE );
gfMSBattle = TRUE;
// GroupArrivedAtSector( pEnemyGroup->ubGroupID , TRUE, FALSE );
EnterAutoResolveMode( targetX, targetY );
// }
}
} }
} }
} }
+1 -1
View File
@@ -3062,7 +3062,7 @@ void SendReinforcementsForGarrison( INT32 iDstGarrisonID, UINT16 usDefencePoints
//Send the lowest of the two: number requested or number available //Send the lowest of the two: number requested or number available
iReinforcementsApproved = min( iReinforcementsRequested, iReinforcementsAvailable ); iReinforcementsApproved = min( iReinforcementsRequested, iReinforcementsAvailable );
if( iReinforcementsApproved < iMaxReinforcementsAllowed - ubNumExtraReinforcements ) if( iReinforcementsApproved > iMaxReinforcementsAllowed - ubNumExtraReinforcements )
{ {
//The force isn't strong enough, but the queen isn't willing to apply extra resources //The force isn't strong enough, but the queen isn't willing to apply extra resources
iReinforcementsApproved = iMaxReinforcementsAllowed - ubNumExtraReinforcements; iReinforcementsApproved = iMaxReinforcementsAllowed - ubNumExtraReinforcements;