Changeset 5448
- Timestamp:
- 26/06/2009 01:23:36 (9 months ago)
- Location:
- Mirrors/AMXModX/dlls/geoip_ex
- Files:
-
- 8 modified
-
GeoIP.c (modified) (2 diffs)
-
Makefile (modified) (2 diffs)
-
geoip_amxx.cpp (modified) (8 diffs)
-
geoip_amxx.h (modified) (1 diff)
-
include/geoip_ex.inc (modified) (1 diff)
-
msvc8/geoip.vcproj (modified) (2 diffs)
-
sdk/amxxmodule.cpp (modified) (2 diffs)
-
sdk/amxxmodule.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Mirrors/AMXModX/dlls/geoip_ex/GeoIP.c
r5443 r5448 251 251 } 252 252 253 /* 254 static 253 /* static 255 254 int _file_exists(const char *file_name) { 256 255 struct stat file_stat; 257 256 return( (stat(file_name, &file_stat) == 0) ? 1:0); 258 } 259 260 int GeoIP_db_avail(int type) {257 } */ 258 259 /* int GeoIP_db_avail(int type) { 261 260 const char * filePath; 262 261 if (type < 0 || type >= NUM_DB_TYPES) { … … 269 268 } 270 269 return _file_exists(filePath); 271 } 272 */ 270 }*/ 273 271 274 272 static -
Mirrors/AMXModX/dlls/geoip_ex/Makefile
r5444 r5448 10 10 DEBUG_FLAGS = -g -ggdb3 11 11 CPP = gcc-4.1 12 NAME = geoip ex12 NAME = geoip 13 13 14 14 BIN_SUFFIX_32 = amxx_i386.so 15 15 BIN_SUFFIX_64 = amxx_amd64.so 16 16 17 OBJECTS = sdk/amxxmodule.cpp GeoIP.c GeoIPCity.c regionName.c timeZone.cgeoip_amxx.cpp17 OBJECTS = sdk/amxxmodule.cpp GeoIP.c geoip_amxx.cpp 18 18 19 LINK = 19 LINK = 20 20 21 21 INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \ … … 62 62 mkdir -p $(BIN_DIR) 63 63 mkdir -p $(BIN_DIR)/sdk 64 $(MAKE) geoip ex64 $(MAKE) geoip 65 65 66 66 amd64: 67 67 $(MAKE) all AMD64=true 68 68 69 geoip ex: $(OBJ_LINUX)69 geoip: $(OBJ_LINUX) 70 70 $(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) 71 71 -
Mirrors/AMXModX/dlls/geoip_ex/geoip_amxx.cpp
r5443 r5448 17 17 } 18 18 19 /* Deprec ated */19 /* Depreceted */ 20 20 static cell AMX_NATIVE_CALL amx_geoip_code2(AMX *amx, cell *params) 21 21 { … … 29 29 } 30 30 31 /* Deprec ated */31 /* Depreceted */ 32 32 static cell AMX_NATIVE_CALL amx_geoip_code3( AMX *amx, cell *params ) 33 33 { … … 130 130 static cell AMX_NATIVE_CALL amx_geoip_city( AMX *amx, cell *params ) 131 131 { 132 int len = 0; 133 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 134 135 StripPort( ip ); 136 GeoIPRecord* rec = GeoIP_record_by_addr( gi, ip ); 137 138 if ( rec ) 139 { 140 cell res = MF_SetAmxString( amx, params[2], rec->city ? rec->city : "error", params[3] ); 141 free( rec ); 142 return res; 132 if ( !db_default ) 133 { 134 int len = 0; 135 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 136 137 StripPort( ip ); 138 GeoIPRecord* rec = GeoIP_record_by_addr( gi, ip ); 139 140 if ( rec ) 141 { 142 cell res = MF_SetAmxString( amx, params[2], rec->city ? rec->city : "error", params[3] ); 143 free( rec ); 144 return res; 145 } 143 146 } 144 147 … … 148 151 static cell AMX_NATIVE_CALL amx_geoip_latitude( AMX *amx, cell *params ) 149 152 { 150 int len = 0; 151 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 152 153 StripPort( ip ); 154 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 155 156 return ( rec ) ? amx_ftoc( rec->latitude ) : 0; 153 if ( !db_default ) 154 { 155 int len = 0; 156 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 157 158 StripPort( ip ); 159 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 160 161 return ( rec ) ? amx_ftoc( rec->latitude ) : 0; 162 } 163 164 return 0; 157 165 } 158 166 159 167 static cell AMX_NATIVE_CALL amx_geoip_longitude( AMX *amx, cell *params ) 160 168 { 161 int len = 0; 162 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 163 164 StripPort( ip ); 165 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 166 167 return ( rec ) ? amx_ftoc( rec->longitude ) : 0; 169 if ( !db_default ) 170 { 171 int len = 0; 172 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 173 174 StripPort( ip ); 175 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 176 177 return ( rec ) ? amx_ftoc( rec->longitude ) : 0; 178 } 179 180 return 0; 168 181 } 169 182 170 183 static cell AMX_NATIVE_CALL amx_geoip_region( AMX *amx, cell *params ) 171 184 { 172 int len = 0; 173 char *ip = MF_GetAmxString(amx, params[1], 0, &len); 174 175 StripPort( ip ); 176 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 177 178 if ( rec ) 179 { 180 MF_SetAmxString( amx, params[2], rec->region, 2 ); 181 return 1; 185 if ( !db_default ) 186 { 187 int len = 0; 188 char *ip = MF_GetAmxString(amx, params[1], 0, &len); 189 190 StripPort( ip ); 191 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 192 193 if ( rec ) 194 { 195 MF_SetAmxString( amx, params[2], rec->region, 2 ); 196 return 1; 197 } 182 198 } 183 199 … … 187 203 static cell AMX_NATIVE_CALL amx_geoip_region_name( AMX *amx, cell *params ) 188 204 { 189 int len = 0; 190 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 191 192 StripPort( ip ); 193 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 194 195 if ( rec ) 196 { 197 const char *region = GeoIP_region_name_by_code( rec->country_code, rec->region ); 198 return MF_SetAmxString( amx, params[2], region, params[3] ); 205 if ( !db_default ) 206 { 207 int len = 0; 208 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 209 210 StripPort( ip ); 211 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 212 213 if ( rec ) 214 { 215 const char *region = GeoIP_region_name_by_code( rec->country_code, rec->region ); 216 return MF_SetAmxString( amx, params[2], region, params[3] ); 217 } 199 218 } 200 219 … … 204 223 static cell AMX_NATIVE_CALL amx_geoip_timezone( AMX *amx, cell *params ) 205 224 { 206 int len = 0; 207 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 208 209 StripPort( ip ); 210 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 211 212 if ( rec ) 213 { 214 const char *timezone = GeoIP_time_zone_by_country_and_region( rec->country_code, rec->region ); 215 return MF_SetAmxString( amx, params[2], timezone, params[3] ); 225 if ( !db_default ) 226 { 227 int len = 0; 228 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 229 230 StripPort( ip ); 231 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 232 233 if ( rec ) 234 { 235 const char *timezone = GeoIP_time_zone_by_country_and_region( rec->country_code, rec->region ); 236 return MF_SetAmxString( amx, params[2], timezone, params[3] ); 237 } 216 238 } 217 239 … … 221 243 static cell AMX_NATIVE_CALL amx_geoip_continent_code( AMX *amx, cell *params ) 222 244 { 223 int len = 0; 224 char *ip = MF_GetAmxString(amx, params[1], 0, &len); 225 226 StripPort( ip ); 227 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 228 229 if ( rec ) 230 { 231 MF_SetAmxString( amx, params[2], rec->continent_code, 2 ); 232 return 1; 233 } 234 235 return 0; 245 if ( !db_default ) 246 { 247 int len = 0; 248 char *ip = MF_GetAmxString(amx, params[1], 0, &len); 249 250 StripPort( ip ); 251 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 252 253 if ( rec ) 254 { 255 MF_SetAmxString( amx, params[2], rec->continent_code, 2 ); 256 return 1; 257 } 258 } 259 260 return 0; 261 } 262 263 static cell AMX_NATIVE_CALL amx_geoip_distance( AMX *amx, cell *params ) 264 { 265 REAL RAD_CONVERT = (REAL)M_PI / 180; 266 REAL EARTH_RADIUS = (REAL)6378.2; 267 268 REAL lat1 = amx_ctof( params[1] ) * RAD_CONVERT; 269 REAL lon1 = amx_ctof( params[2] ) * RAD_CONVERT; 270 REAL lat2 = amx_ctof( params[3] ) * RAD_CONVERT; 271 REAL lon2 = amx_ctof( params[4] ) * RAD_CONVERT; 272 273 return amx_ftoc( EARTH_RADIUS * acos( sin( lat1 ) * sin( lat2 ) + cos( lat1 ) * cos( lat2 ) * cos( lon2 - lon1 ) ) ); 236 274 } 237 275 … … 297 335 { "geoip_continent_code", amx_geoip_continent_code }, 298 336 337 { "geoip_distance" , amx_geoip_distance }, 299 338 { NULL , NULL }, 300 339 }; -
Mirrors/AMXModX/dlls/geoip_ex/geoip_amxx.h
r5442 r5448 4 4 #define GEOIPDATADIR "" 5 5 6 #define M_PI 3.14159265358979323846 7 8 9 #include <math.h> 6 10 #include "amxxmodule.h" 7 11 #include "GeoIP.h" -
Mirrors/AMXModX/dlls/geoip_ex/include/geoip_ex.inc
r5442 r5448 140 140 * 141 141 * @param ip The IP address to lookup. 142 * @ param result The result of the geoiplookup.142 * @return true on a successful lookup, false on a failed lookup. 143 143 */ 144 native geoip_continent_code( const ip[], result[3] ); 144 native bool:geoip_continent_code( const ip[], result[3] ); 145 146 /** 147 * Calculate the distance between geographical coordinates, latitude and longitude. 148 * 149 * @param lat1 The first IP latitude. 150 * @param lon1 The first IP longitude. 151 * @param lat2 The second IP latitude. 152 * @param lon2 The second IP longitude. 153 * @param result The distance as result in kilometer. 154 */ 155 native Float:geoip_distance( Float:lat1, Float:lon1, Float:lat2, Float:lon2 ); -
Mirrors/AMXModX/dlls/geoip_ex/msvc8/geoip.vcproj
r5441 r5448 201 201 > 202 202 </File> 203 <File204 RelativePath="..\svn_version.h"205 >206 </File>207 203 </Filter> 208 204 <Filter … … 258 254 > 259 255 <File 260 RelativePath="..\ ..\..\plugins\include\geoip.inc"256 RelativePath="..\geoip.inc" 261 257 > 262 258 </File> -
Mirrors/AMXModX/dlls/geoip_ex/sdk/amxxmodule.cpp
r5442 r5448 2707 2707 va_start(arglst, fmt); 2708 2708 vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); 2709 // vsnprintf_s(msg, sizeof(msg), _TRUNCATE, fmt, arglst); 2709 2710 va_end(arglst); 2710 2711 … … 2718 2719 va_start(arglst, fmt); 2719 2720 vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); 2721 // vsnprintf_s(msg, sizeof(msg), _TRUNCATE, fmt, arglst); 2720 2722 va_end(arglst); 2721 2723 -
Mirrors/AMXModX/dlls/geoip_ex/sdk/amxxmodule.h
r5442 r5448 287 287 * functions above are deprecated. */ 288 288 #pragma warning (disable:4996) 289 289 290 290 #endif 291 291 #else

