mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7932] Store in DB only spell part of pet action bar, set other to default state (reaction saved).
This commit is contained in:
parent
c386bef32e
commit
7d6bf1fdbf
7 changed files with 44 additions and 27 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `character_db_version`;
|
DROP TABLE IF EXISTS `character_db_version`;
|
||||||
CREATE TABLE `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';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
||||||
9
sql/updates/7932_01_characters_character_pet.sql
Normal file
9
sql/updates/7932_01_characters_character_pet.sql
Normal file
|
|
@ -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);
|
||||||
|
|
||||||
|
|
@ -208,6 +208,7 @@ pkgdata_DATA = \
|
||||||
7908_01_mangos_creature_template.sql \
|
7908_01_mangos_creature_template.sql \
|
||||||
7908_02_mangos_creature_addon.sql \
|
7908_02_mangos_creature_addon.sql \
|
||||||
7908_03_mangos_creature_template_addon.sql \
|
7908_03_mangos_creature_template_addon.sql \
|
||||||
|
7932_01_characters_character_pet.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -396,4 +397,5 @@ EXTRA_DIST = \
|
||||||
7908_01_mangos_creature_template.sql \
|
7908_01_mangos_creature_template.sql \
|
||||||
7908_02_mangos_creature_addon.sql \
|
7908_02_mangos_creature_addon.sql \
|
||||||
7908_03_mangos_creature_template_addon.sql \
|
7908_03_mangos_creature_template_addon.sql \
|
||||||
|
7932_01_characters_character_pet.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -239,14 +239,9 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||||
CharacterDatabase.CommitTransaction();
|
CharacterDatabase.CommitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load action bar, if data broken will fill later by default spells.
|
||||||
if (!is_temporary_summoned)
|
if (!is_temporary_summoned)
|
||||||
{
|
m_charmInfo->LoadPetActionBar(fields[13].GetCppString());
|
||||||
if(!m_charmInfo->LoadActionBar(fields[13].GetCppString()))
|
|
||||||
{
|
|
||||||
delete result;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// since last save (in seconds)
|
// since last save (in seconds)
|
||||||
uint32 timediff = (time(NULL) - fields[14].GetUInt32());
|
uint32 timediff = (time(NULL) - fields[14].GetUInt32());
|
||||||
|
|
@ -411,7 +406,8 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||||
<< curmana << ", "
|
<< curmana << ", "
|
||||||
<< GetPower(POWER_HAPPINESS) << ", '";
|
<< 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) << " "
|
ss << uint32(m_charmInfo->GetActionBarEntry(i)->Type) << " "
|
||||||
<< uint32(m_charmInfo->GetActionBarEntry(i)->SpellOrAction) << " ";
|
<< uint32(m_charmInfo->GetActionBarEntry(i)->SpellOrAction) << " ";
|
||||||
|
|
|
||||||
|
|
@ -10319,21 +10319,22 @@ CharmInfo::CharmInfo(Unit* unit)
|
||||||
void CharmInfo::InitPetActionBar()
|
void CharmInfo::InitPetActionBar()
|
||||||
{
|
{
|
||||||
// the first 3 SpellOrActions are attack, follow and stay
|
// the first 3 SpellOrActions are attack, follow and stay
|
||||||
// last 3 SpellOrActions are reactions
|
for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_START - ACTION_BAR_INDEX_START; ++i)
|
||||||
for(uint32 i = 0; i < 3; ++i)
|
SetActionBar(ACTION_BAR_INDEX_START + i,COMMAND_ATTACK - i,ACT_COMMAND);
|
||||||
{
|
|
||||||
SetActionBar(i,COMMAND_ATTACK - i,ACT_COMMAND);
|
|
||||||
SetActionBar(i + 7,COMMAND_ATTACK - i,ACT_REACTION);
|
|
||||||
}
|
|
||||||
// middle 4 SpellOrActions are spells/special attacks/abilities
|
// middle 4 SpellOrActions are spells/special attacks/abilities
|
||||||
for(uint32 i = 0; i < 4; ++i)
|
for(uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START; ++i)
|
||||||
SetActionBar(i + 3,0,ACT_DISABLED);
|
SetActionBar(ACTION_BAR_INDEX_PET_SPELL_START + i,0,ACT_DISABLED);
|
||||||
|
|
||||||
|
// 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()
|
void CharmInfo::InitEmptyActionBar()
|
||||||
{
|
{
|
||||||
SetActionBar(0,COMMAND_ATTACK,ACT_COMMAND);
|
SetActionBar(ACTION_BAR_INDEX_START,COMMAND_ATTACK,ACT_COMMAND);
|
||||||
for(uint32 x = 1; x < MAX_UNIT_ACTION_BAR_INDEX; ++x)
|
for(uint32 x = ACTION_BAR_INDEX_START+1; x < ACTION_BAR_INDEX_END; ++x)
|
||||||
SetActionBar(x,0,ACT_PASSIVE);
|
SetActionBar(x,0,ACT_PASSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -10470,16 +10471,18 @@ void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow)
|
||||||
m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0);
|
m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CharmInfo::LoadActionBar( std::string data )
|
void CharmInfo::LoadPetActionBar( std::string data )
|
||||||
{
|
{
|
||||||
|
InitPetActionBar();
|
||||||
|
|
||||||
Tokens tokens = StrSplit(data, " ");
|
Tokens tokens = StrSplit(data, " ");
|
||||||
|
|
||||||
if (tokens.size() != MAX_UNIT_ACTION_BAR_INDEX*2)
|
if (tokens.size() != (ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START)*2)
|
||||||
return false;
|
return; // non critical, will reset to default
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
Tokens::iterator iter;
|
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
|
// use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion
|
||||||
PetActionBar[index].Type = atol((*iter).c_str());
|
PetActionBar[index].Type = atol((*iter).c_str());
|
||||||
|
|
@ -10490,7 +10493,6 @@ bool CharmInfo::LoadActionBar( std::string data )
|
||||||
if(PetActionBar[index].IsActionBarForSpell() && !sSpellStore.LookupEntry(PetActionBar[index].SpellOrAction))
|
if(PetActionBar[index].IsActionBarForSpell() && !sSpellStore.LookupEntry(PetActionBar[index].SpellOrAction))
|
||||||
SetActionBar(index,0,ACT_DISABLED);
|
SetActionBar(index,0,ACT_DISABLED);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharmInfo::BuildActionBar( WorldPacket* data )
|
void CharmInfo::BuildActionBar( WorldPacket* data )
|
||||||
|
|
|
||||||
|
|
@ -791,7 +791,15 @@ struct CharmSpellEntry
|
||||||
uint16 active;
|
uint16 active;
|
||||||
};
|
};
|
||||||
|
|
||||||
#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
|
struct CharmInfo
|
||||||
{
|
{
|
||||||
|
|
@ -815,7 +823,7 @@ struct CharmInfo
|
||||||
//return true if successful
|
//return true if successful
|
||||||
bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE);
|
bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE);
|
||||||
bool RemoveSpellFromActionBar(uint32 spell_id);
|
bool RemoveSpellFromActionBar(uint32 spell_id);
|
||||||
bool LoadActionBar(std::string data);
|
void LoadPetActionBar(std::string data);
|
||||||
void BuildActionBar(WorldPacket* data);
|
void BuildActionBar(WorldPacket* data);
|
||||||
void SetSpellAutocast(uint32 spell_id, bool state);
|
void SetSpellAutocast(uint32 spell_id, bool state);
|
||||||
void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type)
|
void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7931"
|
#define REVISION_NR "7932"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue