comparison Player.cpp @ 1363:fd661c9e7f97

Player::CanFitItem refactored
author Grumpy7
date Mon, 15 Jul 2013 00:57:06 +0200
parents d6cf8ead9242
children b691c96d8e06
comparison
equal deleted inserted replaced
1362:d6cf8ead9242 1363:fd661c9e7f97
801 } 801 }
802 802
803 //----- (00492528) -------------------------------------------------------- 803 //----- (00492528) --------------------------------------------------------
804 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) 804 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
805 { 805 {
806 //unsigned int v3; // eax@1 806 Texture *texture; // esi@1
807 Texture *v4; // esi@1 807 unsigned int slotWidth; // ebx@1
808 unsigned int v5; // ebx@1 808 unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1
809 signed int v6; // edi@5 809
810 int *v7; // ecx@6 810 texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
811 signed int v8; // edx@7 811 slotWidth = GetSizeInInventorySlots(texture->uTextureWidth);
812 int *v9; // eax@8 812 slotHeight = GetSizeInInventorySlots(texture->uTextureHeight);
813 //Player *v11; // [sp+Ch] [bp-4h]@1
814 unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1
815
816 v4 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
817 v5 = GetSizeInInventorySlots(v4->uTextureWidth);
818 uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight);
819 if ( !areWeLoadingTexture ) 813 if ( !areWeLoadingTexture )
820 { 814 {
821 v4->Release(); 815 texture->Release();
822 pIcons_LOD->SyncLoadedFilesCount(); 816 pIcons_LOD->SyncLoadedFilesCount();
823 } 817 }
824 if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 ) 818 if ( slotHeight == 0 || slotWidth == 0)
825 { 819 {
826 v6 = 0; 820 assert("Items should have nonzero dimensions");
827 if ( (signed int)uItemIDa <= 0 ) 821 return 1;
828 return 1; 822 }
829 v7 = &pInventoryIndices[uSlot]; 823 if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT )
830 while ( 1 ) 824 {
831 { 825 int startOfInnerLoop = uSlot;
832 v8 = 0; 826 for (int y = 0; y < slotHeight; y++)
833 if ( (signed int)v5 > 0 ) 827 {
834 break; 828 int innerLoopPos = startOfInnerLoop;
835 LABEL_11: 829 for (int x = 0; x < slotWidth; x++)
836 ++v6; 830 {
837 v7 += 14; 831 if (pInventoryIndices[innerLoopPos] != 0)
838 if ( v6 >= (signed int)uItemIDa ) 832 {
839 return 1; 833 return false;
840 } 834 }
841 v9 = v7; 835 innerLoopPos++;
842 while ( !*v9 ) 836 }
843 { 837 startOfInnerLoop += INVETORYSLOTSWIDTH;
844 ++v8; 838 }
845 ++v9; 839 return true;
846 if ( v8 >= (signed int)v5 ) 840 }
847 goto LABEL_11; 841 return false;
848 }
849 }
850 return 0;
851 } 842 }
852 // 506128: using guessed type int areWeLoadingTexture; 843 // 506128: using guessed type int areWeLoadingTexture;
853 844
854 //----- (004925E6) -------------------------------------------------------- 845 //----- (004925E6) --------------------------------------------------------
855 unsigned int Player::FindFreeInventorySlot() 846 unsigned int Player::FindFreeInventorySlot()