comparison Player.cpp @ 973:ec7568e13b24

Minor code cleaning.
author Nomad
date Wed, 08 May 2013 21:37:12 +0200
parents c0d0656aa662
children a6ef7125f6e4
comparison
equal deleted inserted replaced
972:c8a0f6d89c70 973:ec7568e13b24
1358 } 1358 }
1359 1359
1360 //----- (00492528) -------------------------------------------------------- 1360 //----- (00492528) --------------------------------------------------------
1361 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) 1361 bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID)
1362 { 1362 {
1363 unsigned int v3; // eax@1 1363 //unsigned int v3; // eax@1
1364 Texture *v4; // esi@1 1364 Texture *v4; // esi@1
1365 unsigned int v5; // ebx@1 1365 unsigned int v5; // ebx@1
1366 signed int v6; // edi@5 1366 signed int v6; // edi@5
1367 int *v7; // ecx@6 1367 int *v7; // ecx@6
1368 signed int v8; // edx@7 1368 signed int v8; // edx@7
1369 int *v9; // eax@8 1369 int *v9; // eax@8
1370 Player *v11; // [sp+Ch] [bp-4h]@1 1370 //Player *v11; // [sp+Ch] [bp-4h]@1
1371 unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1 1371 unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1
1372 1372
1373 v11 = this; 1373 v4 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1374 v3 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1374 v5 = GetSizeInInventorySlots(v4->uTextureWidth);
1375 v4 = (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0);
1376 v5 = GetSizeInInventorySlots(v3 != -1 ? pIcons_LOD->pTextures[v3].uTextureWidth : 24);
1377 uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight); 1375 uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight);
1378 if ( !areWeLoadingTexture ) 1376 if ( !areWeLoadingTexture )
1379 { 1377 {
1380 v4->Release(); 1378 v4->Release();
1381 pIcons_LOD->_40F9C5(); 1379 pIcons_LOD->_40F9C5();
1383 if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 ) 1381 if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 )
1384 { 1382 {
1385 v6 = 0; 1383 v6 = 0;
1386 if ( (signed int)uItemIDa <= 0 ) 1384 if ( (signed int)uItemIDa <= 0 )
1387 return 1; 1385 return 1;
1388 v7 = &v11->pInventoryIndices[uSlot]; 1386 v7 = &pInventoryIndices[uSlot];
1389 while ( 1 ) 1387 while ( 1 )
1390 { 1388 {
1391 v8 = 0; 1389 v8 = 0;
1392 if ( (signed int)v5 > 0 ) 1390 if ( (signed int)v5 > 0 )
1393 break; 1391 break;
1433 { 1431 {
1434 signed int v3; // edx@1 1432 signed int v3; // edx@1
1435 ItemGen *v4; // eax@1 1433 ItemGen *v4; // eax@1
1436 int result; // eax@8 1434 int result; // eax@8
1437 unsigned int v6; // ebx@10 1435 unsigned int v6; // ebx@10
1438 unsigned int v7; // eax@10 1436 //unsigned int v7; // eax@10
1439 Texture *v8; // esi@10 1437 Texture *v8; // esi@10
1440 void *v9; // esi@13 1438 void *v9; // esi@13
1441 unsigned int v10; // [sp+0h] [bp-Ch]@10 1439 unsigned int v10; // [sp+0h] [bp-Ch]@10
1442 Player *v11; // [sp+4h] [bp-8h]@1 1440 Player *v11; // [sp+4h] [bp-8h]@1
1443 signed int v12; // [sp+8h] [bp-4h]@4 1441 signed int v12; // [sp+8h] [bp-4h]@4
1465 result = 0; 1463 result = 0;
1466 } 1464 }
1467 else 1465 else
1468 { 1466 {
1469 v6 = uItemID; 1467 v6 = uItemID;
1470 v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1468 v8 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1471 v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); 1469 v10 = GetSizeInInventorySlots(v8->uTextureWidth);
1472 v10 = GetSizeInInventorySlots(v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
1473 uItemIDa = GetSizeInInventorySlots(v8->uTextureHeight); 1470 uItemIDa = GetSizeInInventorySlots(v8->uTextureHeight);
1474 if ( !areWeLoadingTexture ) 1471 if ( !areWeLoadingTexture )
1475 { 1472 {
1476 v8->Release(); 1473 v8->Release();
1477 pIcons_LOD->_40F9C5(); 1474 pIcons_LOD->_40F9C5();
1520 signed int v2; // eax@1 1517 signed int v2; // eax@1
1521 ItemGen *v3; // edx@1 1518 ItemGen *v3; // edx@1
1522 int v4; // edi@6 1519 int v4; // edi@6
1523 char *v5; // eax@6 1520 char *v5; // eax@6
1524 char *v6; // esi@6 1521 char *v6; // esi@6
1522
1523 __debugbreak(); // sub is definetly broken
1525 1524
1526 v2 = 0; 1525 v2 = 0;
1527 v3 = this->pInventoryItems; 1526 v3 = this->pInventoryItems;
1528 while ( v3->uItemID ) 1527 while ( v3->uItemID )
1529 { 1528 {
1645 int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src) 1644 int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src)
1646 { 1645 {
1647 signed int v3; // ebx@1 1646 signed int v3; // ebx@1
1648 ItemGen *v4; // eax@1 1647 ItemGen *v4; // eax@1
1649 int result; // eax@6 1648 int result; // eax@6
1650 unsigned int v6; // eax@7 1649 //unsigned int v6; // eax@7
1651 Texture *v7; // esi@7 1650 Texture *v7; // esi@7
1652 unsigned int v8; // edx@9 1651 unsigned int v8; // edx@9
1653 void *v9; // esi@10 1652 void *v9; // esi@10
1654 unsigned int v10; // [sp+4h] [bp-Ch]@7 1653 unsigned int v10; // [sp+4h] [bp-Ch]@7
1655 unsigned int v11; // [sp+8h] [bp-8h]@7 1654 unsigned int v11; // [sp+8h] [bp-8h]@7
1673 { 1672 {
1674 result = 0; 1673 result = 0;
1675 } 1674 }
1676 else 1675 else
1677 { 1676 {
1678 v6 = pIcons_LOD->LoadTexture( 1677 v7 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1679 pItemsTable->pItems[Src->uItemID].pIconName, 1678 v10 = GetSizeInInventorySlots(v7->uTextureWidth);
1680 TEXTURE_16BIT_PALETTE);
1681 v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
1682 v10 = GetSizeInInventorySlots(v6 != -1 ? pIcons_LOD->pTextures[v6].uTextureWidth : 24);
1683 v11 = GetSizeInInventorySlots(v7->uTextureHeight); 1679 v11 = GetSizeInInventorySlots(v7->uTextureHeight);
1684 if ( !areWeLoadingTexture ) 1680 if ( !areWeLoadingTexture )
1685 { 1681 {
1686 v7->Release(); 1682 v7->Release();
1687 pIcons_LOD->_40F9C5(); 1683 pIcons_LOD->_40F9C5();
1709 // 506128: using guessed type int areWeLoadingTexture; 1705 // 506128: using guessed type int areWeLoadingTexture;
1710 1706
1711 //----- (0049298B) -------------------------------------------------------- 1707 //----- (0049298B) --------------------------------------------------------
1712 bool Player::_49298B(ItemGen *a2, int a3, int a4) 1708 bool Player::_49298B(ItemGen *a2, int a3, int a4)
1713 { 1709 {
1714 Player *v4; // ebx@1 1710 //Player *v4; // ebx@1
1715 unsigned int v5; // eax@1 1711 //unsigned int v5; // eax@1
1716 Texture *v6; // esi@1 1712 Texture *v6; // esi@1
1717 void *v7; // esi@4 1713 void *v7; // esi@4
1718 unsigned int v9; // [sp+Ch] [bp-4h]@1 1714 unsigned int v9; // [sp+Ch] [bp-4h]@1
1719 unsigned int a2a; // [sp+18h] [bp+8h]@1 1715 unsigned int a2a; // [sp+18h] [bp+8h]@1
1720 1716
1721 v4 = this; 1717 v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[a2->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
1722 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2->uItemID].pIconName, TEXTURE_16BIT_PALETTE); 1718 v9 = GetSizeInInventorySlots(v6->uTextureWidth);
1723 v6 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
1724 v9 = GetSizeInInventorySlots(v5 != -1 ? pIcons_LOD->pTextures[v5].uTextureWidth : 24);
1725 a2a = GetSizeInInventorySlots(v6->uTextureHeight); 1719 a2a = GetSizeInInventorySlots(v6->uTextureHeight);
1726 if ( !areWeLoadingTexture ) 1720 if ( !areWeLoadingTexture )
1727 { 1721 {
1728 v6->Release(); 1722 v6->Release();
1729 pIcons_LOD->_40F9C5(); 1723 pIcons_LOD->_40F9C5();
1730 } 1724 }
1731 if ( (signed int)a2a > 0 ) 1725 if ( (signed int)a2a > 0 )
1732 { 1726 {
1733 v7 = &v4->pInventoryIndices[a4]; 1727 v7 = &pInventoryIndices[a4];
1734 do 1728 do
1735 { 1729 {
1736 if ( (signed int)v9 > 0 ) 1730 if ( (signed int)v9 > 0 )
1737 memset32(v7, -1 - a4, v9); 1731 memset32(v7, -1 - a4, v9);
1738 v7 = (char *)v7 + 56; 1732 v7 = (char *)v7 + 56;
1739 --a2a; 1733 --a2a;
1740 } 1734 }
1741 while ( a2a ); 1735 while ( a2a );
1742 } 1736 }
1743 v4->pInventoryIndices[a4] = a3 + 1; 1737 pInventoryIndices[a4] = a3 + 1;
1744 return 1; 1738 return 1;
1745 } 1739 }
1746 1740
1747 // 506128: using guessed type int areWeLoadingTexture; 1741 // 506128: using guessed type int areWeLoadingTexture;
1748 1742
1750 unsigned int Player::RemoveItemAtInventoryIndex(unsigned int uSlot) 1744 unsigned int Player::RemoveItemAtInventoryIndex(unsigned int uSlot)
1751 { 1745 {
1752 int *pIndices; // edi@1 1746 int *pIndices; // edi@1
1753 ItemGen *v3; // ecx@1 1747 ItemGen *v3; // ecx@1
1754 unsigned int v4; // esi@1 1748 unsigned int v4; // esi@1
1755 unsigned int v5; // eax@1 1749 //unsigned int v5; // eax@1
1756 Texture *v6; // esi@1 1750 Texture *v6; // esi@1
1757 unsigned int result; // eax@1 1751 unsigned int result; // eax@1
1758 unsigned int v8; // ebp@1 1752 unsigned int v8; // ebp@1
1759 void *v9; // edx@4 1753 void *v9; // edx@4
1760 unsigned int uSlota; // [sp+14h] [bp+4h]@1 1754 unsigned int uSlota; // [sp+14h] [bp+4h]@1
1761 1755
1762 pIndices = &this->pInventoryIndices[uSlot]; 1756 pIndices = &this->pInventoryIndices[uSlot];
1763 v3 = &this->pInventoryItems[*pIndices-1]; 1757 v3 = &this->pInventoryItems[*pIndices-1];
1764 v4 = v3->uItemID; 1758 v4 = v3->uItemID;
1765 v3->Reset(); 1759 v3->Reset();
1766 v5 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE); 1760 v6 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[v4].pIconName, TEXTURE_16BIT_PALETTE);
1767 v6 = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0); 1761 uSlota = GetSizeInInventorySlots(v6->uTextureWidth);
1768 uSlota = GetSizeInInventorySlots(v5 != -1 ? pIcons_LOD->pTextures[v5].uTextureWidth : 24);
1769 result = GetSizeInInventorySlots(v6->uTextureHeight); 1762 result = GetSizeInInventorySlots(v6->uTextureHeight);
1770 v8 = result; 1763 v8 = result;
1771 if ( !areWeLoadingTexture ) 1764 if ( !areWeLoadingTexture )
1772 { 1765 {
1773 v6->Release(); 1766 v6->Release();
2378 { 2371 {
2379 unsigned int v2; // eax@1 2372 unsigned int v2; // eax@1
2380 unsigned int v3; // ecx@4 2373 unsigned int v3; // ecx@4
2381 signed int v4; // edx@4 2374 signed int v4; // edx@4
2382 char *v5; // eax@8 2375 char *v5; // eax@8
2383 unsigned int v6; // eax@10 2376 //unsigned int v6; // eax@10
2384 Texture *v7; // ebx@10 2377 Texture *v7; // ebx@10
2385 signed int v8; // esi@10 2378 signed int v8; // esi@10
2386 Player *v9; // edi@11 2379 Player *v9; // edi@11
2387 int v10; // eax@11 2380 int v10; // eax@11
2388 bool result; // eax@15 2381 bool result; // eax@15
2420 while ( v4 < 4 ); 2413 while ( v4 < 4 );
2421 } 2414 }
2422 v5 = pItemsTable->pItems[v2].pIconName; 2415 v5 = pItemsTable->pItems[v2].pIconName;
2423 if ( v5 ) 2416 if ( v5 )
2424 { 2417 {
2425 v6 = pIcons_LOD->LoadTexture(v5, TEXTURE_16BIT_PALETTE); 2418 v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
2426 v7 = (Texture *)(v6 != -1 ? &pIcons_LOD->pTextures[v6] : 0);
2427 v21 = areWeLoadingTexture; 2419 v21 = areWeLoadingTexture;
2428 v8 = 0; 2420 v8 = 0;
2429 while ( 1 ) 2421 while ( 1 )
2430 { 2422 {
2431 v9 = &v20->pPlayers[v15[v8]]; 2423 v9 = &v20->pPlayers[v15[v8]];