aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDDuarte <dnpd.dd@gmail.com>2016-04-16 20:57:50 +0100
committerDDuarte <dnpd.dd@gmail.com>2016-04-16 20:57:50 +0100
commit0257aa05280651b48e07e89950ad6ad5becfe9d2 (patch)
treeb846b1852d4f424a016987c16b25c465022cca7c
parentacdfc36a4e93dc422d5bb9015d5b2b673fbdb242 (diff)
Core/Items: Move Item::GetSkill to ItemPrototype::GetSkill
Also moved some methods of ItemPrototype to .cpp Thanks to Yehonal for the original patch Closes #16884
-rw-r--r--src/server/game/Entities/Item/Item.cpp34
-rw-r--r--src/server/game/Entities/Item/ItemPrototype.cpp121
-rw-r--r--src/server/game/Entities/Item/ItemPrototype.h68
3 files changed, 129 insertions, 94 deletions
diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp
index 773d5a05772..a8dad0b2fbc 100644
--- a/src/server/game/Entities/Item/Item.cpp
+++ b/src/server/game/Entities/Item/Item.cpp
@@ -519,41 +519,11 @@ Player* Item::GetOwner()const
return ObjectAccessor::FindPlayer(GetOwnerGUID());
}
+// Just a "legacy shortcut" for proto->GetSkill()
uint32 Item::GetSkill()
{
- const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] =
- {
- SKILL_AXES, SKILL_2H_AXES, SKILL_BOWS, SKILL_GUNS, SKILL_MACES,
- SKILL_2H_MACES, SKILL_POLEARMS, SKILL_SWORDS, SKILL_2H_SWORDS, 0,
- SKILL_STAVES, 0, 0, SKILL_FIST_WEAPONS, 0,
- SKILL_DAGGERS, SKILL_THROWN, SKILL_ASSASSINATION, SKILL_CROSSBOWS, SKILL_WANDS,
- SKILL_FISHING
- };
-
- const static uint32 item_armor_skills[MAX_ITEM_SUBCLASS_ARMOR] =
- {
- 0, SKILL_CLOTH, SKILL_LEATHER, SKILL_MAIL, SKILL_PLATE_MAIL, 0, SKILL_SHIELD, 0, 0, 0, 0
- };
-
ItemTemplate const* proto = GetTemplate();
-
- switch (proto->Class)
- {
- case ITEM_CLASS_WEAPON:
- if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
- return 0;
- else
- return item_weapon_skills[proto->SubClass];
-
- case ITEM_CLASS_ARMOR:
- if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
- return 0;
- else
- return item_armor_skills[proto->SubClass];
-
- default:
- return 0;
- }
+ return proto->GetSkill();
}
uint32 Item::GetSpell()
diff --git a/src/server/game/Entities/Item/ItemPrototype.cpp b/src/server/game/Entities/Item/ItemPrototype.cpp
new file mode 100644
index 00000000000..3bb7b128b08
--- /dev/null
+++ b/src/server/game/Entities/Item/ItemPrototype.cpp
@@ -0,0 +1,121 @@
+/*
+* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation; either version 2 of the License, or (at your
+* option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+* more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ItemPrototype.h"
+
+bool ItemTemplate::CanChangeEquipStateInCombat() const
+{
+ switch (InventoryType)
+ {
+ case INVTYPE_RELIC:
+ case INVTYPE_SHIELD:
+ case INVTYPE_HOLDABLE:
+ return true;
+ }
+
+ switch (Class)
+ {
+ case ITEM_CLASS_WEAPON:
+ case ITEM_CLASS_PROJECTILE:
+ return true;
+ }
+
+ return false;
+}
+
+
+float ItemTemplate::getDPS() const
+{
+ if (Delay == 0)
+ return 0;
+ float temp = 0;
+ for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
+ temp += Damage[i].DamageMin + Damage[i].DamageMax;
+ return temp * 500 / Delay;
+}
+
+
+int32 ItemTemplate::getFeralBonus(int32 extraDPS /*= 0*/) const
+{
+ // 0x02A5F3 - is mask for Melee weapon from ItemSubClassMask.dbc
+ if (Class == ITEM_CLASS_WEAPON && (1 << SubClass) & 0x02A5F3)
+ {
+ int32 bonus = int32((extraDPS + getDPS())*14.0f) - 767;
+ if (bonus < 0)
+ return 0;
+ return bonus;
+ }
+ return 0;
+}
+
+float ItemTemplate::GetItemLevelIncludingQuality() const
+{
+ float itemLevel = (float)ItemLevel;
+ switch (Quality)
+ {
+ case ITEM_QUALITY_POOR:
+ case ITEM_QUALITY_NORMAL:
+ case ITEM_QUALITY_UNCOMMON:
+ case ITEM_QUALITY_ARTIFACT:
+ case ITEM_QUALITY_HEIRLOOM:
+ itemLevel -= 13; // leaving this as a separate statement since we do not know the real behavior in this case
+ break;
+ case ITEM_QUALITY_RARE:
+ itemLevel -= 13;
+ break;
+ case ITEM_QUALITY_EPIC:
+ case ITEM_QUALITY_LEGENDARY:
+ default:
+ break;
+ }
+ return std::max<float>(0.f, itemLevel);
+}
+
+uint32 ItemTemplate::GetSkill() const
+{
+ const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] =
+ {
+ SKILL_AXES, SKILL_2H_AXES, SKILL_BOWS, SKILL_GUNS, SKILL_MACES,
+ SKILL_2H_MACES, SKILL_POLEARMS, SKILL_SWORDS, SKILL_2H_SWORDS, 0,
+ SKILL_STAVES, 0, 0, SKILL_FIST_WEAPONS, 0,
+ SKILL_DAGGERS, SKILL_THROWN, SKILL_ASSASSINATION, SKILL_CROSSBOWS, SKILL_WANDS,
+ SKILL_FISHING
+ };
+
+ const static uint32 item_armor_skills[MAX_ITEM_SUBCLASS_ARMOR] =
+ {
+ 0, SKILL_CLOTH, SKILL_LEATHER, SKILL_MAIL, SKILL_PLATE_MAIL, 0, SKILL_SHIELD, 0, 0, 0, 0
+ };
+
+ switch (Class)
+ {
+ case ITEM_CLASS_WEAPON:
+ if (SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
+ return 0;
+ else
+ return item_weapon_skills[SubClass];
+
+ case ITEM_CLASS_ARMOR:
+ if (SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
+ return 0;
+ else
+ return item_armor_skills[SubClass];
+
+ default:
+ return 0;
+ }
+}
diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h
index 48ef9e81016..9b0f4628364 100644
--- a/src/server/game/Entities/Item/ItemPrototype.h
+++ b/src/server/game/Entities/Item/ItemPrototype.h
@@ -664,25 +664,7 @@ struct ItemTemplate
uint32 FlagsCu;
// helpers
- bool CanChangeEquipStateInCombat() const
- {
- switch (InventoryType)
- {
- case INVTYPE_RELIC:
- case INVTYPE_SHIELD:
- case INVTYPE_HOLDABLE:
- return true;
- }
-
- switch (Class)
- {
- case ITEM_CLASS_WEAPON:
- case ITEM_CLASS_PROJECTILE:
- return true;
- }
-
- return false;
- }
+ bool CanChangeEquipStateInCombat() const;
bool IsCurrencyToken() const { return (BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) != 0; }
@@ -691,51 +673,13 @@ struct ItemTemplate
return (Stackable == 2147483647 || Stackable <= 0) ? uint32(0x7FFFFFFF-1) : uint32(Stackable);
}
- float getDPS() const
- {
- if (Delay == 0)
- return 0;
- float temp = 0;
- for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
- temp+=Damage[i].DamageMin + Damage[i].DamageMax;
- return temp*500/Delay;
- }
+ float getDPS() const;
- int32 getFeralBonus(int32 extraDPS = 0) const
- {
- // 0x02A5F3 - is mask for Melee weapon from ItemSubClassMask.dbc
- if (Class == ITEM_CLASS_WEAPON && (1<<SubClass)&0x02A5F3)
- {
- int32 bonus = int32((extraDPS + getDPS())*14.0f) - 767;
- if (bonus < 0)
- return 0;
- return bonus;
- }
- return 0;
- }
+ int32 getFeralBonus(int32 extraDPS = 0) const;
- float GetItemLevelIncludingQuality() const
- {
- float itemLevel = (float)ItemLevel;
- switch (Quality)
- {
- case ITEM_QUALITY_POOR:
- case ITEM_QUALITY_NORMAL:
- case ITEM_QUALITY_UNCOMMON:
- case ITEM_QUALITY_ARTIFACT:
- case ITEM_QUALITY_HEIRLOOM:
- itemLevel -= 13; // leaving this as a separate statement since we do not know the real behavior in this case
- break;
- case ITEM_QUALITY_RARE:
- itemLevel -= 13;
- break;
- case ITEM_QUALITY_EPIC:
- case ITEM_QUALITY_LEGENDARY:
- default:
- break;
- }
- return std::max<float>(0.f, itemLevel);
- }
+ float GetItemLevelIncludingQuality() const;
+
+ uint32 GetSkill() const;
bool IsPotion() const { return Class == ITEM_CLASS_CONSUMABLE && SubClass == ITEM_SUBCLASS_POTION; }
bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; }