128{
129 if (error)
130 {
131
132 return;
133 }
134
135 LOG_DEBUG(
"server.authserver",
"Updating Realm List...");
136
139
140 std::map<RealmHandle, std::string> existingRealms;
142 {
144 }
145
147
148
149 if (result)
150 {
151 for (auto const& fields : *result)
152 {
153 try
154 {
156 std::string name = fields[1].Get<std::string>();
157 std::string externalAddressString = fields[2].Get<std::string>();
158 std::string localAddressString = fields[3].Get<std::string>();
159 std::string localSubmaskString = fields[4].Get<std::string>();
161
163 if (!externalAddress)
164 {
165 LOG_ERROR(
"server.authserver",
"Could not resolve address {} for realm \"{}\" id {}", externalAddressString, name, realmId);
166 continue;
167 }
168
170 if (!localAddress)
171 {
172 LOG_ERROR(
"server.authserver",
"Could not resolve localAddress {} for realm \"{}\" id {}", localAddressString, name, realmId);
173 continue;
174 }
175
177 if (!localSubmask)
178 {
179 LOG_ERROR(
"server.authserver",
"Could not resolve localSubnetMask {} for realm \"{}\" id {}", localSubmaskString, name, realmId);
180 continue;
181 }
182
184
186 {
188 }
189
191 {
193 }
194
197 uint8 allowedSecurityLevel = fields[9].Get<
uint8>();
198 float pop = fields[10].Get<float>();
200
202
203 UpdateRealm(
id, build, name, externalAddress->address(), localAddress->address(), localSubmask->address(), port, icon, flag,
205
206 if (!existingRealms.count(id))
207 {
208 LOG_INFO(
"server.authserver",
"Added realm \"{}\" at {}:{}.", name, externalAddressString, port);
209 }
210 else
211 {
212 LOG_DEBUG(
"server.authserver",
"Updating realm \"{}\" at {}:{}.", name, externalAddressString, port);
213 }
214
215 existingRealms.erase(id);
216 }
217 catch (std::exception const& ex)
218 {
219 LOG_ERROR(
"server.authserver",
"Realmlist::UpdateRealms has thrown an exception: {}", ex.what());
221 }
222 }
223 }
224
225 for (auto itr = existingRealms.begin(); itr != existingRealms.end(); ++itr)
226 LOG_INFO(
"server.authserver",
"Removed realm \"{}\".", itr->second);
227
229 {
232 }
233}
AccountTypes
Definition: Common.h:65
@ SEC_ADMINISTRATOR
Definition: Common.h:69
#define ABORT
Definition: Errors.h:76
std::uint8_t uint8
Definition: Define.h:110
std::uint16_t uint16
Definition: Define.h:109
#define LOG_INFO(filterType__,...)
Definition: Log.h:167
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:50
@ LOGIN_SEL_REALMLIST
Definition: LoginDatabase.h:31
RealmFlags
Definition: Realm.h:25
@ REALM_TYPE_FFA_PVP
Definition: Realm.h:61
@ MAX_CLIENT_REALM_TYPE
Definition: Realm.h:59
@ REALM_TYPE_PVP
Definition: Realm.h:54
@ REALM_TYPE_NORMAL
Definition: Realm.h:53
Definition: PreparedStatement.h:158
void UpdateRealm(RealmHandle const &id, uint32 build, std::string const &name, boost::asio::ip::address &&address, boost::asio::ip::address &&localAddr, boost::asio::ip::address &&localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population)
Definition: RealmList.cpp:93