Core/Commands: Add support for ip2nation database lookups when using .pinfo command.

This will (when a full database exists) allow for seeing (approximately) which country a player might be from when doing .pinfo <player>
Note: External data required for this patch to work correctly can be found at http://www.ip2nation.com/ip2nation/Download

Signed-off-by: click <[email protected]>
This commit is contained in:
Spp
2012-03-23 05:35:32 +01:00
committed by click
parent 479c0976ab
commit 0fe4580fe0
4 changed files with 58 additions and 0 deletions
+15
View File
@@ -42,6 +42,7 @@
#include "Transport.h"
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
#include "CreatureGroups.h"
#include "ace/INET_Addr.h"
//mute player for some times
bool ChatHandler::HandleMuteCommand(const char* args)
@@ -347,6 +348,20 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
{
last_ip = fields[3].GetString();
last_login = fields[4].GetString();
uint32 ip = inet_addr(last_ip.c_str());
#if TRINITY_ENDIAN == BIGENDIAN
EndianConvertReverse(ip);
#endif
if (QueryResult result2 = WorldDatabase.PQuery("SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE "
"i.ip < %u AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1", ip))
{
Field* fields2 = result2->Fetch();
last_ip.append(" (");
last_ip.append(fields2[0].GetString());
last_ip.append(")");
}
}
else
{