40{
41
43 {
44 LOG_INFO(
"server.loading",
">> Warden disabled, loading checks skipped.");
46 return;
47 }
48
50
51 if (!result)
52 {
53 LOG_WARN(
"server.loading",
">> Loaded 0 Warden checks. DB table `warden_checks` is empty!");
55 return;
56 }
57
58 Field* fields = result->Fetch();
59
61
63
64
65 result =
WorldDatabase.Query(
"SELECT id, type, data, result, address, length, str, comment FROM warden_checks ORDER BY id ASC");
66
68 do
69 {
70 fields = result->Fetch();
71
74
76 {
77 LOG_ERROR(
"warden",
"sql.sql: Warden Lua check with id {} found in `warden_checks`. Lua checks may have four-digit IDs at most. Skipped.",
id);
78 continue;
79 }
80
81 std::string data = fields[2].
Get<std::string>();
82 std::string checkResult = fields[3].
Get<std::string>();
85 std::string str = fields[6].
Get<std::string>();
86 std::string comment = fields[7].
Get<std::string>();
87
89 wardenCheck.Type = checkType;
90 wardenCheck.CheckId = id;
91
92
95 {
97 }
98
100 {
101 wardenCheck.Address = address;
102 wardenCheck.Length = length;
103 }
104
105
107 {
108 wardenCheck.Str = str;
109 }
110
112 {
116 }
117
118 if (comment.empty())
119 wardenCheck.Comment = "Undocumented Check";
120 else
121 wardenCheck.Comment = comment;
122
123
124 switch (checkType)
125 {
128 {
130 break;
131 }
133 {
135 {
137 continue;
138 }
139
142 std::copy(str2.begin(), str2.end(), wardenCheck.IdStr.begin());
143
145 break;
146 }
147 default:
148 {
150 wardenCheck.Data.SetHexStr(data.c_str());
151
153 break;
154 }
155 }
156
157 ++count;
158 } while (result->NextRow());
159
160 LOG_INFO(
"server.loading",
">> Loaded {} warden checks.", count);
162}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
#define LOG_WARN(filterType__,...)
Definition: Log.h:160
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
#define ASSERT
Definition: Errors.h:68
@ CONFIG_WARDEN_CLIENT_FAIL_ACTION
Definition: IWorld.h:379
@ CONFIG_WARDEN_ENABLED
Definition: IWorld.h:153
constexpr uint8 WARDEN_MAX_LUA_CHECK_LENGTH
Definition: WardenCheckMgr.h:56
@ WARDEN_ACTION_BAN
Definition: WardenCheckMgr.h:29
@ WARDEN_CHECK_MEM_TYPE
Definition: WardenCheckMgr.h:36
@ WARDEN_CHECK_LUA_TYPE
Definition: WardenCheckMgr.h:37
@ WARDEN_CHECK_OTHER_TYPE
Definition: WardenCheckMgr.h:38
constexpr uint8 MAX_WARDEN_ACTION
Definition: WardenCheckMgr.h:32
@ PROC_CHECK
Definition: Warden.h:56
@ DRIVER_CHECK
Definition: Warden.h:54
@ PAGE_CHECK_A
Definition: Warden.h:50
@ PAGE_CHECK_B
Definition: Warden.h:51
@ LUA_EVAL_CHECK
Definition: Warden.h:53
@ MPQ_CHECK
Definition: Warden.h:52
@ MEM_CHECK
Definition: Warden.h:49
@ MODULE_CHECK
Definition: Warden.h:57
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
#define sWorld
Definition: World.h:444
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
bool SetHexStr(char const *str)
Definition: BigNumber.cpp:65
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: WardenCheckMgr.h:44
Definition: WardenCheckMgr.h:59
BigNumber Result
Definition: WardenCheckMgr.h:60
std::vector< uint16 > CheckIdPool[MAX_WARDEN_CHECK_TYPES]
Definition: WardenCheckMgr.h:79