// loads the extra item creation info from DB void LoadSkillExtraItemTable() { uint32 count = 0; SkillExtraItemStore.clear(); // need for reload // 0 1 2 3 QueryResult* result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template"); if (result) { BarGoLink bar(result->GetRowCount()); do { Field* fields = result->Fetch(); bar.step(); uint32 spellId = fields[0].GetUInt32(); if (!sSpellTemplate.LookupEntry<SpellEntry>(spellId)) { sLog.outError("Skill specialization %u has nonexistent spell id in `skill_extra_item_template`!", spellId); continue; } uint32 requiredSpecialization = fields[1].GetUInt32(); if (!sSpellTemplate.LookupEntry<SpellEntry>(requiredSpecialization)) { sLog.outError("Skill specialization %u have nonexistent required specialization spell id %u in `skill_extra_item_template`!", spellId, requiredSpecialization); continue; } float additionalCreateChance = fields[2].GetFloat(); if (additionalCreateChance <= 0.0f) { sLog.outError("Skill specialization %u has too low additional create chance in `skill_extra_item_template`!", spellId); continue; } uint8 additionalMaxNum = fields[3].GetUInt8(); if (!additionalMaxNum) { sLog.outError("Skill specialization %u has 0 max number of extra items in `skill_extra_item_template`!", spellId); continue; } SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId]; skillExtraItemEntry.requiredSpecialization = requiredSpecialization; skillExtraItemEntry.additionalCreateChance = additionalCreateChance; skillExtraItemEntry.additionalMaxNum = additionalMaxNum; ++count; } while (result->NextRow()); delete result; sLog.outString(">> Loaded %u spell specialization definitions", count); } else sLog.outString(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty."); sLog.outString(); }
// loads the extra item creation info from DB void LoadSkillExtraItemTable() { uint32 oldMSTime = getMSTime(); SkillExtraItemStore.clear(); // need for reload // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template"); if (!result) { TC_LOG_ERROR(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty."); return; } uint32 count = 0; do { Field* fields = result->Fetch(); uint32 spellId = fields[0].GetUInt32(); if (!sSpellMgr->GetSpellInfo(spellId)) { TC_LOG_ERROR(LOG_FILTER_SQL, "Skill specialization %u has non-existent spell id in `skill_extra_item_template`!", spellId); continue; } uint32 requiredSpecialization = fields[1].GetUInt32(); if (!sSpellMgr->GetSpellInfo(requiredSpecialization)) { TC_LOG_ERROR(LOG_FILTER_SQL, "Skill specialization %u have not existed required specialization spell id %u in `skill_extra_item_template`!", spellId, requiredSpecialization); continue; } float additionalCreateChance = fields[2].GetFloat(); if (additionalCreateChance <= 0.0f) { TC_LOG_ERROR(LOG_FILTER_SQL, "Skill specialization %u has too low additional create chance in `skill_extra_item_template`!", spellId); continue; } uint8 additionalMaxNum = fields[3].GetUInt8(); if (!additionalMaxNum) { TC_LOG_ERROR(LOG_FILTER_SQL, "Skill specialization %u has 0 max number of extra items in `skill_extra_item_template`!", spellId); continue; } SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId]; skillExtraItemEntry.requiredSpecialization = requiredSpecialization; skillExtraItemEntry.additionalCreateChance = additionalCreateChance; skillExtraItemEntry.additionalMaxNum = additionalMaxNum; ++count; } while (result->NextRow()); TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, ">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); }
// loads the extra item creation info from DB void LoadSkillExtraItemTable() { uint32 oldMSTime = getMSTime(); SkillExtraItemStore.clear(); // need for reload // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum, newItemId FROM skill_extra_item_template"); if(!result) { sLog->outErrorDb(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty."); sLog->outString(); return; } uint32 count = 0; do { Field* fields = result->Fetch(); uint32 spellId = fields[0].GetUInt32(); if(!sSpellStore.LookupEntry(spellId)) { sLog->outError("Skill specialization %u has non-existent spell id in `skill_extra_item_template`!", spellId); continue; } uint32 requiredSpecialization = fields[1].GetUInt32(); if(!sSpellStore.LookupEntry(requiredSpecialization)) { sLog->outError("Skill specialization %u have not existed required specialization spell id %u in `skill_extra_item_template`!", spellId, requiredSpecialization); continue; } float additionalCreateChance = fields[2].GetFloat(); if(additionalCreateChance <= 0.0f) { sLog->outError("Skill specialization %u has too low additional create chance in `skill_extra_item_template`!", spellId); continue; } uint8 additionalMaxNum = fields[3].GetUInt8(); if(!additionalMaxNum) { sLog->outError("Skill specialization %u has 0 max number of extra items in `skill_extra_item_template`!", spellId); continue; } uint32 newItemId = fields[4].GetUInt32(); if(newItemId < 0) { sLog->outError("Skill specialization %u has newItemId lower than 0 in `skill_extra_item_template`!", spellId); continue; } SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId]; skillExtraItemEntry.requiredSpecialization = requiredSpecialization; skillExtraItemEntry.additionalCreateChance = additionalCreateChance; skillExtraItemEntry.additionalMaxNum = additionalMaxNum; skillExtraItemEntry.newItemId = newItemId; ++count; } while(result->NextRow()); sLog->outString(">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); }