mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +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:
@@ -3949,8 +3949,10 @@ INT16 GetBonusTrainingPtsDueToInstructor( SOLDIERTYPE *pInstructor, SOLDIERTYPE
|
||||
}
|
||||
|
||||
// factor in their mutual relationship
|
||||
bOpinionFactor = gMercProfiles[ pStudent->ubProfile ].bMercOpinion[ pInstructor->ubProfile ];
|
||||
bOpinionFactor += gMercProfiles[ pInstructor->ubProfile ].bMercOpinion[ pStudent->ubProfile ] / 2;
|
||||
if (OKToCheckOpinion(pInstructor->ubProfile))
|
||||
bOpinionFactor = gMercProfiles[ pStudent->ubProfile ].bMercOpinion[ pInstructor->ubProfile ];
|
||||
if (OKToCheckOpinion(pStudent->ubProfile))
|
||||
bOpinionFactor += gMercProfiles[ pInstructor->ubProfile ].bMercOpinion[ pStudent->ubProfile ] / 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -697,7 +697,8 @@ void QuickSetupOfMercProfileItems( UINT32 uiCount, UINT8 ubProfileIndex )
|
||||
|
||||
// TEMP!
|
||||
// make carman's opinion of us high!
|
||||
gMercProfiles[ 78 ].bMercOpinion[ ubProfileIndex ] = 25;
|
||||
if (OKToCheckOpinion(ubProfileIndex))
|
||||
gMercProfiles[ 78 ].bMercOpinion[ ubProfileIndex ] = 25;
|
||||
|
||||
}
|
||||
else if ( uiCount == 1 )
|
||||
|
||||
@@ -991,8 +991,10 @@ void UpdateBuddyAndHatedCounters( void )
|
||||
else if (pProfile->bLearnToHateCount == 0)
|
||||
{
|
||||
// set as bHated[2];
|
||||
if (OKToCheckOpinion(ubOtherProfileID)) {
|
||||
pProfile->bHated[2] = pProfile->bLearnToHate;
|
||||
pProfile->bMercOpinion[ubOtherProfileID] = HATED_OPINION;
|
||||
}
|
||||
|
||||
if (pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__MERC || (pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__NPC && (pSoldier->ubProfile == DEVIN || pSoldier->ubProfile == SLAY || pSoldier->ubProfile == IGGY || pSoldier->ubProfile == CONRAD ) ) )
|
||||
{
|
||||
@@ -1012,9 +1014,11 @@ void UpdateBuddyAndHatedCounters( void )
|
||||
if (pProfile->bLearnToHateCount < pProfile->bLearnToHateTime / 2)
|
||||
{
|
||||
// gradual opinion drop
|
||||
if (OKToCheckOpinion(ubOtherProfileID)) {
|
||||
pProfile->bMercOpinion[ubOtherProfileID] += (HATED_OPINION - pProfile->bMercOpinion[ubOtherProfileID]) / (pProfile->bLearnToHateCount + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !fUpdatedTimeTillNextHatedComplaint )
|
||||
@@ -1045,13 +1049,17 @@ void UpdateBuddyAndHatedCounters( void )
|
||||
if (pProfile->bLearnToLikeCount == 0)
|
||||
{
|
||||
// add to liked!
|
||||
pProfile->bBuddy[2] = pProfile->bLearnToLike;
|
||||
pProfile->bMercOpinion[ubOtherProfileID] = BUDDY_OPINION;
|
||||
if (OKToCheckOpinion(ubOtherProfileID)) {
|
||||
pProfile->bBuddy[2] = pProfile->bLearnToLike;
|
||||
pProfile->bMercOpinion[ubOtherProfileID] = BUDDY_OPINION;
|
||||
}
|
||||
}
|
||||
else if (pProfile->bLearnToLikeCount < pProfile->bLearnToLikeTime / 2)
|
||||
{
|
||||
// increase opinion of them!
|
||||
pProfile->bMercOpinion[ubOtherProfileID] += (BUDDY_OPINION - pProfile->bMercOpinion[ubOtherProfileID]) / (pProfile->bLearnToLikeCount + 1);
|
||||
if (OKToCheckOpinion(ubOtherProfileID)) {
|
||||
pProfile->bMercOpinion[ubOtherProfileID] += (BUDDY_OPINION - pProfile->bMercOpinion[ubOtherProfileID]) / (pProfile->bLearnToLikeCount + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+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];
|
||||
|
||||
+4
-1
@@ -575,7 +575,10 @@ UINT8 CalcDesireToTalk( UINT8 ubNPC, UINT8 ubMerc, INT8 bApproach )
|
||||
pNPCProfile = &(gMercProfiles[ubNPC]);
|
||||
pMercProfile = &(gMercProfiles[ubMerc]);
|
||||
|
||||
iPersonalVal = 50 + pNPCProfile->bMercOpinion[ubMerc]; /* + pNPCProfile->bMercTownReputation[ pNPCProfile->bTown ] */;
|
||||
iPersonalVal = 50; /* + pNPCProfile->bMercTownReputation[ pNPCProfile->bTown ] */;
|
||||
if (OKToCheckOpinion(ubMerc)) {
|
||||
iPersonalVal += pNPCProfile->bMercOpinion[ubMerc];
|
||||
}
|
||||
|
||||
// ARM: NOTE - for towns which don't use loyalty (San Mona, Estoni, Tixa, Orta )
|
||||
// loyalty will always remain 0 (this was OKed by Ian)
|
||||
|
||||
Reference in New Issue
Block a user