[7920] Ignore racial skill and skills without recipes in .learn all_recipes. Cleanup code.

This commit is contained in:
VladimirMangos 2009-05-31 04:23:50 +04:00
parent d2e0e3c439
commit 91157c7eb9
5 changed files with 60 additions and 62 deletions

View file

@ -519,6 +519,7 @@ class ChatHandler
bool HandleBanInfoHelper(uint32 accountid, char const* accountname); bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
bool HandleUnBanHelper(BanMode mode,char const* args); bool HandleUnBanHelper(BanMode mode,char const* args);
void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel); void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel);
void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id);
void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
private: private:

View file

@ -1238,7 +1238,7 @@ struct SkillLineEntry
uint32 spellIcon; // 37 m_spellIconID uint32 spellIcon; // 37 m_spellIconID
//char* alternateVerb[16]; // 38-53 m_alternateVerb_lang //char* alternateVerb[16]; // 38-53 m_alternateVerb_lang
// 54 string flags // 54 string flags
// 55 m_canLink uint32 canLink; // 55 m_canLink (prof. with recipes
}; };
struct SkillLineAbilityEntry struct SkillLineAbilityEntry

View file

@ -77,7 +77,7 @@ const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx";
const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii"; const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii";
const char ScalingStatDistributionfmt[]="niiiiiiiiiiiiiiiiiiiii"; const char ScalingStatDistributionfmt[]="niiiiiiiiiiiiiiiiiiiii";
const char ScalingStatValuesfmt[]="iniiiiiiiiiiiiiiiii"; const char ScalingStatValuesfmt[]="iniiiiiiiiiiiiiiiii";
const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxx"; const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxi";
const char SkillLineAbilityfmt[]="niiiixxiiiiixx"; const char SkillLineAbilityfmt[]="niiiixxiiiiixx";
const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char SpellCastTimefmt[]="nixx"; const char SpellCastTimefmt[]="nixx";

View file

@ -3899,6 +3899,40 @@ bool ChatHandler::HandleCombatStopCommand(const char* args)
return true; return true;
} }
void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id)
{
uint32 classmask = player->getClassMask();
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
{
SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
if (!skillLine)
continue;
// wrong skill
if( skillLine->skillId != skill_id)
continue;
// not high rank
if(skillLine->forward_spellid )
continue;
// skip racial skills
if (skillLine->racemask != 0)
continue;
// skip wrong class skills
if( skillLine->classmask && (skillLine->classmask & classmask) == 0)
continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false))
continue;
player->learnSpell(skillLine->spellId,false);
}
}
bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/)
{ {
uint32 classmask = m_session->GetPlayer()->getClassMask(); uint32 classmask = m_session->GetPlayer()->getClassMask();
@ -3909,31 +3943,10 @@ bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/)
if( !skillInfo ) if( !skillInfo )
continue; continue;
if( skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY ) if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) &&
skillInfo->canLink) // only prof. with recipes have
{ {
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) HandleLearnSkillRecipesHelper(m_session->GetPlayer(),skillInfo->id);
{
SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
if( !skillLine )
continue;
// skip racial skills
if( skillLine->racemask != 0 )
continue;
// skip wrong class skills
if( skillLine->classmask && (skillLine->classmask & classmask) == 0)
continue;
if( skillLine->skillId != i || skillLine->forward_spellid )
continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false))
continue;
m_session->GetPlayer()->learnSpell(skillLine->spellId,false);
}
} }
} }
@ -3965,55 +3978,39 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
wstrToLower( wnamepart ); wstrToLower( wnamepart );
uint32 classmask = m_session->GetPlayer()->getClassMask(); uint32 classmask = m_session->GetPlayer()->getClassMask();
std::string name;
for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) SkillLineEntry const *targetSkillInfo = NULL;
for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i)
{ {
SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i);
if( !skillInfo ) if (!skillInfo)
continue; continue;
if( skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION &&
skillInfo->categoryId != SKILL_CATEGORY_SECONDARY ) skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) ||
!skillInfo->canLink) // only prof with recipes have set
continue; continue;
int loc = GetSessionDbcLocale(); int loc = GetSessionDbcLocale();
std::string name = skillInfo->name[loc]; name = skillInfo->name[loc];
if(Utf8FitTo(name, wnamepart)) if(Utf8FitTo(name, wnamepart))
{ {
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) targetSkillInfo = skillInfo;
{ break;
SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
if( !skillLine )
continue;
if( skillLine->skillId != i || skillLine->forward_spellid )
continue;
// skip racial skills
if( skillLine->racemask != 0 )
continue;
// skip wrong class skills
if( skillLine->classmask && (skillLine->classmask & classmask) == 0)
continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false))
continue;
if( !target->HasSpell(spellInfo->Id) )
m_session->GetPlayer()->learnSpell(skillLine->spellId,false);
}
uint16 maxLevel = target->GetPureMaxSkillValue(skillInfo->id);
target->SetSkill(skillInfo->id, maxLevel, maxLevel);
PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str());
return true;
} }
} }
return false; if(!targetSkillInfo)
return false;
HandleLearnSkillRecipesHelper(target,targetSkillInfo->id);
uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id);
target->SetSkill(targetSkillInfo->id, maxLevel, maxLevel);
PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str());
return true;
} }
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7919" #define REVISION_NR "7920"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__