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)
{
+1 -1
View File
@@ -71,7 +71,7 @@ void ResetIMPCharactersEyesAndMouthOffsets( UINT8 ubMercProfileID );
BOOLEAN ImpExists ( STR fileName );
INT32 iGetProfileCost( void ); // added by SANDRO
INT32 GetProfileCost( BOOLEAN aWithGearCost ); // added by SANDRO
void MakeProfileInvItemAnySlot( MERCPROFILESTRUCT *pProfile, UINT16 usItem, UINT8 ubStatus, UINT8 ubHowMany );
+1 -1
View File
@@ -568,7 +568,7 @@ void BtnIMPGearFinishCallback( GUI_BUTTON *btn, INT32 reason )
INT32 GetIMPGearCost( )
{
if ( IsIMPGearUsed( ) )
return max( 0, gIMPGearCost - 3000 );
return max( 0, gIMPGearCost - gGameExternalOptions.iIMPProfileCost );
return 0;
}
+1 -1
View File
@@ -404,7 +404,7 @@ void BtnIMPMainPageBeginCallback(GUI_BUTTON *btn,INT32 reason)
else
{
//if( LaptopSaveInfo.iCurrentBalance < COST_OF_PROFILE )
if( LaptopSaveInfo.iCurrentBalance < iGetProfileCost() ) // SANDRO - changed to find actual profile cost in IMPConfirm
if( LaptopSaveInfo.iCurrentBalance < GetProfileCost(TRUE) ) // SANDRO - changed to find actual profile cost in IMPConfirm
{
DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 3 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, BeginMessageBoxCallBack);
+1 -1
View File
@@ -351,7 +351,7 @@ void PrintImpText( void )
//LoadAndDisplayIMPText( LAPTOP_SCREEN_UL_X + 160, LAPTOP_SCREEN_WEB_UL_Y + 145, ( 200 ), IMP_CON_3 , FONT12ARIAL, FONT_WHITE, TRUE, 0);
// SANDRO - changed to show exact cost of profile
CHAR16 chPayCost[1000];
swprintf( chPayCost, gzIMPProfileCostText[ 0 ], iGetProfileCost() );
swprintf( chPayCost, gzIMPProfileCostText[ 0 ], GetProfileCost(TRUE) );
DisplayWrappedString( LAPTOP_SCREEN_UL_X + 160, LAPTOP_SCREEN_WEB_UL_Y + 145, ( 200 ), 2, FONT12ARIAL, FONT_WHITE, chPayCost,FONT_BLACK,FALSE,LEFT_JUSTIFIED);
break;