Change: Regardless of whether or not an IMP is created via old/new method or by loading an existing callsign, gear costs exceeding IMP_PROFILE_COST are deducted extra.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8638 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-11-08 20:11:25 +00:00
parent 6b601809d0
commit b988df876f
5 changed files with 30 additions and 15 deletions
+26 -11
View File
@@ -323,7 +323,7 @@ void BtnIMPConfirmYes(GUI_BUTTON *btn,INT32 reason)
// silversurfer: We need to store the profile cost here because right now our new IMP doesn't occupy a slot yet.
// However function iGetProfileCost() will already calculate price including that slot. We would charge too much money after the IMP is created below.
INT32 iIMPCost = iGetProfileCost();
INT32 iIMPCost = GetProfileCost(TRUE);
if( LaptopSaveInfo.iCurrentBalance < iIMPCost )
{
// not enough
@@ -580,6 +580,21 @@ void DistributeInitialGear(MERCPROFILESTRUCT *pProfile)
}
}
INT32 GetEquippedGearCost( MERCPROFILESTRUCT *pProfile )
{
INT32 cost = 0;
for ( int i = INV_START_POS; i<NUM_INV_SLOTS; ++i )
{
if ( pProfile->inv[i] != NOTHING )
{
cost += pProfile->bInvNumber[i] * Item[pProfile->inv[i]].usPrice;
}
}
return cost;
}
void GiveItemsToPC( UINT8 ubProfileId )
{
MERCPROFILESTRUCT *pProfile;
@@ -1517,14 +1532,7 @@ BOOLEAN LoadImpCharacter( STR nickName )
if (iProfileId != -1)
{
LaptopSaveInfo.iIMPIndex = iProfileId;
// silversurfer: Store current IMP cost. Function iGetProfileCost() already takes the new slot into account.
// If we create the IMP first we would charge too much.
INT32 iIMPCost = iGetProfileCost();
// read in the profile
//if ( !gMercProfiles[ iProfileId ].Load(hFile, false) )
// anv: before loading profile we need to set guiCurrentSaveGameVersion to profile's version
// and set it back to SAVE_GAME_VERSION right after or else new saves will be broken!
guiCurrentSaveGameVersion = version;
@@ -1555,6 +1563,13 @@ BOOLEAN LoadImpCharacter( STR nickName )
//CHRISL: At this point, we need to resort profile inventory so that NewInv items don't accidentally appear in OldInv
DistributeInitialGear(&gMercProfiles[iProfileId]);
// silversurfer: Store current IMP cost. Function iGetProfileCost() already takes the new slot into account.
// If we create the IMP first we would charge too much.
INT32 iIMPCost = GetProfileCost(FALSE);
// Flugente: as we do not store the cost of the gear in the IMP file, we have to determine the cost here
iIMPCost += max(0, GetEquippedGearCost( &gMercProfiles[iProfileId] ) - gGameExternalOptions.iIMPProfileCost );
// Changed to find actual IMP cost - SANDRO
if( LaptopSaveInfo.iCurrentBalance < iIMPCost )
{
@@ -1748,10 +1763,10 @@ void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeInd
}
// SANDRO - Function to determine actual cost of profile
INT32 iGetProfileCost()
INT32 GetProfileCost( BOOLEAN aWithGearCost )
{
// Flugente: aditional imp gear cost
INT32 impgearcost = GetIMPGearCost();
INT32 impgearcost = aWithGearCost ? GetIMPGearCost() : 0;
if (gGameExternalOptions.fDynamicIMPProfileCost)
{