mirror of
https://github.com/mangosfour/server.git
synced 2025-12-30 10:37:12 +00:00
[11623] Implement ClassFamilyMask as wrapper for uint64+uint32 spell family masks
Inspired by patch suggested by darkstalker Also * Remove existed enums for family masks as contra-productive for developement. * Drop one from horrible hack checks in SpellMgr::IsNoStackSpellDueToSpell (spells for any fimilies with exactly 0x800 mask) I fail find useful cases for current spell data with this check. All cases expected work correct without it. If will some problems detected with this please report for fix in less strange way.
This commit is contained in:
parent
20e9484e74
commit
c686697c2d
12 changed files with 117 additions and 127 deletions
|
|
@ -1500,6 +1500,42 @@ struct SoundEntriesEntry
|
|||
// 29 m_soundEntriesAdvancedID
|
||||
};
|
||||
|
||||
|
||||
struct ClassFamilyMask
|
||||
{
|
||||
uint64 Flags;
|
||||
uint32 Flags2;
|
||||
|
||||
ClassFamilyMask() : Flags(0), Flags2(0) {}
|
||||
explicit ClassFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) : Flags(familyFlags), Flags2(familyFlags2) {}
|
||||
|
||||
bool Empty() const { return Flags == 0 && Flags2 == 0; }
|
||||
bool operator! () const { return Empty(); }
|
||||
operator void const* () const { return Empty() ? NULL : this; }// for allow normal use in if(mask)
|
||||
|
||||
bool IsFitToFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) const
|
||||
{
|
||||
return (Flags & familyFlags) || (Flags2 & familyFlags2);
|
||||
}
|
||||
|
||||
bool IsFitToFamilyMask(ClassFamilyMask const& mask) const
|
||||
{
|
||||
return (Flags & mask.Flags) || (Flags2 & mask.Flags2);
|
||||
}
|
||||
|
||||
uint64 operator& (uint64 mask) const // possible will removed at finish convertion code use IsFitToFamilyMask
|
||||
{
|
||||
return Flags & mask;
|
||||
}
|
||||
|
||||
ClassFamilyMask& operator|= (ClassFamilyMask const& mask)
|
||||
{
|
||||
Flags |= mask.Flags;
|
||||
Flags2 |= mask.Flags2;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#define MAX_SPELL_REAGENTS 8
|
||||
#define MAX_SPELL_TOTEMS 2
|
||||
#define MAX_SPELL_TOTEM_CATEGORIES 2
|
||||
|
|
@ -1579,9 +1615,7 @@ struct SpellEntry
|
|||
int32 EffectMiscValueB[MAX_EFFECT_INDEX]; // 113-115 m_effectMiscValueB
|
||||
uint32 EffectTriggerSpell[MAX_EFFECT_INDEX]; // 116-118 m_effectTriggerSpell
|
||||
float EffectPointsPerComboPoint[MAX_EFFECT_INDEX]; // 119-121 m_effectPointsPerCombo
|
||||
uint32 EffectSpellClassMaskA[3]; // 122-124 m_effectSpellClassMaskA, effect 0
|
||||
uint32 EffectSpellClassMaskB[3]; // 125-127 m_effectSpellClassMaskB, effect 1
|
||||
uint32 EffectSpellClassMaskC[3]; // 128-130 m_effectSpellClassMaskC, effect 2
|
||||
ClassFamilyMask EffectSpellClassMask[MAX_EFFECT_INDEX]; // 122-130 m_effectSpellClassMaskA/B/C, effect 0/1/2
|
||||
uint32 SpellVisual[2]; // 131-132 m_spellVisualID
|
||||
uint32 SpellIconID; // 133 m_spellIconID
|
||||
uint32 activeIconID; // 134 m_activeIconID
|
||||
|
|
@ -1599,8 +1633,7 @@ struct SpellEntry
|
|||
uint32 StartRecoveryTime; // 206 m_startRecoveryTime
|
||||
uint32 MaxTargetLevel; // 207 m_maxTargetLevel
|
||||
uint32 SpellFamilyName; // 208 m_spellClassSet
|
||||
uint64 SpellFamilyFlags; // 209-210 m_spellClassMask NOTE: size is 12 bytes!!!
|
||||
uint32 SpellFamilyFlags2; // 211 addition to m_spellClassMask
|
||||
ClassFamilyMask SpellFamilyFlags; // 209-211 m_spellClassMask NOTE: size is 12 bytes!!!
|
||||
uint32 MaxAffectedTargets; // 212 m_maxTargets
|
||||
uint32 DmgClass; // 213 m_defenseType
|
||||
uint32 PreventionType; // 214 m_preventionType
|
||||
|
|
@ -1621,14 +1654,14 @@ struct SpellEntry
|
|||
|
||||
// helpers
|
||||
int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff] + int32(1); }
|
||||
uint32 const* GetEffectSpellClassMask(SpellEffectIndex effect) const
|
||||
ClassFamilyMask const& GetEffectSpellClassMask(SpellEffectIndex effect) const
|
||||
{
|
||||
return EffectSpellClassMaskA + effect * 3;
|
||||
return EffectSpellClassMask[effect];
|
||||
}
|
||||
|
||||
bool IsFitToFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) const
|
||||
{
|
||||
return (SpellFamilyFlags & familyFlags) || (SpellFamilyFlags2 & familyFlags2);
|
||||
return SpellFamilyFlags.IsFitToFamilyMask(familyFlags, familyFlags2);
|
||||
}
|
||||
|
||||
bool IsFitToFamily(SpellFamily family, uint64 familyFlags, uint32 familyFlags2 = 0) const
|
||||
|
|
@ -1636,6 +1669,16 @@ struct SpellEntry
|
|||
return SpellFamily(SpellFamilyName) == family && IsFitToFamilyMask(familyFlags, familyFlags2);
|
||||
}
|
||||
|
||||
bool IsFitToFamilyMask(ClassFamilyMask const& mask) const
|
||||
{
|
||||
return SpellFamilyFlags.IsFitToFamilyMask(mask);
|
||||
}
|
||||
|
||||
bool IsFitToFamily(SpellFamily family, ClassFamilyMask const& mask) const
|
||||
{
|
||||
return SpellFamily(SpellFamilyName) == family && IsFitToFamilyMask(mask);
|
||||
}
|
||||
|
||||
private:
|
||||
// prevent creating custom entries (copy data from original in fact)
|
||||
SpellEntry(SpellEntry const&); // DON'T must have implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue