mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
- Fix: possible mismatch of individual militia profiles if trained militia were immediately promoted
- Fix: Armour/Misc. resources also limit training of green militia - cleaned up button deletion git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8456 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -451,53 +451,20 @@ BOOLEAN CreateButtonsForMapBorder( void )
|
|||||||
|
|
||||||
void DeleteMapBorderButtons( void )
|
void DeleteMapBorderButtons( void )
|
||||||
{
|
{
|
||||||
UINT8 ubCnt;
|
for ( int i = 0; i < NUM_MAP_BORDER_BTNS; ++i )
|
||||||
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_TOWN_BTN ]);
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_MINE_BTN ]);
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_TEAMS_BTN ]);
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_AIRSPACE_BTN ]);
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_ITEM_BTN ]);
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_MILITIA_BTN ]);
|
|
||||||
|
|
||||||
// WANNE: Only remove if we added the button
|
|
||||||
if ( gGameExternalOptions.gfAllowMilitiaGroups && !gGameExternalOptions.fMilitiaStrategicCommand )
|
|
||||||
RemoveButton( giMapBorderButtons[ MAP_BORDER_MOBILE_BTN ]); // HEADROCK HAM 4
|
|
||||||
|
|
||||||
if ( giMapBorderButtons[MAP_BORDER_DISEASE_BTN] != -1 )
|
|
||||||
RemoveButton( giMapBorderButtons[MAP_BORDER_DISEASE_BTN] );
|
|
||||||
|
|
||||||
if ( giMapBorderButtons[MAP_BORDER_WEATHER_BTN] != -1 )
|
|
||||||
RemoveButton( giMapBorderButtons[MAP_BORDER_WEATHER_BTN] );
|
|
||||||
|
|
||||||
// images
|
|
||||||
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_TOWN_BTN ] );
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_MINE_BTN ] );
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_TEAMS_BTN ] );
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_AIRSPACE_BTN ] );
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_ITEM_BTN ] );
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_MILITIA_BTN ] );
|
|
||||||
|
|
||||||
// WANNE: Only unload if we added the button
|
|
||||||
if ( gGameExternalOptions.gfAllowMilitiaGroups && !gGameExternalOptions.fMilitiaStrategicCommand )
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[ MAP_BORDER_MOBILE_BTN ] ); // HEADROCK HAM 4
|
|
||||||
|
|
||||||
if ( giMapBorderButtonsImage[MAP_BORDER_DISEASE_BTN] != -1 )
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[MAP_BORDER_DISEASE_BTN] );
|
|
||||||
|
|
||||||
if ( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] != -1 )
|
|
||||||
UnloadButtonImage( giMapBorderButtonsImage[MAP_BORDER_WEATHER_BTN] );
|
|
||||||
|
|
||||||
// HEADROCK HAM 4: Increased number of buttons by one.
|
|
||||||
for ( ubCnt = 0; ubCnt < NUM_MAP_BORDER_BTNS; ++ubCnt )
|
|
||||||
{
|
{
|
||||||
giMapBorderButtons[ ubCnt ] = -1;
|
if ( giMapBorderButtons[i] != -1 )
|
||||||
giMapBorderButtonsImage[ ubCnt ] = -1;
|
RemoveButton( giMapBorderButtons[i] );
|
||||||
|
|
||||||
|
giMapBorderButtons[i] = -1;
|
||||||
|
|
||||||
|
if ( giMapBorderButtonsImage[i] != -1 )
|
||||||
|
UnloadButtonImage( giMapBorderButtonsImage[i] );
|
||||||
|
|
||||||
|
giMapBorderButtonsImage[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
void BtnMilitiaCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnMilitiaCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
@@ -512,7 +479,6 @@ void BtnMilitiaCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BtnTeamCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnTeamCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||||
@@ -526,7 +492,6 @@ void BtnTeamCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BtnTownCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnTownCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||||
@@ -540,7 +505,6 @@ void BtnTownCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BtnMineCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnMineCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||||
@@ -554,7 +518,6 @@ void BtnMineCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BtnAircraftCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnAircraftCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||||
@@ -569,7 +532,6 @@ void BtnAircraftCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BtnItemCallback(GUI_BUTTON *btn,INT32 reason)
|
void BtnItemCallback(GUI_BUTTON *btn,INT32 reason)
|
||||||
{
|
{
|
||||||
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
|
||||||
|
|||||||
+54
-21
@@ -198,17 +198,6 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
// if we can't train as many militia as we should due to lack of volunteers, the excess training goes into promoting militia
|
// if we can't train as many militia as we should due to lack of volunteers, the excess training goes into promoting militia
|
||||||
UINT8 promotionsfromvolunteers = ubMilitiaToTrain;
|
UINT8 promotionsfromvolunteers = ubMilitiaToTrain;
|
||||||
ubMilitiaToTrain = min( ubMilitiaToTrain, GetVolunteerPool( ) );
|
ubMilitiaToTrain = min( ubMilitiaToTrain, GetVolunteerPool( ) );
|
||||||
|
|
||||||
if ( gGameExternalOptions.fMilitiaResources && !gGameExternalOptions.fMilitiaUseSectorInventory )
|
|
||||||
{
|
|
||||||
FLOAT val_gun, val_armour, val_misc;
|
|
||||||
GetResources( val_gun, val_armour, val_misc );
|
|
||||||
|
|
||||||
ubMilitiaToTrain = min( ubMilitiaToTrain, (INT32)val_gun );
|
|
||||||
ubMilitiaToTrain = min( ubMilitiaToTrain, (INT32)val_armour );
|
|
||||||
ubMilitiaToTrain = min( ubMilitiaToTrain, (INT32)val_misc );
|
|
||||||
}
|
|
||||||
|
|
||||||
promotionsfromvolunteers -= ubMilitiaToTrain;
|
promotionsfromvolunteers -= ubMilitiaToTrain;
|
||||||
|
|
||||||
// HEADROCK HAM 3.4: Composition of new Mobile Militia groups is now dictated by two INI settings controlling
|
// HEADROCK HAM 3.4: Composition of new Mobile Militia groups is now dictated by two INI settings controlling
|
||||||
@@ -324,6 +313,49 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
--ubTargetGreen;
|
--ubTargetGreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flugente: resources limit our training
|
||||||
|
if ( gGameExternalOptions.fMilitiaResources && !gGameExternalOptions.fMilitiaUseSectorInventory )
|
||||||
|
{
|
||||||
|
FLOAT val_gun, val_armour, val_misc;
|
||||||
|
GetResources( val_gun, val_armour, val_misc );
|
||||||
|
|
||||||
|
while ( ubTargetElite > (INT32)val_misc )
|
||||||
|
{
|
||||||
|
--ubTargetElite;
|
||||||
|
++ubTargetRegular;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( 2 * ubTargetElite + ubTargetRegular > (INT32)val_armour )
|
||||||
|
{
|
||||||
|
if ( ubTargetElite )
|
||||||
|
{
|
||||||
|
--ubTargetElite;
|
||||||
|
++ubTargetRegular;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
--ubTargetRegular;
|
||||||
|
++ubTargetGreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( 3 * ubTargetElite + 2 * ubTargetRegular + ubTargetGreen > (INT32)val_gun )
|
||||||
|
{
|
||||||
|
if ( ubTargetElite )
|
||||||
|
{
|
||||||
|
--ubTargetElite;
|
||||||
|
++ubTargetRegular;
|
||||||
|
}
|
||||||
|
else if ( ubTargetRegular )
|
||||||
|
{
|
||||||
|
--ubTargetRegular;
|
||||||
|
++ubTargetGreen;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
--ubTargetGreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ( trained + promotionstodo < ubMilitiaToTrain )
|
while ( trained + promotionstodo < ubMilitiaToTrain )
|
||||||
{
|
{
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -389,6 +421,17 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
AddResources( -numcreated[GREEN_MILITIA] - numcreated[REGULAR_MILITIA] - numcreated[ELITE_MILITIA], -numcreated[REGULAR_MILITIA] - numcreated[ELITE_MILITIA], -numcreated[ELITE_MILITIA] );
|
AddResources( -numcreated[GREEN_MILITIA] - numcreated[REGULAR_MILITIA] - numcreated[ELITE_MILITIA], -numcreated[REGULAR_MILITIA] - numcreated[ELITE_MILITIA], -numcreated[ELITE_MILITIA] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flugente: we need to create profiles fro individual militia here, as they might immediately be promoted afterwards in rare cases
|
||||||
|
// Flugente: create individual militia
|
||||||
|
for ( int i = 0; i < numcreated[GREEN_MILITIA]; ++i )
|
||||||
|
CreateNewIndividualMilitia( GREEN_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
||||||
|
|
||||||
|
for ( int i = 0; i < numcreated[REGULAR_MILITIA]; ++i )
|
||||||
|
CreateNewIndividualMilitia( REGULAR_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
||||||
|
|
||||||
|
for ( int i = 0; i < numcreated[ELITE_MILITIA]; ++i )
|
||||||
|
CreateNewIndividualMilitia( ELITE_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
||||||
|
|
||||||
// handle promotions
|
// handle promotions
|
||||||
UINT8 promotions = 0;
|
UINT8 promotions = 0;
|
||||||
UINT8 promotedto = 0;
|
UINT8 promotedto = 0;
|
||||||
@@ -411,16 +454,6 @@ void GenerateMilitiaSquad(INT16 sMapX, INT16 sMapY, INT16 sTMapX, INT16 sTMapY,
|
|||||||
|
|
||||||
// Flugente: substract volunteers
|
// Flugente: substract volunteers
|
||||||
AddVolunteers( -trained );
|
AddVolunteers( -trained );
|
||||||
|
|
||||||
// Flugente: create individual militia
|
|
||||||
for ( int i = 0; i < numcreated[GREEN_MILITIA]; ++i )
|
|
||||||
CreateNewIndividualMilitia( GREEN_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < numcreated[REGULAR_MILITIA]; ++i )
|
|
||||||
CreateNewIndividualMilitia( REGULAR_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
|
||||||
|
|
||||||
for ( int i = 0; i < numcreated[ELITE_MILITIA]; ++i )
|
|
||||||
CreateNewIndividualMilitia( ELITE_MILITIA, MO_ARULCO, SECTOR( sTMapX, sTMapY ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( gGameExternalOptions.fMilitiaResources && !gGameExternalOptions.fMilitiaUseSectorInventory )
|
if ( gGameExternalOptions.fMilitiaResources && !gGameExternalOptions.fMilitiaUseSectorInventory )
|
||||||
|
|||||||
@@ -270,8 +270,6 @@ void TownMilitiaTrainingCompleted( SOLDIERTYPE *pTrainer, INT16 sMapX, INT16 sMa
|
|||||||
GetResources( val_gun, val_armour, val_misc );
|
GetResources( val_gun, val_armour, val_misc );
|
||||||
|
|
||||||
iTrainingSquadSize = min( iTrainingSquadSize, (INT32)val_gun );
|
iTrainingSquadSize = min( iTrainingSquadSize, (INT32)val_gun );
|
||||||
iTrainingSquadSize = min( iTrainingSquadSize, (INT32)val_armour );
|
|
||||||
iTrainingSquadSize = min( iTrainingSquadSize, (INT32)val_misc );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
promotionsfromvolunteers -= iTrainingSquadSize;
|
promotionsfromvolunteers -= iTrainingSquadSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user