From 51342b0669376aa23821df0f9469ebc0cbcf6208 Mon Sep 17 00:00:00 2001 From: Flugente Date: Wed, 14 Nov 2012 01:23:13 +0000 Subject: [PATCH] - 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 --- Strategic/Assignments.cpp | 11 +++++++---- Tactical/Food.cpp | 18 +++++++++--------- Tactical/TeamTurns.cpp | 11 ++++++++++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 827063b5c..caf8b0c79 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -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) /////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Tactical/Food.cpp b/Tactical/Food.cpp index 2a6c61381..c0217946f 100644 --- a/Tactical/Food.cpp +++ b/Tactical/Food.cpp @@ -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 ) diff --git a/Tactical/TeamTurns.cpp b/Tactical/TeamTurns.cpp index 41dae0c12..208119164 100644 --- a/Tactical/TeamTurns.cpp +++ b/Tactical/TeamTurns.cpp @@ -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 )