[7901] Refactoting pet action bar related code. Fixed some related bugs. Author: VladimirMangos

* Correctly update action bar at loading and other cases when listed unlearned/not existed spells
    * Avoid send data by PetSpellInitialize() many times while pet loading

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-27 17:02:39 -05:00
parent 7ccd99ecab
commit 514fc49c3c
6 changed files with 170 additions and 130 deletions
+32 -22
View File
@@ -770,24 +770,6 @@ struct SpellNonMeleeDamage{
uint32 createProcExtendMask(SpellNonMeleeDamage *damageInfo, SpellMissInfo missCondition);
struct UnitActionBarEntry
{
UnitActionBarEntry() : Raw(0) {}
union
{
struct
{
uint16 SpellOrAction;
uint16 Type;
};
struct
{
uint32 Raw;
};
};
};
#define MAX_DECLINED_NAME_CASES 5
struct DeclinedName
@@ -830,6 +812,20 @@ enum CommandStates
COMMAND_ABANDON = 3
};
struct UnitActionBarEntry
{
UnitActionBarEntry() : SpellOrAction(0), Type(ACT_DISABLED) {}
uint16 SpellOrAction;
uint16 Type;
// helper
bool IsActionBarForSpell() const
{
return Type == ACT_DISABLED || Type == ACT_ENABLED || Type == ACT_PASSIVE;
}
};
struct CharmSpellEntry
{
uint16 spellId;
@@ -838,7 +834,9 @@ struct CharmSpellEntry
typedef std::list<Player*> SharedVisionList;
struct TRINITY_DLL_SPEC CharmInfo
#define MAX_UNIT_ACTION_BAR_INDEX 10
struct CharmInfo
{
public:
explicit CharmInfo(Unit* unit);
@@ -857,15 +855,27 @@ struct TRINITY_DLL_SPEC CharmInfo
void InitCharmCreateSpells();
void InitPetActionBar();
void InitEmptyActionBar(bool withAttack = true);
//return true if successful
bool AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate = ACT_DECIDE);
bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE);
bool RemoveSpellFromActionBar(uint32 spell_id);
bool LoadActionBar(std::string data);
void BuildActionBar(WorldPacket* data);
void SetSpellAutocast(uint32 spell_id, bool state);
void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type)
{
PetActionBar[index].Type = type;
PetActionBar[index].SpellOrAction = spellOrAction;
}
UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); }
void ToggleCreatureAutocast(uint32 spellid, bool apply);
UnitActionBarEntry* GetActionBarEntry(uint8 index) { return &(PetActionBar[index]); }
CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); }
private:
Unit* m_unit;
UnitActionBarEntry PetActionBar[10];
UnitActionBarEntry PetActionBar[MAX_UNIT_ACTION_BAR_INDEX];
CharmSpellEntry m_charmspells[4];
CommandStates m_CommandState;
//ReactStates m_reactState;