Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
ChatLink.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRESERVER_CHATLINK_H
7#define SKYFIRESERVER_CHATLINK_H
8
9#include "SharedDefines.h"
10#include <list>
11#include <sstream>
12
13struct ItemLocale;
14struct ItemTemplate;
17class SpellInfo;
18struct AchievementEntry;
20class Quest;
21
23// ChatLink - abstract base class for various links
25{
26public:
27 ChatLink() : _color(0), _startPos(0), _endPos(0) { }
28 virtual ~ChatLink() { }
29 void SetColor(uint32 color) { _color = color; }
30 // This will allow to extract the whole link string from the message, if necessary.
31 void SetBounds(std::istringstream::pos_type startPos, std::istringstream::pos_type endPos) { _startPos = startPos; _endPos = endPos; }
32
33 virtual bool Initialize(std::istringstream& iss) = 0;
34 virtual bool ValidateName(char* buffer, const char* context) = 0;
35
36protected:
38 std::string _name;
39 std::istringstream::pos_type _startPos;
40 std::istringstream::pos_type _endPos;
41};
42
43// ItemChatLink - link to item
44class ItemChatLink : public ChatLink
45{
46public:
47 ItemChatLink() : ChatLink(), _item(NULL), _suffix(NULL), _property(NULL) { memset(_data, 0, sizeof(_data)); }
48 virtual bool Initialize(std::istringstream& iss);
49 virtual bool ValidateName(char* buffer, const char* context);
50
51protected:
52 std::string FormatName(uint8 index, ItemLocale const* locale, char* suffixStrings) const;
53
58};
59
60// QuestChatLink - link to quest
61class QuestChatLink : public ChatLink
62{
63public:
65 virtual bool Initialize(std::istringstream& iss);
66 virtual bool ValidateName(char* buffer, const char* context);
67
68protected:
69 Quest const* _quest;
71};
72
73// SpellChatLink - link to quest
74class SpellChatLink : public ChatLink
75{
76public:
77 SpellChatLink() : ChatLink(), _spell(NULL) { }
78 virtual bool Initialize(std::istringstream& iss);
79 virtual bool ValidateName(char* buffer, const char* context);
80
81protected:
83};
84
85// AchievementChatLink - link to quest
87{
88public:
89 AchievementChatLink() : ChatLink(), _guid(0), _achievement(NULL) { memset(_data, 0, sizeof(_data)); }
90 virtual bool Initialize(std::istringstream& iss);
91 virtual bool ValidateName(char* buffer, const char* context);
92
93protected:
97};
98
99// TradeChatLink - link to trade info
101{
102public:
104 virtual bool Initialize(std::istringstream& iss);
105private:
109 std::string _base64;
110};
111
112// TalentChatLink - link to talent
114{
115public:
117 virtual bool Initialize(std::istringstream& iss);
118
119private:
122};
123
124// EnchantmentChatLink - link to enchantment
126{
127public:
129 virtual bool Initialize(std::istringstream& iss);
130};
131
132// GlyphChatLink - link to glyph
134{
135public:
137 virtual bool Initialize(std::istringstream& iss);
138private:
141};
142
144{
145public:
146 explicit LinkExtractor(const char* msg);
148
149 bool IsValidMessage();
150
151private:
152 typedef std::list<ChatLink*> Links;
154 std::istringstream _iss;
155};
156
157
158#endif // SKYFIRESERVER_CHATLINK_H
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77