[8426] Use upper/lower iterator pairs as result instead 2 function calls.

This commit is contained in:
VladimirMangos 2009-08-27 10:51:23 +04:00
parent fdb2842f60
commit 5d50bb16b8
9 changed files with 139 additions and 173 deletions

View file

@ -114,21 +114,18 @@ void LoadSkillDiscoveryTable()
SkillDiscoveryStore[reqSkillOrSpell].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) );
}
else if( reqSkillOrSpell == 0 ) // skill case
else if (reqSkillOrSpell == 0) // skill case
{
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spellId);
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spellId);
SkillLineAbilityMapBounds bounds = spellmgr.GetSkillLineAbilityMapBounds(spellId);
if(lower==upper)
if (bounds.first==bounds.second)
{
sLog.outErrorDb("Spell (ID: %u) not listed in `SkillLineAbility.dbc` but listed with `reqSpell`=0 in `skill_discovery_template` table",spellId);
continue;
}
for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
{
for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
SkillDiscoveryStore[-int32(_spell_idx->second->skillId)].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) );
}
}
else
{
@ -143,21 +140,21 @@ void LoadSkillDiscoveryTable()
sLog.outString();
sLog.outString( ">> Loaded %u skill discovery definitions", count );
if(!ssNonDiscoverableEntries.str().empty())
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());
// report about empty data for explicit discovery spells
for(uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id);
if(!spellEntry)
if (!spellEntry)
continue;
// skip not explicit discovery spells
if (!IsExplicitDiscoverySpell(spellEntry))
continue;
if(SkillDiscoveryStore.find(spell_id)==SkillDiscoveryStore.end())
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);
}
}
@ -170,9 +167,8 @@ uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player)
if (tab == SkillDiscoveryStore.end())
return 0;
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spellId);
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spellId);
uint32 skillvalue = lower != upper ? player->GetSkillValue(lower->second->skillId) : 0;
SkillLineAbilityMapBounds bounds = spellmgr.GetSkillLineAbilityMapBounds(spellId);
uint32 skillvalue = bounds.first != bounds.second ? player->GetSkillValue(bounds.first->second->skillId) : 0;
float full_chance = 0;
for(SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)