# HG changeset patch # User Ritor1 # Date 1362304678 -21600 # Node ID ec3546510fa104a94f4f2b05ddb371ee43701c03 # Parent 9d3d8091251b750d7f38badb5f3b9c1dd139c189# Parent 6e4619fb5808956e828ad1ad873f8ae9352b8ac6 Слияние diff -r 9d3d8091251b -r ec3546510fa1 Chest.cpp --- a/Chest.cpp Sun Mar 03 15:57:44 2013 +0600 +++ b/Chest.cpp Sun Mar 03 15:57:58 2013 +0600 @@ -29,9 +29,9 @@ Chest pChests[20]; -const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42}; -const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34}; -const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; +const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42}; +const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34}; +const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; @@ -271,7 +271,7 @@ signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1 int chest_offs_x; // [sp+1Ch] [bp-18h]@1 signed int chestWidthCells; // [sp+20h] [bp-14h]@1 - signed int cells_counter; // [sp+30h] [bp-4h]@1 + signed int item_counter; // [sp+30h] [bp-4h]@1 v16 = pRenderer->pActiveZBuffer; pRenderer->ClearZBuffer(0, 479); @@ -284,9 +284,9 @@ v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); - for (cells_counter = 0; cells_counter< chestWidthCells * chestHeghtCells; ++cells_counter) + for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter) { - chest_item_index = pChests[uChestID].pInventoryIndices[cells_counter]; + chest_item_index = pChests[uChestID].pInventoryIndices[item_counter]; if ( chest_item_index > 0 ) { item_texture_id = pIcons_LOD->LoadTexture( @@ -302,11 +302,11 @@ v13 = v12 + 32; if ( itemPixelHeght < 14 ) itemPixelHeght = 14; - itemPixelPosX = chest_offs_x + (32 * cells_counter) % chestWidthCells + ((v13 - itemPixelWidth) >> 1); - itemPixelPosY = chest_offs_y + (32 * cells_counter) / chestHeghtCells + + itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((v13 - itemPixelWidth) >> 1); + itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) + ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1); pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture); - sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, cells_counter + 1); + sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1); } } pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, @@ -333,8 +333,6 @@ signed int v17; // [sp+10h] [bp-8h]@1 signed int chest_cell_width; // [sp+14h] [bp-4h]@1 - v17 = test_cell_position; - 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); @@ -364,12 +362,14 @@ _column = 0; if ( texture_cell_width > 0 ) { - while ( !pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]) + while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0) { ++_column; if ( _column >= texture_cell_width ) break; } + if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0) + return false; } _cell_rows += chest_cell_width; ++_row; @@ -516,83 +516,55 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (0042013E) -------------------------------------------------------- -void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int uItemIdx, unsigned int uChestID ) +void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, unsigned int uChestID ) { - int v3; // esi@1 - unsigned int v4; // ebx@1 - int uItemID; // edi@1 - int v6; // edx@4 - unsigned int v7; // eax@5 - Texture *v8; // ecx@5 - signed int v9; // eax@5 - signed int v10; // edi@7 - unsigned int v11; // ebx@7 - int v12; // edi@9 - int v13; // edx@12 - void *v14; // edi@14 - int v15; // edi@14 - int i; // ecx@14 - unsigned int result; // eax@18 - __int16 v18; // [sp+Ch] [bp-10h]@1 - int v19; // [sp+10h] [bp-Ch]@11 - int v20; // [sp+14h] [bp-8h]@12 - unsigned int v21; // [sp+18h] [bp-4h]@1 + + int uItemID; // edi@1 + int v6; // edx@4 + unsigned int v7; // eax@5 + Texture *v8; // ecx@5 + signed int v9; // eax@5 + signed int v10; // edi@7 + unsigned int texture_cell_width; // ebx@7 + int textute_cell_height; // edi@9 + int chest_cell_row_pos; // edx@12 + int chest_cell_width; // [sp+10h] [bp-Ch]@11 - v3 = 5324 * uChestID; - v21 = put_cell_pos; - v4 = 5324 * uChestID + 36 * uItemIdx; - v18 = uItemIdx; - uItemID = pChests[ uChestID].igChestItems[uItemIdx].uItemID; - pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[uItemIdx]); - if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[uItemIdx].uNumCharges) - { - v6 = rand() % 21 + 10; - pChests[ uChestID].igChestItems[uItemIdx].uNumCharges = v6; - pChests[ uChestID].igChestItems[uItemIdx].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); - if ( v9 < 14 ) - v9 = 14; - v10 = v8->uTextureHeight; - v11 = ((v9 - 14) >> 5) + 1; - if ( v10 < 14 ) - v10 = 14; - v12 = ((v10 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v8->Release(); - pIcons_LOD->_40F9C5(); - } - v19 = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; - if ( v12 > 0 ) - { - v13 = 0; - v20 = v12; - do - { - if ( (signed int)v11 > 0 ) - { - v14 = &pChests[uChestID].pInventoryIndices[v21 + v13]; - LOWORD(v3) = -1 - v21; - v3 <<= 16; - LOWORD(v3) = -1 - v21; - memset32(v14, v3, v11 >> 1); - v15 = (int)((char *)v14 + 4 * (v11 >> 1)); - for ( i = v11 & 1; i; --i ) + uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID; + pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]); + if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges) { - *(short *)v15 = v3; - v15 += 2; + v6 = rand() % 21 + 10; + pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6; + pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6; } - } - v13 += v19; - --v20; + 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); + if ( v9 < 14 ) + v9 = 14; + v10 = v8->uTextureHeight; + texture_cell_width = ((v9 - 14) >> 5) + 1; + if ( v10 < 14 ) + v10 = 14; + textute_cell_height = ((v10 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + v8->Release(); + pIcons_LOD->_40F9C5(); + } + chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; + chest_cell_row_pos = 0; + for(int i=0; iClearZBuffer(0, 479); uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; memset(chest_cells_map, 0, 144); //fill cell map at random positions - for (cell_counter = 0; cell_counter