changeset 2246:0be4f17b7986

shop stealing cleaned up a bit
author Grumpy7
date Wed, 26 Feb 2014 01:14:18 +0100
parents 9df0477a5e2b
children 529bf95fb0d7
files UI/UIShops.cpp mm7_4.cpp mm7_unsorted_subs.h
diffstat 3 files changed, 55 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIShops.cpp	Sun Feb 23 18:44:01 2014 +0100
+++ b/UI/UIShops.cpp	Wed Feb 26 01:14:18 2014 +0100
@@ -1650,61 +1650,48 @@
       if ( pMapStats->GetMapInfo(pCurrentMapName) )
         a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)]._steal_perm;
       party_reputation = pParty->GetPartyReputation();
-      if (pPlayers[uActiveCharacter]->CanSteal())
+      if ((!pPlayers[uActiveCharacter]->CanSteal() || !GetAsyncKeyState(VK_CONTROL)) && pParty->uNumGold < uPriceItemService) 
       {
-        if ( GetAsyncKeyState(VK_CONTROL) )
-        {
+        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
+        return;
+      }
+      if (pPlayers[uActiveCharacter]->CanSteal() && GetAsyncKeyState(VK_CONTROL))
+      {
           uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6);
           if ( !uNumSeconds )
           {
             sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6);
             return;
           }
-        }
-      }
-      if ( pParty->uNumGold < uPriceItemService )
-      {
-        if ( uNumSeconds != 2 )
-        {
-          if ( uNumSeconds != 1 )
-          {
-            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
-            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
-            return;
-          }
-        }
       }
       v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID);
       if ( v39 )
       {
         bought_item->SetIdentified();
         memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1], bought_item, sizeof(ItemGen));
-        if ( pPlayers[uActiveCharacter]->CanSteal() )
+        if (uNumSeconds != 0)
         {
-          if ( GetAsyncKeyState(VK_CONTROL) )
-          {
-            if ( uNumSeconds == 1 || uNumSeconds == 2 )
-            {
-              pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1].SetStolen();
-              sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6);
-              viewparams->bRedrawGameUI = 1;
-              bought_item->Reset();
-              pRenderer->ClearZBuffer(0, 479);
-              pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
-              return;
-            }
-          }
+          pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1].SetStolen();
+          sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6);
         }
-        dword_F8B1E4 = 1;
-        Party::TakeGold(uPriceItemService);
+        else
+        {
+          dword_F8B1E4 = 1;
+          Party::TakeGold(uPriceItemService);
+        }
         viewparams->bRedrawGameUI = 1;
         bought_item->Reset();
         pRenderer->ClearZBuffer(0, 479);
         pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
         return;
       }
-      pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!"
+      else
+      {
+        pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!"
+        return;
+      }
       break;
     }
     default:// if click video screen in shop
--- a/mm7_4.cpp	Sun Feb 23 18:44:01 2014 +0100
+++ b/mm7_4.cpp	Wed Feb 26 01:14:18 2014 +0100
@@ -1674,60 +1674,45 @@
 }
 
 //----- (004B1447) --------------------------------------------------------
-void sub_4B1447_party_fine(int a1, int a2, int a3)
+void sub_4B1447_party_fine(int shopId, int stealingResult, int fineToAdd)
 {
   signed int v3; // esi@1
-  char v4; // sf@8
-  int v5; // eax@8
-  unsigned __int64 v6; // qax@12
   DDM_DLV_Header *v7; // eax@14
 
-  v3 = 0;
-  if ( a2 )
+  if ( stealingResult == 0 || stealingResult == 1) 
   {
-    if ( a2 == 1 )
+    if ( pParty->uFine < 4000000 )
+    {
+      if ( fineToAdd + pParty->uFine < 0 )
+        pParty->uFine = 0;
+      else if ( fineToAdd + pParty->uFine > 4000000 )
+        pParty->uFine = 4000000;
+      else 
+        pParty->uFine += fineToAdd;
+    }
+    if ( pParty->uFine )
+    {
+      for ( uint i = 1; i <= 4; ++i )
+      {
+        if ( !_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1) )
+          _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1);
+      }
+    }
+    if (stealingResult == 1)
       v3 = 2;
-    if ( a2 == 2 )
-      v3 = 2;
-    goto LABEL_13;
+    else
+      v3 = 1;
   }
   else
-    v3 = 1;
-  if ( pParty->uFine < 4000000 )
-  {
-    v4 = a3 + pParty->uFine < 0;
-    v5 = a3 + pParty->uFine;
-    pParty->uFine += a3;
-    if ( v4 )
-    {
-      v5 = 0;
-      pParty->uFine = 0;
-    }
-    if ( v5 > 4000000 )
-      pParty->uFine = 4000000;
-  }
-
-  pParty->PartyTimes._shop_ban_times[a1] = pParty->uTimePlayed + 368640;
- 
-LABEL_13:
-  pParty->InTheShopFlags[a1] = 1;
-  if ( v3 )
-  {
-    v7 = &pOutdoor->ddm;
-    if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
-      v7 = &pIndoor->dlv;
-    v7->uReputation += v3;
-    if ( v7->uReputation > 10000 )
-      v7->uReputation = 10000;
-  }
-  for ( uint i = 1; i <= 4; ++i )
-  {
-    if ( pParty->uFine )
-    {
-      if ( !_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1) )
-        _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1);
-    }
-  }
+    v3 = 2;
+  pParty->PartyTimes._shop_ban_times[shopId] = pParty->uTimePlayed + 368640;
+  pParty->InTheShopFlags[shopId] = 1;
+  v7 = &pOutdoor->ddm;
+  if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
+    v7 = &pIndoor->dlv;
+  v7->uReputation += v3;
+  if ( v7->uReputation > 10000 )
+    v7->uReputation = 10000;
 }
 
 
@@ -2139,6 +2124,8 @@
 
 
 //----- (004B3FE5) --------------------------------------------------------
+//Originally called _4B254D_SkillMasteryTeacher to have contract_approved assigned, to be able to set some button name. 
+//But it the name gets immediately overwritten
 void _4B3FE5_training_dialogue(int a4)
 {
   const char *v2; // edi@1
--- a/mm7_unsorted_subs.h	Sun Feb 23 18:44:01 2014 +0100
+++ b/mm7_unsorted_subs.h	Wed Feb 26 01:14:18 2014 +0100
@@ -219,7 +219,7 @@
 int GetSoundStrengthByDistanceFromParty(int x, int y, int z);
 void PlayLevelMusic();
 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb
-void sub_4B1447_party_fine(int a1, int a2, int a3);
+void sub_4B1447_party_fine(int shopId, int stealingResult, int fineToAdd);
 void sub_4B1523_showSpellbookInfo(int spellItemId);
 void ShowPopupShopItem();
 void RestAndHeal(__int64 uNumMinutes); // idb