# HG changeset patch # User David Anderson # Date 1186688926 0 # Node ID 2a71249ca0aba0c745651323ccd33b368dee40af # Parent 753dd36abf1701e885b5426095500bae471faeb8 fixed silly design decisions in geoip that were copied over from amxmodx. natives now return true/false and the buffer is zeroed instead of filled with "ERROR" diff -r 753dd36abf17 -r 2a71249ca0ab extensions/geoip/extension.cpp --- a/extensions/geoip/extension.cpp Thu Aug 09 19:14:15 2007 +0000 +++ b/extensions/geoip/extension.cpp Thu Aug 09 19:48:46 2007 +0000 @@ -90,9 +90,10 @@ StripPort(ip); ccode = GeoIP_country_code_by_addr(gi, ip); - pCtx->StringToLocal(params[2], 3, (ccode) ? ccode : "er"); - return 1; + pCtx->StringToLocal(params[2], 3, ccode ? ccode : ""); + + return ccode ? 1 : 0; } static cell_t sm_Geoip_Code3(IPluginContext *pCtx, const cell_t *params) @@ -104,9 +105,9 @@ StripPort(ip); ccode = GeoIP_country_code3_by_addr(gi, ip); - pCtx->StringToLocal(params[2], 4, (ccode) ? ccode : "err"); + pCtx->StringToLocal(params[2], 4, ccode ? ccode : ""); - return 1; + return ccode ? 1 : 0; } static cell_t sm_Geoip_Country(IPluginContext *pCtx, const cell_t *params) @@ -118,9 +119,9 @@ StripPort(ip); ccode = GeoIP_country_name_by_addr(gi, ip); - pCtx->StringToLocal(params[2], params[3], (ccode) ? ccode : "error"); + pCtx->StringToLocal(params[2], params[3], (ccode) ? ccode : ""); - return 1; + return ccode ? 1 : 0; } const sp_nativeinfo_t geoip_natives[] = diff -r 753dd36abf17 -r 2a71249ca0ab plugins/include/geoip.inc --- a/plugins/include/geoip.inc Thu Aug 09 19:14:15 2007 +0000 +++ b/plugins/include/geoip.inc Thu Aug 09 19:48:46 2007 +0000 @@ -29,18 +29,18 @@ * * @param ip Ip to determine the country code. * @param ccode Destination string buffer to store the code. - * @noreturn + * @return True on success, false if no country found. */ -native GeoipCode2(const String:ip[], String:ccode[3]); +native bool:GeoipCode2(const String:ip[], String:ccode[3]); /** * Gets the three character country code from an IP address. (USA, CAN, etc) * * @param ip Ip to determine the country code. * @param ccode Destination string buffer to store the code. - * @noreturn + * @return True on success, false if no country found. */ -native GeoipCode3(const String:ip[], String:ccode[4]); +native bool:GeoipCode3(const String:ip[], String:ccode[4]); /** * Gets the full country name. (max length of output string is 45) @@ -48,9 +48,9 @@ * @param ip Ip to determine the country code. * @param ccode Destination string buffer to store the country name. * @param len Maximum length of output string buffer. - * @noreturn + * @return True on success, false if no country found. */ -native GeoipCountry(const String:ip[], String:name[], len=45); +native bool:GeoipCountry(const String:ip[], String:name[], maxlength); /** * @endsection