Core/ObjectMgr: Refactor sCreatureStorage

This commit is contained in:
leak
2011-04-28 22:57:08 +02:00
parent e2e9431ca3
commit c51c817a45
45 changed files with 474 additions and 396 deletions
@@ -392,7 +392,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
me->setFaction(action.set_faction.factionId);
else
{
if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(me->GetEntry()))
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(me->GetEntry()))
{
//if no id provided, assume reset and then use default
if (me->getFaction() != ci->faction_A)
@@ -408,7 +408,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
//set model based on entry from creature_template
if (action.morph.creatureId)
{
if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(action.morph.creatureId))
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(action.morph.creatureId))
{
uint32 display_id = sObjectMgr->ChooseDisplayId(0,ci);
me->SetDisplayId(display_id);
@@ -831,7 +831,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
// set model based on entry from creature_template
if (action.mount.creatureId)
{
if (CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(action.mount.creatureId))
if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(action.mount.creatureId))
{
uint32 display_id = sObjectMgr->ChooseDisplayId(0, cInfo);
me->Mount(display_id);
@@ -204,7 +204,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
temp.raw.param4 = fields[9].GetUInt32();
//Creature does not exist in database
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.creature_id))
if (!sObjectMgr->GetCreatureTemplate(temp.creature_id))
{
sLog->outErrorDb("CreatureEventAI: Event %u has script for non-existing creature entry (%u), skipping.", i, temp.creature_id);
continue;
@@ -322,7 +322,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog->outErrorDb("CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
break;
case EVENT_T_SUMMONED_UNIT:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.summon_unit.creatureId))
if (!sObjectMgr->GetCreatureTemplate(temp.summon_unit.creatureId))
sLog->outErrorDb("CreatureEventAI: Creature %u are using event(%u) with not existed creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summon_unit.creatureId);
if (temp.summon_unit.repeatMax < temp.summon_unit.repeatMin)
sLog->outErrorDb("CreatureEventAI: Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
@@ -453,7 +453,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
if (action.morph.creatureId !=0 || action.morph.modelId !=0)
{
if (action.morph.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.morph.creatureId))
if (action.morph.creatureId && !sObjectMgr->GetCreatureTemplate(action.morph.creatureId))
{
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant Creature entry %u.", i, j+1, action.morph.creatureId);
action.morph.creatureId = 0;
@@ -524,7 +524,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
}
case ACTION_T_SUMMON:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.summon.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.summon.creatureId);
if (action.summon.target >= TARGET_T_END)
@@ -554,7 +554,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_CAST_EVENT:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.cast_event.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.cast_event.creatureId);
if (!sSpellStore.LookupEntry(action.cast_event.spellId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast_event.spellId);
@@ -592,7 +592,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent Quest entry %u.", i, j+1, action.quest_event_all.questId);
break;
case ACTION_T_CAST_EVENT_ALL:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event_all.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.cast_event_all.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent creature entry %u.", i, j+1, action.cast_event_all.creatureId);
if (!sSpellStore.LookupEntry(action.cast_event_all.spellId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast_event_all.spellId);
@@ -624,7 +624,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
}
break;
case ACTION_T_SUMMON_ID:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon_id.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.summon_id.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.summon_id.creatureId);
if (action.summon_id.target >= TARGET_T_END)
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
@@ -632,7 +632,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog->outErrorDb("CreatureEventAI: Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j+1, action.summon_id.spawnId);
break;
case ACTION_T_KILLED_MONSTER:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.killed_monster.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.killed_monster.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.killed_monster.creatureId);
if (action.killed_monster.target >= TARGET_T_END)
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
@@ -650,7 +650,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1);
break;
case ACTION_T_UPDATE_TEMPLATE:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId))
if (!sObjectMgr->GetCreatureTemplate(action.update_template.creatureId))
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existant creature entry %u.", i, j+1, action.update_template.creatureId);
break;
case ACTION_T_SET_SHEATH:
@@ -673,7 +673,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
if (action.mount.creatureId != 0 || action.mount.modelId != 0)
{
if (action.mount.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.mount.creatureId))
if (action.mount.creatureId && !sObjectMgr->GetCreatureTemplate(action.mount.creatureId))
{
sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j+1, action.mount.creatureId);
action.morph.creatureId = 0;
@@ -731,16 +731,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
m_CreatureEventAI_Event_Map[creature_id].push_back(temp);
++count;
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(temp.creature_id))
if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(temp.creature_id))
{
if (!cInfo->AIName || !cInfo->AIName[0])
if (!cInfo->AIName.empty())
{
//sLog->outErrorDb("CreatureEventAI: Creature Entry %u has EventAI script but its AIName is empty. Set to EventAI as default.", cInfo->Entry);
size_t len = strlen("EventAI")+1;
const_cast<CreatureInfo*>(cInfo)->AIName = new char[len];
strncpy(const_cast<char*>(cInfo->AIName), "EventAI", len);
const_cast<CreatureTemplate*>(cInfo)->AIName = "EventAI";
}
if (strcmp(cInfo->AIName, "EventAI"))
if (cInfo->AIName.compare("EventAI"))
{
//sLog->outErrorDb("CreatureEventAI: Creature Entry %u has EventAI script but it has AIName %s. EventAI script will be overriden.", cInfo->Entry, cInfo->AIName);
}
@@ -421,7 +421,7 @@ void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO
{
if (loadDefault)
{
if (CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(me->GetEntry()))
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(me->GetEntry()))
me->LoadEquipment(creatureInfo->equipmentId, true);
return;
@@ -234,7 +234,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
else
{
if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate((*itr)->ToCreature()->GetEntry()))
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate((*itr)->ToCreature()->GetEntry()))
{
if ((*itr)->ToCreature()->getFaction() != ci->faction_A)
{
@@ -266,7 +266,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
//set model based on entry from creature_template
if (e.action.morphOrMount.creature)
{
if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(e.action.morphOrMount.creature))
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
{
uint32 display_id = sObjectMgr->ChooseDisplayId(0, ci);
(*itr)->ToCreature()->SetDisplayId(display_id);
@@ -940,7 +940,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (e.action.morphOrMount.creature > 0)
{
if (CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(e.action.morphOrMount.creature))
if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
{
uint32 display_id = sObjectMgr->ChooseDisplayId(0, cInfo);
(*itr)->ToUnit()->Mount(display_id);
@@ -128,7 +128,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
{
case SMART_SCRIPT_TYPE_CREATURE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>((uint32)temp.entryOrGuid))
if (!sObjectMgr->GetCreatureTemplate((uint32)temp.entryOrGuid))
{
sLog->outErrorDb("SmartAIMgr::LoadSmartAIFromDB: Creature entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
continue;
@@ -231,7 +231,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder e)
case SMART_TARGET_CREATURE_DISTANCE:
case SMART_TARGET_CREATURE_RANGE:
{
if (e.target.unitDistance.creature && !sCreatureStorage.LookupEntry<CreatureInfo>(e.target.unitDistance.creature))
if (e.target.unitDistance.creature && !sObjectMgr->GetCreatureTemplate(e.target.unitDistance.creature))
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u as target_param1, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.target.unitDistance.creature);
return false;
@@ -505,7 +505,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
case SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL:
if (e.action.morphOrMount.creature || e.action.morphOrMount.model)
{
if (e.action.morphOrMount.creature > 0 && !sCreatureStorage.LookupEntry<CreatureInfo>(e.action.morphOrMount.creature))
if (e.action.morphOrMount.creature > 0 && !sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.morphOrMount.creature);
return false;
@@ -1264,7 +1264,7 @@ class SmartAIMgr
}
inline bool IsCreatureValid(SmartScriptHolder e, uint32 entry)
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(entry))
if (!sObjectMgr->GetCreatureTemplate(entry))
{
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Creature entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
return false;
@@ -110,7 +110,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
case ACHIEVEMENT_CRITERIA_DATA_INSTANCE_SCRIPT:
return true;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE:
if (!creature.id || !ObjectMgr::GetCreatureTemplate(creature.id))
if (!creature.id || !sObjectMgr->GetCreatureTemplate(creature.id))
{
sLog->outErrorDb("Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_CREATURE (%u) has non-existing creature id in value1 (%u), ignored.",
criteria->ID, criteria->requiredType,dataType,creature.id);
@@ -2406,7 +2406,7 @@ void AchievementGlobalMgr::LoadRewards()
//check mail data before item for report including wrong item case
if (reward.sender)
{
if (!ObjectMgr::GetCreatureTemplate(reward.sender))
if (!sObjectMgr->GetCreatureTemplate(reward.sender))
{
sLog->outErrorDb("Table `achievement_reward` (Entry: %u) has invalid creature entry %u as sender, mail reward skipped.", entry, reward.sender);
reward.sender = 0;
@@ -748,7 +748,7 @@ bool AuctionEntry::LoadFromDB(Field* fields)
return false;
}
CreatureInfo const* auctioneerInfo = ObjectMgr::GetCreatureTemplate(auctioneerData->id);
CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id);
if (!auctioneerInfo)
{
sLog->outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", Id, auctioneer, auctioneerData->id);
@@ -1497,7 +1497,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
pCreature->SetHomePosition(x, y, z, o);
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(entry);
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
sLog->outError("Battleground::AddCreature: creature template (entry: %u) does not exist for BG (map: %u, instance id: %u)!",
+1 -1
View File
@@ -762,7 +762,7 @@ bool ChatHandler::HandleCreatePetCommand(const char* /*args*/)
return false;
}
CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(creatureTarget->GetEntry());
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
// Creatures with family 0 crashes the server
if (cInfo->family == 0)
{
+10 -13
View File
@@ -684,7 +684,7 @@ bool ChatHandler::HandleListCreatureCommand(const char *args)
return false;
}
CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(cr_id);
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cr_id);
if (!cInfo)
{
PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id);
@@ -1223,21 +1223,18 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args)
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
for (uint32 id = 0; id< sCreatureStorage.MaxEntry; ++id)
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo> (id);
if (!cInfo)
continue;
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
uint32 id = itr->second.Entry;
uint8 localeIndex = GetSessionDbLocaleIndex();
if (localeIndex >= 0)
{
uint8 uloc_idx = uint8(loc_idx);
if (CreatureLocale const *cl = sObjectMgr->GetCreatureLocale (id))
if (CreatureLocale const *cl = sObjectMgr->GetCreatureLocale(id))
{
if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty ())
if (cl->Name.size() > localeIndex && !cl->Name[localeIndex].empty ())
{
std::string name = cl->Name[uloc_idx];
std::string name = cl->Name[localeIndex];
if (Utf8FitTo (name, wnamepart))
{
@@ -1261,7 +1258,7 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args)
}
}
std::string name = cInfo->Name;
std::string name = itr->second.Name;
if (name.empty ())
continue;
+7 -7
View File
@@ -908,7 +908,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
}
case CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(cond->mSourceEntry))
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceEntry))
{
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceEntry);
return false;
@@ -1000,7 +1000,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
break;
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(cond->mSourceGroup))
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceGroup))
{
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
return false;
@@ -1237,13 +1237,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
case SPELL_TARGET_TYPE_CREATURE:
case SPELL_TARGET_TYPE_DEAD:
{
if (cond->mConditionValue2 && !sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue2))
if (cond->mConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->mConditionValue2))
{
sLog->outErrorDb("SpellTarget condition has non existing creature template entry (%u) as target, skipped", cond->mConditionValue2);
return false;
}
const CreatureInfo* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue2);
const CreatureTemplate* cInfo = sObjectMgr->GetCreatureTemplate(cond->mConditionValue2);
if (cond->mSourceEntry == 30427 && !cInfo->SkinLootId)
{
sLog->outErrorDb("SpellTarget condition has creature entry %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!, skipped", cond->mConditionValue2);
@@ -1256,7 +1256,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
case CONDITION_CREATURE_TARGET:
{
if (!cond->mConditionValue1 && !sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue1))
if (!cond->mConditionValue1 && !sObjectMgr->GetCreatureTemplate(cond->mConditionValue1))
{
sLog->outErrorDb("CreatureTarget condition has non existing creature template entry (%u) as target, skipped", cond->mConditionValue1);
return false;
@@ -1308,7 +1308,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
return false;
}
if (!cond->mConditionValue2 && !sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue2))
if (!cond->mConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->mConditionValue2))
{
sLog->outErrorDb("ItemTarget condition has non existing creature template entry (%u) as target, skipped", cond->mConditionValue2);
return false;
@@ -1360,7 +1360,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
case CONDITION_NEAR_CREATURE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue1))
if (!sObjectMgr->GetCreatureTemplate(cond->mConditionValue1))
{
sLog->outErrorDb("NearCreature condition has non existing creature template entry (%u), skipped", cond->mConditionValue1);
return false;
+22 -22
View File
@@ -82,7 +82,7 @@ VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extend
return NULL;
}
uint32 CreatureInfo::GetRandomValidModelId() const
uint32 CreatureTemplate::GetRandomValidModelId() const
{
uint8 c = 0;
uint32 modelIDs[4];
@@ -95,7 +95,7 @@ uint32 CreatureInfo::GetRandomValidModelId() const
return ((c>0) ? modelIDs[urand(0,c-1)] : 0);
}
uint32 CreatureInfo::GetFirstValidModelId() const
uint32 CreatureTemplate::GetFirstValidModelId() const
{
if (Modelid1) return Modelid1;
if (Modelid2) return Modelid2;
@@ -254,7 +254,7 @@ void Creature::RemoveCorpse(bool setSpawnTime)
*/
bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData *data)
{
CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
CreatureTemplate const *normalInfo = sObjectMgr->GetCreatureTemplate(Entry);
if (!normalInfo)
{
sLog->outErrorDb("Creature::InitEntry creature entry %u does not exist.", Entry);
@@ -262,13 +262,13 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData *data
}
// get difficulty 1 mode entry
CreatureInfo const *cinfo = normalInfo;
CreatureTemplate const *cinfo = normalInfo;
for (uint8 diff = uint8(GetMap()->GetSpawnMode()); diff > 0;)
{
// we already have valid Map pointer for current creature!
if (normalInfo->DifficultyEntry[diff - 1])
{
cinfo = ObjectMgr::GetCreatureTemplate(normalInfo->DifficultyEntry[diff - 1]);
cinfo = sObjectMgr->GetCreatureTemplate(normalInfo->DifficultyEntry[diff - 1]);
if (cinfo)
break; // template found
@@ -347,7 +347,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
if (!InitEntry(Entry,team,data))
return false;
CreatureInfo const* cInfo = GetCreatureInfo();
CreatureTemplate const* cInfo = GetCreatureInfo();
m_regenHealth = cInfo->RegenHealth;
@@ -382,12 +382,12 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(getLevel(), cInfo->unit_class);
float armor = (float)stats->GenerateArmor(cInfo); // TODO: Why is this treated as uint32 when it's a float?
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, armor);
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(cInfo->resistance1));
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(cInfo->resistance2));
SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(cInfo->resistance3));
SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(cInfo->resistance4));
SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(cInfo->resistance5));
SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(cInfo->resistance6));
SetModifierValue(UNIT_MOD_RESISTANCE_HOLY, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_HOLY]));
SetModifierValue(UNIT_MOD_RESISTANCE_FIRE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FIRE]));
SetModifierValue(UNIT_MOD_RESISTANCE_NATURE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_NATURE]));
SetModifierValue(UNIT_MOD_RESISTANCE_FROST, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_FROST]));
SetModifierValue(UNIT_MOD_RESISTANCE_SHADOW, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_SHADOW]));
SetModifierValue(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(cInfo->resistance[SPELL_SCHOOL_ARCANE]));
SetCanModifyStats(true);
UpdateAllStats();
@@ -739,7 +739,7 @@ bool Creature::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry,
SetMap(map);
SetPhaseMask(phaseMask,false);
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(Entry);
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(Entry);
if (!cinfo)
{
sLog->outErrorDb("Creature::Create(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, Entry);
@@ -1048,7 +1048,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS);
// check if it's a custom model and if not, use 0 for displayId
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
if (cinfo)
{
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
@@ -1124,7 +1124,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
WorldDatabase.CommitTransaction(trans);
}
void Creature::SelectLevel(const CreatureInfo *cinfo)
void Creature::SelectLevel(const CreatureTemplate *cinfo)
{
uint32 rank = isPet()? 0 : cinfo->rank;
@@ -1239,7 +1239,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, uint3
return false;
}
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(Entry);
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(Entry);
if (!cinfo)
{
sLog->outErrorDb("Creature::CreateFromProto(): creature template (guidlow: %u, entry: %u) does not exist.", guidlow, Entry);
@@ -1542,7 +1542,7 @@ void Creature::setDeathState(DeathState s)
SetFullHealth();
SetLootRecipient(NULL);
ResetPlayerDamageReq();
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
if (GetCreatureInfo()->InhabitType & INHABIT_AIR)
AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING);
@@ -1604,7 +1604,7 @@ void Creature::Respawn(bool force)
if (m_originalEntry != GetEntry())
UpdateEntry(m_originalEntry);
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
SelectLevel(cinfo);
if (m_isDeadByDefault)
@@ -2255,7 +2255,7 @@ void Creature::AllLootRemovedFromCorpse()
return;
float decayRate;
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
decayRate = sWorld->getRate(RATE_CORPSE_DECAY_LOOTED);
uint32 diff = uint32((m_corpseRemoveTime - now) * decayRate);
@@ -2285,7 +2285,7 @@ uint8 Creature::getLevelForTarget(WorldObject const* target) const
std::string Creature::GetAIName() const
{
return ObjectMgr::GetCreatureTemplate(GetEntry())->AIName;
return sObjectMgr->GetCreatureTemplate(GetEntry())->AIName;
}
std::string Creature::GetScriptName() const
@@ -2295,7 +2295,7 @@ std::string Creature::GetScriptName() const
uint32 Creature::GetScriptId() const
{
return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID;
return sObjectMgr->GetCreatureTemplate(GetEntry())->ScriptID;
}
VendorItemData const* Creature::GetVendorItems() const
@@ -2416,6 +2416,6 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
bool Creature::IsDungeonBoss() const
{
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(GetEntry());
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
}
+15 -18
View File
@@ -77,7 +77,7 @@ enum CreatureFlagsExtra
#define MAX_CREATURE_QUEST_ITEMS 6
// from `creature_template` table
struct CreatureInfo
struct CreatureTemplate
{
uint32 Entry;
uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
@@ -86,9 +86,9 @@ struct CreatureInfo
uint32 Modelid2;
uint32 Modelid3;
uint32 Modelid4;
char* Name;
char* SubName;
char* IconName;
std::string Name;
std::string SubName;
std::string IconName;
uint32 GossipMenuId;
uint8 minlevel;
uint8 maxlevel;
@@ -123,18 +123,13 @@ struct CreatureInfo
uint32 lootid;
uint32 pickpocketLootId;
uint32 SkinLootId;
int32 resistance1;
int32 resistance2;
int32 resistance3;
int32 resistance4;
int32 resistance5;
int32 resistance6;
int32 resistance[MAX_SPELL_SCHOOL];
uint32 spells[CREATURE_MAX_SPELLS];
uint32 PetSpellDataId;
uint32 VehicleId;
uint32 mingold;
uint32 maxgold;
char const* AIName;
std::string AIName;
uint32 MovementType;
uint32 InhabitType;
float ModHealth;
@@ -174,6 +169,9 @@ struct CreatureInfo
}
};
// Benchmarked: Faster than std::map (insert/find)
typedef UNORDERED_MAP<uint32, CreatureTemplate> CreatureTemplateContainer;
// Represents max amount of expansions.
// TODO: Add MAX_EXPANSION constant.
#define MAX_CREATURE_BASE_HP 3
@@ -187,12 +185,12 @@ struct CreatureBaseStats
// Helpers
uint32 GenerateHealth(CreatureInfo const* info) const
uint32 GenerateHealth(CreatureTemplate const* info) const
{
return uint32((BaseHealth[info->expansion] * info->ModHealth) + 0.5f);
}
uint32 GenerateMana(CreatureInfo const* info) const
uint32 GenerateMana(CreatureTemplate const* info) const
{
// Mana can be 0.
if (!BaseMana)
@@ -201,7 +199,7 @@ struct CreatureBaseStats
return uint32((BaseMana * info->ModMana) + 0.5f);
}
uint32 GenerateArmor(CreatureInfo const* info) const
uint32 GenerateArmor(CreatureTemplate const* info) const
{
return uint32((BaseArmor * info->ModArmor) + 0.5f);
}
@@ -422,11 +420,10 @@ class Creature : public Unit, public GridObject<Creature>
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData *data = NULL);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(const CreatureInfo *cinfo);
void SelectLevel(const CreatureTemplate *cinfo);
void LoadEquipment(uint32 equip_entry, bool force=false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
char const* GetSubName() const { return GetCreatureInfo()->SubName; }
void Update(uint32 time); // overwrited Unit::Update
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
@@ -527,7 +524,7 @@ class Creature : public Unit, public GridObject<Creature>
TrainerSpellData const* GetTrainerSpells() const;
CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
CreatureTemplate const *GetCreatureInfo() const { return m_creatureInfo; }
CreatureData const *GetCreatureData() const { return m_creatureData; }
CreatureAddon const* GetCreatureAddon() const;
@@ -721,7 +718,7 @@ class Creature : public Unit, public GridObject<Creature>
bool DisableReputationGain;
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjectMgr::GetCreatureTemplate(GetEntry())
CreatureTemplate const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->GetCreatureTemplate(GetEntry())
CreatureData const* m_creatureData;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
+1 -1
View File
@@ -585,7 +585,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
{
if (GetTypeId() == TYPEID_UNIT)
{
const CreatureInfo* cinfo = this->ToCreature()->GetCreatureInfo();
const CreatureTemplate* cinfo = this->ToCreature()->GetCreatureInfo();
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
{
if (target->isGameMaster())
+11 -21
View File
@@ -154,7 +154,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
PetType pet_type = PetType(fields[18].GetUInt8());
if (pet_type == HUNTER_PET)
{
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(petentry);
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(petentry);
if (!creatureInfo || !creatureInfo->isTameable(owner->CanTameExoticPets()))
return false;
}
@@ -187,7 +187,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
setFaction(owner->getFaction());
SetUInt32Value(UNIT_CREATED_BY_SPELL, summon_spell_id);
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
if (cinfo->type == CREATURE_TYPE_CRITTER)
{
map->Add(this->ToCreature());
@@ -754,7 +754,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
return false;
}
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
if (!cinfo)
{
sLog->outError("CreateBaseAtCreature() failed, creatureInfo is missing!");
@@ -771,7 +771,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
return true;
}
bool Pet::CreateBaseAtCreatureInfo(CreatureInfo const* cinfo, Unit * owner)
bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit * owner)
{
if (!CreateBaseAtTamed(cinfo, owner->GetMap(), owner->GetPhaseMask()))
return false;
@@ -784,7 +784,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureInfo const* cinfo, Unit * owner)
return true;
}
bool Pet::CreateBaseAtTamed(CreatureInfo const * cinfo, Map * map, uint32 phaseMask)
bool Pet::CreateBaseAtTamed(CreatureTemplate const * cinfo, Map * map, uint32 phaseMask)
{
sLog->outDebug(LOG_FILTER_PETS, "Pet::CreateBaseForTamed");
uint32 guid=sObjectMgr->GenerateLowGuid(HIGHGUID_PET);
@@ -813,7 +813,7 @@ bool Pet::CreateBaseAtTamed(CreatureInfo const * cinfo, Map * map, uint32 phaseM
// TODO: Move stat mods code to pet passive auras
bool Guardian::InitStatsForLevel(uint8 petlevel)
{
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
ASSERT(cinfo);
SetLevel(petlevel);
@@ -862,19 +862,9 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetFloatValue(OBJECT_FIELD_SCALE_X, scale);
}
//resistance
int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0};
if (cinfo && petType != HUNTER_PET)
{
createResistance[SPELL_SCHOOL_HOLY] = cinfo->resistance1;
createResistance[SPELL_SCHOOL_FIRE] = cinfo->resistance2;
createResistance[SPELL_SCHOOL_NATURE] = cinfo->resistance3;
createResistance[SPELL_SCHOOL_FROST] = cinfo->resistance4;
createResistance[SPELL_SCHOOL_SHADOW] = cinfo->resistance5;
createResistance[SPELL_SCHOOL_ARCANE] = cinfo->resistance6;
}
// Resistance
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(createResistance[i]));
SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i]));
//health, mana, armor and resistance
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel);
@@ -1056,7 +1046,7 @@ bool Pet::HaveInDiet(ItemTemplate const* item) const
if (!item->FoodType)
return false;
CreatureInfo const* cInfo = GetCreatureInfo();
CreatureTemplate const* cInfo = GetCreatureInfo();
if (!cInfo)
return false;
@@ -1583,7 +1573,7 @@ bool Pet::resetTalents(bool no_cost)
if (owner->ToPlayer()->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
owner->ToPlayer()->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true);
CreatureInfo const * ci = GetCreatureInfo();
CreatureTemplate const * ci = GetCreatureInfo();
if (!ci)
return false;
// Check pet talent type
@@ -1888,7 +1878,7 @@ bool Pet::HasSpell(uint32 spell) const
// Get all passive spells in our skill line
void Pet::LearnPetPassives()
{
CreatureInfo const* cInfo = GetCreatureInfo();
CreatureTemplate const* cInfo = GetCreatureInfo();
if (!cInfo)
return;
+2 -2
View File
@@ -138,8 +138,8 @@ class Pet : public Guardian
bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
bool CreateBaseAtCreature(Creature* creature);
bool CreateBaseAtCreatureInfo(CreatureInfo const* cinfo,Unit * owner);
bool CreateBaseAtTamed(CreatureInfo const * cinfo, Map * map, uint32 phaseMask);
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo,Unit * owner);
bool CreateBaseAtTamed(CreatureTemplate const * cinfo, Map * map, uint32 phaseMask);
bool LoadPetFromDB(Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false);
bool isBeingLoaded() const { return m_loading;}
void SavePetToDB(PetSaveMode mode);
+5 -5
View File
@@ -1942,7 +1942,7 @@ bool Player::BuildEnumData(QueryResult result, WorldPacket* data)
if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (plrClass == CLASS_WARLOCK || plrClass == CLASS_HUNTER || plrClass == CLASS_DEATH_KNIGHT))
{
uint32 entry = fields[16].GetUInt32();
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(entry);
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(entry);
if (creatureInfo)
{
petDisplayId = fields[17].GetUInt32();
@@ -15701,7 +15701,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count)
UpdateForQuestWorldObjects();
}
void Player::KilledMonster(CreatureInfo const* cInfo, uint64 guid)
void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid)
{
if (cInfo->Entry)
KilledMonsterCredit(cInfo->Entry, guid);
@@ -15814,7 +15814,7 @@ void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
reqTarget = qInfo->ReqCreatureOrGOId[j];
if (reqTarget != entry) // if entry doesn't match, check for killcredits referenced in template
{
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(entry);
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(entry);
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
if (cinfo->KillCredit[i] == reqTarget)
entry = cinfo->KillCredit[i];
@@ -23533,7 +23533,7 @@ void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank)
if (!talentTabInfo)
return;
CreatureInfo const *ci = pet->GetCreatureInfo();
CreatureTemplate const *ci = pet->GetCreatureInfo();
if (!ci)
return;
@@ -23787,7 +23787,7 @@ void Player::BuildPetTalentsInfoData(WorldPacket *data)
data->put<uint32>(pointsPos, unspentTalentPoints); // put real points
CreatureInfo const *ci = pet->GetCreatureInfo();
CreatureTemplate const *ci = pet->GetCreatureInfo();
if (!ci)
return;
+1 -1
View File
@@ -1428,7 +1428,7 @@ class Player : public Unit, public GridObject<Player>
void GroupEventHappens(uint32 questId, WorldObject const* pEventObject);
void ItemAddedQuestCheck(uint32 entry, uint32 count);
void ItemRemovedQuestCheck(uint32 entry, uint32 count);
void KilledMonster(CreatureInfo const* cInfo, uint64 guid);
void KilledMonster(CreatureTemplate const* cInfo, uint64 guid);
void KilledMonsterCredit(uint32 entry, uint64 guid);
void CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id);
void TalkedToCreature(uint32 entry, uint64 guid);
+1 -1
View File
@@ -54,7 +54,7 @@ void Totem::InitStats(uint32 duration)
{
Minion::InitStats(duration);
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureTemplate const *cinfo = GetCreatureInfo();
if (m_owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 displayID = sObjectMgr->ChooseDisplayId(m_owner->ToPlayer()->GetTeam(), cinfo);
+5 -5
View File
@@ -14744,7 +14744,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id)
if (GetTypeId() != TYPEID_PLAYER)
return NULL;
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creatureEntry);
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry);
if (!creatureInfo)
return NULL;
@@ -15165,7 +15165,7 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss)
if (!creature->isPet())
{
creature->DeleteThreatList();
CreatureInfo const* cInfo = creature->GetCreatureInfo();
CreatureTemplate const* cInfo = creature->GetCreatureInfo();
if (cInfo && (cInfo->lootid || cInfo->maxgold > 0))
creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
}
@@ -15603,7 +15603,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const * a
case CHARM_TYPE_CHARM:
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
CreatureInfo const *cinfo = this->ToCreature()->GetCreatureInfo();
CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo();
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
//to prevent client crash
@@ -15707,7 +15707,7 @@ void Unit::RemoveCharmedBy(Unit *charmer)
case CHARM_TYPE_CHARM:
if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK)
{
CreatureInfo const *cinfo = this->ToCreature()->GetCreatureInfo();
CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo();
if (cinfo && cinfo->type == CREATURE_TYPE_DEMON)
{
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
@@ -15746,7 +15746,7 @@ void Unit::RestoreFaction()
}
}
if (CreatureInfo const *cinfo = this->ToCreature()->GetCreatureInfo()) // normal creature
if (CreatureTemplate const *cinfo = this->ToCreature()->GetCreatureInfo()) // normal creature
{
FactionTemplateEntry const *faction = getFactionTemplateEntry();
setFaction((faction && faction->friendlyMask & 0x004) ? cinfo->faction_H : cinfo->faction_A);
+2 -2
View File
@@ -1114,7 +1114,7 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id)
if (cr)
{
uint32 npcflag = GetNPCFlag(cr);
if (const CreatureInfo * ci = cr->GetCreatureInfo())
if (const CreatureTemplate * ci = cr->GetCreatureInfo())
npcflag |= ci->npcflag;
cr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag);
// reset gossip options, since the flag change might have added / removed some
@@ -1330,7 +1330,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
CreatureData const* data2 = sObjectMgr->GetCreatureData(itr->first);
if (data2 && activate)
{
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(data2->id);
CreatureTemplate const *cinfo = sObjectMgr->GetCreatureTemplate(data2->id);
uint32 displayID = sObjectMgr->ChooseDisplayId(0,cinfo,data2);
CreatureModelInfo const *minfo = sObjectMgr->GetCreatureModelRandomGender(displayID);
+209 -78
View File
@@ -547,17 +547,143 @@ void ObjectMgr::LoadCreatureTemplates()
{
uint32 oldMSTime = getMSTime();
SQLCreatureLoader loader;
loader.Load(sCreatureStorage);
// 0 1 2 3 4 5 6 7 8
QueryResult result = WorldDatabase.Query("SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, "
// 9 10 11 12 13 14 15 16 17 18 19 20 21
"modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, "
// 22 23 24 25 26 27 28 29 30 31 32
"scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, "
// 33 34 35 36 37 38 39 40 41 42
"dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, "
// 43 44 45 46 47 48 49 50 51 52 53
"type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, "
// 54 55 56 57 58 59 60 61 62 63 64 65 66
"spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, "
// 67 68 69 70 71 72 73 74 75 76 77
"InhabitType, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, "
// 78 79 80 81 82 83
"movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName "
"FROM creature_template;");
// check data correctness
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
if (!result)
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i);
CheckCreatureTemplate(cInfo);
sLog->outString(">> Loaded 0 creature template definitions. DB table `creature_template` is empty.");
sLog->outString();
return;
}
sLog->outString(">> Loaded %u creature definitions in %u ms", sCreatureStorage.RecordCount, GetMSTimeDiffToNow(oldMSTime));
uint32 count = 0;
do
{
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
CreatureTemplate creatureTemplate;
creatureTemplate.Entry = entry;
for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
{
creatureTemplate.DifficultyEntry[i] = fields[1 + i].GetUInt32();
}
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
{
creatureTemplate.KillCredit[i] = fields[4 + i].GetUInt32();
}
creatureTemplate.Modelid1 = fields[6].GetUInt32();
creatureTemplate.Modelid2 = fields[7].GetUInt32();
creatureTemplate.Modelid3 = fields[8].GetUInt32();
creatureTemplate.Modelid4 = fields[9].GetUInt32();
creatureTemplate.Name = fields[10].GetString();
creatureTemplate.SubName = fields[11].GetString();
creatureTemplate.IconName = fields[12].GetString();
creatureTemplate.GossipMenuId = fields[13].GetUInt32();
creatureTemplate.minlevel = fields[14].GetUInt8();
creatureTemplate.maxlevel = fields[15].GetUInt8();
creatureTemplate.expansion = uint32(fields[16].GetUInt16());
creatureTemplate.faction_A = uint32(fields[17].GetUInt16());
creatureTemplate.faction_H = uint32(fields[18].GetUInt16());
creatureTemplate.npcflag = fields[19].GetUInt32();
creatureTemplate.speed_walk = fields[20].GetFloat();
creatureTemplate.speed_run = fields[21].GetFloat();
creatureTemplate.scale = fields[22].GetFloat();
creatureTemplate.rank = uint32(fields[23].GetUInt8());
creatureTemplate.mindmg = fields[24].GetFloat();
creatureTemplate.maxdmg = fields[25].GetFloat();
creatureTemplate.dmgschool = uint32(fields[26].GetInt8());
creatureTemplate.attackpower = fields[27].GetUInt32();
creatureTemplate.dmg_multiplier = fields[28].GetFloat();
creatureTemplate.baseattacktime = fields[29].GetUInt32();
creatureTemplate.rangeattacktime = fields[30].GetUInt32();
creatureTemplate.unit_class = uint32(fields[31].GetUInt8());
creatureTemplate.unit_flags = fields[32].GetUInt32();
creatureTemplate.dynamicflags = fields[33].GetUInt32();
creatureTemplate.family = uint32(fields[34].GetUInt8());
creatureTemplate.trainer_type = uint32(fields[35].GetUInt8());
creatureTemplate.trainer_spell = fields[36].GetUInt32();
creatureTemplate.trainer_class = uint32(fields[37].GetUInt8());
creatureTemplate.trainer_race = uint32(fields[38].GetUInt8());
creatureTemplate.minrangedmg = fields[39].GetFloat();
creatureTemplate.maxrangedmg = fields[40].GetFloat();
creatureTemplate.rangedattackpower = uint32(fields[41].GetUInt16());
creatureTemplate.type = uint32(fields[42].GetUInt8());
creatureTemplate.type_flags = fields[43].GetUInt32();
creatureTemplate.lootid = fields[44].GetUInt32();
creatureTemplate.pickpocketLootId = fields[45].GetUInt32();
creatureTemplate.SkinLootId = fields[46].GetUInt32();
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
{
creatureTemplate.resistance[i] = fields[47 + i -1].GetInt32();
}
for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{
creatureTemplate.spells[i] = fields[53 + i].GetUInt32();
}
creatureTemplate.PetSpellDataId = fields[61].GetUInt32();
creatureTemplate.VehicleId = fields[62].GetUInt32();
creatureTemplate.mingold = fields[63].GetUInt32();
creatureTemplate.maxgold = fields[64].GetUInt32();
creatureTemplate.AIName = fields[65].GetString();
creatureTemplate.MovementType = uint32(fields[66].GetUInt8());
creatureTemplate.InhabitType = uint32(fields[67].GetUInt8());
creatureTemplate.ModHealth = fields[68].GetFloat();
creatureTemplate.ModMana = fields[69].GetFloat();
creatureTemplate.ModArmor = fields[70].GetFloat();
creatureTemplate.RacialLeader = fields[71].GetBool();
for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
{
creatureTemplate.questItems[i] = fields[72 + i].GetUInt32();
}
creatureTemplate.movementId = fields[78].GetUInt32();
creatureTemplate.RegenHealth = fields[79].GetBool();
creatureTemplate.equipmentId = fields[80].GetUInt32();
creatureTemplate.MechanicImmuneMask = fields[81].GetUInt32();
creatureTemplate.flags_extra = fields[82].GetUInt32();
creatureTemplate.ScriptID = GetScriptId(fields[83].GetCString());
// Add to map
CreatureTemplateStore[entry] = creatureTemplate;
++count;
}
while (result->NextRow());
// Checking needs to be done after loading because of the difficulty self referencing
for (CreatureTemplateContainer::const_iterator itr = CreatureTemplateStore.begin(); itr != CreatureTemplateStore.end(); ++itr)
{
CheckCreatureTemplate(&itr->second);
}
sLog->outString(">> Loaded %u creature definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
@@ -582,7 +708,7 @@ void ObjectMgr::LoadCreatureTemplateAddons()
uint32 entry = fields[0].GetUInt32();
if (!sCreatureStorage.LookupEntry<CreatureInfo>(entry))
if (!sObjectMgr->GetCreatureTemplate(entry))
{
sLog->outErrorDb("Creature template (Entry: %u) does not exist but has a record in `creature_template_addon`", entry);
continue;
@@ -632,7 +758,7 @@ void ObjectMgr::LoadCreatureTemplateAddons()
sLog->outString();
}
void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
{
if (!cInfo)
return;
@@ -644,7 +770,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
continue;
ok = false; // will be set to true at the end of this loop again
CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
CreatureTemplate const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
if (!difficultyInfo)
{
sLog->outErrorDb("Creature (Entry: %u) has `difficulty_entry_%u`=%u but creature entry %u does not exist.",
@@ -717,7 +843,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
continue;
}
if (difficultyInfo->AIName && *difficultyInfo->AIName)
if (!difficultyInfo->AIName.empty())
{
sLog->outErrorDb("Creature (Entry: %u) lists difficulty %u mode entry %u with `AIName` filled in. `AIName` of difficulty 0 mode creature is always used instead.",
cInfo->Entry, diff + 1, cInfo->DifficultyEntry[diff]);
@@ -753,7 +879,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!displayEntry)
{
sLog->outErrorDb("Creature (Entry: %u) lists non-existing Modelid1 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid1);
const_cast<CreatureInfo*>(cInfo)->Modelid1 = 0;
const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
@@ -769,7 +895,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!displayEntry)
{
sLog->outErrorDb("Creature (Entry: %u) lists non-existing Modelid2 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid2);
const_cast<CreatureInfo*>(cInfo)->Modelid2 = 0;
const_cast<CreatureTemplate*>(cInfo)->Modelid2 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
@@ -785,7 +911,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!displayEntry)
{
sLog->outErrorDb("Creature (Entry: %u) lists non-existing Modelid3 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid3);
const_cast<CreatureInfo*>(cInfo)->Modelid3 = 0;
const_cast<CreatureTemplate*>(cInfo)->Modelid3 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
@@ -801,7 +927,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!displayEntry)
{
sLog->outErrorDb("Creature (Entry: %u) lists non-existing Modelid4 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid4);
const_cast<CreatureInfo*>(cInfo)->Modelid4 = 0;
const_cast<CreatureTemplate*>(cInfo)->Modelid4 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
@@ -821,7 +947,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!GetCreatureTemplate(cInfo->KillCredit[k]))
{
sLog->outErrorDb("Creature (Entry: %u) lists non-existing creature entry %u in `KillCredit%d`.", cInfo->Entry, cInfo->KillCredit[k], k + 1);
const_cast<CreatureInfo*>(cInfo)->KillCredit[k] = 0;
const_cast<CreatureTemplate*>(cInfo)->KillCredit[k] = 0;
}
}
}
@@ -829,20 +955,20 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!cInfo->unit_class || ((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0)
{
sLog->outErrorDb("Creature (Entry: %u) has invalid unit_class (%u) in creature_template. Set to 1 (UNIT_CLASS_WARRIOR).", cInfo->Entry, cInfo->unit_class);
const_cast<CreatureInfo*>(cInfo)->unit_class = UNIT_CLASS_WARRIOR;
const_cast<CreatureTemplate*>(cInfo)->unit_class = UNIT_CLASS_WARRIOR;
}
if (cInfo->dmgschool >= MAX_SPELL_SCHOOL)
{
sLog->outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`.", cInfo->Entry, cInfo->dmgschool);
const_cast<CreatureInfo*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
const_cast<CreatureTemplate*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
}
if (cInfo->baseattacktime == 0)
const_cast<CreatureInfo*>(cInfo)->baseattacktime = BASE_ATTACK_TIME;
const_cast<CreatureTemplate*>(cInfo)->baseattacktime = BASE_ATTACK_TIME;
if (cInfo->rangeattacktime == 0)
const_cast<CreatureInfo*>(cInfo)->rangeattacktime = BASE_ATTACK_TIME;
const_cast<CreatureTemplate*>(cInfo)->rangeattacktime = BASE_ATTACK_TIME;
if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE)
sLog->outErrorDb("Creature (Entry: %u) has wrong trainer type %u.", cInfo->Entry, cInfo->trainer_type);
@@ -850,20 +976,20 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type))
{
sLog->outErrorDb("Creature (Entry: %u) has invalid creature type (%u) in `type`.", cInfo->Entry, cInfo->type);
const_cast<CreatureInfo*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
const_cast<CreatureTemplate*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
}
// must exist or used hidden but used in data horse case
if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM)
{
sLog->outErrorDb("Creature (Entry: %u) has invalid creature family (%u) in `family`.", cInfo->Entry, cInfo->family);
const_cast<CreatureInfo*>(cInfo)->family = 0;
const_cast<CreatureTemplate*>(cInfo)->family = 0;
}
if (cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE)
{
sLog->outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly.", cInfo->Entry, cInfo->InhabitType);
const_cast<CreatureInfo*>(cInfo)->InhabitType = INHABIT_ANYWHERE;
const_cast<CreatureTemplate*>(cInfo)->InhabitType = INHABIT_ANYWHERE;
}
if (cInfo->VehicleId)
@@ -872,7 +998,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!vehId)
{
sLog->outErrorDb("Creature (Entry: %u) has a non-existing VehicleId (%u). This *WILL* cause the client to freeze!", cInfo->Entry, cInfo->VehicleId);
const_cast<CreatureInfo*>(cInfo)->VehicleId = 0;
const_cast<CreatureTemplate*>(cInfo)->VehicleId = 0;
}
}
@@ -888,14 +1014,14 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j]))
{
sLog->outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0.", cInfo->Entry, j+1, cInfo->spells[j]);
const_cast<CreatureInfo*>(cInfo)->spells[j] = 0;
const_cast<CreatureTemplate*>(cInfo)->spells[j] = 0;
}
}
if (cInfo->MovementType >= MAX_DB_MOTION_TYPE)
{
sLog->outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignored and set to IDLE.", cInfo->Entry, cInfo->MovementType);
const_cast<CreatureInfo*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
}
if (cInfo->equipmentId > 0) // 0 no equipment
@@ -903,7 +1029,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (!GetEquipmentInfo(cInfo->equipmentId))
{
sLog->outErrorDb("Table `creature_template` lists creature (Entry: %u) with `equipment_id` %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId);
const_cast<CreatureInfo*>(cInfo)->equipmentId = 0;
const_cast<CreatureTemplate*>(cInfo)->equipmentId = 0;
}
}
@@ -911,24 +1037,24 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
if (cInfo->scale <= 0.0f)
{
if (displayScaleEntry)
const_cast<CreatureInfo*>(cInfo)->scale = displayScaleEntry->scale;
const_cast<CreatureTemplate*>(cInfo)->scale = displayScaleEntry->scale;
else
const_cast<CreatureInfo*>(cInfo)->scale = 1.0f;
const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
}
if (cInfo->expansion > (MAX_CREATURE_BASE_HP - 1))
{
sLog->outErrorDb("Table `creature_template` lists creature (Entry: %u) with expansion %u. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
const_cast<CreatureInfo*>(cInfo)->expansion = 0;
const_cast<CreatureTemplate*>(cInfo)->expansion = 0;
}
if (uint32 badFlags = (cInfo->flags_extra & ~CREATURE_FLAG_EXTRA_DB_ALLOWED))
{
sLog->outErrorDb("Table `creature_template` lists creature (Entry: %u) with disallowed `flags_extra` %u, removing incorrect flag.", cInfo->Entry, badFlags);
const_cast<CreatureInfo*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
const_cast<CreatureTemplate*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
}
const_cast<CreatureInfo*>(cInfo)->dmg_multiplier *= Creature::_GetDamageMod(cInfo->rank);
const_cast<CreatureTemplate*>(cInfo)->dmg_multiplier *= Creature::_GetDamageMod(cInfo->rank);
}
void ObjectMgr::LoadCreatureAddons()
@@ -1105,7 +1231,7 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelId)
return NULL;
}
uint32 ObjectMgr::ChooseDisplayId(uint32 /*team*/, const CreatureInfo *cinfo, const CreatureData *data /*= NULL*/)
uint32 ObjectMgr::ChooseDisplayId(uint32 /*team*/, const CreatureTemplate *cinfo, const CreatureData *data /*= NULL*/)
{
// Load creature model (display id)
uint32 display_id = 0;
@@ -1120,7 +1246,7 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 /*team*/, const CreatureInfo *cinfo, co
return display_id;
}
void ObjectMgr::ChooseCreatureFlags(const CreatureInfo *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data /*= NULL*/)
void ObjectMgr::ChooseCreatureFlags(const CreatureTemplate *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data /*= NULL*/)
{
npcflag = cinfo->npcflag;
unit_flags = cinfo->unit_flags;
@@ -1473,11 +1599,12 @@ void ObjectMgr::LoadCreatures()
// Build single time for check creature data
std::set<uint32> difficultyCreatures[MAX_DIFFICULTY - 1];
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
if (cInfo->DifficultyEntry[diff])
difficultyCreatures[diff].insert(cInfo->DifficultyEntry[diff]);
if (itr->second.DifficultyEntry[diff])
difficultyCreatures[diff].insert(itr->second.DifficultyEntry[diff]);
// Build single time for check spawnmask
std::map<uint32,uint32> spawnMasks;
@@ -1495,7 +1622,7 @@ void ObjectMgr::LoadCreatures()
uint32 guid = fields[ 0].GetUInt32();
uint32 entry = fields[ 1].GetUInt32();
CreatureInfo const* cInfo = GetCreatureTemplate(entry);
CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
if (!cInfo)
{
sLog->outErrorDb("Table `creature` has creature (GUID: %u) with non existing creature entry %u, skipped.", guid, entry);
@@ -1733,7 +1860,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos)
uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay)
{
CreatureInfo const *cInfo = GetCreatureTemplate(entry);
CreatureTemplate const *cInfo = GetCreatureTemplate(entry);
if (!cInfo)
return 0;
@@ -2905,13 +3032,13 @@ void ObjectMgr::LoadVehicleTemplateAccessories()
uint8 uiSummonType = fields[4].GetUInt8();
uint32 uiSummonTimer= fields[5].GetUInt32();
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiEntry))
if (!sObjectMgr->GetCreatureTemplate(uiEntry))
{
sLog->outErrorDb("Table `vehicle_template_accessory`: creature template entry %u does not exist.", uiEntry);
continue;
}
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiAccessory))
if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
{
sLog->outErrorDb("Table `vehicle_template_accessory`: Accessory %u does not exist.", uiAccessory);
continue;
@@ -2961,7 +3088,7 @@ void ObjectMgr::LoadVehicleAccessories()
uint8 uiSummonType = fields[4].GetUInt8();
uint32 uiSummonTimer= fields[5].GetUInt32();
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiAccessory))
if (!sObjectMgr->GetCreatureTemplate(uiAccessory))
{
sLog->outErrorDb("Table `vehicle_accessory`: Accessory %u does not exist.", uiAccessory);
continue;
@@ -3040,7 +3167,7 @@ void ObjectMgr::LoadPetLevelInfo()
Field* fields = result->Fetch();
uint32 creature_id = fields[0].GetUInt32();
if (!sCreatureStorage.LookupEntry<CreatureInfo>(creature_id))
if (!sObjectMgr->GetCreatureTemplate(creature_id))
{
sLog->outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.",creature_id);
continue;
@@ -4733,7 +4860,7 @@ void ObjectMgr::LoadQuests()
qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
}
if (id > 0 && !sCreatureStorage.LookupEntry<CreatureInfo>(id))
if (id > 0 && !sObjectMgr->GetCreatureTemplate(id))
{
sLog->outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,uint32(id));
@@ -5839,13 +5966,13 @@ void ObjectMgr::LoadInstanceEncounters()
{
case ENCOUNTER_CREDIT_KILL_CREATURE:
{
CreatureInfo const* creatureInfo = GetCreatureTemplate(creditEntry);
CreatureTemplate const* creatureInfo = GetCreatureTemplate(creditEntry);
if (!creatureInfo)
{
sLog->outErrorDb("Table `instance_encounters` has an invalid creature (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
continue;
}
const_cast<CreatureInfo*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
break;
}
case ENCOUNTER_CREDIT_CAST_SPELL:
@@ -6323,7 +6450,7 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt
mount_entry = team == ALLIANCE ? node->MountCreatureID[0] : node->MountCreatureID[1];
}
CreatureInfo const *mount_info = GetCreatureTemplate(mount_entry);
CreatureTemplate const *mount_info = GetCreatureTemplate(mount_entry);
if (mount_info)
{
mount_id = mount_info->GetRandomValidModelId();
@@ -7400,10 +7527,11 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
if (list0.empty() || list1.empty())
{
CreatureInfo const *cinfo = GetCreatureTemplate(entry);
CreatureTemplate const *cinfo = GetCreatureTemplate(entry);
char* petname = GetPetName(cinfo->family, sWorld->GetDefaultDbcLocale());
if (!petname)
petname = cinfo->Name;
return cinfo->Name;
return std::string(petname);
}
@@ -7842,7 +7970,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
Field *fields = result->Fetch();
uint32 npc_entry = fields[0].GetUInt32();
CreatureInfo const* cInfo = GetCreatureTemplate(npc_entry);
CreatureTemplate const* cInfo = GetCreatureTemplate(npc_entry);
if (!cInfo)
{
sLog->outErrorDb("Table npc_spellclick_spells references unknown creature_template %u. Skipping entry.", npc_entry);
@@ -7926,15 +8054,13 @@ void ObjectMgr::LoadNPCSpellClickSpells()
// all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
// NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
if (CreatureInfo const* cInfo = GetCreatureTemplate(i))
if ((itr->second.npcflag & UNIT_NPC_FLAG_SPELLCLICK) && mSpellClickInfoMap.find(itr->second.Entry) == mSpellClickInfoMap.end())
{
if ((cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK) && mSpellClickInfoMap.find(i) == mSpellClickInfoMap.end())
{
sLog->outErrorDb("npc_spellclick_spells: Creature template %u has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", i);
const_cast<CreatureInfo*>(cInfo)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
}
sLog->outErrorDb("npc_spellclick_spells: Creature template %u has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", itr->second.Entry);
const_cast<CreatureTemplate*>(&itr->second)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
}
}
@@ -8169,7 +8295,7 @@ void ObjectMgr::LoadCreatureQuestRelations()
for (QuestRelations::iterator itr = mCreatureQuestRelations.begin(); itr != mCreatureQuestRelations.end(); ++itr)
{
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
if (!cInfo)
sLog->outErrorDb("Table `creature_questrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second);
else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
@@ -8183,7 +8309,7 @@ void ObjectMgr::LoadCreatureInvolvedRelations()
for (QuestRelations::iterator itr = mCreatureQuestInvolvedRelations.begin(); itr != mCreatureQuestInvolvedRelations.end(); ++itr)
{
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
if (!cInfo)
sLog->outErrorDb("Table `creature_involvedrelation` have data for not existed creature entry (%u) and existed quest %u",itr->first,itr->second);
else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
@@ -8840,7 +8966,7 @@ void ObjectMgr::AddSpellToTrainer( uint32 entry, uint32 spell, uint32 spellCost,
if (entry >= TRINITY_TRAINER_START_REF)
return;
CreatureInfo const* cInfo = GetCreatureTemplate(entry);
CreatureTemplate const* cInfo = GetCreatureTemplate(entry);
if (!cInfo)
{
sLog->outErrorDb("Table `npc_trainer` contains an entry for a non-existing creature template (Entry: %u), ignoring", entry);
@@ -9205,7 +9331,7 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item, bool savetodb)
bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag) const
{
CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry);
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(vendor_entry);
if (!cInfo)
{
if (pl)
@@ -9447,8 +9573,7 @@ void ObjectMgr::LoadCreatureClassLevelStats()
return;
}
uint32 counter = 0;
uint32 count = 0;
do
{
Field *fields = result->Fetch();
@@ -9457,45 +9582,42 @@ void ObjectMgr::LoadCreatureClassLevelStats()
uint8 Class = fields[1].GetUInt8();
CreatureBaseStats stats;
for (uint8 i = 0; i < MAX_CREATURE_BASE_HP; ++i)
stats.BaseHealth[i] = fields[i + 2].GetUInt32();
stats.BaseMana = fields[5].GetUInt32();
stats.BaseArmor = fields[6].GetUInt32();
if (!Class || ((1 << (Class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
sLog->outErrorDb("Creature base stats for level %u has invalid class %u",
Level, Class);
sLog->outErrorDb("Creature base stats for level %u has invalid class %u", Level, Class);
for (uint8 i = 0; i < MAX_CREATURE_BASE_HP; ++i)
{
if (stats.BaseHealth[i] < 1)
{
sLog->outErrorDb("Creature base stats for class %u, level %u has invalid zero base HP[%u] - set to 1",
Class, Level, i);
sLog->outErrorDb("Creature base stats for class %u, level %u has invalid zero base HP[%u] - set to 1", Class, Level, i);
stats.BaseHealth[i] = 1;
}
}
m_creatureBaseStatsMap[MAKE_PAIR16(Level, Class)] = stats;
++counter;
++count;
}
while (result->NextRow());
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
CreatureInfo const* info = sCreatureStorage.LookupEntry<CreatureInfo>(i);
if (!info)
continue;
for (uint16 lvl = info->minlevel; lvl <= info->maxlevel; ++lvl)
for (uint16 lvl = itr->second.minlevel; lvl <= itr->second.maxlevel; ++lvl)
{
if (m_creatureBaseStatsMap.find(MAKE_PAIR16(lvl, info->unit_class)) == m_creatureBaseStatsMap.end())
sLog->outErrorDb("Missing base stats for creature class %u level %u", info->unit_class, lvl);
if (m_creatureBaseStatsMap.find(MAKE_PAIR16(lvl, itr->second.unit_class)) == m_creatureBaseStatsMap.end())
sLog->outErrorDb("Missing base stats for creature class %u level %u", itr->second.unit_class, lvl);
}
}
sLog->outString(">> Loaded %u creature base stats in %u ms", counter, GetMSTimeDiffToNow(oldMSTime));
sLog->outString(">> Loaded %u creature base stats in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
@@ -9696,3 +9818,12 @@ GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry)
return NULL;
}
CreatureTemplate const* ObjectMgr::GetCreatureTemplate(uint32 entry)
{
CreatureTemplateContainer::const_iterator itr = CreatureTemplateStore.find(entry);
if (itr != CreatureTemplateStore.end())
return &(itr->second);
return NULL;
}
+6 -5
View File
@@ -44,7 +44,6 @@
#include "ConditionMgr.h"
#include <functional>
extern SQLStorage sCreatureStorage;
class Group;
class Guild;
@@ -671,11 +670,12 @@ class ObjectMgr
ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); }
static CreatureInfo const *GetCreatureTemplate(uint32 id) { return sCreatureStorage.LookupEntry<CreatureInfo>(id); }
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
CreatureTemplateContainer const* GetCreatureTemplates() { return &CreatureTemplateStore; }
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId);
CreatureModelInfo const* GetCreatureModelRandomGender(uint32 &displayID);
uint32 ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data = NULL);
static void ChooseCreatureFlags(const CreatureInfo *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data = NULL);
uint32 ChooseDisplayId(uint32 team, const CreatureTemplate *cinfo, const CreatureData *data = NULL);
static void ChooseCreatureFlags(const CreatureTemplate *cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData *data = NULL);
EquipmentInfo const *GetEquipmentInfo(uint32 entry);
CreatureAddon const *GetCreatureAddon(uint32 lowguid);
CreatureAddon const *GetCreatureTemplateAddon(uint32 entry);
@@ -918,7 +918,7 @@ class ObjectMgr
void LoadCreatureLocales();
void LoadCreatureTemplates();
void LoadCreatureTemplateAddons();
void CheckCreatureTemplate(CreatureInfo const* cInfo);
void CheckCreatureTemplate(CreatureTemplate const* cInfo);
void LoadCreatures();
void LoadLinkedRespawn();
bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid);
@@ -1397,6 +1397,7 @@ class ObjectMgr
MapObjectGuids mMapObjectGuids;
CreatureDataMap mCreatureDataMap;
CreatureTemplateContainer CreatureTemplateStore;
CreatureModelContainer CreatureModelStore;
CreatureAddonContainer CreatureAddonStore;
CreatureAddonContainer CreatureTemplateAddonStore;
+26 -29
View File
@@ -1424,20 +1424,19 @@ void LoadLootTemplates_Creature()
LootIdSet ids_set, ids_setUsed;
uint32 count = LootTemplates_Creature.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
// Remove real entries and check loot existence
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (uint32 lootid = itr->second.lootid)
{
if (uint32 lootid = cInfo->lootid)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Creature.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
}
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
@@ -1614,20 +1613,19 @@ void LoadLootTemplates_Pickpocketing()
LootIdSet ids_set, ids_setUsed;
uint32 count = LootTemplates_Pickpocketing.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
// Remove real entries and check loot existence
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (uint32 lootid = itr->second.pickpocketLootId)
{
if (uint32 lootid = cInfo->pickpocketLootId)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
}
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
@@ -1709,19 +1707,18 @@ void LoadLootTemplates_Skinning()
uint32 count = LootTemplates_Skinning.LoadAndCollectLootIds(ids_set);
// remove real entries and check existence loot
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if (uint32 lootid = itr->second.SkinLootId)
{
if (uint32 lootid = cInfo->SkinLootId)
{
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
if (ids_set.find(lootid) == ids_set.end())
LootTemplates_Skinning.ReportNotExistedId(lootid);
else
ids_setUsed.insert(lootid);
}
}
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr);
+1 -1
View File
@@ -203,7 +203,7 @@ void SystemMgr::LoadScriptWaypoints()
pTemp.fZ = pFields[4].GetFloat();
pTemp.uiWaitTime = pFields[5].GetUInt32();
CreatureInfo const* pCInfo = ObjectMgr::GetCreatureTemplate(pTemp.uiCreatureEntry);
CreatureTemplate const* pCInfo = sObjectMgr->GetCreatureTemplate(pTemp.uiCreatureEntry);
if (!pCInfo)
{
@@ -134,7 +134,7 @@ void WorldSession::SendTrainerList(uint64 guid, const std::string& strTitle)
if (!unit->isCanTrainingOf(_player,true))
return;
CreatureInfo const *ci = unit->GetCreatureInfo();
CreatureTemplate const *ci = unit->GetCreatureInfo();
if (!ci)
{
@@ -704,7 +704,7 @@ void WorldSession::HandleUnstablePetCallback(QueryResult result, uint32 petnumbe
return;
}
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id);
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature_id);
if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{
// if problem in exotic pet
@@ -832,7 +832,7 @@ void WorldSession::HandleStableSwapPetCallback(QueryResult result, uint32 petnum
return;
}
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id);
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creature_id);
if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{
// if problem in exotic pet
@@ -155,7 +155,7 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket & recv_data)
uint64 guid;
recv_data >> guid;
CreatureInfo const *ci = ObjectMgr::GetCreatureTemplate(entry);
CreatureTemplate const *ci = sObjectMgr->GetCreatureTemplate(entry);
if (ci)
{
@@ -3351,7 +3351,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const * aurApp, uint8 mode,
}
else
{
CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(GetMiscValue());
CreatureTemplate const * ci = sObjectMgr->GetCreatureTemplate(GetMiscValue());
if (!ci)
{
target->SetDisplayId(16358); // pig pink ^_^
@@ -3410,7 +3410,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const * aurApp, uint8 mode,
if (!target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty())
{
uint32 cr_id = target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetMiscValue();
if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(cr_id))
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(cr_id))
{
uint32 team = 0;
if (target->GetTypeId() == TYPEID_PLAYER)
@@ -3866,7 +3866,7 @@ void AuraEffect::HandleAuraMounted(AuraApplication const * aurApp, uint8 mode, b
creatureEntry = 15665;
}
CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(creatureEntry);
CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(creatureEntry);
if (!ci)
{
sLog->outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need its modelid)",GetMiscValue());
@@ -6147,7 +6147,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
else
creatureEntry = target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetMiscValue();
if (CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creatureEntry))
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
{
uint32 team = 0;
if (target->GetTypeId() == TYPEID_PLAYER)
@@ -6389,7 +6389,7 @@ void AuraEffect::HandleAuraEmpathy(AuraApplication const * aurApp, uint8 mode, b
return;
}
CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(target->GetEntry());
CreatureTemplate const * ci = sObjectMgr->GetCreatureTemplate(target->GetEntry());
if (ci && ci->type == CREATURE_TYPE_BEAST)
target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
}
+8 -11
View File
@@ -2195,7 +2195,7 @@ void SpellMgr::LoadPetLevelupSpellMap()
sLog->outString();
}
bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
bool LoadPetDefaultSpells_helper(CreatureTemplate const* cInfo, PetDefaultSpellsEntry& petDefSpells)
{
// skip empty list;
bool have_spell = false;
@@ -2252,27 +2252,24 @@ void SpellMgr::LoadPetDefaultSpells()
uint32 countCreature = 0;
uint32 countData = 0;
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates();
for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr)
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i);
if (!cInfo)
continue;
if (!cInfo->PetSpellDataId)
if (!itr->second.PetSpellDataId)
continue;
// for creature with PetSpellDataId get default pet spells from dbc
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(itr->second.PetSpellDataId);
if (!spellDataEntry)
continue;
int32 petSpellsId = -int32(cInfo->PetSpellDataId);
int32 petSpellsId = -int32(itr->second.PetSpellDataId);
PetDefaultSpellsEntry petDefSpells;
for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
petDefSpells.spellid[j] = spellDataEntry->spellId[j];
if (LoadPetDefaultSpells_helper(cInfo, petDefSpells))
if (LoadPetDefaultSpells_helper(&itr->second, petDefSpells))
{
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
++countData;
@@ -2298,7 +2295,7 @@ void SpellMgr::LoadPetDefaultSpells()
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);
CreatureTemplate const *cInfo = sObjectMgr->GetCreatureTemplate(creature_id);
if (!cInfo)
continue;