- If a sector has less placements for militia than militia slots, distribute excess militia to random locations instead of not spawning them.

- Fix: crash in mine display due to invalid gridno.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7868 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2015-05-19 20:50:05 +00:00
parent c677c462bc
commit 62d5dd1854
3 changed files with 88 additions and 12 deletions
+9 -9
View File
@@ -15,9 +15,9 @@
#ifdef JA2EDITOR
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.7868 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.7868 (Development Build)" };
#endif
// ------------------------------
@@ -27,11 +27,11 @@
//DEBUG BUILD VERSION
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.7868 (Development Build)" };
#elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.7868 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Debug: v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Debug: v1.13.7868 (Development Build)" };
#endif
#elif defined CRIPPLED_VERSION
@@ -46,16 +46,16 @@
//RELEASE BUILD VERSION
#ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.7868 (Development Build)" };
#elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.7868 (Development Build)" };
#else
CHAR16 zVersionLabel[256] = { L"Release v1.13.7823 (Development Build)" };
CHAR16 zVersionLabel[256] = { L"Release v1.13.7868 (Development Build)" };
#endif
#endif
CHAR8 czVersionNumber[16] = { "Build 15.04.19" }; //YY.MM.DD
CHAR8 czVersionNumber[16] = { "Build 15.05.19" }; //YY.MM.DD
CHAR16 zTrackingNumber[16] = { L"Z" };
// SAVE_GAME_VERSION is defined in header, change it there
+6 -3
View File
@@ -989,9 +989,12 @@ void AddMinesObjectsToViewArea()
{
INT32& sGridNo = gCoverViewArea[ ubX ][ ubY ][ ubZ ].sGridNo;
TileDefines tile = GetOverlayIndex( bOverlayType );
AddCoverObjectToWorld( sGridNo, tile, (BOOLEAN)ubZ, fNightTime );
fChanged = TRUE;
if ( !TileIsOutOfBounds( sGridNo ) )
{
TileDefines tile = GetOverlayIndex( bOverlayType );
AddCoverObjectToWorld( sGridNo, tile, (BOOLEAN)ubZ, fNightTime );
fChanged = TRUE;
}
}
}
}
+73
View File
@@ -1569,8 +1569,10 @@ void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumEl
}
curr = curr->next;
}
if( !ubMaxNum )
return;
//Now count the number of nodes that are basic placements of desired team AND CLASS
//This information will be used to randomly determine which of these placements
//will be added based on the number of slots we can still add.
@@ -1615,6 +1617,7 @@ void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumEl
pCurrTotal = &ubNumRegs;
break;
}
//Now, loop through the basic placement of the list.
curr = mark; //mark is the marker where the basic placements start.
while( curr && !curr->pSoldier && ubMaxNum && *pCurrTotal && *pCurrSlots )
@@ -1656,8 +1659,10 @@ void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumEl
curr = curr->next;
}
}
if( !ubMaxNum )
return;
//If we are at this point, that means that there are some compatibility issues. This is fine. An example
//would be a map containing 1 elite placement, and 31 troop placements. If we had 3 elites move into this
//sector, we would not have placements for two of them. What we have to do is override the class information
@@ -1737,6 +1742,74 @@ void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumEl
}
curr = curr->next;
}
// Flugente: it is possible that a sector has more militia than placements. In this case they would not be placed, thereby not joining any battle
// we solve this problem by adding them to a random gridno here, but only up to the minimum of MAX_MILITIA_PER_SECTOR, MAX_NUMBER_MILITIA_IN_TACTICAL and MAX_STRATEGIC_ENEMY_GROUP_SIZE
if ( ubMaxNum && ( ubNumElites || ubNumRegs || ubNumGreen ) )
{
// determine how many militia have already been created in this sector (this can also have happened in another function), so count all active ones
UINT16 tacticalmilitia = 0;
for ( UINT16 i = gTacticalStatus.Team[MILITIA_TEAM].bFirstID; i <= gTacticalStatus.Team[MILITIA_TEAM ].bLastID; ++i )
{
if ( MercPtrs[i]->bInSector && MercPtrs[i]->bActive )
++tacticalmilitia;
}
// is there still room tom add more?
UINT16 militiamax = min( gGameExternalOptions.iMaxMilitiaPerSector, gGameExternalOptions.ubGameMaximumNumberOfRebels);
militiamax = min( militiamax, gGameExternalOptions.iMaxEnemyGroupSize );
while ( tacticalmilitia < militiamax )
{
SOLDIERTYPE* pSoldier = NULL;
if ( ubNumElites )
{
pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_ELITE_MILITIA, gWorldSectorX, gWorldSectorY );
--ubNumElites;
}
else if ( ubNumRegs )
{
pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_REG_MILITIA, gWorldSectorX, gWorldSectorY );
--ubNumRegs;
}
else if ( ubNumGreen )
{
pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_GREEN_MILITIA, gWorldSectorX, gWorldSectorY );
--ubNumGreen;
}
if ( pSoldier )
{
//no edgepoints left, so put him at the entrypoint.
pSoldier->ubStrategicInsertionCode = INSERTION_CODE_GRIDNO;
pSoldier->usStrategicInsertionData = RandomGridNo();
pSoldier->ubInsertionDirection = DIRECTION_IRRELEVANT;
// Lesh: militia came from another sector can't reach opposite side of map in case of battle there
// they are often stop at a half way. trying to fix this
if ( gTacticalStatus.Team[MILITIA_TEAM].bAwareOfOpposition )
{
pSoldier->aiData.bOrders = SEEKENEMY;
pSoldier->aiData.bAlertStatus = STATUS_RED;
}
else
{
pSoldier->aiData.bOrders = ONGUARD;
pSoldier->aiData.bAlertStatus = STATUS_GREEN;
pSoldier->aiData.sNoiseGridno = (CENTRAL_GRIDNO + (Random( CENTRAL_RADIUS * 2 + 1 ) - CENTRAL_RADIUS) + (Random( CENTRAL_RADIUS * 2 + 1 ) - CENTRAL_RADIUS) * WORLD_COLS);
pSoldier->aiData.ubNoiseVolume = MAX_MISC_NOISE_DURATION;
}
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
++tacticalmilitia;
}
else
return;
}
}
}
void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT8 ubNumLarvae, UINT8 ubNumInfants,