diff --git a/Laptop/IMP Confirm.cpp b/Laptop/IMP Confirm.cpp index 2509f738..40340279 100644 --- a/Laptop/IMP Confirm.cpp +++ b/Laptop/IMP Confirm.cpp @@ -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 = GetProfileCost(TRUE); + INT32 iIMPCost = GetProfileCost(TRUE, FALSE); if( LaptopSaveInfo.iCurrentBalance < iIMPCost ) { // not enough @@ -1565,7 +1565,7 @@ BOOLEAN LoadImpCharacter( STR nickName ) // 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); + INT32 iIMPCost = GetProfileCost(FALSE, TRUE); // 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 ); @@ -1763,19 +1763,18 @@ void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeInd } // SANDRO - Function to determine actual cost of profile -INT32 GetProfileCost( BOOLEAN aWithGearCost ) +INT32 GetProfileCost( BOOLEAN aWithGearCost, BOOLEAN profileSlotAllocated ) { // Flugente: aditional imp gear cost INT32 impgearcost = aWithGearCost ? GetIMPGearCost() : 0; + INT32 impProfileCost = gGameExternalOptions.iIMPProfileCost; if (gGameExternalOptions.fDynamicIMPProfileCost) { - // silversurfer: When we create an IMP he doesn't occupy a slot yet so we need to add 1 to get the correct price in advance. - INT32 iIMPProfileCost = gGameExternalOptions.iIMPProfileCost * (CountFilledIMPSlots() + 1); - - if ( iIMPProfileCost + impgearcost >= gGameExternalOptions.iIMPProfileCost ) - return iIMPProfileCost + impgearcost; + // sun_alf: if the IMP profile already occupies a slot, CountFilledIMPSlots() return the number we want to multiply on, + // but if a slot is not allocated still, we need to add 1 to get the correct price in advance. + impProfileCost *= profileSlotAllocated ? CountFilledIMPSlots() : CountFilledIMPSlots() + 1; } - return gGameExternalOptions.iIMPProfileCost + impgearcost; + return impProfileCost + impgearcost; } diff --git a/Laptop/IMP Confirm.h b/Laptop/IMP Confirm.h index ff6bb00b..81787c25 100644 --- a/Laptop/IMP Confirm.h +++ b/Laptop/IMP Confirm.h @@ -71,7 +71,7 @@ void ResetIMPCharactersEyesAndMouthOffsets( UINT8 ubMercProfileID ); BOOLEAN ImpExists ( STR fileName ); -INT32 GetProfileCost( BOOLEAN aWithGearCost ); // added by SANDRO +INT32 GetProfileCost( BOOLEAN aWithGearCost, BOOLEAN profileSlotAllocated ); // added by SANDRO void MakeProfileInvItemAnySlot( MERCPROFILESTRUCT *pProfile, UINT16 usItem, UINT8 ubStatus, UINT8 ubHowMany ); diff --git a/Laptop/IMP MainPage.cpp b/Laptop/IMP MainPage.cpp index aa9d0488..9e39003d 100644 --- a/Laptop/IMP MainPage.cpp +++ b/Laptop/IMP MainPage.cpp @@ -401,7 +401,7 @@ void BtnIMPMainPageBeginCallback(GUI_BUTTON *btn,INT32 reason) } else { - if( LaptopSaveInfo.iCurrentBalance < GetProfileCost(FALSE) ) // SANDRO - changed to find actual profile cost in IMPConfirm + if( LaptopSaveInfo.iCurrentBalance < GetProfileCost(FALSE, FALSE) ) // SANDRO - changed to find actual profile cost in IMPConfirm { DoLapTopMessageBox( MSG_BOX_IMP_STYLE, pImpPopUpStrings[ 3 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, BeginMessageBoxCallBack); } diff --git a/Laptop/IMP Text System.cpp b/Laptop/IMP Text System.cpp index 2829a348..309d2d68 100644 --- a/Laptop/IMP Text System.cpp +++ b/Laptop/IMP Text System.cpp @@ -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 ], GetProfileCost(TRUE) ); + swprintf( chPayCost, gzIMPProfileCostText[ 0 ], GetProfileCost(TRUE, FALSE) ); DisplayWrappedString( LAPTOP_SCREEN_UL_X + 160, LAPTOP_SCREEN_WEB_UL_Y + 145, ( 200 ), 2, FONT12ARIAL, FONT_WHITE, chPayCost,FONT_BLACK,FALSE,LEFT_JUSTIFIED); break;