mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
Merged from revision: 7199
Fixes (by Buggler) - Fixed town militia training bug after declining to train a new mobile militia squad upon completion - Fixed income from facilities not properly added to cash balance git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7200 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+7
-1
@@ -489,7 +489,10 @@ typedef struct
|
||||
UINT8 ubHelicopterHoverTime;
|
||||
UINT8 ubHelicopterTimeToFullRefuel;
|
||||
|
||||
UINT8 ubFiller[273]; //This structure should be 1588 bytes
|
||||
// Buggler: New global variable that tracks money earned for facility use.
|
||||
INT32 iTotalEarnedForFacilityOperationsToday;
|
||||
|
||||
UINT8 ubFiller[266]; //This structure should be 1588 bytes
|
||||
|
||||
} GENERAL_SAVE_INFO;
|
||||
|
||||
@@ -8197,6 +8200,7 @@ BOOLEAN SaveGeneralInfo( HWFILE hFile )
|
||||
sGeneralInfo.fMikeShouldSayHi = gfMikeShouldSayHi;
|
||||
|
||||
// HEADROCK HAM 3.6: Save new global variable for facility costs
|
||||
sGeneralInfo.iTotalEarnedForFacilityOperationsToday = giTotalEarnedForFacilityOperationsToday;
|
||||
sGeneralInfo.iTotalOwedForFacilityOperationsToday = giTotalOwedForFacilityOperationsToday;
|
||||
|
||||
// HEADROCK HAM 3.6: Save Skyrider Costs Modifier
|
||||
@@ -8471,6 +8475,7 @@ BOOLEAN LoadGeneralInfo( HWFILE hFile )
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.ubHelicopterSeriousRepairsSoFar, sizeof(sGeneralInfo.ubHelicopterSeriousRepairsSoFar), sizeof(UINT8), numBytesRead);
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.ubHelicopterHoverTime, sizeof(sGeneralInfo.ubHelicopterHoverTime), sizeof(UINT8), numBytesRead);
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.ubHelicopterTimeToFullRefuel, sizeof(sGeneralInfo.ubHelicopterTimeToFullRefuel), sizeof(UINT8), numBytesRead);
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.iTotalEarnedForFacilityOperationsToday, sizeof(sGeneralInfo.iTotalEarnedForFacilityOperationsToday), sizeof(INT32), numBytesRead);
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.ubFiller, sizeof(sGeneralInfo.ubFiller), sizeof(UINT8), numBytesRead);
|
||||
} else {
|
||||
numBytesRead = ReadFieldByField(hFile, &sGeneralInfo.HiddenNames, sizeof(sGeneralInfo.HiddenNames), sizeof(BOOLEAN), numBytesRead);
|
||||
@@ -8753,6 +8758,7 @@ BOOLEAN LoadGeneralInfo( HWFILE hFile )
|
||||
gfMikeShouldSayHi = sGeneralInfo.fMikeShouldSayHi;
|
||||
|
||||
// HEADROCK HAM 3.6: Load new global variable for facility costs
|
||||
giTotalEarnedForFacilityOperationsToday = sGeneralInfo.iTotalEarnedForFacilityOperationsToday;
|
||||
giTotalOwedForFacilityOperationsToday = sGeneralInfo.iTotalOwedForFacilityOperationsToday;
|
||||
|
||||
// HEADROCK HAM 3.6: Load Skyrider Costs Modifier
|
||||
|
||||
@@ -41,9 +41,10 @@
|
||||
#endif
|
||||
|
||||
INT16 gsSkyriderCostModifier;
|
||||
// HEADROCK HAM 3.6: Strategic info variable, total of costs accumulated for the use of facilities today. Deducted
|
||||
// from account and reset at midnight, unless player can't pay (in which case, carries over to the next day).
|
||||
// HEADROCK HAM 3.6: Strategic info variable, total of income/costs accumulated for the use of facilities today.
|
||||
// Account settle and reset at midnight, unless player can't pay (in which case, carries over to the next day).
|
||||
// This variable is SAVED and LOADED.
|
||||
INT32 giTotalEarnedForFacilityOperationsToday = 0;
|
||||
INT32 giTotalOwedForFacilityOperationsToday = 0;
|
||||
BOOLEAN gfOutstandingFacilityDebt = TRUE;
|
||||
|
||||
@@ -626,9 +627,9 @@ void UpdateFacilityUsageCosts( )
|
||||
else if (sCost < 0)
|
||||
{
|
||||
/////////////////////////////////////////////////////////
|
||||
// Put money directly into the player's account
|
||||
// Increase income for operating this facility
|
||||
|
||||
LaptopSaveInfo.iCurrentBalance += (-1 * sCost);
|
||||
giTotalEarnedForFacilityOperationsToday += (-1 * gFacilityTypes[ubFacilityType].AssignmentData[ubAssignmentType].sCostPerHour);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -637,6 +638,13 @@ void UpdateFacilityUsageCosts( )
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDailyPaymentFacilityIncome( void )
|
||||
{
|
||||
// Pay total income.
|
||||
AddTransactionToPlayersBook( FACILITY_OPERATIONS, 0, GetWorldTotalMin(), giTotalEarnedForFacilityOperationsToday );
|
||||
giTotalEarnedForFacilityOperationsToday = 0;
|
||||
}
|
||||
|
||||
// HEADROCK HAM 3.6: This function runs once at the end of each day.
|
||||
// It handles debt accrued by operation facilities. If there is enough money to pay the debt off, this
|
||||
// is done automatically. If only part of the money is available, or none of it, your account is emptied and all
|
||||
@@ -2036,7 +2044,8 @@ INT32 GetTotalFacilityHourlyCosts( BOOLEAN fPositive )
|
||||
|
||||
void InitFacilities()
|
||||
{
|
||||
// Initialize facility debt.
|
||||
// Initialize facility accounts.
|
||||
giTotalEarnedForFacilityOperationsToday = 0;
|
||||
giTotalOwedForFacilityOperationsToday = 0;
|
||||
gfOutstandingFacilityDebt = FALSE;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ extern void UpdateStrategicDetectionLevel( );
|
||||
extern void UpdateSkyriderCostModifier( );
|
||||
extern INT16 gsSkyriderCostModifier; // This variable is SAVED/LOADED
|
||||
|
||||
// HEADROCK HAM 3.6: Strategic info variable, total of costs accumulated for the use of facilities today. Deducted
|
||||
// from account and reset at midnight, unless player can't pay (in which case, carries over to the next day).
|
||||
// HEADROCK HAM 3.6: Strategic info variable, total of income/costs accumulated for the use of facilities today.
|
||||
// Account settle and reset at midnight, unless player can't pay (in which case, carries over to the next day).
|
||||
extern INT32 giTotalEarnedForFacilityOperationsToday; // This variable is SAVED and LOADED.
|
||||
extern INT32 giTotalOwedForFacilityOperationsToday; // This variable is SAVED and LOADED.
|
||||
// Do we have outstanding debts for facility operation?
|
||||
extern BOOLEAN gfOutstandingFacilityDebt; // This variable is SAVED and LOADED.
|
||||
@@ -65,6 +66,7 @@ enum
|
||||
void UpdateGlobalVariablesFromFacilities( void );
|
||||
void UpdateFacilityUsageCosts( void );
|
||||
|
||||
void HandleDailyPaymentFacilityIncome( void );
|
||||
void HandleDailyPaymentFacilityDebt( void );
|
||||
void HandleManualPaymentFacilityDebt( void );
|
||||
void HandleHourlyRisks( void );
|
||||
|
||||
@@ -593,6 +593,12 @@ void MercDailyUpdate()
|
||||
AdjustRoamingRestrictions( FALSE );
|
||||
}
|
||||
|
||||
// Buggler: Pay income for operating Facilities today.
|
||||
if (giTotalEarnedForFacilityOperationsToday)
|
||||
{
|
||||
HandleDailyPaymentFacilityIncome();
|
||||
}
|
||||
|
||||
// HEADROCK HAM 3.6: Pay debt for operating Facilities today. If can't be paid, apply loyalty hit.
|
||||
if (giTotalOwedForFacilityOperationsToday)
|
||||
{
|
||||
|
||||
+18
-17
@@ -691,25 +691,25 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia2");
|
||||
if (IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier, REGULAR_MILITIA )
|
||||
&& (gGameExternalOptions.gfTrainVeteranMilitia)
|
||||
&& (GetWorldDay( ) >= gGameExternalOptions.guiTrainVeteranMilitiaDelay))
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iVeteranCostModifier) * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
gfAreWePromotingRegular = TRUE;
|
||||
}
|
||||
else if (IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier, GREEN_MILITIA ))
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iRegularCostModifier) * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
gfAreWePromotingGreen = TRUE;
|
||||
}
|
||||
// Normal training.
|
||||
else
|
||||
{
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iVeteranCostModifier) * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
gfAreWePromotingRegular = TRUE;
|
||||
}
|
||||
else if (IsMilitiaTrainableFromSoldiersSectorMaxed( pSoldier, GREEN_MILITIA ))
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost*gGameExternalOptions.iRegularCostModifier) * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
gfAreWePromotingGreen = TRUE;
|
||||
}
|
||||
// Normal training.
|
||||
else
|
||||
{
|
||||
giTotalCostOfTraining = iMilitiaTrainingCost * iNumberOfSectors;
|
||||
Assert( giTotalCostOfTraining > 0 );
|
||||
}
|
||||
gfAreWeTrainingMobile = FALSE;
|
||||
}
|
||||
|
||||
// Mobile
|
||||
else
|
||||
{
|
||||
@@ -1032,6 +1032,7 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Militia3");
|
||||
{
|
||||
giTotalCostOfTraining = (iMilitiaTrainingCost);
|
||||
}
|
||||
gfAreWeTrainingMobile = FALSE;
|
||||
}
|
||||
|
||||
// can player afford to continue training?
|
||||
|
||||
Reference in New Issue
Block a user