[7932] Store in DB only spell part of pet action bar, set other to default state (reaction saved). Author: VladimirMangos
--HG-- branch : trunk
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@
|
||||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_7903_01_characters_character_pet` bit(1) default NULL
|
||||
`required_7932_01_characters_character_pet` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-- ALTER TABLE character_db_version CHANGE COLUMN required_7903_01_characters_character_pet required_7932_01_characters_character_pet bit;
|
||||
|
||||
UPDATE character_pet
|
||||
SET abdata = CONCAT(REPLACE(TRIM(abdata),' ',' '),' ');
|
||||
|
||||
UPDATE character_pet
|
||||
SET abdata = SUBSTRING_INDEX(SUBSTRING_INDEX(abdata,' ',(10-3)*2),' ',-(10-3-3)*2)
|
||||
WHERE length(SUBSTRING_INDEX(abdata, ' ', 20)) < length(abdata) and length(SUBSTRING_INDEX(abdata, ' ', 21)) >= length(abdata);
|
||||
|
||||
+4
-7
@@ -268,14 +268,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load action bar data
|
||||
// load action bar, if data broken will fill later by default spells.
|
||||
if (!is_temporary_summoned)
|
||||
{
|
||||
if(!m_charmInfo->LoadActionBar(fields[13].GetCppString()))
|
||||
{
|
||||
delete result;
|
||||
return false;
|
||||
}
|
||||
m_charmInfo->LoadPetActionBar(fields[13].GetCppString());
|
||||
|
||||
_LoadSpells();
|
||||
_LoadSpellCooldowns();
|
||||
@@ -398,7 +394,8 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||
<< curmana << ", "
|
||||
<< GetPower(POWER_HAPPINESS) << ", '";
|
||||
|
||||
for(uint32 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
|
||||
// save only spell slots from action bar
|
||||
for(uint32 i = ACTION_BAR_INDEX_PET_SPELL_START; i < ACTION_BAR_INDEX_PET_SPELL_END; ++i)
|
||||
{
|
||||
ss << uint32(m_charmInfo->GetActionBarEntry(i)->Type) << " "
|
||||
<< uint32(m_charmInfo->GetActionBarEntry(i)->SpellOrAction) << " ";
|
||||
|
||||
+20
-15
@@ -11752,21 +11752,25 @@ CharmInfo::~CharmInfo()
|
||||
void CharmInfo::InitPetActionBar()
|
||||
{
|
||||
// the first 3 SpellOrActions are attack, follow and stay
|
||||
for(uint32 i = 0; i < 3; i++)
|
||||
{
|
||||
SetActionBar(i,COMMAND_ATTACK - i,ACT_COMMAND);
|
||||
SetActionBar(i + 7,COMMAND_ATTACK - i,ACT_REACTION);
|
||||
}
|
||||
for(uint32 i = 3; i < 7; ++i)
|
||||
SetActionBar(i,0,ACT_PASSIVE);
|
||||
for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_START - ACTION_BAR_INDEX_START; ++i)
|
||||
SetActionBar(ACTION_BAR_INDEX_START + i,COMMAND_ATTACK - i,ACT_COMMAND);
|
||||
|
||||
// middle 4 SpellOrActions are spells/special attacks/abilities
|
||||
for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START; ++i)
|
||||
SetActionBar(ACTION_BAR_INDEX_PET_SPELL_START + i,0,ACT_PASSIVE);
|
||||
|
||||
// last 3 SpellOrActions are reactions
|
||||
for(uint32 i = 0; i < ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_PET_SPELL_END; ++i)
|
||||
SetActionBar(ACTION_BAR_INDEX_PET_SPELL_END + i,COMMAND_ATTACK - i,ACT_REACTION);
|
||||
}
|
||||
|
||||
void CharmInfo::InitEmptyActionBar(bool withAttack)
|
||||
{
|
||||
if(withAttack)
|
||||
SetActionBar(0,COMMAND_ATTACK,ACT_COMMAND);
|
||||
|
||||
for(uint32 x = withAttack ? 1 : 0; x < MAX_UNIT_ACTION_BAR_INDEX; ++x)
|
||||
SetActionBar(ACTION_BAR_INDEX_START,COMMAND_ATTACK,ACT_COMMAND);
|
||||
else
|
||||
SetActionBar(ACTION_BAR_INDEX_START,0,ACT_PASSIVE);
|
||||
for(uint32 x = ACTION_BAR_INDEX_START+1; x < ACTION_BAR_INDEX_END; ++x)
|
||||
SetActionBar(x,0,ACT_PASSIVE);
|
||||
}
|
||||
|
||||
@@ -11916,16 +11920,18 @@ void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow)
|
||||
m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0);
|
||||
}
|
||||
|
||||
bool CharmInfo::LoadActionBar( std::string data )
|
||||
void CharmInfo::LoadPetActionBar( std::string data )
|
||||
{
|
||||
InitPetActionBar();
|
||||
|
||||
Tokens tokens = StrSplit(data, " ");
|
||||
|
||||
if (tokens.size() != MAX_UNIT_ACTION_BAR_INDEX*2)
|
||||
return false;
|
||||
if (tokens.size() != (ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START)*2)
|
||||
return; // non critical, will reset to default
|
||||
|
||||
int index;
|
||||
Tokens::iterator iter;
|
||||
for(iter = tokens.begin(), index = 0; index < MAX_UNIT_ACTION_BAR_INDEX; ++iter, ++index )
|
||||
for(iter = tokens.begin(), index = ACTION_BAR_INDEX_PET_SPELL_START; index < ACTION_BAR_INDEX_PET_SPELL_END; ++iter, ++index )
|
||||
{
|
||||
// use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion
|
||||
PetActionBar[index].Type = atol((*iter).c_str());
|
||||
@@ -11941,7 +11947,6 @@ bool CharmInfo::LoadActionBar( std::string data )
|
||||
SetActionBar(index,PetActionBar[index].SpellOrAction,ACT_PASSIVE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CharmInfo::BuildActionBar( WorldPacket* data )
|
||||
|
||||
+10
-2
@@ -885,7 +885,15 @@ struct CharmSpellEntry
|
||||
|
||||
typedef std::list<Player*> SharedVisionList;
|
||||
|
||||
#define MAX_UNIT_ACTION_BAR_INDEX 10
|
||||
enum ActionBarIndex
|
||||
{
|
||||
ACTION_BAR_INDEX_START = 0,
|
||||
ACTION_BAR_INDEX_PET_SPELL_START = 3,
|
||||
ACTION_BAR_INDEX_PET_SPELL_END = 7,
|
||||
ACTION_BAR_INDEX_END = 10,
|
||||
};
|
||||
|
||||
#define MAX_UNIT_ACTION_BAR_INDEX (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)
|
||||
|
||||
struct CharmInfo
|
||||
{
|
||||
@@ -910,7 +918,7 @@ struct CharmInfo
|
||||
//return true if successful
|
||||
bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE);
|
||||
bool RemoveSpellFromActionBar(uint32 spell_id);
|
||||
bool LoadActionBar(std::string data);
|
||||
void LoadPetActionBar(std::string data);
|
||||
void BuildActionBar(WorldPacket* data);
|
||||
void SetSpellAutocast(uint32 spell_id, bool state);
|
||||
void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type)
|
||||
|
||||
Reference in New Issue
Block a user