41{
42
44 {
45 LOG_INFO(
"server.loading",
">> Warden disabled, loading checks skipped.");
47 return;
48 }
49
51
52 if (!result)
53 {
54 LOG_WARN(
"server.loading",
">> Loaded 0 Warden checks. DB table `warden_checks` is empty!");
56 return;
57 }
58
59 Field* fields = result->Fetch();
60
62
64
65
66 result =
WorldDatabase.Query(
"SELECT id, type, data, result, address, length, str, comment FROM warden_checks ORDER BY id ASC");
67
69 do
70 {
71 fields = result->Fetch();
72
75
77 {
78 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);
79 continue;
80 }
81
82 std::string data = fields[2].
Get<std::string>();
83 std::string checkResult = fields[3].
Get<std::string>();
86 std::string str = fields[6].
Get<std::string>();
87 std::string comment = fields[7].
Get<std::string>();
88
90 wardenCheck.Type = checkType;
91 wardenCheck.CheckId = id;
92
93
96 {
98 }
99
101 {
102 wardenCheck.Address = address;
103 wardenCheck.Length = length;
104 }
105
106
108 {
109 wardenCheck.Str = str;
110 }
111
113 {
117 }
118
119 if (comment.empty())
120 wardenCheck.Comment = "Undocumented Check";
121 else
122 wardenCheck.Comment = comment;
123
124
125 switch (checkType)
126 {
129 {
131 break;
132 }
134 {
136 {
138 continue;
139 }
140
143 std::copy(str2.begin(), str2.end(), wardenCheck.IdStr.begin());
144
146 break;
147 }
148 default:
149 {
151 wardenCheck.Data.SetHexStr(data.c_str());
152
154 break;
155 }
156 }
157
158 ++count;
159 } while (result->NextRow());
160
161 LOG_INFO(
"server.loading",
">> Loaded {} warden checks.", count);
163}
#define ASSERT
Definition: Errors.h:68
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ CONFIG_WARDEN_CLIENT_FAIL_ACTION
Definition: IWorld.h:376
@ CONFIG_WARDEN_ENABLED
Definition: IWorld.h:148
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:55
@ DRIVER_CHECK
Definition: Warden.h:53
@ PAGE_CHECK_A
Definition: Warden.h:49
@ PAGE_CHECK_B
Definition: Warden.h:50
@ LUA_EVAL_CHECK
Definition: Warden.h:52
@ MPQ_CHECK
Definition: Warden.h:51
@ MEM_CHECK
Definition: Warden.h:48
@ MODULE_CHECK
Definition: Warden.h:56
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
#define sWorld
Definition: World.h:443
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:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
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