Fix squad oversizing based on user prefs

Fix militia issue in auto-resolve:  Militia were not always being promoted even when it said they were.  Since first X slots are for militia already in the sector, militia from other sectors are not sorted by rank.  This actually affects battle outcome!
Added fix to editor to skip cached tiles in RaiseWorldLand.  Otherwise it can crash when invoked within the game.

ja2_2005Express projects:
Added output directory for JA2 exe based on environment variable JA2GAMEPATH
Restored editor built by default for debug mode


Removed #define LUA_CONSOLE.  It is no longer relevant.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1081 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-07-20 10:12:43 +00:00
parent 12e6655e29
commit 5231251b57
7 changed files with 160 additions and 65 deletions
+7
View File
@@ -1171,6 +1171,13 @@ void RaiseWorldLand( )
while( pStruct )
{
// Skip cached tiles
if (pStruct->usIndex >= NUMBEROFTILES)
{
pStruct = pStruct->pNext;
continue;
}
pTileElement = &(gTileDatabase[ pStruct->usIndex ]);
if (pTileElement->fType==FIRSTCLIFF)
{
+12
View File
@@ -2239,6 +2239,12 @@ void RefreshScreen(void *DummyVariable)
NULL);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
// Prevent the minimizing bug
if (ReturnCode == DDERR_INVALIDRECT)
{
return;
}
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
@@ -2266,6 +2272,12 @@ void RefreshScreen(void *DummyVariable)
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
// Prevent the minimizing bug
if (ReturnCode == DDERR_INVALIDRECT)
{
return;
}
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
+118 -58
View File
@@ -66,6 +66,7 @@
#include "Assignments.h"
#include "cheats.h"
#include "Map Information.h"
#include "MilitiaSquads.h"
#endif
#include "Reinforcement.h"
@@ -1954,12 +1955,95 @@ void RenderAutoResolve()
InvalidateScreen();
}
static void ARCreateMilitia( UINT8 mclass, INT32 i, INT16 sX, INT16 sY)
{
// reset counter of how many mortars this team has rolled
ResetMortarsOnTeamCount();
if( mclass == SOLDIER_CLASS_ELITE_MILITIA )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_ELITE_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA3F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA3_FACE;
}
}
else if( mclass == SOLDIER_CLASS_REG_MILITIA )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_REG_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA2F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA2_FACE;
}
}
else if( mclass == SOLDIER_CLASS_GREEN_MILITIA )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_GREEN_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA1F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA1_FACE;
}
}
else
{
AssertMsg( 0, "Attempting to illegally create a militia soldier." );
}
if( !gpCivs[ i ].pSoldier )
{
AssertMsg( 0, "Failed to create militia soldier for autoresolve." );
}
gpCivs[i].uiVObjectID = gpAR->iFaces;
gpCivs[i].pSoldier->sSectorX = sX;
gpCivs[i].pSoldier->sSectorY = sY;
swprintf( gpCivs[i].pSoldier->name, gpStrategicString[ STR_AR_MILITIA_NAME ] );
}
static void ARCreateMilitiaSquad( UINT8 *cnt, UINT8 ubEliteMilitia, UINT8 ubRegMilitia, UINT8 ubGreenMilitia, INT16 sX, INT16 sY)
{
while( *cnt < gpAR->ubCivs && (ubEliteMilitia || ubRegMilitia || ubGreenMilitia) )
{
if (ubEliteMilitia)
{
ARCreateMilitia( SOLDIER_CLASS_ELITE_MILITIA, *cnt, sX, sY);
ubEliteMilitia--;
}
else if (ubRegMilitia)
{
ARCreateMilitia( SOLDIER_CLASS_REG_MILITIA, *cnt, sX, sY);
ubRegMilitia--;
}
else if (ubGreenMilitia)
{
ARCreateMilitia( SOLDIER_CLASS_GREEN_MILITIA, *cnt, sX, sY);
ubGreenMilitia--;
}
(*cnt)++;
}
}
void CreateAutoResolveInterface()
{
VOBJECT_DESC VObjectDesc;
INT32 i, index;
HVOBJECT hVObject;
UINT8 ubGreenMilitia, ubRegMilitia, ubEliteMilitia;
UINT16 pMoveDir[4][3];
UINT8 uiDirNumber = 0;
UINT8 cnt;
//Setup new autoresolve blanket interface.
MSYS_DefineRegion( &gpAR->AutoResolveRegion, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MSYS_PRIORITY_HIGH-1, 0,
MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
@@ -2049,9 +2133,18 @@ void CreateAutoResolveInterface()
}
}
ubEliteMilitia = MilitiaInFiveSectorsOfRank( gpAR->ubSectorX, gpAR->ubSectorY, ELITE_MILITIA );
ubRegMilitia = MilitiaInFiveSectorsOfRank( gpAR->ubSectorX, gpAR->ubSectorY, REGULAR_MILITIA );
ubGreenMilitia = MilitiaInFiveSectorsOfRank( gpAR->ubSectorX, gpAR->ubSectorY, GREEN_MILITIA );
// 0verhaul: The following code was modified so that militia bookkeeping could be handled.
// In the previous auto-resolve method, promotions were often lost because the sector did not
// actually have the militia to be promoted--they came from surrounding sectors. The
// sector X and Y are not actually used for auto-resolve itself, so I can use it to adjust
// both the actual sector counts and the promotions, by using the origin sectors of each
// soldier.
ubEliteMilitia = MilitiaInSectorOfRank( gpAR->ubSectorX, gpAR->ubSectorY, ELITE_MILITIA );
ubRegMilitia = MilitiaInSectorOfRank( gpAR->ubSectorX, gpAR->ubSectorY, REGULAR_MILITIA );
ubGreenMilitia = MilitiaInSectorOfRank( gpAR->ubSectorX, gpAR->ubSectorY, GREEN_MILITIA );
// This block should be unnecessary. If the counts do not line up, there is a bug.
#if 0
while( ubEliteMilitia + ubRegMilitia + ubGreenMilitia < gpAR->ubCivs )
{
switch( PreRandom( 3 ) )
@@ -2061,60 +2154,27 @@ void CreateAutoResolveInterface()
case 2: ubGreenMilitia++; break;
}
}
for( i = 0; i < gpAR->ubCivs; i++ )
{
// reset counter of how many mortars this team has rolled
ResetMortarsOnTeamCount();
#endif
if( i < ubEliteMilitia )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_ELITE_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA3F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA3_FACE;
}
}
else if( i < ubRegMilitia + ubEliteMilitia )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_REG_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA2F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA2_FACE;
}
}
else if( i < ubGreenMilitia + ubRegMilitia + ubEliteMilitia )
{
gpCivs[i].pSoldier = TacticalCreateMilitia( SOLDIER_CLASS_GREEN_MILITIA );
if( gpCivs[i].pSoldier->ubBodyType == REGFEMALE )
{
gpCivs[i].usIndex = MILITIA1F_FACE;
}
else
{
gpCivs[i].usIndex = MILITIA1_FACE;
}
}
else
{
AssertMsg( 0, "Attempting to illegally create a militia soldier." );
}
if( !gpCivs[ i ].pSoldier )
{
AssertMsg( 0, "Failed to create militia soldier for autoresolve." );
}
gpCivs[i].uiVObjectID = gpAR->iFaces;
gpCivs[i].pSoldier->sSectorX = gpAR->ubSectorX;
gpCivs[i].pSoldier->sSectorY = gpAR->ubSectorY;
swprintf( gpCivs[i].pSoldier->name, gpStrategicString[ STR_AR_MILITIA_NAME ] );
cnt = 0;
// Add the militia in this sector
ARCreateMilitiaSquad( &cnt, ubEliteMilitia, ubRegMilitia, ubGreenMilitia, gpAR->ubSectorX, gpAR->ubSectorY);
// Add the militia in the surrounding sectors
GenerateDirectionInfos( gpAR->ubSectorX, gpAR->ubSectorY, &uiDirNumber, pMoveDir,
( GetTownIdForSector( gpAR->ubSectorX, gpAR->ubSectorY ) != BLANK_SECTOR ? TRUE : FALSE ), TRUE, FALSE );
for( i=0; i<uiDirNumber; i++)
{
INT16 sX = SECTORX( pMoveDir[ i ][0] );
INT16 sY = SECTORY( pMoveDir[ i ][0] );
ubEliteMilitia = MilitiaInSectorOfRank( sX, sY, ELITE_MILITIA );
ubRegMilitia = MilitiaInSectorOfRank( sX, sY, REGULAR_MILITIA );
ubGreenMilitia = MilitiaInSectorOfRank( sX, sY, GREEN_MILITIA );
ARCreateMilitiaSquad( &cnt, ubEliteMilitia, ubRegMilitia, ubGreenMilitia, sX, sY );
}
if( gubEnemyEncounterCode != CREATURE_ATTACK_CODE )
{
for( i = 0, index = 0; i < gpAR->ubElites; i++, index++ )
@@ -2391,8 +2451,8 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
if( fDeleteForGood && gpCivs[ i ].pSoldier->bLife < OKLIFE/2 )
{
AddDeadSoldierToUnLoadedSector( gpAR->ubSectorX, gpAR->ubSectorY, 0, gpCivs[ i ].pSoldier, RandomGridNo(), ADD_DEAD_SOLDIER_TO_SWEETSPOT );
// StrategicRemoveMilitiaFromSector( gpAR->ubSectorX, gpAR->ubSectorY, ubCurrentRank, 1 );
ARRemoveMilitiaMan( gpAR->ubSectorX, gpAR->ubSectorY, ubCurrentRank );
StrategicRemoveMilitiaFromSector( gpCivs[ i ].pSoldier->sSectorX, gpCivs[ i ].pSoldier->sSectorY, ubCurrentRank, 1 );
// ARRemoveMilitiaMan( gpAR->ubSectorX, gpAR->ubSectorY, ubCurrentRank );
if( ProcessLoyalty() )HandleGlobalLoyaltyEvent( GLOBAL_LOYALTY_NATIVE_KILLED, gpAR->ubSectorX, gpAR->ubSectorY, 0 );
}
else
@@ -2401,7 +2461,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve2");
// this will check for promotions and handle them for you
if( fDeleteForGood && ( gpCivs[ i ].pSoldier->ubMilitiaKills > 0) && ( ubCurrentRank < ELITE_MILITIA ) )
{
ubPromotions = CheckOneMilitiaForPromotion( gpAR->ubSectorX, gpAR->ubSectorY, ubCurrentRank, gpCivs[ i ].pSoldier->ubMilitiaKills );
ubPromotions = CheckOneMilitiaForPromotion( gpCivs[ i ].pSoldier->sSectorX, gpCivs[ i ].pSoldier->sSectorY, ubCurrentRank, gpCivs[ i ].pSoldier->ubMilitiaKills );
if( ubPromotions )
{
if( ubPromotions == 2 )
+19 -1
View File
@@ -690,6 +690,24 @@ GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmin
pNew->pEnemyGroup = (ENEMYGROUP*)MemAlloc( sizeof( ENEMYGROUP ) );
AssertMsg( pNew->pEnemyGroup, "MemAlloc failure during enemy group creation." );
memset( pNew->pEnemyGroup, 0, sizeof( ENEMYGROUP ) );
// Make sure group is not bigger than allowed!
while (ubNumAdmins + ubNumTroops + ubNumElites > gGameExternalOptions.iMaxEnemyGroupSize)
{
if (ubNumTroops)
{
ubNumTroops--;
}
else if (ubNumAdmins)
{
ubNumAdmins--;
}
else
{
ubNumElites--;
}
}
pNew->pWaypoints = NULL;
pNew->ubSectorX = (UINT8)SECTORX( uiSector );
pNew->ubSectorY = (UINT8)SECTORY( uiSector );
@@ -702,7 +720,7 @@ GROUP* CreateNewEnemyGroupDepartingFromSector( UINT32 uiSector, UINT8 ubNumAdmin
pNew->pEnemyGroup->ubNumAdmins = ubNumAdmins;
pNew->pEnemyGroup->ubNumTroops = ubNumTroops;
pNew->pEnemyGroup->ubNumElites = ubNumElites;
pNew->ubGroupSize = (UINT8)(ubNumTroops + ubNumElites);
pNew->ubGroupSize = (UINT8)(ubNumAdmins + ubNumTroops + ubNumElites);
pNew->ubTransportationMask = FOOT;
pNew->fVehicle = FALSE;
pNew->ubCreatedSectorID = pNew->ubOriginalSector;
-2
View File
@@ -13,8 +13,6 @@
//#define DEBUG_ATTACKBUSY
//#define LUACONSOLE
#define ROBOT_ALWAYS_READY
//#ifdef _DEBUG
+3 -3
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="ja2_2005Express"
ProjectGUID="{F44669E7-74AC-444B-B75F-F16F4B9F0265}"
RootNamespace="ja2_2005Express"
@@ -17,7 +17,7 @@
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="C:\Games\Jagged Alliance 2"
OutputDirectory="$(JA2GAMEPATH)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets=".\ja2_2005Express.vsprops;.\ja2_2005ExpressDebug.vsprops"
@@ -97,7 +97,7 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="C:\Games\Jagged Alliance 2"
OutputDirectory="$(JA2GAMEPATH)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets=".\ja2_2005Express.vsprops"
+1 -1
View File
@@ -6,6 +6,6 @@
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="JA2BETAVERSION;JA2TESTVERSION;DEBUG_ATTACKBUSY"
PreprocessorDefinitions="JA2BETAVERSION;JA2TESTVERSION;JA2EDITOR;DEBUG_ATTACKBUSY"
/>
</VisualStudioPropertySheet>