changeset 945:0d96349d8c87

Restoring inlined methods
author Nomad
date Wed, 01 May 2013 14:09:49 +0200
parents 4dd4184d4248
children eb3bb0f2e1b9
files Chest.cpp GUIWindow.cpp Indoor.cpp LOD.h mm7_1.cpp mm7_2.cpp mm7_3.cpp
diffstat 7 files changed, 30 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/Chest.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/Chest.cpp	Wed May 01 14:09:49 2013 +0200
@@ -242,7 +242,7 @@
   pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0);
   pChestWindow = pGUIWindow_CurrentMenu;
   pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1,  0,  UIMSG_Escape,  0, 0,  pGlobalTXT_LocalizationStrings[79],// Exit
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
+                 pIcons_LOD->GetTexture(uExitCancelTextureId),   0);
   pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, UIMSG_C, 0, 0, "", 0);
   pCurrentScreen = SCREEN_CHEST;
   pEventTimer->Pause();
@@ -282,7 +282,7 @@
     chestHeghtCells = pChestHeightsByType[chestBitmapId];
     sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
     v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
+    pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5));
 
     for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter)
         {
@@ -292,9 +292,9 @@
             item_texture_id = pIcons_LOD->LoadTexture(
                 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
                 pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-            item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0);
-            itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
-            itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26);
+            item_texture = pIcons_LOD->GetTexture(item_texture_id);
+            itemPixelWidth = item_texture->uTextureWidth;
+            itemPixelHeght = item_texture->uTextureHeight;
             if ( itemPixelWidth < 14 )
                 itemPixelWidth = 14;
             v12 = itemPixelWidth - 14;
@@ -309,8 +309,7 @@
             sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
             }
         }
-    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-        (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
+    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
     }
 
 
@@ -336,8 +335,8 @@
     chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
     chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
     item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
-    item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0);
-    v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
+    item_texture = pIcons_LOD->GetTexture(item_texture_id);
+    v6 = item_texture->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     texture_cell_width = (v6 - 14 >> 5) + 1;
@@ -417,7 +416,7 @@
   int result; // eax@11
   unsigned int v7; // eax@12
   int v8; // edx@12
-  int v9; // ecx@12
+  Texture *v9; // ecx@12
   signed int v10; // eax@12
   signed int v11; // edi@14
   unsigned int v12; // esi@14
@@ -464,11 +463,11 @@
     }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
     HIWORD(v8) = 0;
-    v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
-    v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v9 = pIcons_LOD->GetTexture(v7);
+    v10 = v9->uTextureWidth;
     if ( v10 < 14 )
       v10 = 14;
-    v11 = *(short *)(v9 + 26);
+    v11 = v9->uTextureHeight;
     v12 = ((v10 - 14) >> 5) + 1;
     if ( v11 < 14 )
       v11 = 14;
@@ -539,8 +538,8 @@
         pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
         }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
-    v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v8 = pIcons_LOD->GetTexture(v7);
+    v9 = v8->uTextureWidth;
     if ( v9 < 14 )
         v9 = 14;
     v10 = v8->uTextureHeight;
@@ -773,8 +772,8 @@
     //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
 	v17 = pChestWidthsByType[pChests[v20].uChestBitmapID];
     v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
-    v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
+    v5 = pIcons_LOD->GetTexture(v4);
+    v6 = v5->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     v7 = v6 - 14;
--- a/GUIWindow.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/GUIWindow.cpp	Wed May 01 14:09:49 2013 +0200
@@ -1999,7 +1999,7 @@
     {
       pMouse->SetCursorBitmap("MICON2");
       pBtn_ExitCancel = pWindow->CreateButton(0x188u, 0x13Eu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],//Отмена
-                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+                     pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);//Выбрать цель
       ++pIcons_LOD->uTexturePacksCount;
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
--- a/Indoor.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/Indoor.cpp	Wed May 01 14:09:49 2013 +0200
@@ -1206,7 +1206,7 @@
 
   v1 = &pIndoor->pFaces[uFaceID];
   v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID];
-  v3 = (Texture *)(v1->uBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[v1->uBitmapID] : 0);
+  v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID);
   stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU;
   stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV;
   v4 = GetTickCount();
@@ -1619,7 +1619,7 @@
     v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_);
   else
     v1 = uBitmapID;
-  return (Texture *)(v1 != -1 ? (int)&pBitmaps_LOD->pTextures[v1] : 0);
+  return pBitmaps_LOD->GetTexture(v1);
 }
 
 
@@ -3705,7 +3705,7 @@
             {
               v52 = v15->uBitmapID;
               if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82 + (v52 != -1 ? pBitmaps_LOD->pTextures[v52].uTextureHeight : 26);
+                v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight;
             }
           }
           if ( BYTE2(v15->uAttributes) & 4 )
--- a/LOD.h	Wed May 01 13:54:46 2013 +0200
+++ b/LOD.h	Wed May 01 14:09:49 2013 +0200
@@ -162,8 +162,7 @@
   inline Texture *GetTexture(int idx)
   {
     assert(idx < 1000);
-    if (idx == -1)
-      return nullptr;
+    if (idx == -1) return nullptr; // we need to return dummy texture here
     return pTextures + idx;
   }
 
--- a/mm7_1.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/mm7_1.cpp	Wed May 01 14:09:49 2013 +0200
@@ -694,9 +694,8 @@
   v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, v1, 0);
   pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_A8, 0, 0,
                  pGlobalTXT_LocalizationStrings[79], // Close
-                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
-                 0);
+                 pIcons_LOD->GetTexture(papredoll_dbrds[2]),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
   pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
   v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
@@ -727,7 +726,7 @@
   v0 = pIcons_LOD->LoadTexture(
          pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
          TEXTURE_16BIT_PALETTE);
-  v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0);
+  v1 = pIcons_LOD->GetTexture(v0);
   v11 = areWeLoadingTexture;
   if ( uActiveCharacter
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
--- a/mm7_2.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/mm7_2.cpp	Wed May 01 14:09:49 2013 +0200
@@ -290,7 +290,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -433,7 +433,7 @@
     pDialogueWindow->pControlsTail = 0;
     pDialogueWindow->uNumControls = 0;
     pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79],
-                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                   pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x55u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x57u, 0, "", 0);
@@ -578,12 +578,8 @@
       pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
       pRenderer->uTargetGMask | pRenderer->uTargetBMask);
 
-  auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-  pRenderer->_4A6A68(
-    8u,
-    352 - v0,
-    pTex,
-    (pTex ? pTex->uTextureHeight : 26) - v0);
+  auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+  pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0);
 
   pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428);
   v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);
--- a/mm7_3.cpp	Wed May 01 13:54:46 2013 +0200
+++ b/mm7_3.cpp	Wed May 01 14:09:49 2013 +0200
@@ -4548,9 +4548,9 @@
         v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
         v9 = v48;
       }
-      pFaceTexture = (Texture *)(v9 != -1 ? (int)&pBitmaps_LOD->pTextures[v9] : 0);
+      pFaceTexture = pBitmaps_LOD->GetTexture(v9);
       v7->pTexture = pFaceTexture;
-      v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
+      v12 = pFaceTexture->uTextureWidth;
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
       v10 = (pFace->uAttributes & 0x10) == 0;