aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Chat/Chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r--src/server/game/Chat/Chat.cpp79
1 files changed, 3 insertions, 76 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 5b462589164..427619d0533 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -19,17 +19,14 @@
#include "AccountMgr.h"
#include "CellImpl.h"
#include "CharacterCache.h"
-#include "DatabaseEnv.h"
-#include "DBCStores.h"
#include "GridNotifiersImpl.h"
#include "Language.h"
-#include "Log.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Optional.h"
#include "Player.h"
#include "Realm.h"
-#include "ScriptMgr.h"
+#include "StringConvert.h"
#include "World.h"
#include "WorldSession.h"
#include <boost/algorithm/string/replace.hpp>
@@ -510,76 +507,6 @@ Creature* ChatHandler::GetCreatureFromPlayerMapByDbGuid(ObjectGuid::LowType lowg
return creature;
}
-enum SpellLinkType
-{
- SPELL_LINK_SPELL = 0,
- SPELL_LINK_TALENT = 1,
- SPELL_LINK_ENCHANT = 2,
- SPELL_LINK_TRADE = 3,
- SPELL_LINK_GLYPH = 4
-};
-
-static char const* const spellKeys[] =
-{
- "Hspell", // normal spell
- "Htalent", // talent spell
- "Henchant", // enchanting recipe spell
- "Htrade", // profession/skill spell
- "Hglyph", // glyph
- nullptr
-};
-
-uint32 ChatHandler::extractSpellIdFromLink(char* text)
-{
- // number or [name] Shift-click form |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r
- // number or [name] Shift-click form |color|Hglyph:glyph_slot_id:glyph_prop_id|h[%s]|h|r
- // 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* param1_str = nullptr;
- char* idS = extractKeyFromLink(text, spellKeys, &type, &param1_str);
- if (!idS)
- return 0;
-
- uint32 id = atoul(idS);
-
- switch (type)
- {
- case SPELL_LINK_SPELL:
- return id;
- case SPELL_LINK_TALENT:
- {
- // talent
- TalentEntry const* talentEntry = sTalentStore.LookupEntry(id);
- if (!talentEntry)
- return 0;
-
- uint32 rank = param1_str ? atol(param1_str) : 0u;
- if (rank >= MAX_TALENT_RANK)
- return 0;
-
- return talentEntry->SpellRank[rank];
- }
- case SPELL_LINK_ENCHANT:
- case SPELL_LINK_TRADE:
- return id;
- case SPELL_LINK_GLYPH:
- {
- uint32 glyph_prop_id = param1_str ? atoul(param1_str) : 0;
-
- GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id);
- if (!glyphPropEntry)
- return 0;
-
- return glyphPropEntry->SpellID;
- }
- }
-
- // unknown type?
- return 0;
-}
-
enum GuidLinkType
{
GUID_LINK_PLAYER = 0, // must be first for selection in not link case
@@ -625,13 +552,13 @@ ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& gu
case GUID_LINK_CREATURE:
{
guidHigh = HighGuid::Unit;
- ObjectGuid::LowType lowguid = atoul(idS);
+ ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
return lowguid;
}
case GUID_LINK_GAMEOBJECT:
{
guidHigh = HighGuid::GameObject;
- ObjectGuid::LowType lowguid = atoul(idS);
+ ObjectGuid::LowType lowguid = Trinity::StringTo<ObjectGuid::LowType>(idS).value_or(0);
return lowguid;
}
}