changeset 1567:9f8b3e904e14

Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
author Grumpy7
date Sun, 08 Sep 2013 05:22:33 +0200
parents 1e5086f7d401
children addae48bc203
files CastSpellInfo.cpp Items.cpp Items.h Mouse.cpp Player.cpp Player.h UI/UICharacter.cpp UI/UIGuilds.cpp UI/UIPopup.cpp UI/UIShops.cpp mm7_4.cpp mm7_6.cpp
diffstat 12 files changed, 59 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/CastSpellInfo.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -998,7 +998,7 @@
 			auto _itm = &pItemsTable->pItems[v730c->uItemID];
 			v730c->UpdateTempBonus(pParty->uTimePlayed);
 			if ( v730c->uItemID < 64 || v730c->uItemID > 65 
-				&& !v730c->Broken()
+				&& !v730c->IsBroken()
 				&& !v730c->uSpecEnchantmentType
 				&& !v730c->uEnchantmentType
 				&& ( _itm->uEquipType == 0 || _itm->uEquipType == 1 || _itm->uEquipType == 2)
@@ -1950,7 +1950,7 @@
 				v245->uSpecEnchantmentType == 0 &&
 				v245->uEnchantmentType == 0 &&
 				v245->_bonus_strength== 0 &&
-				!v245->Broken() )
+				!v245->IsBroken() )
 			{
 				if ( v245->GetValue() < 450 || 
 					(v245->GetValue() < 250 && (v731 == 3 || v731 == 4) && _v725->uEquipType >= 0 && _v725->uEquipType <= 2)
--- a/Items.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/Items.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -1459,7 +1459,7 @@
 //----- (00456499) --------------------------------------------------------
 const char *ItemGen::GetDisplayName()
 {
-  if (Identified())
+  if (IsIdentified())
     return GetIdentifiedName();
   else
     return pItemsTable->pItems[uItemID].pUnidentifiedName;
--- a/Items.h	Sun Sep 08 04:11:10 2013 +0200
+++ b/Items.h	Sun Sep 08 05:22:33 2013 +0200
@@ -167,10 +167,11 @@
  //   Reset();
  // }
 
-  inline bool Broken()        {return (uAttributes & ITEM_BROKEN) != 0;}
-  inline bool Identified()    {return (uAttributes & ITEM_IDENTIFIED) != 0;}
+  inline bool IsBroken()        {return (uAttributes & ITEM_BROKEN) != 0;}
+  inline void SetBroken()     {uAttributes |= ITEM_BROKEN;}
+  inline bool IsIdentified()    {return (uAttributes & ITEM_IDENTIFIED) != 0;}
   inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;}
-  inline bool Stolen()        {return (uAttributes & ITEM_STOLEN) != 0;}
+  inline bool IsStolen()        {return (uAttributes & ITEM_STOLEN) != 0;}
   inline void SetStolen()     {uAttributes |= ITEM_STOLEN;}
 
   bool GenerateArtifact();
--- a/Mouse.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/Mouse.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -453,9 +453,9 @@
         while ( v8 < this->field_4C );
         v6 = v15;
       }
-      if (pParty->pPickedItem.Broken())
+      if (pParty->pPickedItem.IsBroken())
         pRenderer->DrawTransparentRedShade(a2, v6, pTexture);
-      else if (!pParty->pPickedItem.Identified())
+      else if (!pParty->pPickedItem.IsIdentified())
         pRenderer->DrawTransparentGreenShade(a2, v6, pTexture);
       else
         pRenderer->DrawTextureTransparent(a2, v6, pTexture);
--- a/Player.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/Player.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -242,7 +242,7 @@
   item_value =pOwnItems[item_index].GetValue();
   v6 = p2DEvents[ _2devent_idx - 1].fPriceMultiplier;
   sell_price = GetPriceSell(item_value, v6);
-  if ( pOwnItems[item_index].Broken() )
+  if ( pOwnItems[item_index].IsBroken() )
     sell_price = 1;
   if ( sell_price < 1 )
     sell_price = 1;
@@ -1073,7 +1073,7 @@
       Error("(%u)", building_type);
     break;
   }
