diff options
Diffstat (limited to 'src/server/authserver/Realms')
-rw-r--r-- | src/server/authserver/Realms/RealmList.cpp | 25 | ||||
-rw-r--r-- | src/server/authserver/Realms/RealmList.h | 15 |
2 files changed, 23 insertions, 17 deletions
diff --git a/src/server/authserver/Realms/RealmList.cpp b/src/server/authserver/Realms/RealmList.cpp index 4aeecfc0aaa..7ed9021dd21 100644 --- a/src/server/authserver/Realms/RealmList.cpp +++ b/src/server/authserver/Realms/RealmList.cpp @@ -16,10 +16,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <boost/asio.hpp> #include "Common.h" #include "RealmList.h" #include "Database/DatabaseEnv.h" +namespace boost { namespace asio { namespace ip { class address; } } } + RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { } // Load the realm list from the database @@ -31,7 +34,8 @@ void RealmList::Initialize(uint32 updateInterval) UpdateRealms(true); } -void RealmList::UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build) +void RealmList::UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr, + ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population, uint32 build) { // Create new if not exist or update existed Realm& realm = m_realms[name]; @@ -42,12 +46,14 @@ void RealmList::UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr co realm.flag = flag; realm.timezone = timezone; realm.allowedSecurityLevel = allowedSecurityLevel; - realm.populationLevel = popu; + realm.populationLevel = population; // Append port to IP address. + realm.ExternalAddress = address; realm.LocalAddress = localAddr; realm.LocalSubnetMask = localSubmask; + realm.port = port; realm.gamebuild = build; } @@ -81,9 +87,9 @@ void RealmList::UpdateRealms(bool init) Field* fields = result->Fetch(); uint32 realmId = fields[0].GetUInt32(); std::string name = fields[1].GetString(); - std::string externalAddress = fields[2].GetString(); - std::string localAddress = fields[3].GetString(); - std::string localSubmask = fields[4].GetString(); + ip::address externalAddress = ip::address::from_string(fields[2].GetString()); + ip::address localAddress = ip::address::from_string(fields[3].GetString()); + ip::address localSubmask = ip::address::from_string(fields[4].GetString()); uint16 port = fields[5].GetUInt16(); uint8 icon = fields[6].GetUInt8(); RealmFlags flag = RealmFlags(fields[7].GetUInt8()); @@ -92,14 +98,11 @@ void RealmList::UpdateRealms(bool init) float pop = fields[10].GetFloat(); uint32 build = fields[11].GetUInt32(); - ACE_INET_Addr externalAddr(port, externalAddress.c_str(), AF_INET); - ACE_INET_Addr localAddr(port, localAddress.c_str(), AF_INET); - ACE_INET_Addr submask(0, localSubmask.c_str(), AF_INET); - - UpdateRealm(realmId, name, externalAddr, localAddr, submask, icon, flag, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); + UpdateRealm(realmId, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone, + (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); if (init) - TC_LOG_INFO("server.authserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.get_host_addr(), port); + TC_LOG_INFO("server.authserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[name].ExternalAddress.to_string(), port); } while (result->NextRow()); } diff --git a/src/server/authserver/Realms/RealmList.h b/src/server/authserver/Realms/RealmList.h index 29b6aca07d3..b96d5523da9 100644 --- a/src/server/authserver/Realms/RealmList.h +++ b/src/server/authserver/Realms/RealmList.h @@ -19,9 +19,11 @@ #ifndef _REALMLIST_H #define _REALMLIST_H -#include <ace/INET_Addr.h> +#include <boost/asio.hpp> #include "Common.h" +using namespace boost::asio; + enum RealmFlags { REALM_FLAG_NONE = 0x00, @@ -38,9 +40,10 @@ enum RealmFlags // Storage object for a realm struct Realm { - ACE_INET_Addr ExternalAddress; - ACE_INET_Addr LocalAddress; - ACE_INET_Addr LocalSubnetMask; + ip::address ExternalAddress; + ip::address LocalAddress; + ip::address LocalSubnetMask; + uint16 port; std::string name; uint8 icon; RealmFlags flag; @@ -77,8 +80,8 @@ private: RealmList(); void UpdateRealms(bool init = false); - void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, - uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build); + void UpdateRealm(uint32 id, const std::string& name, ip::address const& address, ip::address const& localAddr, + ip::address const& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population, uint32 build); RealmMap m_realms; uint32 m_UpdateInterval; |