- Fix: fully repairing a gun did not always clean it

- Fix: need to sleep modifiers from food were applied wrong
- Fix: under certain circumstances, player mercs won an AI interrupt, leading a deadlock or - potentially - AI-controlled player mercs

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5686 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-11-14 01:23:13 +00:00
parent 1a7e900df5
commit 51342b0669
3 changed files with 26 additions and 14 deletions
+7 -4
View File
@@ -3809,16 +3809,19 @@ BOOLEAN RepairObject( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOwner, OBJECTTYPE *
if ( (*pObj)[ubLoop]->data.objectStatus == threshold && (((*pObj)[ubLoop]->data.objectStatus - ubBeforeRepair) > 4 ))
{
gMercProfiles[ pSoldier->ubProfile ].records.usItemsRepaired++;
// if item was fully repaired, consider it cleaned
if ( gGameExternalOptions.fDirtSystem )
(*pObj)[ubLoop]->data.bDirtLevel = 0.0f;
}
// if the item was now repaired to a status of 96-99 and the repair was at least 2%, add a point, consider the item repaired (no points will be awarded for it anyway)
else if ( (*pObj)[ubLoop]->data.objectStatus > threshold - 5 && (*pObj)[ubLoop]->data.objectStatus < threshold && ((*pObj)[ubLoop]->data.objectStatus - ubBeforeRepair) > 1)
{
gMercProfiles[ pSoldier->ubProfile ].records.usItemsRepaired++;
}
if ( (*pObj)[ubLoop]->data.objectStatus == threshold )
{
// if item was fully repaired, consider it cleaned
if ( gGameExternalOptions.fDirtSystem )
(*pObj)[ubLoop]->data.bDirtLevel = 0.0f;
}
// note: this system is bad if we can repair only 1% per hour (which is rather we are total losers)
///////////////////////////////////////////////////////////////////////////////////////////////////////
+9 -9
View File
@@ -50,20 +50,20 @@ extern SECTOR_EXT_DATA SectorExternalData[256][4];
// apart from the ubStatDamageChance values, be careful not to set any modifiers below -50 or above 0 unless you know what you are doing!!!
FoodMoraleMod FoodMoraleMods[NUM_FOOD_MORALE_TYPES] =
{
{ 100000, -8, -3, -20, -35, 2}, // FOOD_STUFFED
{ 7500, -5, -2, -5, -5, 0}, // FOOD_EXTREMELY_FULL
{ 5000, 0, -1, -2, -2, 0}, // FOOD_VERY_FULL
{ 2500, 2, -1, -1, 0, 0}, // FOOD_FULL
{ 100000, -8, +3, -20, -35, 2}, // FOOD_STUFFED
{ 7500, -5, +2, -5, -5, 0}, // FOOD_EXTREMELY_FULL
{ 5000, 0, +1, -2, -2, 0}, // FOOD_VERY_FULL
{ 2500, 2, +1, -1, 0, 0}, // FOOD_FULL
{ 1000, 5, 0, 0, 0, 0}, // FOOD_SLIGHTLY_FULL
{ 0, 0, 0, 0, 0, 0}, // FOOD_NORMAL
{ -1000, 0, 0, 0, 0, 0}, // FOOD_LOW
{ -2500, -2, 0, 0, 0, 0}, // FOOD_EVEN_LOWER
{ -5000, -8, -1, -10, -18, 5}, // FOOD_VERY_LOW
{ -7500, -15, -2, -20, -15, 25}, // FOOD_DANGER
{ -8750, -25, -2, -35, -30, 75}, // FOOD_DESPERATE
{ -10000, -40, -3, -45, -45, 100}, // FOOD_STARVING
{ -5000, -8, +1, -10, -18, 5}, // FOOD_VERY_LOW
{ -7500, -15, +2, -20, -15, 25}, // FOOD_DANGER
{ -8750, -25, +2, -35, -30, 75}, // FOOD_DESPERATE
{ -10000, -40, +3, -45, -45, 100}, // FOOD_STARVING
};
@@ -286,7 +286,7 @@ void FoodNeedForSleepModifiy( SOLDIERTYPE *pSoldier, UINT8* pubNeedForSleep )
UINT8 watersituation;
GetFoodSituation( pSoldier, &foodsituation, &watersituation );
(*pubNeedForSleep) += max(1, (INT16)((*pubNeedForSleep) + FoodMoraleMods[foodsituation].bSleepModifier + FoodMoraleMods[watersituation].bSleepModifier ));
(*pubNeedForSleep) = max(1, (INT16)((*pubNeedForSleep) + FoodMoraleMods[foodsituation].bSleepModifier + FoodMoraleMods[watersituation].bSleepModifier ));
}
void ReducePointsForHunger( SOLDIERTYPE *pSoldier, UINT32 *pusPoints )
+10 -1
View File
@@ -1071,7 +1071,16 @@ void StartInterrupt( void )
AddTopMessage( COMPUTER_INTERRUPT_MESSAGE, Message[STR_INTERRUPT] );
if (pTempSoldier != NULL)
StartNPCAI( pTempSoldier );
{
// Flugente 12-11-13: I observed an isntance where the pTempSoldier was a player merc, leading to a deadlock here. The reason was that during an iinterrupot by a civilian, he somehow did not win
// instead the game used the last merc entry... which overflowed, and thus started at merc 0, which is always a player merc
// I am not sure if this is the best solution... however it seems to work for me.
// If anybody knows a better solution, feel free to do so
if ( pTempSoldier->bTeam != OUR_TEAM )
StartNPCAI( pTempSoldier );
else
EndInterrupt(TRUE);
}
}
if ( !gfHiddenInterrupt )