-  if (pItem->Stolen())
+  if (pItem->IsStolen())
     return 6;
 
   multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier;
@@ -1083,7 +1083,7 @@
       price = GetBuyingPrice(itemValue, multiplier);
     break;
     case 3:
-      if (pItem->Broken())
+      if (pItem->IsBroken())
         price = 1;
       else
         price = this->GetPriceSell(itemValue, multiplier);
@@ -1935,7 +1935,7 @@
   }
   if (( dmg_type == DMGT_PHISYCAL ) && ( pEquipment.uArmor ))
   {
-      if (!pOwnItems[pEquipment.uArmor - 1].Broken()) 
+      if (!pOwnItems[pEquipment.uArmor - 1].IsBroken()) 
       {
         armor_skill = GetEquippedItemSkillType(EQUIP_ARMOUR);
         if ( armor_skill==PLAYER_SKILL_PLATE )
@@ -2013,17 +2013,17 @@
 }
 
 //----- (0048D76C) --------------------------------------------------------
-bool Player::StealFromShop(ItemGen *a2, int a3, int reputation, int a5, int *a6)
+bool Player::StealFromShop(ItemGen *itemToSteal, int a3, int reputation, int a5, int *a6)   //check stealing in IDA pro once I get home. The whole thing looks odd, dword_4EDEB4 and dword_4EDEA0 are never filled, might be a bug, might me on purpose
 {
   unsigned __int16 v6; // cx@8
   int v7; // edi@8
   unsigned int v8; // ebx@8
-  unsigned int v9; // esi@8
+  unsigned int itemvalue; // esi@8
   int v10; // eax@8
   int v11; // edi@12
   bool result; // eax@13
 
-  if ( !a2
+  if ( !itemToSteal
     || this->pConditions[16]
     || this->pConditions[14]
     || this->pConditions[15]
@@ -2038,12 +2038,12 @@
     v6 = this->pActiveSkills[34];
     v7 = v6 & 0x3F;
     v8 = SkillToMastery(v6);
-    v9 = a2->GetValue();
-    v10 = pItemsTable->pItems[a2->uItemID].uEquipType;
-    if ( !pItemsTable->pItems[a2->uItemID].uEquipType || v10 == 1 || v10 == 2 )
-      v9 *= 3;
+    itemvalue = itemToSteal->GetValue();
+    v10 = pItemsTable->pItems[itemToSteal->uItemID].uEquipType;
+    if ( !pItemsTable->pItems[itemToSteal->uItemID].uEquipType || v10 == 1 || v10 == 2 )
+      itemvalue *= 3;
     v11 = dword_4EDEB4[rand() % 100 / 20] + v7 * dword_4EDEA0[v8];
-    *a6 = 100 * (reputation + a3) + v9 + (a5 != 0 ? 0x1F4 : 0);
+    *a6 = 100 * (reputation + a3) + itemvalue + (a5 != 0 ? 0x1F4 : 0);
     if ( rand() % 100 >= 5 )
     {
       if ( *a6 > v11 )
@@ -2230,19 +2230,19 @@
 {
   signed int max_health; // eax@3
 
-  if ( !pConditions[Condition_Eradicated] && !pConditions[Condition_Dead] )
+  if ( !IsEradicated() && !IsDead() )
   {
     max_health = GetMaxHealth();
-    if ( pConditions[Condition_Zombie] )
+    if ( IsZombie() )
       max_health /= 2;
     sHealth += amount;
     if ( sHealth > max_health )
         sHealth = max_health;
-    if ( pConditions[Condition_Unconcious] )
+    if ( IsUnconcious() )
     {
       if ( sHealth > 0 )
       {
-        pConditions[Condition_Unconcious] = 0i64;
+        SetUnconcious(false);
       }
     }
   }
@@ -2255,21 +2255,20 @@
   unsigned int armor_indx; // eax@8
   bool broke_armor;
  
-  pConditions[Condition_Sleep] = 0i64;
+  SetAsleep(false);
   recieved_dmg = CalculateIncommingDamage(dmg_type, amount);
   sHealth -= recieved_dmg;
   broke_armor = sHealth <= -10;
   if ( sHealth < 1 ) //
   {
     if ( (sHealth + uEndurance + GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) >= 1)
-      || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0i64 )
-    {
-      SetCondition(Condition_Unconcious, 0);
+      || pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 )
+    {
+      SetCondUnconsciousWithBlockCheck(false);
     }
     else
     {
-      SetCondition(Condition_Dead, 0);
-      //v6 = LODWORD(pParty->uTimePlayed); ???? if equals 0 do not broke armor?
+      SetCondDeadWithBlockCheck(false);
       if ( sHealth > 0 )
         sHealth = 0;
     }
@@ -2280,7 +2279,7 @@
       {
         if ( !pOwnItems[armor_indx-1].uAttributes & ITEM_ENCHANTED)
         {
-          pOwnItems[armor_indx-1].uAttributes|=ITEM_BROKEN;
+          pOwnItems[armor_indx-1].SetBroken();
         }
       }
     }
@@ -2387,7 +2386,7 @@
       v13 = this->pInventoryItemList;
       do
       {
-        if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->Broken())
+        if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->IsBroken())
           v46[v4++] = v12;
         ++v12;
         ++v13;
@@ -4390,7 +4389,7 @@
 
       for (int j = 0; j < 16; ++j) 
       {
-        if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken()))
+        if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].IsBroken()))
         {
           int curr_item = pOwnItems[pEquipment.pIndices[j] - 1].uItemID;
           PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType;
@@ -8988,3 +8987,8 @@
 {
   SetCondition(Condition_Dead, blockable);
 }
+
+void Player::SetCondUnconsciousWithBlockCheck( int blockable )
+{
+  SetCondition(Condition_Dead, blockable);
+}
\ No newline at end of file
--- a/Player.h	Sun Sep 08 04:11:10 2013 +0200
+++ b/Player.h	Sun Sep 08 05:22:33 2013 +0200
@@ -617,6 +617,7 @@
   void SetCondWeakWithBlockCheck (int blockable);
   void SetCondInsaneWithBlockCheck (int blockable);
   void SetCondDeadWithBlockCheck (int blockable);
+  void SetCondUnconsciousWithBlockCheck( int blockable );
 
   inline bool IsRaceHuman() {return GetRace() == CHARACTER_RACE_HUMAN;}
   inline bool IsRaceDwarf() {return GetRace() == CHARACTER_RACE_DWARF;}
--- a/UI/UICharacter.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/UI/UICharacter.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -1593,9 +1593,9 @@
     }
     else
     {
-      if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].Identified() || pCurrentScreen != SCREEN_HOUSE)
+      if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsIdentified() || pCurrentScreen != SCREEN_HOUSE)
       {
-        if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].Broken())
+        if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].IsBroken())
           pRenderer->DrawTransparentRedShade(uCellX, uCellY, pTexture);
         else
           pRenderer->DrawTextureTransparent(uCellX, uCellY, pTexture);
