diff options
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Commands/cs_account.cpp | 18 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_battlenet_account.cpp | 18 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 12 |
3 files changed, 15 insertions, 33 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index b8eec0b6581..5c9aafb700f 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "Chat.h" #include "DatabaseEnv.h" #include "IpAddress.h" +#include "IPLocation.h" #include "Language.h" #include "Log.h" #include "Player.h" @@ -290,25 +291,18 @@ public: { if (param == "on") { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY); - uint32 ip = Trinity::Net::address_to_uint(Trinity::Net::make_address_v4(handler->GetSession()->GetRemoteAddress())); - EndianConvertReverse(ip); - stmt->setUInt32(0, ip); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (result) + if (IpLocationRecord* location = sIPLocation->GetData(handler->GetSession()->GetRemoteAddress())) { - Field* fields = result->Fetch(); - std::string country = fields[0].GetString(); - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY); - stmt->setString(0, country); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY); + stmt->setString(0, location->country_code); stmt->setUInt32(1, handler->GetSession()->GetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); } else { - handler->PSendSysMessage("[IP2NATION] Table empty"); - TC_LOG_DEBUG("server.bnetserver", "[IP2NATION] Table empty"); + handler->PSendSysMessage("IP2Location] No information"); + TC_LOG_DEBUG("server.bnetserver", "IP2Location] No information"); } } else if (param == "off") diff --git a/src/server/scripts/Commands/cs_battlenet_account.cpp b/src/server/scripts/Commands/cs_battlenet_account.cpp index 6db54c2ee5e..c801770dc8d 100644 --- a/src/server/scripts/Commands/cs_battlenet_account.cpp +++ b/src/server/scripts/Commands/cs_battlenet_account.cpp @@ -21,6 +21,7 @@ #include "Chat.h" #include "DatabaseEnv.h" #include "IpAddress.h" +#include "IPLocation.h" #include "Language.h" #include "Log.h" #include "Player.h" @@ -143,25 +144,18 @@ public: { if (param == "on") { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY); - uint32 ip = Trinity::Net::address_to_uint(Trinity::Net::make_address_v4(handler->GetSession()->GetRemoteAddress())); - EndianConvertReverse(ip); - stmt->setUInt32(0, ip); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (result) + if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(handler->GetSession()->GetRemoteAddress())) { - Field* fields = result->Fetch(); - std::string country = fields[0].GetString(); - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_ACCOUNT_LOCK_CONTRY); - stmt->setString(0, country); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_ACCOUNT_LOCK_CONTRY); + stmt->setString(0, location->CountryCode); stmt->setUInt32(1, handler->GetSession()->GetBattlenetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); } else { - handler->PSendSysMessage("[IP2NATION] Table empty"); - TC_LOG_DEBUG("server.bnetserver", "[IP2NATION] Table empty"); + handler->PSendSysMessage("IP2Location] No information"); + TC_LOG_DEBUG("server.bnetserver", "IP2Location] No information"); } } else if (param == "off") diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index e77e551825c..417153bfeff 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -27,6 +27,7 @@ #include "GroupMgr.h" #include "InstanceSaveMgr.h" #include "IpAddress.h" +#include "IPLocation.h" #include "Item.h" #include "Language.h" #include "LFG.h" @@ -1768,17 +1769,10 @@ public: lastIp = fields[4].GetString(); lastLogin = fields[5].GetString(); - uint32 ip = Trinity::Net::address_to_uint(Trinity::Net::make_address_v4(lastIp)); - EndianConvertReverse(ip); - - // If ip2nation table is populated, it displays the country - stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP2NATION_COUNTRY); - stmt->setUInt32(0, ip); - if (PreparedQueryResult result2 = LoginDatabase.Query(stmt)) + if (IpLocationRecord* location = sIPLocation->GetData(lastIp)) { - Field* fields2 = result2->Fetch(); lastIp.append(" ("); - lastIp.append(fields2[0].GetString()); + lastIp.append(location->country_name); lastIp.append(")"); } } |
