diff options
Diffstat (limited to 'src/game/Chat.cpp')
-rw-r--r-- | src/game/Chat.cpp | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 03f78c3938c..81bf48491da 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -45,10 +45,11 @@ // |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|Hplayer:name|h[name]|h|r - client, in some messages, at click copy only name instead link // |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|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 @@ -1245,12 +1246,23 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes, // [name] Shift-click form |color|linkType:key|h[name]|h|r // or // [name] Shift-click form |color|linkType:key:something1:...:somethingN|h[name]|h|r + // or + // [name] Shift-click form |linkType:key|h[name]|h|r - char* check = strtok(text, "|"); // skip color - if(!check) - return NULL; // end of data + char* tail; - char* cLinkType = strtok(NULL, ":"); // linktype + if(text[1]=='c') + { + char* check = strtok(text, "|"); // skip color + if(!check) + return NULL; // end of data + + tail = strtok(NULL, ""); // tail + } + else + tail = text+1; // skip first | + + char* cLinkType = strtok(tail, ":"); // linktype if(!cLinkType) return NULL; // end of data @@ -1410,12 +1422,14 @@ GameTele const* ChatHandler::extractGameTeleFromLink(char* text) enum GuidLinkType { - SPELL_LINK_CREATURE = 0, - SPELL_LINK_GAMEOBJECT = 1 + SPELL_LINK_PLAYER = 0, // must be first for selection in not link case + SPELL_LINK_CREATURE = 1, + SPELL_LINK_GAMEOBJECT = 2 }; static char const* const guidKeys[] = { + "Hplayer", "Hcreature", "Hgameobject", 0 @@ -1427,32 +1441,65 @@ uint64 ChatHandler::extractGuidFromLink(char* text) // |color|Hcreature:creature_guid|h[name]|h|r // |color|Hgameobject:go_guid|h[name]|h|r + // |color|Hplayer:name|h[name]|h|r char* idS = extractKeyFromLink(text,guidKeys,&type); if(!idS) return 0; - uint32 lowguid = (uint32)atol(idS); - switch(type) { + case SPELL_LINK_PLAYER: + { + std::string name = idS; + if(!normalizePlayerName(name)) + return 0; + + if(Player* player = objmgr.GetPlayer(name.c_str())) + return player->GetGUID(); + + if(uint64 guid = objmgr.GetPlayerGUIDByName(name)) + return guid; + + return 0; + } case SPELL_LINK_CREATURE: { + uint32 lowguid = (uint32)atol(idS); + if(CreatureData const* data = objmgr.GetCreatureData(lowguid) ) return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_UNIT); else return 0; } case SPELL_LINK_GAMEOBJECT: + { + uint32 lowguid = (uint32)atol(idS); + if(GameObjectData const* data = objmgr.GetGOData(lowguid) ) return MAKE_NEW_GUID(lowguid,data->id,HIGHGUID_GAMEOBJECT); else return 0; + } } // unknown type? return 0; } +std::string ChatHandler::extractPlayerNameFromLink(char* text) +{ + // |color|Hplayer:name|h[name]|h|r + char* name_str = extractKeyFromLink(text,"Hplayer"); + if(!name_str) + return ""; + + std::string name = name_str; + if(!normalizePlayerName(name)) + return ""; + + return name; +} + const char *ChatHandler::GetName() const { return m_session->GetPlayer()->GetName(); |