@@ -1634,9 +1634,9 @@
   }
   else
   {
-    if (item->Broken())
+    if (item->IsBroken())
       pRenderer->DrawTransparentRedShade(x, y, item_texture);
-    else if (!item->Identified())
+    else if (!item->IsIdentified())
       pRenderer->DrawTransparentGreenShade(x, y, item_texture);
     else
       pRenderer->DrawTextureTransparent(x, y, item_texture);
--- a/UI/UIGuilds.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/UI/UIGuilds.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -329,7 +329,7 @@
     ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i];
     item_spellbook->Reset();
     pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum;
-    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
+    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].IsIdentified();
     ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE);
   }
   return;
--- a/UI/UIPopup.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/UI/UIPopup.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -282,14 +282,14 @@
     if ( uActiveCharacter )
         {
         //try to identify
-        if (!inspect_item->Identified())
+        if (!inspect_item->IsIdentified())
             {
 
             v11 = inspect_item;
             if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 )
                 inspect_item->SetIdentified();
             v83 = SPEECH_9;
-            if ( !inspect_item->Identified() )
+            if ( !inspect_item->IsIdentified() )
                 {
                 ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);//"Identify Failed"
                 }
@@ -306,12 +306,12 @@
                 }
             }
         inspect_item->UpdateTempBonus(pParty->uTimePlayed);
