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"
authorDavid Anderson <dvander@alliedmods.net>
Thu Aug 09 19:48:46 2007 +0000 (2007-08-09)
changeset 12932a71249ca0ab
parent 1292 753dd36abf17
child 1294 63af7da6c82c
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"
extensions/geoip/extension.cpp
plugins/include/geoip.inc
     1.1 --- a/extensions/geoip/extension.cpp	Thu Aug 09 19:14:15 2007 +0000
     1.2 +++ b/extensions/geoip/extension.cpp	Thu Aug 09 19:48:46 2007 +0000
     1.3 @@ -90,9 +90,10 @@
     1.4  	StripPort(ip);
     1.5  
     1.6  	ccode = GeoIP_country_code_by_addr(gi, ip);
     1.7 -	pCtx->StringToLocal(params[2], 3, (ccode) ? ccode : "er");
     1.8  
     1.9 -	return 1;
    1.10 +	pCtx->StringToLocal(params[2], 3, ccode ? ccode : "");
    1.11 +
    1.12 +	return ccode ? 1 : 0;
    1.13  }
    1.14  
    1.15  static cell_t sm_Geoip_Code3(IPluginContext *pCtx, const cell_t *params)
    1.16 @@ -104,9 +105,9 @@
    1.17  	StripPort(ip);
    1.18  
    1.19  	ccode = GeoIP_country_code3_by_addr(gi, ip);
    1.20 -	pCtx->StringToLocal(params[2], 4, (ccode) ? ccode : "err");
    1.21 +	pCtx->StringToLocal(params[2], 4, ccode ? ccode : "");
    1.22  
    1.23 -	return 1;
    1.24 +	return ccode ? 1 : 0;
    1.25  }
    1.26  
    1.27  static cell_t sm_Geoip_Country(IPluginContext *pCtx, const cell_t *params)
    1.28 @@ -118,9 +119,9 @@
    1.29  	StripPort(ip);
    1.30  
    1.31  	ccode = GeoIP_country_name_by_addr(gi, ip);
    1.32 -	pCtx->StringToLocal(params[2], params[3], (ccode) ? ccode : "error");
    1.33 +	pCtx->StringToLocal(params[2], params[3], (ccode) ? ccode : "");
    1.34  
    1.35 -	return 1;
    1.36 +	return ccode ? 1 : 0;
    1.37  }
    1.38  
    1.39  const sp_nativeinfo_t geoip_natives[] = 
     2.1 --- a/plugins/include/geoip.inc	Thu Aug 09 19:14:15 2007 +0000
     2.2 +++ b/plugins/include/geoip.inc	Thu Aug 09 19:48:46 2007 +0000
     2.3 @@ -29,18 +29,18 @@
     2.4   *
     2.5   * @param ip			Ip to determine the country code.
     2.6   * @param ccode			Destination string buffer to store the code.
     2.7 - * @noreturn
     2.8 + * @return				True on success, false if no country found.
     2.9   */
    2.10 -native GeoipCode2(const String:ip[], String:ccode[3]);
    2.11 +native bool:GeoipCode2(const String:ip[], String:ccode[3]);
    2.12  
    2.13  /**
    2.14   * Gets the three character country code from an IP address. (USA, CAN, etc)
    2.15   *
    2.16   * @param ip			Ip to determine the country code.
    2.17   * @param ccode			Destination string buffer to store the code.
    2.18 - * @noreturn
    2.19 + * @return				True on success, false if no country found.
    2.20   */
    2.21 -native GeoipCode3(const String:ip[], String:ccode[4]);
    2.22 +native bool:GeoipCode3(const String:ip[], String:ccode[4]);
    2.23  
    2.24  /**
    2.25   * Gets the full country name. (max length of output string is 45)
    2.26 @@ -48,9 +48,9 @@
    2.27   * @param ip			Ip to determine the country code.
    2.28   * @param ccode			Destination string buffer to store the country name.
    2.29   * @param len			Maximum length of output string buffer.
    2.30 - * @noreturn
    2.31 + * @return				True on success, false if no country found.
    2.32   */
    2.33 -native GeoipCountry(const String:ip[], String:name[], len=45);
    2.34 +native bool:GeoipCountry(const String:ip[], String:name[], maxlength);
    2.35  
    2.36  /**
    2.37   * @endsection