[7886] Drop use table petcreateinfo_spell

This is first commit in chain for remove oudated and not used pet functionality.

* Use instead dropped table CreatureSpellData.dbc if creature_template.PetSpellDataId set (mostly hunter pets)
* Use creature_template.spellN if not set creature_template.PetSpellDataId (mostly different summon creatures)
* Fixed bug with not removing from action bar spell icon for not ranked unlearned spells.

Note: summoned controllable creatures without PetSpellDataId must have expected spells in spellN feilds for creature_template.
This commit is contained in:
VladimirMangos 2009-05-24 06:28:46 +04:00
parent 37f8cea0a1
commit 8171bb57dd
11 changed files with 206 additions and 58 deletions

View file

@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`required_7884_02_mangos_playercreateinfo_action` bit(1) default NULL
`required_7886_01_mangos_petcreateinfo_spell` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -3660,29 +3660,6 @@ INSERT INTO `pet_name_generation` (`word`,`entry`,`half`) VALUES
/*!40000 ALTER TABLE `pet_name_generation` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `petcreateinfo_spell`
--
DROP TABLE IF EXISTS `petcreateinfo_spell`;
CREATE TABLE `petcreateinfo_spell` (
`entry` mediumint(8) unsigned NOT NULL default '0',
`Spell1` mediumint(8) unsigned NOT NULL default '0',
`Spell2` mediumint(8) unsigned NOT NULL default '0',
`Spell3` mediumint(8) unsigned NOT NULL default '0',
`Spell4` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet Create Spells';
--
-- Dumping data for table `petcreateinfo_spell`
--
LOCK TABLES `petcreateinfo_spell` WRITE;
/*!40000 ALTER TABLE `petcreateinfo_spell` DISABLE KEYS */;
/*!40000 ALTER TABLE `petcreateinfo_spell` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `pickpocketing_loot_template`
--

View file

@ -0,0 +1,4 @@
ALTER TABLE db_version CHANGE COLUMN required_7884_02_mangos_playercreateinfo_action required_7886_01_mangos_petcreateinfo_spell bit;
DROP TABLE IF EXISTS `petcreateinfo_spell`;

View file

@ -197,6 +197,7 @@ pkgdata_DATA = \
7884_03_characters_character_spell.sql \
7884_04_characters_character_aura.sql \
7884_05_characters_character_action.sql \
7886_01_mangos_petcreateinfo_spell.sql \
README
## Additional files to include when running 'make dist'
@ -374,4 +375,5 @@ EXTRA_DIST = \
7884_03_characters_character_spell.sql \
7884_04_characters_character_aura.sql \
7884_05_characters_character_action.sql \
7886_01_mangos_petcreateinfo_spell.sql \
README

View file

@ -704,11 +704,13 @@ struct CreatureFamilyEntry
// 27 m_iconFile
};
#define MAX_CREATURE_SPELL_DATA_SLOT 4
struct CreatureSpellDataEntry
{
uint32 ID; // 0 m_ID
//uint32 spellId[4]; // 1-4 m_spells[4]
//uint32 availability[4]; // 4-7 m_availability[4]
uint32 spellId[MAX_CREATURE_SPELL_DATA_SLOT]; // 1-4 m_spells[4]
//uint32 availability[MAX_CREATURE_SPELL_DATA_SLOT]; // 4-7 m_availability[4]
};
struct CreatureTypeEntry

View file

@ -37,7 +37,7 @@ const char ChrRacesEntryfmt[]="nxixiixxixxxxissssssssssssssssxxxxxxxxxxxxxxxxxxx
const char CinematicSequencesEntryfmt[]="nxxxxxxxxx";
const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx";
const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx";
const char CreatureSpellDatafmt[]="nxxxxxxxx";
const char CreatureSpellDatafmt[]="niiiixxxx";
const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx";
const char CurrencyTypesfmt[]="xnxi";
const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii";

View file

@ -3572,7 +3572,7 @@ void ObjectMgr::LoadPetCreateSpells()
sLog.outString();
sLog.outString( ">> Loaded 0 pet create spells" );
sLog.outErrorDb("`petcreateinfo_spell` table is empty!");
//sLog.outErrorDb("`petcreateinfo_spell` table is empty!");
return;
}
@ -3644,6 +3644,7 @@ void ObjectMgr::LoadPetCreateSpells()
sLog.outString();
sLog.outString( ">> Loaded %u pet create spells", count );
sLog.outErrorDb("`petcreateinfo_spell` table use deprecated! Must be empty!");
}
void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)

View file

@ -1437,16 +1437,10 @@ bool Pet::learnSpell(uint32 spell_id)
void Pet::InitLevelupSpellsForLevel()
{
uint32 family = GetCreatureInfo()->family;
if(!family)
return;
PetLevelupSpellSet const *levelupSpells = spellmgr.GetPetLevelupSpellList(family);
if(!levelupSpells)
return;
uint32 level = getLevel();
if(PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL)
{
// PetLevelupSpellSet ordered by levels, process in reversed order
for(PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
{
@ -1459,6 +1453,27 @@ void Pet::InitLevelupSpellsForLevel()
}
}
int32 petSpellsId = GetCreatureInfo()->PetSpellDataId ? -(int32)GetCreatureInfo()->PetSpellDataId : GetEntry();
// default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game)
if(PetDefaultSpellsEntry const *defSpells = spellmgr.GetPetDefaultSpellsEntry(petSpellsId))
{
for(int i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i)
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]);
if(!spellEntry)
continue;
// will called first if level down
if(spellEntry->spellLevel > level)
unlearnSpell(spellEntry->Id,false);
// will called if level up
else
learnSpell(spellEntry->Id);
}
}
}
bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev)
{
if(removeSpell(spell_id,learn_prev))
@ -1516,15 +1531,17 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev)
learnSpell(prev_id);
}
else
{
m_charmInfo->AddSpellToAB(spell_id, 0);
learn_prev = false;
}
// if remove last rank or non-ranked then update action bar at server and client if need
if(!learn_prev && m_charmInfo->AddSpellToAB(spell_id, 0))
{
// need update action bar for last removed rank
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER)
((Player*)owner)->PetSpellInitialize();
}
}
return true;
}

View file

@ -2223,6 +2223,131 @@ void SpellMgr::LoadPetLevelupSpellMap()
sLog.outString( ">> Loaded %u pet levelup and default spells for %u families", count, family_count );
}
bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
{
// skip empty list;
bool have_spell = false;
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{
if(petDefSpells.spellid[j])
{
have_spell = true;
break;
}
}
if(!have_spell)
return false;
// remove duplicates with levelupSpells if any
if(PetLevelupSpellSet const *levelupSpells = cInfo->family ? spellmgr.GetPetLevelupSpellList(cInfo->family) : NULL)
{
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{
if(!petDefSpells.spellid[j])
continue;
for(PetLevelupSpellSet::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr)
{
if (itr->second == petDefSpells.spellid[j])
{
petDefSpells.spellid[j] = 0;
break;
}
}
}
}
// skip empty list;
have_spell = false;
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
{
if(petDefSpells.spellid[j])
{
have_spell = true;
break;
}
}
return have_spell;
}
void SpellMgr::LoadPetDefaultSpells()
{
assert(MAX_CREATURE_SPELL_DATA_SLOT==CREATURE_MAX_SPELLS);
mPetDefaultSpellsMap.clear();
uint32 countCreature = 0;
uint32 countData = 0;
for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i )
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i);
if(!cInfo)
continue;
if(!cInfo->PetSpellDataId)
continue;
// for creature with PetSpellDataId get default pet spells from dbc
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
if(!spellDataEntry)
continue;
int32 petSpellsId = -(int32)cInfo->PetSpellDataId;
PetDefaultSpellsEntry petDefSpells;
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
petDefSpells.spellid[j] = spellDataEntry->spellId[j];
if(LoadPetDefaultSpells_helper(cInfo, petDefSpells))
{
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
++countData;
}
}
// different summon spells
for(uint32 i = 0; i < sSpellStore.GetNumRows(); ++i )
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(i);
if(!spellEntry)
continue;
for(int k = 0; k < 3; ++k)
{
if(spellEntry->Effect[k]==SPELL_EFFECT_SUMMON || spellEntry->Effect[k]==SPELL_EFFECT_SUMMON_PET)
{
uint32 creature_id = spellEntry->EffectMiscValue[k];
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(creature_id);
if(!cInfo)
continue;
// already loaded
if(cInfo->PetSpellDataId)
continue;
// for creature without PetSpellDataId get default pet spells from creature_template
int32 petSpellsId = cInfo->Entry;
if(mPetDefaultSpellsMap.find(cInfo->Entry) != mPetDefaultSpellsMap.end())
continue;
PetDefaultSpellsEntry petDefSpells;
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
petDefSpells.spellid[j] = cInfo->spells[j];
if(LoadPetDefaultSpells_helper(cInfo, petDefSpells))
{
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
++countCreature;
}
}
}
}
sLog.outString();
sLog.outString( ">> Loaded addition spells for %u pet spell data entries and %u summonable creature templates", countData, countCreature );
}
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
{

View file

@ -564,6 +564,15 @@ typedef std::multimap<uint32, SkillLineAbilityEntry const*> SkillLineAbilityMap;
typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
struct PetDefaultSpellsEntry
{
uint32 spellid[MAX_CREATURE_SPELL_DATA_SLOT];
};
// < 0 for petspelldata id, > 0 for creature_id
typedef std::map<int32, PetDefaultSpellsEntry> PetDefaultSpellsMap;
inline bool IsPrimaryProfessionSkill(uint32 skill)
{
SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill);
@ -814,6 +823,15 @@ class SpellMgr
return NULL;
}
// < 0 for petspelldata id, > 0 for creature_id
PetDefaultSpellsEntry const* GetPetDefaultSpellsEntry(int32 id) const
{
PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id);
if(itr != mPetDefaultSpellsMap.end())
return &itr->second;
return NULL;
}
SpellCastResult GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL);
SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const
@ -862,6 +880,7 @@ class SpellMgr
void LoadSkillLineAbilityMap();
void LoadSpellPetAuras();
void LoadPetLevelupSpellMap();
void LoadPetDefaultSpells();
void LoadSpellAreas();
private:
@ -878,6 +897,7 @@ class SpellMgr
SkillLineAbilityMap mSkillLineAbilityMap;
SpellPetAuraMap mSpellPetAuraMap;
PetLevelupSpellMap mPetLevelupSpellMap;
PetDefaultSpellsMap mPetDefaultSpellsMap; // only spells not listed in related mPetLevelupSpellMap entry
SpellAreaMap mSpellAreaMap;
SpellAreaForQuestMap mSpellAreaForQuestMap;
SpellAreaForQuestMap mSpellAreaForActiveQuestMap;

View file

@ -1158,12 +1158,15 @@ void World::SetInitialWorldSettings()
sLog.outString( "Loading Points Of Interest Data..." );
objmgr.LoadPointsOfInterest();
sLog.outString( "Loading Pet Create Spells..." );
objmgr.LoadPetCreateSpells();
sLog.outString( "Loading Creature Data..." );
objmgr.LoadCreatures();
sLog.outString( "Loading pet levelup spells..." );
spellmgr.LoadPetLevelupSpellMap();
sLog.outString( "Loading pet default spell additional to levelup spells..." );
spellmgr.LoadPetDefaultSpells();
sLog.outString( "Loading Creature Addon Data..." );
sLog.outString();
objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
@ -1230,9 +1233,6 @@ void World::SetInitialWorldSettings()
sLog.outString( "Loading spell pet auras..." );
spellmgr.LoadSpellPetAuras();
sLog.outString( "Loading pet levelup spells..." );
spellmgr.LoadPetLevelupSpellMap();
sLog.outString( "Loading Player Create Info & Level Stats..." );
sLog.outString();
objmgr.LoadPlayerInfo();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7885"
#define REVISION_NR "7886"
#endif // __REVISION_NR_H__