diff Items.cpp @ 377:243418228760

GetIdentifiedName
author Gloval
date Fri, 22 Feb 2013 22:27:45 +0400
parents c606cabd7cbf
children b509ef97807a
line wrap: on
line diff
--- a/Items.cpp	Fri Feb 22 20:03:15 2013 +0400
+++ b/Items.cpp	Fri Feb 22 22:27:45 2013 +0400
@@ -77,7 +77,7 @@
     *v3 = v5;
     return v5;
   }
-  v8 = v4->uAdditionalValue;
+  v8 = v4->uSpecEnchantmentType;
   if ( v8 > 46 )
   {
     v5 = 0;
@@ -184,12 +184,12 @@
 //----- (00402F07) --------------------------------------------------------
 void ItemGen::Reset()
 {
-  this->field_1A = 0;
+  this->uHolderPlayer = 0;
   this->uAttributes = 0;
   this->uNumCharges = 0;
-  this->uAdditionalValue = 0;
+  this->uSpecEnchantmentType = 0;
   this->_bonus_strength = 0;
-  this->_bonus_type = 0;
+  this->uEncantmentType = 0;
   this->uItemID = 0;
   this->uBodyAnchor = 0;
   this->uExpireTime = 0i64;
@@ -205,9 +205,9 @@
   {
     if ( uTimePlayed > (signed __int64)this->uExpireTime )
     {
-      this->_bonus_type = 0;
+      this->uEncantmentType = 0;
       LOBYTE(v2) = v2 & 0xF7;
-      this->uAdditionalValue = 0;
+      this->uSpecEnchantmentType = 0;
       this->uAttributes = v2;
     }
   }
@@ -698,20 +698,20 @@
 					{
 					if ( !_strcmpi(test_string, "artifact") )
 						{
-						pItems[item_counter].uMaterial = 1;
+						pItems[item_counter].uMaterial = MATERIAL_ARTEFACT;
 						break;
 						}
 					if ( !_strcmpi(test_string, "relic") )
 						{
-						pItems[item_counter].uMaterial = 2;
+						pItems[item_counter].uMaterial = MATERIAL_RELIC;
 						break;
 						}
 					if ( !_strcmpi(test_string, "special") )
 						{
-						pItems[item_counter].uMaterial = 3;
+						pItems[item_counter].uMaterial = MATERIAL_SPECIAL;
 						break;
 						}
-					pItems[item_counter].uMaterial = 0;
+					pItems[item_counter].uMaterial = MATERIAL_COMMON;
 					break;}
 				case 9:  //ID/Rep/St
 					pItems[item_counter].uItemID_Rep_St=atoi(test_string);
@@ -726,7 +726,7 @@
 					{
 					pItems[item_counter]._additional_value=0;
 					pItems[item_counter]._bonus_type=0;
-					if (pItems[item_counter].uMaterial==3)
+					if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL)
 						{
 						for(int ii=0; ii<24; ++ii)
 							{
@@ -751,7 +751,7 @@
 					break;
 					}
 				case 13: //VarB
-					if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type))
+					if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type))
 						{
 						char b_s=atoi(test_string);
 						if (b_s)
@@ -1192,25 +1192,25 @@
   v2 = &this->pItems[pItem->uItemID];
   if ( v2->uMaterial == 3 )
   {
-    pItem->_bonus_type = v2->_bonus_type;
-    pItem->uAdditionalValue = v2->_additional_value;
+    pItem->uEncantmentType = v2->_bonus_type;
+    pItem->uSpecEnchantmentType = v2->_additional_value;
     pItem->_bonus_strength = v2->_bonus_strength;
   }
 }
 
 //----- (00456D43) --------------------------------------------------------
-bool ItemsTable::_456D43_is_material_equals_3(ItemGen *pItem)
+bool ItemsTable::IsMaterialSpecial(ItemGen *pItem)
 {
-  return this->pItems[pItem->uItemID].uMaterial == 3;
+  return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL;
 }
 
 //----- (00456D5E) --------------------------------------------------------
-bool ItemsTable::_456D5E_is_some_material(ItemGen *pItem)
+bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem)
 {
   unsigned __int8 v2; // al@1
 
   v2 = this->pItems[pItem->uItemID].uMaterial;
-  return v2 == 3 || v2 == 1 || v2 == 2;
+  return v2 == MATERIAL_SPECIAL || v2 == MATERIAL_RELIC || v2 == MATERIAL_ARTEFACT;
 }
 
 
@@ -1385,14 +1385,14 @@
 
   v1 = this;
   uBaseValue = pItemsTable->pItems[this->uItemID].uValue;
-  if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->_456D5E_is_some_material(this) )
+  if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) )
     return uBaseValue;
-  if ( v1->_bonus_type )
+  if ( v1->uEncantmentType )
   {
     v3 = 100 * v1->_bonus_strength;
     return uBaseValue + v3;
   }
-  v4 = v1->uAdditionalValue;
+  v4 = v1->uSpecEnchantmentType;
   if ( !v4 )
   {
     result = uBaseValue;
@@ -1419,89 +1419,69 @@
 //----- (004564B3) --------------------------------------------------------
 const char *ItemGen::GetIdentifiedName()
 {
-  ItemGen *v1; // esi@1
-  unsigned int v2; // eax@1
-  unsigned __int8 v3; // cl@1
-  char *v4; // edi@4
-  char v5; // al@6
-  const char *v6; // esi@8
-  int v7; // eax@15
-  const char *v9; // [sp-Ch] [bp-14h]@14
-  const char *v10; // [sp-8h] [bp-10h]@4
-  char *v11; // [sp-4h] [bp-Ch]@4
+  unsigned __int8 equip_type; 
+  const char *player_name; 
+  const char *nameModificator; 
+  const char *format_str; 
 
-  v1 = this;
-  v2 = this->uItemID;
-  v3 = pItemsTable->pItems[v2].uEquipType;
-  if ( v3 >= EQUIP_REAGENT && (v3 <= EQUIP_POTION || v3 == EQUIP_GOLD) )
+  equip_type = pItemsTable->pItems[uItemID].uEquipType;
+  if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) )
   {
-    v11 = pItemsTable->pItems[v2].pName;
-    v4 = item__getname_buffer;
-    v10 = "%s";
-    sprintf(v4, v10, v11);
-    return v4;
+    sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName);
+    return item__getname_buffer;
   }
-  v4 = item__getname_buffer;
-  sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName);
-  if ( v1->uItemID == 601 )
+  sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName);
+  if ( uItemID == ITEM_LICH_JAR )  //Lich Jar
   {
-    v5 = v1->field_1A;
-    if ( (unsigned __int8)v5 >= 1u )
-    {
-      if ( (unsigned __int8)v5 <= 4u )
+    if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) )
       {
-        v6 = pPlayers[(unsigned __int8)v5]->pName;
-        strlen(pPlayers[(unsigned __int8)v5]->pName);
-        v11 = (char *)v6;
-        if ( v6[strlen(v6) - 1] == 115 )
-          v10 = pGlobalTXT_LocalizationStrings[655];
+        player_name = pPlayers[uHolderPlayer]->pName;
+        strlen(player_name);
+        if ( player_name[strlen(player_name) - 1] == 's' )
+          format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar"
         else
-          v10 = pGlobalTXT_LocalizationStrings[654];
-		sprintf(v4, v10, v11);
-		return v4;
+          format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar"
+		sprintf(item__getname_buffer, format_str, pPlayers[uHolderPlayer]->pName);
+		return item__getname_buffer;
       }
-    }
   }