-        if (inspect_item->Broken())
+        if (inspect_item->IsBroken())
             {
             if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 )
                 inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1;
             v83 = SPEECH_11;
-            if ( !inspect_item->Broken() )
+            if ( !inspect_item->IsBroken() )
                 v83 = SPEECH_10;
             else
                 ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);//"Repair Failed"
@@ -325,7 +325,7 @@
     //v13 = _this->uAttributes;
     //v14 = _this->Identified();
     //a2.y = inspect_item->Identified();
-    if (inspect_item->Broken())
+    if (inspect_item->IsBroken())
         {
         wHintWindow.DrawMessageBox(0);
         //v15 = &;
@@ -337,7 +337,7 @@
         wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
         wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
         pRenderer->DrawTransparentRedShade(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73);
-        if ( inspect_item->Identified())
+        if ( inspect_item->IsIdentified())
             v16 = inspect_item->GetIdentifiedName();
         else
             v16 = item_desc->pUnidentifiedName;
@@ -354,7 +354,7 @@
             }
         return;
         }
-    if (!inspect_item->Identified())
+    if (!inspect_item->IsIdentified())
         {
         wHintWindow.DrawMessageBox(0);
         pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12,  wHintWindow.uFrameY + 12,
--- a/UI/UIShops.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/UI/UIShops.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -286,7 +286,7 @@
         || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) )
         return;
       v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      if (!v4->Identified())
+      if (!v4->IsIdentified())
       {
         v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4);
         v7 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
@@ -918,7 +918,7 @@
             if ( v2 )
             {
               v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1];
-              if (v3->Identified())
+              if (v3->IsIdentified())
                 v5 = "%24";
               else
               {
@@ -1407,7 +1407,7 @@
          || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) )
         return;
       v37 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      if (!v37->Identified())
+      if (!v37->IsIdentified())
       {
         v42 = pPlayer->SelectPhrasesTransaction(v37, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4);
         v38 = (char *)pMerchantsIdentifyPhrases[v42];
--- a/mm7_4.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/mm7_4.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -2055,7 +2055,7 @@
             if ( a5 == 3 )
             {
               v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier);
-              if (a3->Broken())
+              if (a3->IsBroken())
                 v29 = 1;
               sprintfex(a1, "%lu", v29);
               strcat(pTmpBuf2.data(), a1);
@@ -2072,7 +2072,7 @@
                 if ( a5 == 6 )
                 {
                   v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier) / 2;
-                  if (a3->Broken())
+                  if (a3->IsBroken())
                     v29 = 1;
                   if (!v29)
                     v29 = 1;
@@ -3658,7 +3658,7 @@
   bool test;
 
   if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771)
-    && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->Stolen())
+    && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->IsStolen())
     return 0;
   switch( p2DEvents[_2da_idx - 1].uType )
   {
--- a/mm7_6.cpp	Sun Sep 08 04:11:10 2013 +0200
+++ b/mm7_6.cpp	Sun Sep 08 05:22:33 2013 +0200
@@ -1118,7 +1118,7 @@
 
     //v31 = player->pEquipment.uBow;
   int bow_idx = player->pEquipment.uBow;
-  if (bow_idx && player->pInventoryItemList[bow_idx - 1].Broken())
+  if (bow_idx && player->pInventoryItemList[bow_idx - 1].IsBroken())
     bow_idx = 0;
 
     //v32 = 0;
@@ -1132,7 +1132,7 @@
   {
     auto item = &player->pInventoryItemList[main_hand_idx - 1];
       //v5 = (char *)v1 + 36 * v4;
-    if (!item->Broken())
+    if (!item->IsBroken())
     {
 		//v28b = &v1->pInventoryItems[v4].uItemID;
         //v6 = v1->pInventoryItems[v4].uItemID;//*((int *)v5 + 124);