- Fix: same militia profile is used several times in autoresolve

- Fix: sometimes no battle repoer is written for autoresolve
- Fix: no militia profile found in autoresolve due to bad sector

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8229 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-05-22 23:04:05 +00:00
parent 74bebdd454
commit db00927287
6 changed files with 44 additions and 7 deletions
+18 -2
View File
@@ -2526,7 +2526,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
else
{
// Flugente: take care of promotions and individual militia update
HandlePossibleMilitiaPromotion( gpCivs[i].pSoldier );
HandlePossibleMilitiaPromotion( gpCivs[i].pSoldier, TRUE );
}
TacticalRemoveSoldierPointer( gpCivs[ i ].pSoldier, FALSE );
@@ -5802,7 +5802,7 @@ void AutoResolveMilitiaDropAndPromote()
else if ( gpCivs[i].pSoldier->stats.bLife >= OKLIFE / 2 )
{
// Flugente: take care of promotions and individual militia update
HandlePossibleMilitiaPromotion( gpCivs[i].pSoldier );
HandlePossibleMilitiaPromotion( gpCivs[i].pSoldier, TRUE );
}
// DO NOT DELETE HERE!!!!
@@ -5810,4 +5810,20 @@ void AutoResolveMilitiaDropAndPromote()
//memset( &gpCivs[i], 0, sizeof(SOLDIERCELL) );
}
}
}
BOOLEAN IndividualMilitiaInUse_AutoResolve( UINT32 aMilitiaId )
{
if ( gpAR )
{
for ( INT32 i = 0; i < gpAR->ubCivs; ++i )
{
if ( gpCivs[i].pSoldier && aMilitiaId == gpCivs[i].pSoldier->usIndividualMilitiaID && IsLegalMilitiaId( gpCivs[i].pSoldier->usIndividualMilitiaID ) )
{
return TRUE;
}
}
}
return FALSE;
}
+2
View File
@@ -53,4 +53,6 @@ void CheckForSoldiersWhoRetreatedIntoMilitiaHeldSectors();
// Flugente: have all militia in autoresolve drop their gear and be promoted in necessary
void AutoResolveMilitiaDropAndPromote();
BOOLEAN IndividualMilitiaInUse_AutoResolve( UINT32 aMilitiaId );
#endif
+13 -3
View File
@@ -15,6 +15,7 @@
#include "CampaignStats.h"
#include "Town Militia.h"
#include "message.h"
#include "Auto Resolve.h" // added for IndividualMilitiaInUse_AutoResolve(...)
MilitiaOriginData gMilitiaOriginData[MO_MAX];
@@ -538,6 +539,11 @@ UINT32 GetIdOfUnusedindividualMilitia( UINT8 aSoldierClass, UINT8 aSector )
}
}
if ( IndividualMilitiaInUse_AutoResolve( (*it).id ) )
{
found = TRUE;
}
if ( !found )
{
return (*it).id;
@@ -554,7 +560,7 @@ UINT32 GetIdOfUnusedindividualMilitia( UINT8 aSoldierClass, UINT8 aSector )
}
// handle possible militia promotion and individual militia update
void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier )
void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier, BOOLEAN aAutoResolve )
{
// we not only handle promotions here, but basically update this guy
MILITIA militia;
@@ -608,13 +614,17 @@ void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier )
}
// add a battle report if there was a battle (if there was a battle there will have been participants
if ( gCurrentIncident.usParticipants[CAMPAIGNHISTORY_SD_MILITIA_GREEN] +
if ( aAutoResolve || (gCurrentIncident.usParticipants[CAMPAIGNHISTORY_SD_MILITIA_GREEN] +
gCurrentIncident.usParticipants[CAMPAIGNHISTORY_SD_MILITIA_REGULAR] +
gCurrentIncident.usParticipants[CAMPAIGNHISTORY_SD_MILITIA_ELITE] )
gCurrentIncident.usParticipants[CAMPAIGNHISTORY_SD_MILITIA_ELITE]) )
{
MILITIA_BATTLEREPORT report;
report.id = GetIdOfCurrentlyOngoingIncident( );
// if we are in autoresolve, then the report has already been created at this point
if ( aAutoResolve )
report.id = max( 0, report.id - 1 );
if ( pSoldier->stats.bLife < OKLIFE )
report.flagmask |= MILITIA_BATTLEREPORT_FLAG_WOUNDED_COMA;
+1 -1
View File
@@ -166,7 +166,7 @@ UINT32 CreateNewIndividualMilitia( UINT8 aSoldierClass, UINT8 aOrigin, UINT8 aSe
UINT32 GetIdOfUnusedindividualMilitia( UINT8 aSoldierClass, UINT8 aSector );
// handle possible militia promotion and individual militia update
void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier );
void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier, BOOLEAN aAutoResolve );
void MoveIndividualMilitiaProfiles( UINT8 aSourceSector, UINT8 aTargetSector, UINT8 usGreens, UINT8 usRegulars, UINT8 usElites );
+1 -1
View File
@@ -296,7 +296,7 @@ void HandleMilitiaPromotions( void )
if ( pTeamSoldier->bActive && pTeamSoldier->bInSector && pTeamSoldier->stats.bLife > 0 )
{
// Flugente: take care of promotions and individual militia update
HandlePossibleMilitiaPromotion( pTeamSoldier );
HandlePossibleMilitiaPromotion( pTeamSoldier, FALSE );
}
}
+9
View File
@@ -3324,6 +3324,15 @@ SOLDIERTYPE* TacticalCreateMilitia( UINT8 ubMilitiaClass, INT16 sX, INT16 sY )
//bp.bAttitude = AGGRESSIVE;
bp.ubBodyType = -1;
CreateDetailedPlacementGivenBasicPlacementInfo( &pp, &bp, sX, sY );
// Flugente: this might not be properly filled in autoresolve
if ( guiCurrentScreen == AUTORESOLVE_SCREEN )
{
pp.sSectorX = sX;
pp.sSectorY = sY;
pp.bSectorZ = 0;
}
pSoldier = TacticalCreateSoldier( &pp, &ubID );
return pSoldier;