diff 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
line wrap: on
line diff
--- a/Player.cpp	Sat Sep 07 21:17:47 2013 +0200
+++ b/Player.cpp	Sat Sep 07 23:06:13 2013 +0200
@@ -1095,7 +1095,7 @@
       price = this->GetPriceRepair(itemValue, multiplier);
       break;
     default:
-      Assert("(%u)", ShopMenuType);
+      Error("(%u)", ShopMenuType);
     break;
   }
   if ( merchantLevel )
@@ -1349,93 +1349,57 @@
 }
 
 //----- (0048C6F6) --------------------------------------------------------
-bool Party::AddItem(ItemGen *pItem)
+bool Party::AddItemToParty(ItemGen *pItem)
 {
   unsigned int v2; // eax@1
-  unsigned int v3; // ecx@4
-  signed int v4; // edx@4
   char *v5; // eax@8
-  //unsigned int v6; // eax@10
   Texture *v7; // ebx@10
   signed int v8; // esi@10
   Player *v9; // edi@11
   int v10; // eax@11
-  bool result; // eax@15
-  std::string v12; // [sp-18h] [bp-40h]@9
-
-
-  int v15[4] = {0, 1, 2, 3}; // [sp+Ch] [bp-1Ch]@3
-  //int v16; // [sp+10h] [bp-18h]@3
-  //int v17; // [sp+14h] [bp-14h]@3
-  //int v18; // [sp+18h] [bp-10h]@3
-  Player *v19; // [sp+1Ch] [bp-Ch]@9
-  Party *v20; // [sp+20h] [bp-8h]@1
   int v21; // [sp+24h] [bp-4h]@10
 
-  auto thos = this;
-
-  v20 = thos;
   v2 = pItem->uItemID;
   if ( !pItemsTable->pItems[v2].uItemID_Rep_St )
     pItem->SetIdentified();
-  ///v15 = 0;
-  //v16 = 1;
-  //v18 = 3;
-  //v17 = 2;
-  if ( uActiveCharacter )
-  {
-    v3 = uActiveCharacter - 1;
-    v4 = 0;
-    do
-    {
-      v15[v4++] = v3++;
-      if ( (signed int)v3 >= 4 )
-        v3 = 0;
-    }
-    while ( v4 < 4 );
-  }
+
   v5 = pItemsTable->pItems[v2].pIconName;
   if ( v5 )
   {
     v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE);
     v21 = areWeLoadingTexture;
     v8 = 0;
-    while ( 1 )
-    {
-      v9 = &v20->pPlayers[v15[v8]];
-      v19 = &v20->pPlayers[v15[v8]];
-      v10 = v19->AddItem(-1, pItem->uItemID);
+    int startId = uActiveCharacter >= 0 ? uActiveCharacter - 1 : 0;
+    for (int i = 0; i < 4; i++)
+    {
+      v9 = &pPlayers[(startId + i) % 4];  //start with current active player, then cycle right if item won't fit
+      v10 = v9->AddItem(-1, pItem->uItemID);
       if ( v10 )
-        break;
-      ++v8;
-      if ( v8 >= 4 )
       {
+        memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
+        pItem->Reset();
+        pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
+        v9->PlaySound(SPEECH_60, 0);
         if ( !v21 )
         {
           v7->Release();
           pIcons_LOD->SyncLoadedFilesCount();
         }
-        goto LABEL_15;
+        return true;
       }
     }
-    memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u);
-    pItem->Reset();
-    pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0);
-    v19->PlaySound(SPEECH_60, 0);
     if ( !v21 )
     {
       v7->Release();
       pIcons_LOD->SyncLoadedFilesCount();
     }
-    result = 1;
+    return false;
   }
   else
   {
     MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0);
-LABEL_15:
-    result = 0;
-  }
-  return result;
+    return false;
+  }
 }
 // 506128: using guessed type int areWeLoadingTexture;
 
@@ -1573,31 +1537,26 @@
 //----- (0048CCF5) --------------------------------------------------------
 int Player::GetActualAttack(int a2)
 {
-  Player *v2; // esi@1
   int v3; // eax@1
   int v4; // edi@1
   int v5; // ebx@1
   int v6; // ebp@1
 
-  v2 = this;
   v3 = GetActualAccuracy();
   v4 = GetParameterBonus(v3);
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_ATTACK);
   v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ATTACK, a2);
-  return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + v2->_some_attack_bonus;
+  return v4 + v5 + v6 + GetMagicalBonus(CHARACTER_ATTRIBUTE_ATTACK) + this->_some_attack_bonus;
 }
 
 //----- (0048CD45) --------------------------------------------------------
 int Player::GetMeleeDamageMinimal()
 {
-  Player *v1; // edi@1
   int v2; // eax@1
   int v3; // esi@1
   int v4; // esi@1
   int v5; // esi@1
-  int v6; // esi@1
   signed int result; // eax@1
-
  
   v2 = GetActualMight();
   v3 = GetParameterBonus(v2);
@@ -1612,7 +1571,6 @@
 //----- (0048CD90) --------------------------------------------------------
 int Player::GetMeleeDamageMaximal()
 {
-  Player *v1; // edi@1
   int v2; // eax@1
   int v3; // esi@1
   int v4; // esi@1
@@ -1620,12 +1578,11 @@
   int v6; // esi@1
   signed int result; // eax@1
 
-  v1 = this;
   v2 = GetActualMight();
   v3 = GetParameterBonus(v2);
   v4 = GetItemsBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_MAX, 0) + v3;
   v5 = GetSkillBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v4;
-  v6 = v1->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
+  v6 = this->_melee_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS) + v5;
   result = 1;
   if ( v6 >= 1 )
     result = v6;
@@ -1731,7 +1688,6 @@
 //----- (0048D0B9) --------------------------------------------------------
 int Player::GetRangedAttack()
 {
-  Player *v1; // esi@1
   int v2; // eax@1
   int v3; // edi@3
   int v4; // eax@4
@@ -1739,7 +1695,6 @@
   int v6; // edi@4
   int v7; // edi@4
 
-  v1 = this;
   v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1];
   if ( v2 < ITEM_BLASTER || v2 > ITEM_LASER_RIFLE )
   {
@@ -1747,7 +1702,7 @@
     v5 = GetParameterBonus(v4);
     v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK, 0) + v5;
     v7 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v6;
-    v3 = v1->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
+    v3 = this->_ranged_atk_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_ATTACK) + v7;
   }
   else
   {
@@ -1759,17 +1714,14 @@
 //----- (0048D124) --------------------------------------------------------
 int Player::GetRangedDamageMin()
 {
-  Player *v1; // esi@1
   int v2; // edi@1
   int v3; // edi@1
   int v4; // edi@1
-  unsigned __int16 v5; // ax@1
   int result; // eax@6
 
-  v1 = this;
   v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0);
   v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
-  v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
+  v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
   if ( v4 >= 1 )
     result = v4;
   else
@@ -1780,17 +1732,14 @@
 //----- (0048D191) --------------------------------------------------------
 int Player::GetRangedDamageMax()
 {
-  Player *v1; // esi@1
   int v2; // edi@1
   int v3; // edi@1
   int v4; // edi@1
-  unsigned __int16 v5; // ax@1
   int result; // eax@6
 
-  v1 = this;
   v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0);
   v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2;
-  v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
+  v4 = this->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3;
   if ( v4 >= 1 )
     result = v4;
   else
@@ -1801,11 +1750,8 @@
 //----- (0048D1FE) --------------------------------------------------------
 int Player::CalculateRangedDamageTo( int a2 )
 {
-  bool result; // eax@1
   ItemGen *v4; // ebx@2
   unsigned int v5; // edi@2
-  int v7; // edx@4
-  char v8; // zf@4
   int v9; // esi@5
   int v10; // ebx@6
   signed int v15; // [sp+8h] [bp-Ch]@2
@@ -6863,7 +6809,7 @@
         this->sResMagicBonus = (unsigned __int8)var_value;
         break;
       default:
-          Assert("Unexpected var_type: %u", var_type);
+          Error("Unexpected var_type: %u", var_type);
           return;
         break;
     }