diff --git a/sql/characters.sql b/sql/characters.sql index 02a7e26fd..c20530a05 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_7884_05_characters_character_action` bit(1) default NULL + `required_7887_01_characters_character_pet` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -483,7 +483,6 @@ CREATE TABLE `character_pet` ( `resettalents_cost` int(11) unsigned NOT NULL default '0', `resettalents_time` bigint(20) unsigned NOT NULL default '0', `abdata` longtext, - `teachspelldata` longtext, PRIMARY KEY (`id`), KEY `owner` (`owner`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet System'; diff --git a/sql/updates/7887_01_characters_character_pet.sql b/sql/updates/7887_01_characters_character_pet.sql new file mode 100644 index 000000000..2d61410ec --- /dev/null +++ b/sql/updates/7887_01_characters_character_pet.sql @@ -0,0 +1,4 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_7884_05_characters_character_action required_7887_01_characters_character_pet bit; + +ALTER TABLE `character_pet` + DROP TeachSpelldata; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 3dc7bc8e3..81cb82750 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -198,6 +198,7 @@ pkgdata_DATA = \ 7884_04_characters_character_aura.sql \ 7884_05_characters_character_action.sql \ 7886_01_mangos_petcreateinfo_spell.sql \ + 7887_01_characters_character_pet.sql \ README ## Additional files to include when running 'make dist' @@ -376,4 +377,5 @@ EXTRA_DIST = \ 7884_04_characters_character_aura.sql \ 7884_05_characters_character_action.sql \ 7886_01_mangos_petcreateinfo_spell.sql \ + 7887_01_characters_character_pet.sql \ README diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 1c159703a..2f76bd391 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3562,91 +3562,6 @@ void ObjectMgr::LoadQuestLocales() sLog.outString( ">> Loaded %lu Quest locale strings", (unsigned long)mQuestLocaleMap.size() ); } -void ObjectMgr::LoadPetCreateSpells() -{ - QueryResult *result = WorldDatabase.Query("SELECT entry, Spell1, Spell2, Spell3, Spell4 FROM petcreateinfo_spell"); - if(!result) - { - barGoLink bar( 1 ); - bar.step(); - - sLog.outString(); - sLog.outString( ">> Loaded 0 pet create spells" ); - //sLog.outErrorDb("`petcreateinfo_spell` table is empty!"); - return; - } - - uint32 count = 0; - - barGoLink bar( result->GetRowCount() ); - - mPetCreateSpell.clear(); - - do - { - Field *fields = result->Fetch(); - bar.step(); - - uint32 creature_id = fields[0].GetUInt32(); - - if(!creature_id) - { - sLog.outErrorDb("Creature id %u listed in `petcreateinfo_spell` not exist.",creature_id); - continue; - } - - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(creature_id); - if(!cInfo) - { - sLog.outErrorDb("Creature id %u listed in `petcreateinfo_spell` not exist.",creature_id); - continue; - } - - PetCreateSpellEntry PetCreateSpell; - - bool have_spell = false; - bool have_spell_db = false; - for(int i = 0; i < 4; i++) - { - PetCreateSpell.spellid[i] = fields[i + 1].GetUInt32(); - - if(!PetCreateSpell.spellid[i]) - continue; - - have_spell_db = true; - - SpellEntry const* i_spell = sSpellStore.LookupEntry(PetCreateSpell.spellid[i]); - if(!i_spell) - { - sLog.outErrorDb("Spell %u listed in `petcreateinfo_spell` does not exist",PetCreateSpell.spellid[i]); - PetCreateSpell.spellid[i] = 0; - continue; - } - - have_spell = true; - } - - if(!have_spell_db) - { - sLog.outErrorDb("Creature %u listed in `petcreateinfo_spell` have only 0 spell data, why it listed?",creature_id); - continue; - } - - if(!have_spell) - continue; - - mPetCreateSpell[creature_id] = PetCreateSpell; - ++count; - } - while (result->NextRow()); - - delete result; - - 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) { if(sWorld.IsScriptScheduled()) // function don't must be called in time scripts use. diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 0a056afef..bb58b723b 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -196,11 +196,6 @@ struct PointOfInterest std::string icon_name; }; -struct PetCreateSpellEntry -{ - uint32 spellid[4]; -}; - #define WEATHER_SEASONS 4 struct WeatherSeasonChances { @@ -320,8 +315,6 @@ class ObjectMgr typedef UNORDERED_MAP WeatherZoneMap; - typedef UNORDERED_MAP PetCreateSpellMap; - typedef std::vector ScriptNameMap; Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);} @@ -464,14 +457,6 @@ class ObjectMgr return NULL; } - PetCreateSpellEntry const* GetPetCreateSpellEntry(uint32 id) const - { - PetCreateSpellMap::const_iterator itr = mPetCreateSpell.find(id); - if(itr != mPetCreateSpell.end()) - return &itr->second; - return NULL; - } - void LoadGuilds(); void LoadArenaTeams(); void LoadGroups(); @@ -502,7 +487,6 @@ class ObjectMgr bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase,"mangos_string",MIN_MANGOS_STRING_ID,MAX_MANGOS_STRING_ID); } void LoadDbScriptStrings(); - void LoadPetCreateSpells(); void LoadCreatureLocales(); void LoadCreatureTemplates(); void LoadCreatures(); @@ -814,8 +798,6 @@ class ObjectMgr WeatherZoneMap mWeatherZoneMap; - PetCreateSpellMap mPetCreateSpell; - //character reserved names typedef std::set ReservedNamesMap; ReservedNamesMap m_ReservedNames; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 8025d3a85..c68bb21a5 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -87,25 +87,25 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool QueryResult *result; if (petnumber) - // known petnumber entry 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " + // known petnumber entry 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerid, petnumber); else if (current) - // current pet (slot 0) 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " + // current pet (slot 0) 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND slot = '%u'", ownerid, PET_SAVE_AS_CURRENT ); else if (petentry) // known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) - // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " + // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); else // any current or other non-stabled pet (for hunter "call pet") - // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 - result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " + // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ", ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); @@ -122,7 +122,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool return false; } - uint32 summon_spell_id = fields[19].GetUInt32(); + uint32 summon_spell_id = fields[18].GetUInt32(); SpellEntry const* spellInfo = sSpellStore.LookupEntry(summon_spell_id); bool is_temporary_summoned = spellInfo && GetSpellDuration(spellInfo) > 0; @@ -164,7 +164,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool return false; } - setPetType(PetType(fields[20].GetUInt8())); + setPetType(PetType(fields[19].GetUInt8())); SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, owner->getFaction()); SetUInt32Value(UNIT_CREATED_BY_SPELL, summon_spell_id); @@ -257,27 +257,13 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool ++iter; m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); } - - //init teach spells - tokens = StrSplit(fields[15].GetString(), " "); - for (iter = tokens.begin(), index = 0; index < 4; ++iter, ++index) - { - uint32 tmp = atol((*iter).c_str()); - - ++iter; - - if(tmp) - AddTeachSpell(tmp, atol((*iter).c_str())); - else - break; - } } // since last save (in seconds) - uint32 timediff = (time(NULL) - fields[16].GetUInt32()); + uint32 timediff = (time(NULL) - fields[15].GetUInt32()); - m_resetTalentsCost = fields[17].GetUInt32(); - m_resetTalentsTime = fields[18].GetUInt64(); + m_resetTalentsCost = fields[16].GetUInt32(); + m_resetTalentsTime = fields[17].GetUInt64(); delete result; @@ -418,7 +404,7 @@ void Pet::SavePetToDB(PetSaveMode mode) owner,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); // save pet std::ostringstream ss; - ss << "INSERT INTO character_pet ( id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " + ss << "INSERT INTO character_pet ( id, entry, owner, modelid, level, exp, Reactstate, talentpoints, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " << "VALUES (" << m_charmInfo->GetPetNumber() << ", " << GetEntry() << ", " @@ -437,17 +423,6 @@ void Pet::SavePetToDB(PetSaveMode mode) for(uint32 i = 0; i < 10; ++i) ss << uint32(m_charmInfo->GetActionBarEntry(i)->Type) << " " << uint32(m_charmInfo->GetActionBarEntry(i)->SpellOrAction) << " "; - ss << "', '"; - - //save spells the pet can teach to it's Master - { - int i = 0; - for(TeachSpellMap::const_iterator itr = m_teachspells.begin(); i < 4 && itr != m_teachspells.end(); ++i, ++itr) - ss << itr->first << " " << itr->second << " "; - for(; i < 4; ++i) - ss << uint32(0) << " " << uint32(0) << " "; - } - ss << "', " << time(NULL) << ", " << uint32(m_resetTalentsCost) << ", " @@ -1551,65 +1526,11 @@ void Pet::InitPetCreateSpells() m_charmInfo->InitPetActionBar(); m_spells.clear(); - uint32 petspellid; - PetCreateSpellEntry const* CreateSpells = objmgr.GetPetCreateSpellEntry(GetEntry()); - if(CreateSpells) - { - for(uint8 i = 0; i < 4; ++i) - { - if(!CreateSpells->spellid[i]) - break; - - SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(CreateSpells->spellid[i]); - if(!learn_spellproto) - continue; - - if(learn_spellproto->Effect[0] == SPELL_EFFECT_LEARN_SPELL || learn_spellproto->Effect[0] == SPELL_EFFECT_LEARN_PET_SPELL) - { - petspellid = learn_spellproto->EffectTriggerSpell[0]; - Unit* owner = GetOwner(); - if(owner->GetTypeId() == TYPEID_PLAYER && !((Player*)owner)->HasSpell(learn_spellproto->Id)) - { - if(IsPassiveSpell(petspellid)) //learn passive skills when tamed, not sure if thats right - ((Player*)owner)->learnSpell(learn_spellproto->Id,false); - else - AddTeachSpell(learn_spellproto->EffectTriggerSpell[0], learn_spellproto->Id); - } - } - else - petspellid = learn_spellproto->Id; - - addSpell(petspellid); - } - } - LearnPetPassives(); CastPetAuras(false); } -void Pet::CheckLearning(uint32 spellid) -{ - //charmed case -> prevent crash - if(GetTypeId() == TYPEID_PLAYER || getPetType() != HUNTER_PET) - return; - - Unit* owner = GetOwner(); - - if(m_teachspells.empty() || !owner || owner->GetTypeId() != TYPEID_PLAYER) - return; - - TeachSpellMap::iterator itr = m_teachspells.find(spellid); - if(itr == m_teachspells.end()) - return; - - if(urand(0, 100) < 10) - { - ((Player*)owner)->learnSpell(itr->second,false); - m_teachspells.erase(itr); - } -} - bool Pet::resetTalents(bool no_cost) { Unit *owner = GetOwner(); diff --git a/src/game/Pet.h b/src/game/Pet.h index c16a4a550..f8de3ed5e 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -107,7 +107,6 @@ enum PetNameInvalidReason }; typedef UNORDERED_MAP PetSpellMap; -typedef std::map TeachSpellMap; typedef std::vector AutoSpellList; #define HAPPINESS_LEVEL_SIZE 333000 @@ -183,7 +182,6 @@ class Pet : public Creature void ToggleAutocast(uint32 spellid, bool apply); bool HasSpell(uint32 spell) const; - void AddTeachSpell(uint32 learned_id, uint32 source_id) { m_teachspells[learned_id] = source_id; } void LearnPetPassives(); void CastPetAuras(bool current); @@ -204,11 +202,9 @@ class Pet : public Creature bool removeSpell(uint32 spell_id, bool learn_prev); PetSpellMap m_spells; - TeachSpellMap m_teachspells; AutoSpellList m_autospells; void InitPetCreateSpells(); - void CheckLearning(uint32 spellid); bool resetTalents(bool no_cost = false); uint32 resetTalentsCost() const; diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 8de2644f3..7db5abfaa 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -273,8 +273,6 @@ void PetAI::UpdateAI(const uint32 diff) } m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); - if (m_creature->isPet()) - ((Pet*)m_creature)->CheckLearning(spell->m_spellInfo->Id); spell->prepare(&targets); } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index e7e323900..eecc938ed 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -215,8 +215,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) if(result == SPELL_CAST_OK) { ((Creature*)pet)->AddCreatureSpellCooldown(spellid); - if (((Creature*)pet)->isPet()) - ((Pet*)pet)->CheckLearning(spellid); unit_target = spell->m_targets.getUnitTarget(); @@ -627,11 +625,9 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket ) pet->AddCreatureSpellCooldown(spellid); if(pet->isPet()) { - Pet* p = (Pet*)pet; - p->CheckLearning(spellid); //10% chance to play special pet attack talk, else growl //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell - if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) + if(((Pet*)pet)->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); else pet->SendPetAIReaction(guid); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 64b2349c9..5653b1fe1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7886" + #define REVISION_NR "7887" #endif // __REVISION_NR_H__