Mercurial > mm7
diff Player.cpp @ 1363:fd661c9e7f97
Player::CanFitItem refactored
author | Grumpy7 |
---|---|
date | Mon, 15 Jul 2013 00:57:06 +0200 |
parents | d6cf8ead9242 |
children | b691c96d8e06 |
line wrap: on
line diff
--- a/Player.cpp Mon Jul 15 00:42:50 2013 +0200 +++ b/Player.cpp Mon Jul 15 00:57:06 2013 +0200 @@ -803,51 +803,42 @@ //----- (00492528) -------------------------------------------------------- bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) { - //unsigned int v3; // eax@1 - Texture *v4; // esi@1 - unsigned int v5; // ebx@1 - signed int v6; // edi@5 - int *v7; // ecx@6 - signed int v8; // edx@7 - int *v9; // eax@8 - //Player *v11; // [sp+Ch] [bp-4h]@1 - unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1 - - v4 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v5 = GetSizeInInventorySlots(v4->uTextureWidth); - uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight); + Texture *texture; // esi@1 + unsigned int slotWidth; // ebx@1 + unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1 + + texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + slotWidth = GetSizeInInventorySlots(texture->uTextureWidth); + slotHeight = GetSizeInInventorySlots(texture->uTextureHeight); if ( !areWeLoadingTexture ) { - v4->Release(); + texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 ) - { - v6 = 0; - if ( (signed int)uItemIDa <= 0 ) - return 1; - v7 = &pInventoryIndices[uSlot]; - while ( 1 ) - { - v8 = 0; - if ( (signed int)v5 > 0 ) - break; -LABEL_11: - ++v6; - v7 += 14; - if ( v6 >= (signed int)uItemIDa ) - return 1; - } - v9 = v7; - while ( !*v9 ) - { - ++v8; - ++v9; - if ( v8 >= (signed int)v5 ) - goto LABEL_11; - } - } - return 0; + if ( slotHeight == 0 || slotWidth == 0) + { + assert("Items should have nonzero dimensions"); + return 1; + } + if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT ) + { + int startOfInnerLoop = uSlot; + for (int y = 0; y < slotHeight; y++) + { + int innerLoopPos = startOfInnerLoop; + for (int x = 0; x < slotWidth; x++) + { + if (pInventoryIndices[innerLoopPos] != 0) + { + return false; + } + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; + } + return true; + } + return false; } // 506128: using guessed type int areWeLoadingTexture;