diff UI/UIShops.cpp @ 1754:421c29d4ab3e

UITransition.cpp cleaning(continue)
author Ritor1
date Mon, 30 Sep 2013 17:29:27 +0600
parents 999bf8c99514
children 24e756a50073
line wrap: on
line diff
--- a/UI/UIShops.cpp	Mon Sep 30 11:41:55 2013 +0600
+++ b/UI/UIShops.cpp	Mon Sep 30 17:29:27 2013 +0600
@@ -1488,7 +1488,7 @@
   }
   if ( !HouseUI_CheckIfPlayerCanInteract() )
   {
-    pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+    pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
     return;
   }
 
@@ -1502,8 +1502,8 @@
     }
     case HOUSE_DIALOGUE_GUILD_BUY_BOOKS:
     {
-      pCursorPos = pMouse->GetCursorPos(&cursor);
-      v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF;
+      pMouse->GetCursorPos(&cursor);
+      v18 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
       if ( !v18 )
         return;
       bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
@@ -1550,7 +1550,7 @@
         return;
       }
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0);
-      pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+      pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
       break;
     }
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
@@ -1580,7 +1580,7 @@
               PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
               return;
             }
-            pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
             pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
             return;
           }
@@ -1622,7 +1622,7 @@
                 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
                 return;
               }
-              pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+              pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0);
               pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
               return;
             }
@@ -1643,7 +1643,7 @@
       if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];
       else
-        bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
+        bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];
       uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
       uNumSeconds = 0;
       a3 = 0;
@@ -1748,64 +1748,47 @@
 //----- (004B1A2D) --------------------------------------------------------
 void  ShowPopupShopItem()
 {
-  POINT *v1; // esi@5
-  unsigned int v2; // eax@5
   int v3; // ecx@5
-  POINT *v4; // esi@12
-  int v5; // eax@12
   unsigned int v6; // eax@13
   ItemGen *v7; // ecx@13
-  signed int v8; // esi@17
-  unsigned int v9; // eax@19
-  POINT v10; // [sp+8h] [bp-44h]@12
-  POINT v11; // [sp+10h] [bp-3Ch]@12
-  POINT  v12; // [sp+18h] [bp-34h]@18
-  POINT  v13; // [sp+20h] [bp-2Ch]@17
-  POINT v14; // [sp+28h] [bp-24h]@17
-  POINT  v15; // [sp+30h] [bp-1Ch]@17
-  POINT v16; // [sp+38h] [bp-14h]@5
-  POINT a2; // [sp+40h] [bp-Ch]@5
+  POINT  cursor; // [sp+30h] [bp-1Ch]@17
 
   if ( in_current_building_type <= 0 )
     return;
+  if ( dialog_menu_id < HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+    return;
   if ( in_current_building_type <= BuildingType_AlchemistShop )
   {
-    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
     {
-      if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-        return;
-      if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
-      {
-        v8 = pMouse->GetCursorPos(&v15)->x - 14;
-        v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5);
-        if ( pMouse->GetCursorPos(&v13)->x <= 13
-          || pMouse->GetCursorPos(&v12)->x >= 462
-          || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 )
-          return;
-        GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItemList[v9 - 1]);
+      pMouse->GetCursorPos(&cursor);
+      v3 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
+      if ( !v3 )
         return;
-      }
-      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
-        return;
+      v7 = &pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v3 - 1];
+      if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL)
+        v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v3 - 1];
+      GameUI_DrawItemInfo(v7);
+      return;
     }
-    v4 = pMouse->GetCursorPos(&v11);
-    v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF;
-    if ( !v5 )
+
+    if ( dialog_menu_id >= HOUSE_DIALOGUE_SHOP_SELL && dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR
+      || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
+    {
+      pMouse->GetCursorPos(&cursor);
+      v3 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5);
+      if ( cursor.x <= 13 || cursor.x >= 462
+        || !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v3) )
+        return;
+      GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v3) - 1]);
       return;
-    v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
-    v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
-    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-      v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1];
-    GameUI_DrawItemInfo(v7);
-    return;
+    }
   }
   if ( in_current_building_type <= BuildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS )
   {
-    v1 = pMouse->GetCursorPos(&a2);
-    v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
-    v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
-    v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
-    if ( v5 )
+    pMouse->GetCursorPos(&cursor);
+    v3 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF;
+    if ( v3 )
       sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C));
   }
 }