TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ChatLink.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TRINITYCORE_CHATLINK_H
19 #define TRINITYCORE_CHATLINK_H
20 
21 #include "SharedDefines.h"
22 #include <sstream>
23 #include <list>
24 #include <cstring>
25 #include "Common.h"
26 
27 struct ItemLocale;
28 struct ItemTemplate;
31 class SpellInfo;
32 struct AchievementEntry;
34 class Quest;
35 
37 // ChatLink - abstract base class for various links
39 {
40 public:
41  ChatLink() : _color(0), _startPos(0), _endPos(0) { }
42  virtual ~ChatLink() { }
43  void SetColor(uint32 color) { _color = color; }
44  // This will allow to extract the whole link string from the message, if necessary.
45  void SetBounds(std::istringstream::pos_type startPos, std::istringstream::pos_type endPos) { _startPos = startPos; _endPos = endPos; }
46 
47  virtual bool Initialize(std::istringstream& iss) = 0;
48  virtual bool ValidateName(char* buffer, const char* context) = 0;
49 
50 protected:
52  std::string _name;
53  std::istringstream::pos_type _startPos;
54  std::istringstream::pos_type _endPos;
55 };
56 
57 // ItemChatLink - link to item
59 {
60 public:
61  ItemChatLink() : ChatLink(), _item(NULL), _suffix(NULL), _property(NULL)
62  {
63  memset(_data, 0, sizeof(_data));
64  }
65  virtual bool Initialize(std::istringstream& iss) override;
66  virtual bool ValidateName(char* buffer, const char* context) override;
67 
68 protected:
69  std::string FormatName(uint8 index, LocalizedString* suffixStrings) const;
70 
72  int32 _data[11];
73  std::vector<int32> _bonusListIDs;
76 };
77 
78 // QuestChatLink - link to quest
80 {
81 public:
82  QuestChatLink() : ChatLink(), _quest(nullptr), _questLevel(0) { }
83  virtual bool Initialize(std::istringstream& iss) override;
84  virtual bool ValidateName(char* buffer, const char* context) override;
85 
86 protected:
87  Quest const* _quest;
89 };
90 
91 // SpellChatLink - link to quest
93 {
94 public:
95  SpellChatLink() : ChatLink(), _spell(nullptr) { }
96  virtual bool Initialize(std::istringstream& iss) override;
97  virtual bool ValidateName(char* buffer, const char* context) override;
98 
99 protected:
101 };
102 
103 // AchievementChatLink - link to quest
105 {
106 public:
107  AchievementChatLink() : ChatLink(), _guid(0), _achievement(NULL)
108  {
109  memset(_data, 0, sizeof(_data));
110  }
111  virtual bool Initialize(std::istringstream& iss) override;
112  virtual bool ValidateName(char* buffer, const char* context) override;
113 
114 protected:
117  uint32 _data[8];
118 };
119 
120 // TradeChatLink - link to trade info
122 {
123 public:
124  TradeChatLink() : SpellChatLink(), _minSkillLevel(0), _maxSkillLevel(0), _guid(0) { }
125  virtual bool Initialize(std::istringstream& iss) override;
126 private:
130  std::string _base64;
131 };
132 
133 // TalentChatLink - link to talent
135 {
136 public:
137  TalentChatLink() : SpellChatLink(), _talentId(0), _rankId(0) { }
138  virtual bool Initialize(std::istringstream& iss) override;
139 
140 private:
143 };
144 
145 // EnchantmentChatLink - link to enchantment
147 {
148 public:
150  virtual bool Initialize(std::istringstream& iss) override;
151 };
152 
153 // GlyphChatLink - link to glyph
155 {
156 public:
157  GlyphChatLink() : SpellChatLink(), _slotId(0), _glyph(NULL) { }
158  virtual bool Initialize(std::istringstream& iss) override;
159 private:
162 };
163 
165 {
166 public:
167  explicit LinkExtractor(const char* msg);
168  ~LinkExtractor();
169 
170  bool IsValidMessage();
171 
172 private:
173  typedef std::list<ChatLink*> Links;
174  Links _links;
175  std::istringstream _iss;
176 };
177 
178 
179 #endif // TRINITYCORE_CHATLINK_H
Definition: QuestDef.h:279
Definition: SpellInfo.h:326
Definition: Common.h:146
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: DB2Structure.h:27
std::list< ChatLink * > Links
Definition: ChatLink.h:173
std::istringstream _iss
Definition: ChatLink.h:175
Links _links
Definition: ChatLink.h:174
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
Definition: DB2Structure.h:779
Definition: ChatLink.h:164
Definition: DBCStructure.h:509
Definition: ItemTemplate.h:647
#define TC_GAME_API
Definition: Define.h:134
uint8_t uint8
Definition: Define.h:152
Definition: DB2Structure.h:771