diff options
author | leak <none@none> | 2010-12-19 17:06:33 +0100 |
---|---|---|
committer | leak <none@none> | 2010-12-19 17:06:33 +0100 |
commit | fd694cd2324a7e2d61d833a78024b68fd3605053 (patch) | |
tree | 2fb48411eb25ff627b56786b66c96dd646a30651 /src/server/game/Skills | |
parent | 9c35e10444b24848e0a909c46727ac2a312ab5de (diff) |
Streamlining loading functions for server startup
- Added a couple of timer outputs
- Improved code consistency between loading functions
- Progess bars should look and behave similar on all OS now (sLog.outString() is not needed anymore to replace the progress bar in log files)
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Skills')
-rwxr-xr-x | src/server/game/Skills/SkillDiscovery.cpp | 13 | ||||
-rwxr-xr-x | src/server/game/Skills/SkillExtraItems.cpp | 105 |
2 files changed, 62 insertions, 56 deletions
diff --git a/src/server/game/Skills/SkillDiscovery.cpp b/src/server/game/Skills/SkillDiscovery.cpp index a520fa84f9c..510ead760b4 100755 --- a/src/server/game/Skills/SkillDiscovery.cpp +++ b/src/server/game/Skills/SkillDiscovery.cpp @@ -46,22 +46,24 @@ static SkillDiscoveryMap SkillDiscoveryStore; void LoadSkillDiscoveryTable() { + uint32 oldMSTime = getMSTime(); SkillDiscoveryStore.clear(); // need for reload - uint32 count = 0; - // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT spellId, reqSpell, reqSkillValue, chance FROM skill_discovery_template"); if (!result) { + barGoLink bar(1); + bar.step(); + sLog.outErrorDb(">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty."); sLog.outString(); - sLog.outString(">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty."); return; } barGoLink bar(result->GetRowCount()); + uint32 count = 0; std::ostringstream ssNonDiscoverableEntries; std::set<uint32> reportedReqSpells; @@ -135,8 +137,6 @@ void LoadSkillDiscoveryTable() ++count; } while (result->NextRow()); - sLog.outString(); - sLog.outString(">> Loaded %u skill discovery definitions", count); if (!ssNonDiscoverableEntries.str().empty()) sLog.outErrorDb("Some items can't be successfully discovered: have in chance field value < 0.000001 in `skill_discovery_template` DB table . List:\n%s",ssNonDiscoverableEntries.str().c_str()); @@ -154,6 +154,9 @@ void LoadSkillDiscoveryTable() if (SkillDiscoveryStore.find(spell_id) == SkillDiscoveryStore.end()) sLog.outErrorDb("Spell (ID: %u) is 100%% chance random discovery ability but not have data in `skill_discovery_template` table",spell_id); } + + sLog.outString(">> Loaded %u skill discovery definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + sLog.outString(); } uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player) diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp index 5cc86ffbe3c..c487d9a881a 100755 --- a/src/server/game/Skills/SkillExtraItems.cpp +++ b/src/server/game/Skills/SkillExtraItems.cpp @@ -52,68 +52,71 @@ SkillExtraItemMap SkillExtraItemStore; // 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) + if (!result) + { + barGoLink bar(1); + bar.step(); + sLog.outErrorDb(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty."); + sLog.outString(); + return; + } + + barGoLink bar(result->GetRowCount()); + uint32 count = 0; + + do { - uint32 count = 0; + Field *fields = result->Fetch(); + bar.step(); - barGoLink bar(result->GetRowCount()); + uint32 spellId = fields[0].GetUInt32(); - do + if (!sSpellStore.LookupEntry(spellId)) { - Field *fields = result->Fetch(); - bar.step(); - - 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; - } - - SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId]; - - skillExtraItemEntry.requiredSpecialization = requiredSpecialization; - skillExtraItemEntry.additionalCreateChance = additionalCreateChance; - skillExtraItemEntry.additionalMaxNum = additionalMaxNum; - - ++count; - } while (result->NextRow()); + sLog.outError("Skill specialization %u has non-existent spell id in `skill_extra_item_template`!", spellId); + continue; + } - sLog.outString(); - sLog.outString(">> Loaded %u spell specialization definitions", count); - } - else - { - sLog.outString(); - sLog.outString(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty."); + 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; + } + + SkillExtraItemEntry& skillExtraItemEntry = SkillExtraItemStore[spellId]; + + skillExtraItemEntry.requiredSpecialization = requiredSpecialization; + skillExtraItemEntry.additionalCreateChance = additionalCreateChance; + skillExtraItemEntry.additionalMaxNum = additionalMaxNum; + + ++count; } + while (result->NextRow()); + + sLog.outString(">> Loaded %u spell specialization definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + sLog.outString(); } bool canCreateExtraItems(Player * player, uint32 spellId, float &additionalChance, uint8 &additionalMax) |