129{
130 if (error)
131 {
132
133 return;
134 }
135
136 LOG_DEBUG(
"server.authserver",
"Updating Realm List...");
137
140
141 std::map<RealmHandle, std::string> existingRealms;
143 {
145 }
146
148
149
150 if (result)
151 {
152 for (auto const& fields : *result)
153 {
154 try
155 {
157 std::string name = fields[1].Get<std::string>();
158 std::string externalAddressString = fields[2].Get<std::string>();
159 std::string localAddressString = fields[3].Get<std::string>();
160 std::string localSubmaskString = fields[4].Get<std::string>();
162
164 if (!externalAddress)
165 {
166 LOG_ERROR(
"server.authserver",
"Could not resolve address {} for realm \"{}\" id {}", externalAddressString, name, realmId);
167 continue;
168 }
169
171 if (!localAddress)
172 {
173 LOG_ERROR(
"server.authserver",
"Could not resolve localAddress {} for realm \"{}\" id {}", localAddressString, name, realmId);
174 continue;
175 }
176
178 if (!localSubmask)
179 {
180 LOG_ERROR(
"server.authserver",
"Could not resolve localSubnetMask {} for realm \"{}\" id {}", localSubmaskString, name, realmId);
181 continue;
182 }
183
185
187 {
189 }
190
192 {
194 }
195
196 auto flag =
RealmFlags(fields[7].Get<uint8>());
198 uint8 allowedSecurityLevel = fields[9].Get<
uint8>();
199 float pop = fields[10].Get<float>();
201
203
204 UpdateRealm(
id, build, name, externalAddress->address(), localAddress->address(), localSubmask->address(), port, icon, flag,
206
207 if (!existingRealms.count(id))
208 {
209 LOG_INFO(
"server.authserver",
"Added realm \"{}\" at {}:{}.", name, externalAddressString, port);
210 }
211 else
212 {
213 LOG_DEBUG(
"server.authserver",
"Updating realm \"{}\" at {}:{}.", name, externalAddressString, port);
214 }
215
216 existingRealms.erase(id);
217 }
218 catch (std::exception const& ex)
219 {
220 LOG_ERROR(
"server.authserver",
"Realmlist::UpdateRealms has thrown an exception: {}", ex.what());
222 }
223 }
224 }
225
226 for (auto itr = existingRealms.begin(); itr != existingRealms.end(); ++itr)
227 LOG_INFO(
"server.authserver",
"Removed realm \"{}\".", itr->second);
228
230 {
233 }
234}
AccountTypes
Definition Common.h:56
@ SEC_ADMINISTRATOR
Definition Common.h:60
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
std::uint8_t uint8
Definition Define.h:109
std::uint16_t uint16
Definition Define.h:108
#define ABORT
Definition Errors.h:76
#define LOG_INFO(filterType__,...)
Definition Log.h:165
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
@ LOGIN_SEL_REALMLIST
Definition LoginDatabase.h:31
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
RealmFlags
Definition Realm.h:26
@ REALM_TYPE_FFA_PVP
Definition Realm.h:62
@ MAX_CLIENT_REALM_TYPE
Definition Realm.h:60
@ REALM_TYPE_PVP
Definition Realm.h:55
@ REALM_TYPE_NORMAL
Definition Realm.h:54
Definition PreparedStatement.h:157
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 realmTimezone, AccountTypes allowedSecurityLevel, float population)
Definition RealmList.cpp:94
auto GetExpirationTime(int32 seconds)
Definition SteadyTimer.h:25