comparison Player.cpp @ 1558:30db6d265ceb

Changed the new Assert macro definition slightly, Party::AddItem (for some reason in players.cpp) renamed to Party::AddItemToParty, cleaned up; some unused variables in previous functions removed
author Grumpy7
date Sat, 07 Sep 2013 23:06:13 +0200
parents 9c4cf5b07e98
children 1f3f01d39300
comparison
equal deleted inserted replaced
1555:9c4cf5b07e98 1558:30db6d265ceb
1093 break; 1093 break;
1094 case 5: 1094 case 5:
1095 price = this->GetPriceRepair(itemValue, multiplier); 1095 price = this->GetPriceRepair(itemValue, multiplier);
1096 break; 1096 break;
1097 default: 1097 default:
1098 Assert("(%u)", ShopMenuType); 1098 Error("(%u)", ShopMenuType);
1099 break; 1099 break;
1100 } 1100 }
1101 if ( merchantLevel ) 1101 if ( merchantLevel )
1102 { 1102 {
1103 if (price == itemValue) 1103 if (price == itemValue)
1347 1347
1348 lastOpenedSpellbookPage = 0; 1348 lastOpenedSpellbookPage = 0;
1349 } 1349 }
1350 1350
1351 //----- (0048C6F6) -------------------------------------------------------- 1351 //----- (0048C6F6) --------------------------------------------------------
1352 bool Party::AddItem(ItemGen *pItem) 1352 bool Party::AddItemToParty(ItemGen *pItem)
1353 { 1353 {
1354 unsigned int v2; // eax@1 1354 unsigned int v2; // eax@1
1355 unsigned int v3; // ecx@4
1356 signed int v4; // edx@4
1357 char *v5; // eax@8 1355 char *v5; // eax@8
1358 //unsigned int v6; // eax@10
1359 Texture *v7; // ebx@10 1356 Texture *v7; // ebx@10
1360 signed int v8; // esi@10 1357 signed int v8; // esi@10
1361 Player *v9; // edi@11 1358 Player *v9; // edi@11
1362 int v10; // eax@11 1359 int v10; // eax@11
1363 bool result; // eax@15
1364 std::string v12; // [sp-18h] [bp-40h]@9
1365
1366
1367 int v15[4] = {0, 1, 2, 3}; // [sp+Ch] [bp-1Ch]@3
1368 //int v16; // [sp+10h] [bp-18h]@3
1369 //int v17; // [sp+14h] [bp-14h]@3
1370 //int v18; // [sp+18h] [bp-10h]@3
1371 Player *v19; // [sp+1Ch] [bp-Ch]@9
1372 Party *v20; // [sp+20h] [bp-8h]@1
1373 int v21; // [sp+24h] [bp-4h]@10 1360 int v21; // [sp+24h] [bp-4h]@10
1374 1361
1375 auto thos = this;
1376
1377 v20 = thos;
1378 v2 = pItem->uItemID; 1362 v2 = pItem->uItemID;
1379 if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) 1363 if ( !pItemsTable->pItems[v2].uItemID_Rep_St )
1380 pItem->SetIdentified(); 1364 pItem->SetIdentified();
1381 ///v15 = 0; 1365
1382 //v16 = 1;
1383 //v18 = 3;
1384 //v17 = 2;
1385 if ( uActiveCharacter )
1386 {
1387 v3 = uActiveCharacter - 1;
1388 v4 = 0;
1389 do
1390 {
1391 v15[v4++] = v3++;
1392 if ( (signed int)v3 >= 4 )
1393 v3 = 0;
1394 }
1395 while ( v4 < 4 );
1396 }
1397 v5 = pItemsTable->pItems[v2].pIconName; 1366 v5 = pItemsTable->pItems[v2].pIconName;
1398 if ( v5 ) 1367 if ( v5 )
1399 { 1368 {
1400 v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); 1369 v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
1401 v21 = areWeLoadingTexture; 1370 v21 = areWeLoadingTexture;
1402 v8 = 0; 1371 v8 = 0;
1403 while ( 1 ) 1372 int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0;
1404 { 1373 for (int i = 0; i < 4; i++)
1405 v9 = &v20->pPlayers[v15[v8]]; 1374 {
1406 v19 = &v20->pPlayers[v15[v8]]; 1375 v9 = &pPlayers[(startId + i) % 4]; //start with current active player, then cycle right if item won't fit
1407 v10 = v19->AddItem(-1, pItem->uItemID); 1376 v10 = v9->AddItem(-1, pItem->uItemID);
1408 if ( v10 ) 1377 if ( v10 )
1409 break; 1378 {
1410 ++v8; 1379 memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
1411 if ( v8 >= 4 ) 1380 pItem->Reset();
1412 { 1381 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
1382 v9->PlaySound(SPEECH_60, 0);
1413 if ( !v21 ) 1383 if ( !v21 )
1414 { 1384 {
1415 v7->Release(); 1385 v7->Release();
1416 pIcons_LOD->SyncLoadedFilesCount(); 1386 pIcons_LOD->SyncLoadedFilesCount();
1417 } 1387 }
1418 goto LABEL_15; 1388 return true;
1419 } 1389 }
1420 } 1390 }
1421 memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
1422 pItem->Reset();
1423 pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
1424 v19->PlaySound(SPEECH_60, 0);
1425 if ( !v21 ) 1391 if ( !v21 )
1426 { 1392 {
1427 v7->Release(); 1393 v7->Release();
1428 pIcons_LOD->SyncLoadedFilesCount(); 1394 pIcons_LOD->SyncLoadedFilesCount();
1429 } 1395 }
1430 result = 1; 1396 return false;
1431 } 1397 }
1432 else 1398 else
1433 { 1399 {
1434 MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); 1400 MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0);
1435 LABEL_15: 1401 return false;
1436 result = 0; 1402 }
1437 }
1438 return result;
1439 } 1403 }
1440 // 506128: using guessed type int areWeLoadingTexture; 1404 // 506128: using guessed type int areWeLoadingTexture;
1441 1405
1442 //----- (0048C855) -------------------------------------------------------- 1406 //----- (0048C855) --------------------------------------------------------
1443 int Player::GetBaseStrength() 1407 int Player::GetBaseStrength()
1571 } 1535 }
1572 1536
1573 //----- (0048CCF5) -------------------------------------------------------- 1537 //----- (0048CCF5) --------------------------------------------------------
1574 int Player::GetActualAttack(int a2) 1538 int Player::GetActualAttack(int a2)
1575 { 1539 {
1576 Player *v2; // esi@1
1577 int v3; // eax@1 1540 int v3; // eax@1
1578 int v4; // edi@1 1541 int v4; // edi@1
1579 int v5; // ebx@1 1542 int v5; // ebx@1
1580 int v6; // ebp@1 1543 int v6; // ebp@1
1581 1544
1582 v2 = this;
1583 v3 = GetActualAccuracy(); 1545 v3 = GetActualAccuracy();
1584 v4 = GetParameterBonus(v3); 1546 v4 = GetParameterBonus(v3);
1585 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK); 1547 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK);
1586 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2); 1548 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2);
1587 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus; 1549 return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus;
1588 } 1550 }
1589 1551
1590 //----- (0048CD45) -------------------------------------------------------- 1552 //----- (0048CD45) --------------------------------------------------------
1591 int Player::GetMeleeDamageMinimal() 1553 int Player::GetMeleeDamageMinimal()
1592 { 1554 {
1593 Player *v1; // edi@1
1594 int v2; // eax@1 1555 int v2; // eax@1
1595 int v3; // esi@1 1556 int v3; // esi@1
1596 int v4; // esi@1 1557 int v4; // esi@1
1597 int v5; // esi@1 1558 int v5; // esi@1
1598 int v6; // esi@1
1599 signed int result; // eax@1 1559 signed int result; // eax@1
1600
1601 1560
1602 v2 = GetActualMight(); 1561 v2 = GetActualMight();
1603 v3 = GetParameterBonus(v2); 1562 v3 = GetParameterBonus(v2);
1604 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3; 1563 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MIN, 0) + v3;
1605 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; 1564 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
1610 } 1569 }
1611 1570
1612 //----- (0048CD90) -------------------------------------------------------- 1571 //----- (0048CD90) --------------------------------------------------------
1613 int Player::GetMeleeDamageMaximal() 1572 int Player::GetMeleeDamageMaximal()
1614 { 1573 {
1615 Player *v1; // edi@1
1616 int v2; // eax@1 1574 int v2; // eax@1
1617 int v3; // esi@1 1575 int v3; // esi@1
1618 int v4; // esi@1 1576 int v4; // esi@1
1619 int v5; // esi@1 1577 int v5; // esi@1
1620 int v6; // esi@1 1578 int v6; // esi@1
1621 signed int result; // eax@1 1579 signed int result; // eax@1
1622 1580
1623 v1 = this;
1624 v2 = GetActualMight(); 1581 v2 = GetActualMight();
1625 v3 = GetParameterBonus(v2); 1582 v3 = GetParameterBonus(v2);
1626 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3; 1583 v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3;
1627 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4; 1584 v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
1628 v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5; 1585 v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
1629 result = 1; 1586 result = 1;
1630 if ( v6 >= 1 ) 1587 if ( v6 >= 1 )
1631 result = v6; 1588 result = v6;
1632 return result; 1589 return result;
1633 } 1590 }
1729 1686
1730 1687
1731 //----- (0048D0B9) -------------------------------------------------------- 1688 //----- (0048D0B9) --------------------------------------------------------
1732 int Player::GetRangedAttack() 1689 int Player::GetRangedAttack()
1733 { 1690 {
1734 Player *v1; // esi@1
1735 int v2; // eax@1 1691 int v2; // eax@1
1736 int v3; // edi@3 1692 int v3; // edi@3
1737 int v4; // eax@4 1693 int v4; // eax@4
1738 int v5; // edi@4 1694 int v5; // edi@4
1739 int v6; // edi@4 1695 int v6; // edi@4
1740 int v7; // edi@4 1696 int v7; // edi@4
1741 1697
1742 v1 = this;
1743 v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1]; 1698 v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1];
1744 if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE ) 1699 if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE )
1745 { 1700 {
1746 v4 = GetActualAccuracy(); 1701 v4 = GetActualAccuracy();
1747 v5 = GetParameterBonus(v4); 1702 v5 = GetParameterBonus(v4);
1748 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5; 1703 v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5;
1749 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6; 1704 v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6;
1750 v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7; 1705 v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
1751 } 1706 }
1752 else 1707 else
1753 { 1708 {
1754 v3 = GetActualAttack(1); 1709 v3 = GetActualAttack(1);
1755 } 1710 }
1757 } 1712 }
1758 1713
1759 //----- (0048D124) -------------------------------------------------------- 1714 //----- (0048D124) --------------------------------------------------------
1760 int Player::GetRangedDamageMin() 1715 int Player::GetRangedDamageMin()
1761 { 1716 {
1762 Player *v1; // esi@1
1763 int v2; // edi@1 1717 int v2; // edi@1
1764 int v3; // edi@1 1718 int v3; // edi@1
1765 int v4; // edi@1 1719 int v4; // edi@1
1766 unsigned __int16 v5; // ax@1
1767 int result; // eax@6 1720 int result; // eax@6
1768 1721
1769 v1 = this;
1770 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0); 1722 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0);
1771 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; 1723 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
1772 v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; 1724 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
1773 if ( v4 >= 1 ) 1725 if ( v4 >= 1 )
1774 result = v4; 1726 result = v4;
1775 else 1727 else
1776 result = 0; 1728 result = 0;
1777 return result; 1729 return result;
1778 } 1730 }
1779 1731
1780 //----- (0048D191) -------------------------------------------------------- 1732 //----- (0048D191) --------------------------------------------------------
1781 int Player::GetRangedDamageMax() 1733 int Player::GetRangedDamageMax()
1782 { 1734 {
1783 Player *v1; // esi@1
1784 int v2; // edi@1 1735 int v2; // edi@1
1785 int v3; // edi@1 1736 int v3; // edi@1
1786 int v4; // edi@1 1737 int v4; // edi@1
1787 unsigned __int16 v5; // ax@1
1788 int result; // eax@6 1738 int result; // eax@6
1789 1739
1790 v1 = this;
1791 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0); 1740 v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0);
1792 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; 1741 v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
1793 v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; 1742 v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
1794 if ( v4 >= 1 ) 1743 if ( v4 >= 1 )
1795 result = v4; 1744 result = v4;
1796 else 1745 else
1797 result = 0; 1746 result = 0;
1798 return result; 1747 return result;
1799 } 1748 }
1800 1749
1801 //----- (0048D1FE) -------------------------------------------------------- 1750 //----- (0048D1FE) --------------------------------------------------------
1802 int Player::CalculateRangedDamageTo( int a2 ) 1751 int Player::CalculateRangedDamageTo( int a2 )
1803 { 1752 {
1804 bool result; // eax@1
1805 ItemGen *v4; // ebx@2 1753 ItemGen *v4; // ebx@2
1806 unsigned int v5; // edi@2 1754 unsigned int v5; // edi@2
1807 int v7; // edx@4
1808 char v8; // zf@4
1809 int v9; // esi@5 1755 int v9; // esi@5
1810 int v10; // ebx@6 1756 int v10; // ebx@6
1811 signed int v15; // [sp+8h] [bp-Ch]@2 1757 signed int v15; // [sp+8h] [bp-Ch]@2
1812 int v17; // [sp+10h] [bp-4h]@1 1758 int v17; // [sp+10h] [bp-4h]@1
1813 1759
6861 break; 6807 break;
6862 case VAR_MagicResistanceBonus: 6808 case VAR_MagicResistanceBonus:
6863 this->sResMagicBonus = (unsigned __int8)var_value; 6809 this->sResMagicBonus = (unsigned __int8)var_value;
6864 break; 6810 break;
6865 default: 6811 default:
6866 Assert("Unexpected var_type: %u", var_type); 6812 Error("Unexpected var_type: %u", var_type);
6867 return; 6813 return;
6868 break; 6814 break;
6869 } 6815 }
6870 goto LABEL_111; 6816 goto LABEL_111;
6871 } 6817 }