From 6ac889f6e2bd6733d3119e9b1fbfc6fdc260c054 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sun, 16 Jul 2006 13:23:56 +0000 Subject: [PATCH] fixed bug at40963 --- dlls/geoip/geoip_amxx.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dlls/geoip/geoip_amxx.cpp b/dlls/geoip/geoip_amxx.cpp index 04a7d046..5b003972 100755 --- a/dlls/geoip/geoip_amxx.cpp +++ b/dlls/geoip/geoip_amxx.cpp @@ -3,10 +3,19 @@ GeoIP *gi = NULL; +inline void StripPort(char *ip) +{ + char *tmp = strchr(ip, ':'); + if (!tmp) + return; + *tmp = '\0'; +} + static cell AMX_NATIVE_CALL amx_geoip_code2(AMX *amx, cell *params) { int len = 0; char *ip = MF_GetAmxString(amx, params[1], 0, &len); + StripPort(ip); const char *ccode = GeoIP_country_code_by_addr(gi, ip); return MF_SetAmxString(amx, params[2], ccode?ccode:"error", 3); } @@ -15,6 +24,7 @@ static cell AMX_NATIVE_CALL amx_geoip_code3(AMX *amx, cell *params) { int len = 0; char *ip = MF_GetAmxString(amx, params[1], 0, &len); + StripPort(ip); const char *ccode = GeoIP_country_code3_by_addr(gi, ip); return MF_SetAmxString(amx, params[2], ccode?ccode:"error", 4); } @@ -23,6 +33,7 @@ static cell AMX_NATIVE_CALL amx_geoip_country(AMX *amx, cell *params) { int len = 0; char *ip = MF_GetAmxString(amx, params[1], 0, &len); + StripPort(ip); const char *ccode = GeoIP_country_name_by_addr(gi, ip); return MF_SetAmxString(amx, params[2], ccode?ccode:"error", params[3]); }