[7168] Spell shift-link and command improvements.

* Support Htrade shift link (it created by client at click by crafting profession spell icon in spellbook)
  in spell comands.
* Support "all" second arg for .learn for learning not provided spell id but it's all ranks.
* Drop support range for .unlearn command but support instead "all" second arg for unlearn not specific spell id but it's all ranks.
* In .list auras output print spell names as shift links for better readable view.
* Add to beggining Chat.cpp lists all supported by commands shift-links (client generated and server-side)
This commit is contained in:
VladimirMangos 2009-01-25 07:08:38 +03:00
parent ae5b65765d
commit 4dc06d6d9e
9 changed files with 148 additions and 83 deletions

View file

@ -33,6 +33,22 @@
#include "CellImpl.h"
#include "AccountMgr.h"
// Supported shift-links (client generated and server side)
// |color|Harea:area_id|h[name]|h|r
// |color|Hcreature:creature_guid|h[name]|h|r
// |color|Hcreature_entry:creature_id|h[name]|h|r
// |color|Hgameevent:id|h[name]|h|r
// |color|Hgameobject:go_guid|h[name]|h|r
// |color|Hgameobject_entry:go_id|h[name]|h|r
// |color|Hitem:item_id:perm_ench_id:0:0|h[name]|h|r
// |color|Hitemset:itemset_id|h[name]|h|r
// |color|Hquest:quest_id|h[name]|h|r
// |color|Hskill:skill_id|h[name]|h|r
// |color|Hspell:spell_id|h[name]|h|r - client, spellbook spell icon shift-click
// |color|Htalent:talent_id,rank|h[name]|h|r - client, talent icon shift-click
// |color|Htele:id|h[name]|h|r
// |color|Htrade:spell_id,cur_value,max_value,unk3int,unk3str|h[name]|h|r - client, spellbook profession icon shift-click
bool ChatHandler::load_command_table = true;
ChatCommand * ChatHandler::getCommandTable()
@ -1236,9 +1252,18 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
return obj;
}
static char const* const spellTalentKeys[] = {
"Hspell",
"Htalent",
enum SpellLinkType
{
SPELL_LINK_SPELL = 0,
SPELL_LINK_TALENT = 1,
SPELL_LINK_TRADE = 2
};
static char const* const spellKeys[] =
{
"Hspell", // normal spell
"Htalent", // talent spell
"Htrade", // profession/skill spell
0
};
@ -1246,31 +1271,41 @@ uint32 ChatHandler::extractSpellIdFromLink(char* text)
{
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
// number or [name] Shift-click form |color|Htalent:talent_id,rank|h[name]|h|r
// number or [name] Shift-click form |color|Htrade:spell_id,skill_id,max_value,cur_value|h[name]|h|r
int type = 0;
char* rankS = NULL;
char* idS = extractKeyFromLink(text,spellTalentKeys,&type,&rankS);
char* param1_str = NULL;
char* idS = extractKeyFromLink(text,spellKeys,&type,&param1_str);
if(!idS)
return 0;
uint32 id = (uint32)atol(idS);
// spell
if(type==0)
return id;
switch(type)
{
case SPELL_LINK_SPELL:
return id;
case SPELL_LINK_TALENT:
{
// talent
TalentEntry const* talentEntry = sTalentStore.LookupEntry(id);
if(!talentEntry)
return 0;
// talent
TalentEntry const* talentEntry = sTalentStore.LookupEntry(id);
if(!talentEntry)
return 0;
int32 rank = param1_str ? (uint32)atol(param1_str) : 0;
if(rank >= 5)
return 0;
int32 rank = rankS ? (uint32)atol(rankS) : 0;
if(rank >= 5)
return 0;
if(rank < 0)
rank = 0;
if(rank < 0)
rank = 0;
return talentEntry->RankID[rank];
}
case SPELL_LINK_TRADE:
return id;
}
return talentEntry->RankID[rank];
// unknown type?
return 0;
}
GameTele const* ChatHandler::extractGameTeleFromLink(char* text)