mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
Add checks around all use of bMercOpinion
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2854 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+1
-1
@@ -829,7 +829,7 @@ void HourlyMoraleUpdate( void )
|
||||
}
|
||||
|
||||
// WANNE: Fix by Headrock: Morale and the ice-cream truck.
|
||||
if (pOtherSoldier->ubProfile < 75)
|
||||
if (OKToCheckOpinion(pOtherSoldier->ubProfile))
|
||||
{
|
||||
bOpinion = pProfile->bMercOpinion[ pOtherSoldier->ubProfile ];
|
||||
}
|
||||
|
||||
@@ -1216,7 +1216,7 @@ MERCPROFILESTRUCT& MERCPROFILESTRUCT::operator=(const OLD_MERCPROFILESTRUCT_101&
|
||||
|
||||
memcpy( &(this->ubApproachVal), &(src.ubApproachVal), 4 * sizeof (UINT8));
|
||||
memcpy( &(this->ubApproachMod), &(src.ubApproachMod), 3 * 4 * sizeof (UINT8));
|
||||
memcpy( &(this->bMercOpinion), &(src.bMercOpinion), 75 * sizeof (INT8));
|
||||
memcpy( &(this->bMercOpinion), &(src.bMercOpinion), DontUseMeDirectly::MaxIDToCheckForMorale * sizeof (INT8));
|
||||
|
||||
memcpy( &(this->usStatChangeChances), &(src.usStatChangeChances), 12 * sizeof (UINT16));// used strictly for balancing, never shown!
|
||||
memcpy( &(this->usStatChangeSuccesses), &(src.usStatChangeSuccesses), 12 * sizeof (UINT16));// used strictly for balancing, never shown!
|
||||
|
||||
@@ -4270,7 +4270,8 @@ void DebugSoldierPage3( )
|
||||
SetFontShade(LARGEFONT1, FONT_SHADE_GREEN);
|
||||
gprintf( 0, LINE_HEIGHT * ubLine, L"NPC Opinion:");
|
||||
SetFontShade(LARGEFONT1, FONT_SHADE_NEUTRAL);
|
||||
gprintf( 150, LINE_HEIGHT * ubLine, L"%d", gMercProfiles[ pSoldier->ubProfile ].bMercOpinion[ MercPtrs[ gusSelectedSoldier ]->ubProfile ] );
|
||||
if (OKToCheckOpinion(MercPtrs[ gusSelectedSoldier ]->ubProfile))
|
||||
gprintf( 150, LINE_HEIGHT * ubLine, L"%d", gMercProfiles[ pSoldier->ubProfile ].bMercOpinion[ MercPtrs[ gusSelectedSoldier ]->ubProfile ] );
|
||||
ubLine++;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,20 @@
|
||||
#define NEEDS_TRAINING_SKILL_VALUE 50
|
||||
#define NO_CHANCE_IN_HELL_SKILL_VALUE 0
|
||||
|
||||
//
|
||||
// WDS 05/13/2009
|
||||
// This is a temporary fix and should be REALLY fixed someday.
|
||||
// The bMercOpinion array in MERCPROFILESTRUCT below only contains 75 entries. That
|
||||
// means profile ID#s of 75 and beyond are not valid to be used for checking morale.
|
||||
//
|
||||
namespace DontUseMeDirectly {
|
||||
const static int MaxIDToCheckForMorale = 75;
|
||||
}
|
||||
|
||||
inline bool OKToCheckOpinion(int profileNumber) {
|
||||
return (profileNumber < DontUseMeDirectly::MaxIDToCheckForMorale);
|
||||
}
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -354,7 +368,10 @@ public:
|
||||
INT8 bTown;
|
||||
INT8 bTownAttachment;
|
||||
UINT16 usOptionalGearCost;
|
||||
INT8 bMercOpinion[75];
|
||||
|
||||
// See above note near the definition of MaxIDToCheckForMorale
|
||||
INT8 bMercOpinion[DontUseMeDirectly::MaxIDToCheckForMorale];
|
||||
|
||||
INT8 bApproached;
|
||||
INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be.
|
||||
INT8 bHatedTime[5];
|
||||
@@ -589,7 +606,10 @@ public:
|
||||
INT8 bTown;
|
||||
INT8 bTownAttachment;
|
||||
UINT16 usOptionalGearCost;
|
||||
INT8 bMercOpinion[75];
|
||||
|
||||
// See above note near the definition of MaxIDToCheckForMorale
|
||||
INT8 bMercOpinion[DontUseMeDirectly::MaxIDToCheckForMorale];
|
||||
|
||||
INT8 bApproached;
|
||||
INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be.
|
||||
INT8 bHatedTime[5];
|
||||
|
||||
Reference in New Issue
Block a user