diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
| -rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 82 |
1 files changed, 54 insertions, 28 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 71064b3d9fd..a01251af433 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -155,6 +155,16 @@ bool normalizePlayerName(std::string& name) return true; } +// Extracts player and realm names delimited by - +ExtendedPlayerName ExtractExtendedPlayerName(std::string& name) +{ + size_t pos = name.find('-'); + if (pos != std::string::npos) + return ExtendedPlayerName(name.substr(0, pos), name.substr(pos+1)); + else + return ExtendedPlayerName(name, ""); +} + LanguageDesc lang_description[LANGUAGES_COUNT] = { { LANG_ADDON, 0, 0 }, @@ -574,17 +584,17 @@ void ObjectMgr::LoadCreatureTemplateAddons() creatureAddon.auras.resize(tokens.size()); for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr) { - SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr))); + SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr)); if (!AdditionalSpellInfo) { - TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %u defined in `auras` field in `creature_template_addon`.", entry, uint32(atol(*itr))); + TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %lu defined in `auras` field in `creature_template_addon`.", entry, atoul(*itr)); continue; } if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE)) TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, uint32(atol(*itr))); - creatureAddon.auras[i++] = uint32(atol(*itr)); + creatureAddon.auras[i++] = atoul(*itr); } if (creatureAddon.mount) @@ -1022,17 +1032,18 @@ void ObjectMgr::LoadCreatureAddons() creatureAddon.auras.resize(tokens.size()); for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr) { - SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr))); + SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr)); if (!AdditionalSpellInfo) { - TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has wrong spell %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr))); + TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has wrong spell %lu defined in `auras` field in `creature_addon`.", guid, atoul(*itr)); continue; } if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE)) - TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr))); + TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has SPELL_AURA_CONTROL_VEHICLE aura %lu defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr))); - creatureAddon.auras[i++] = uint32(atol(*itr)); + + creatureAddon.auras[i++] = atoul(*itr); } if (creatureAddon.mount) @@ -1222,15 +1233,15 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32* display return NULL; // If a model for another gender exists, 50% chance to use it - if (modelInfo->modelid_other_gender != 0 && urand(0, 1) == 0) + if (modelInfo->displayId_other_gender != 0 && urand(0, 1) == 0) { - CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender); + CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->displayId_other_gender); if (!minfo_tmp) - TC_LOG_ERROR("sql.sql", "Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", *displayID, modelInfo->modelid_other_gender); + TC_LOG_ERROR("sql.sql", "Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", *displayID, modelInfo->displayId_other_gender); else { - // Model ID changed - *displayID = modelInfo->modelid_other_gender; + // DisplayID changed + *displayID = modelInfo->displayId_other_gender; return minfo_tmp; } } @@ -1242,7 +1253,7 @@ void ObjectMgr::LoadCreatureModelInfo() { uint32 oldMSTime = getMSTime(); - QueryResult result = WorldDatabase.Query("SELECT modelid, bounding_radius, combat_reach, gender, modelid_other_gender FROM creature_model_info"); + QueryResult result = WorldDatabase.Query("SELECT DisplayID, BoundingRadius, CombatReach, DisplayID_Other_Gender FROM creature_model_info"); if (!result) { @@ -1257,30 +1268,36 @@ void ObjectMgr::LoadCreatureModelInfo() { Field* fields = result->Fetch(); - uint32 modelId = fields[0].GetUInt32(); + uint32 displayId = fields[0].GetUInt32(); + + CreatureDisplayInfoEntry const* creatureDisplay = sCreatureDisplayInfoStore.LookupEntry(displayId); + if (!creatureDisplay) + { + TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has a non-existent DisplayID (ID: %u). Skipped.", displayId); + continue; + } - CreatureModelInfo& modelInfo = _creatureModelStore[modelId]; + CreatureModelInfo& modelInfo = _creatureModelStore[displayId]; - modelInfo.bounding_radius = fields[1].GetFloat(); - modelInfo.combat_reach = fields[2].GetFloat(); - modelInfo.gender = fields[3].GetUInt8(); - modelInfo.modelid_other_gender = fields[4].GetUInt32(); + modelInfo.bounding_radius = fields[1].GetFloat(); + modelInfo.combat_reach = fields[2].GetFloat(); + modelInfo.displayId_other_gender = fields[3].GetUInt32(); + modelInfo.gender = creatureDisplay->Gender; // Checks - if (!sCreatureDisplayInfoStore.LookupEntry(modelId)) - TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId); - - if (modelInfo.gender > GENDER_NONE) + // to remove when the purpose of GENDER_UNKNOWN is known + if (modelInfo.gender == GENDER_UNKNOWN) { - TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender (%u) for display id (%u).", uint32(modelInfo.gender), modelId); + // We don't need more errors + //TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has an unimplemented Gender (ID: %i) being used by DisplayID (ID: %u). Gender set to GENDER_MALE.", modelInfo.gender, modelId); modelInfo.gender = GENDER_MALE; } - if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender)) + if (modelInfo.displayId_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.displayId_other_gender)) { - TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has nonexistent alt.gender model (%u) for existed display id (%u).", modelInfo.modelid_other_gender, modelId); - modelInfo.modelid_other_gender = 0; + TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has a non-existent DisplayID_Other_Gender (ID: %u) being used by DisplayID (ID: %u).", modelInfo.displayId_other_gender, displayId); + modelInfo.displayId_other_gender = 0; } if (modelInfo.combat_reach < 0.1f) @@ -2492,7 +2509,9 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.SubClass = db2Data->SubClass; itemTemplate.SoundOverrideSubclass = db2Data->SoundOverrideSubclass; itemTemplate.Name1 = sparse->Name->Str[sWorld->GetDefaultDbcLocale()]; - itemTemplate.DisplayInfoID = GetItemDisplayID(db2Data->AppearanceID); + itemTemplate.DisplayInfoID = GetItemDisplayID(db2Data->FileDataID); + itemTemplate.FileDataID = db2Data->FileDataID; + itemTemplate.GroupSoundsID = db2Data->GroupSoundsID; itemTemplate.Quality = sparse->Quality; memcpy(itemTemplate.Flags, sparse->Flags, sizeof(itemTemplate.Flags)); itemTemplate.Unk1 = sparse->Unk1; @@ -2571,6 +2590,7 @@ void ObjectMgr::LoadItemTemplates() itemTemplate.StatScalingFactor = sparse->StatScalingFactor; itemTemplate.CurrencySubstitutionId = sparse->CurrencySubstitutionID; itemTemplate.CurrencySubstitutionCount = sparse->CurrencySubstitutionCount; + itemTemplate.ItemNameDescriptionID = sparse->ItemNameDescriptionID; itemTemplate.ScriptId = 0; itemTemplate.FoodType = 0; itemTemplate.MinMoneyLoot = 0; @@ -9015,6 +9035,12 @@ void ObjectMgr::LoadMissingKeyChains() uint32 id = fields[0].GetUInt32(); KeyChainEntry* kce = sKeyChainStore.CreateEntry(id, true); + if (!kce) + { + TC_LOG_ERROR("sql.sql", "Could not create KeyChainEntry %u, skipped.", id); + continue; + } + kce->Id = id; for (uint32 i = 0; i < KEYCHAIN_SIZE; ++i) kce->Key[i] = fields[1 + i].GetUInt8(); |
