mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
- Fix: missing individual profiles for militia arriving in currently loaded sector
- reduce number of warnings if no individual militia profiles are found git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8558 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
#include "message.h"
|
||||
#include "Auto Resolve.h" // added for IndividualMilitiaInUse_AutoResolve(...)
|
||||
|
||||
// we use this to keep track of when we displayed a warning in order not to spam
|
||||
UINT32 gMIWarningTime = 0;
|
||||
|
||||
MilitiaOriginData gMilitiaOriginData[MO_MAX];
|
||||
|
||||
// later on, make this an array with a vector for each sector
|
||||
@@ -232,6 +235,10 @@ BOOLEAN LoadIndividualMilitiaData( HWFILE hwFile )
|
||||
gIndividualMilitiaVector.push_back(data);
|
||||
}
|
||||
|
||||
|
||||
// reset time tracker
|
||||
gMIWarningTime = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -573,9 +580,9 @@ UINT32 GetIdOfUnusedIndividualMilitia( UINT8 aSoldierClass, UINT8 aSector )
|
||||
UINT8 militialevel = SoldierClassToMilitiaRank( aSoldierClass );
|
||||
|
||||
std::vector<MILITIA>::iterator itend = gIndividualMilitiaVector.end();
|
||||
for ( std::vector<MILITIA>::iterator it = gIndividualMilitiaVector.begin( ); it != itend; ++it )
|
||||
for ( std::vector<MILITIA>::iterator it = gIndividualMilitiaVector.begin(); it != itend; ++it )
|
||||
{
|
||||
if ( !((*it).flagmask & (MILITIAFLAG_DEAD | MILITIAFLAG_FIRED | MILITIAFLAG_DESERTION )) && (*it).sector == aSector && (*it).militiarank == militialevel )
|
||||
if ( !( ( *it ).flagmask & ( MILITIAFLAG_DEAD | MILITIAFLAG_FIRED | MILITIAFLAG_DESERTION ) ) && ( *it ).sector == aSector && ( *it ).militiarank == militialevel )
|
||||
{
|
||||
// fitting data found - now we have to make sure this one isn't already in use
|
||||
BOOLEAN found = FALSE;
|
||||
@@ -584,30 +591,42 @@ UINT32 GetIdOfUnusedIndividualMilitia( UINT8 aSoldierClass, UINT8 aSector )
|
||||
|
||||
INT32 cnt = gTacticalStatus.Team[MILITIA_TEAM].bFirstID;
|
||||
INT32 lastid = gTacticalStatus.Team[MILITIA_TEAM].bLastID;
|
||||
for (pSoldier = MercPtrs[cnt]; cnt < lastid; ++cnt, ++pSoldier)
|
||||
for ( pSoldier = MercPtrs[cnt]; cnt < lastid; ++cnt, ++pSoldier )
|
||||
{
|
||||
if (pSoldier && pSoldier->bActive && (*it).id == pSoldier->usIndividualMilitiaID && IsLegalMilitiaId(pSoldier->usIndividualMilitiaID) )
|
||||
if ( pSoldier && pSoldier->bActive && ( *it ).id == pSoldier->usIndividualMilitiaID && IsLegalMilitiaId( pSoldier->usIndividualMilitiaID ) )
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found && IndividualMilitiaInUse_AutoResolve((*it).id))
|
||||
if ( !found && IndividualMilitiaInUse_AutoResolve( ( *it ).id ) )
|
||||
{
|
||||
found = TRUE;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if ( !found )
|
||||
{
|
||||
return (*it).id;
|
||||
return ( *it ).id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if this feature is on and we get to this point, then there aren't enough individual militia. This is odd, the player should be informed
|
||||
if ( gGameExternalOptions.fIndividualMilitia )
|
||||
{
|
||||
// in debug mode, display messages all the time, otherwise only once per second
|
||||
#ifdef JA2BETAVERSION
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in GetIdOfUnusedindividualMilitia" );
|
||||
#else
|
||||
if ( gMIWarningTime != GetWorldTotalSeconds() )
|
||||
{
|
||||
gMIWarningTime = GetWorldTotalSeconds();
|
||||
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in GetIdOfUnusedindividualMilitia" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// nobody found. That shouldn't really happen, as we are supposed to create data whenever new militia is created. Create new data and use that
|
||||
return CreateNewIndividualMilitia( militialevel, MO_ARULCO, aSector );
|
||||
@@ -879,12 +898,12 @@ void HandlePossibleMilitiaPromotion( SOLDIERTYPE* pSoldier, BOOLEAN aAutoResolve
|
||||
|
||||
void MoveIndividualMilitiaProfiles( UINT8 aSourceSector, UINT8 aTargetSector, UINT8 usGreens, UINT8 usRegulars, UINT8 usElites )
|
||||
{
|
||||
if ( !usGreens && !usRegulars && !usElites )
|
||||
return;
|
||||
|
||||
std::vector<MILITIA>::iterator itend = gIndividualMilitiaVector.end( );
|
||||
for ( std::vector<MILITIA>::iterator it = gIndividualMilitiaVector.begin( ); it != itend; ++it )
|
||||
{
|
||||
if ( !usGreens && !usRegulars && !usElites )
|
||||
return;
|
||||
|
||||
if ( !((*it).flagmask & (MILITIAFLAG_DEAD | MILITIAFLAG_FIRED | MILITIAFLAG_DESERTION )) && (*it).sector == aSourceSector )
|
||||
{
|
||||
if ( usGreens && ( *it ).militiarank == GREEN_MILITIA)
|
||||
@@ -902,6 +921,9 @@ void MoveIndividualMilitiaProfiles( UINT8 aSourceSector, UINT8 aTargetSector, UI
|
||||
(*it).sector = aTargetSector;
|
||||
--usElites;
|
||||
}
|
||||
|
||||
if ( !usGreens && !usRegulars && !usElites )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,8 +1094,20 @@ void PickIndividualMilitia( UINT8 aSector, UINT8 ubType, UINT16 aNumber )
|
||||
}
|
||||
|
||||
// if this feature is on and we get to this point, then there aren't enough individual militia. This is odd, the player should be informed
|
||||
if ( aNumber && gGameExternalOptions.fIndividualMilitia )
|
||||
if ( gGameExternalOptions.fIndividualMilitia )
|
||||
{
|
||||
// in debug mode, display messages all the time, otherwise only once per second
|
||||
#ifdef JA2BETAVERSION
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in PickIndividualMilitia" );
|
||||
#else
|
||||
if ( gMIWarningTime != GetWorldTotalSeconds() )
|
||||
{
|
||||
gMIWarningTime = GetWorldTotalSeconds();
|
||||
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in PickIndividualMilitia" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void DropIndividualMilitia( UINT8 aSector, UINT8 ubType, UINT16 aNumber )
|
||||
@@ -1097,6 +1131,18 @@ void DropIndividualMilitia( UINT8 aSector, UINT8 ubType, UINT16 aNumber )
|
||||
}
|
||||
|
||||
// if this feature is on and we get to this point, then there aren't enough individual militia. This is odd, the player should be informed
|
||||
if ( aNumber && gGameExternalOptions.fIndividualMilitia )
|
||||
if ( gGameExternalOptions.fIndividualMilitia )
|
||||
{
|
||||
// in debug mode, display messages all the time, otherwise only once per second
|
||||
#ifdef JA2BETAVERSION
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in DropIndividualMilitia" );
|
||||
#else
|
||||
if ( gMIWarningTime != GetWorldTotalSeconds() )
|
||||
{
|
||||
gMIWarningTime = GetWorldTotalSeconds();
|
||||
|
||||
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, L"Possible error: Not enough individual militia found in DropIndividualMilitia" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2288,8 +2288,15 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe
|
||||
{
|
||||
// if they arrive in the sector we have currently loaded, let them join from the edge
|
||||
// this will always remove them from the group - if you want them to continue moving, issue a new order
|
||||
// RunAwayScientist fix on 4/10/2018: The below condition needs to have the other functions applied (MoveMilitiaEquipment, MoveMilitiaProfiles, reset)
|
||||
// because the other if-else sections do NOT trigger if milita move into currently loaded sector.
|
||||
// This should be done before dissolving the group.
|
||||
// Currently only MoveMilitiaProfiles is needed, equipment is moved without being called from another func.
|
||||
if ( pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && pGroup->ubSectorZ == gbWorldSectorZ )
|
||||
{
|
||||
// Flugente: move along individual militia data
|
||||
MoveIndividualMilitiaProfiles( SECTOR( pGroup->ubPrevX, pGroup->ubPrevY ), SECTOR( pGroup->ubSectorX, pGroup->ubSectorY ), pGroup->pEnemyGroup->ubNumAdmins, pGroup->pEnemyGroup->ubNumTroops, pGroup->pEnemyGroup->ubNumElites );
|
||||
|
||||
MilitiaGroupEntersCurrentSector( pGroup->ubGroupID, pGroup->ubSectorX, pGroup->ubSectorY );
|
||||
|
||||
if ( !fBattlePending && GroupAtFinalDestination( pGroup ) )
|
||||
|
||||
Reference in New Issue
Block a user