-  if ( !pItemsTable->_456D5E_is_some_material(v1) )
+  if ( !pItemsTable->IsMaterialNonCommon(this) )
   {
-    if ( v1->_bonus_type )
+    if ( uEncantmentType )
     {
       strcat(item__getname_buffer, " ");
-      v9 = (const char *)*((unsigned int *)&pItemsTable->pItems[799].uEquipType + 5 * v1->_bonus_type);
+      nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName;
     }
     else
     {
-      v7 = v1->uAdditionalValue;
-      if ( !v7 )
-        return v4;
-      if ( v7 == 16
-        || v7 == 39
-        || v7 == 40
-        || v7 == 45
-        || v7 == 56
-        || v7 == 57
-        || v7 == 58
-        || v7 == 60
-        || v7 == 61
-        || v7 == 59
-        || v7 == 63
-        || v7 == 64
-        || v7 == 67
-        || v7 == 68 )
-      {
-        sprintf(
-          item__getname_buffer,
-          "%s %s",
-		  pItemsTable->pSpecialEnchantments[v7].pBonusStatement,
-          pItemsTable->pItems[v1->uItemID].pName);
-        return v4;
+      if ( !uSpecEnchantmentType )
+        return item__getname_buffer;
+      if ( uSpecEnchantmentType == 16 //Drain Hit Points from target.
+        || uSpecEnchantmentType == 39 //Double damage vs Demons.
+        || uSpecEnchantmentType == 40 //Double damage vs Dragons
+        || uSpecEnchantmentType == 45 //+5 Speed and Accuracy
+        || uSpecEnchantmentType == 56 //+5 Might and Endurance.
+        || uSpecEnchantmentType == 57 //+5 Intellect and Personality.
+        || uSpecEnchantmentType == 58 //Increased Value.
+        || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills
+        || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills.
+        || uSpecEnchantmentType == 59  //Increased Weapon speed.
+        || uSpecEnchantmentType == 63 //Double Damage vs. Elves.
+        || uSpecEnchantmentType == 64 //Double Damage vs. Undead.
+        || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill.
+        || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class.
+      {  //enchantment and name positions inverted!
+        sprintf( item__getname_buffer, "%s %s",
+				  pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd,
+				  pItemsTable->pItems[uItemID].pName);
+        return item__getname_buffer;
       }
       strcat(item__getname_buffer, " ");
-	  v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement;
+	  nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd;
     }
-    strcat(item__getname_buffer, v9);
+    strcat(item__getname_buffer, nameModificator);
   }
-  return v4;
+  return item__getname_buffer;
 }
 
 
@@ -1666,16 +1646,16 @@
     }
     if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE )
     {
-      v4->_bonus_type = 0;
+      v4->uEncantmentType = 0;
       v14 = 2;
       do
       {
-        v4->_bonus_type += rand() % 4 + 1;
-        v15 = v4->_bonus_type;
+        v4->uEncantmentType += rand() % 4 + 1;
+        v15 = v4->uEncantmentType;
         --v14;
       }
       while ( v14 );
-      v4->_bonus_type = v15 * treasure_level;
+      v4->uEncantmentType = v15 * treasure_level;
     }
   }
   else
@@ -1709,16 +1689,16 @@
       v4->uItemID = 1;
     if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE)
     {
-      v4->_bonus_type = 0;
+      v4->uEncantmentType = 0;
       v19 = 2;
       do
       {
-        v4->_bonus_type += rand() % 4 + 1;
-        v15 = v4->_bonus_type;
+        v4->uEncantmentType += rand() % 4 + 1;
+        v15 = v4->uEncantmentType;
         --v19;
       }
       while ( v19 );
-      v4->_bonus_type = v15 * treasure_level;
+      v4->uEncantmentType = v15 * treasure_level;
     }
   }
   if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION
@@ -1730,8 +1710,8 @@
     v4->uAttributes = 1;
   if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION )
   {
-    v4->uAdditionalValue = 0;
-    v4->_bonus_type = 0;
+    v4->uSpecEnchantmentType = 0;
+    v4->uEncantmentType = 0;
   }
   v20 = pItems[v4->uItemID].uEquipType;
   if ( v20 <= EQUIP_BOW )
@@ -1767,18 +1747,18 @@
     {
       v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType];
       v27 = v4->uItemID;
-      v4->_bonus_type = 0;
+      v4->uEncantmentType = 0;
       for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1];
             i < v26;
-            i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] )
+            i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] )
       {
         v29 = v4->uItemID;
-        ++v4->_bonus_type;
+        ++v4->uEncantmentType;
       }
-      ++v4->_bonus_type;
+      ++v4->uEncantmentType;
       v30 = 10;// v5->field_116D8[2 * v54 + 12];
       v31 = rand();
-      v32 = v4->_bonus_type - 1;
+      v32 = v4->uEncantmentType - 1;
       v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30;
       v4->_bonus_strength = v33;
       if ( v32 == 21 || v32 == 22 || v32 == 23 )
@@ -1882,7 +1862,7 @@
     while ( a2b < pSpecialEnchantments_count );
   }
   v45 = rand();
-  v4->uAdditionalValue = *(uint *)Dst;
+  v4->uSpecEnchantmentType = *(uint *)Dst;
   v46 = v45 % v39 + 1;
   a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType);
   if ( a2c < v46 )
@@ -1893,13 +1873,13 @@
       v49 = (int)(j + 1);
       v59 = v49;
       v50 = *(unsigned int *)v49;
-      v4->uAdditionalValue = v50;
+      v4->uSpecEnchantmentType = v50;
       a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType);
       if ( a2c >= v46 )
         break;
     }
   }
-  ++v4->uAdditionalValue;
+  ++v4->uSpecEnchantmentType;
 }
 
 //----- (004505CC) --------------------------------------------------------