From 2b7776f075b9c6b6cc6c7f298f3d5289de3042a8 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Fri, 19 Jan 2007 02:39:58 +0000 Subject: [PATCH] registered natives and removed todo's --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40326 --- extensions/geoip/extension.cpp | 19 ++++++++++++++++--- extensions/geoip/extension.h | 2 ++ extensions/geoip/smsdk_ext.cpp | 2 ++ extensions/geoip/smsdk_ext.h | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/extensions/geoip/extension.cpp b/extensions/geoip/extension.cpp index e390f81c..ac9df7de 100644 --- a/extensions/geoip/extension.cpp +++ b/extensions/geoip/extension.cpp @@ -8,15 +8,20 @@ SMEXT_LINK(&g_GeoIP); bool GeoIP_Extension::SDK_OnLoad(char *error, size_t err_max, bool late) { - char *path = "GeoIP.dat"; //:TODO: build a real path here - //:TODO: log any errors on load. + char path[PLATFORM_MAX_PATH+1]; + + g_pSM->BuildPath(Path_SM, path, sizeof(path), "configs/geoip/GeoIP.dat"); gi = GeoIP_open(path, GEOIP_MEMORY_CACHE); if (!gi) { - //:TODO: log + snprintf(error, err_max, "Failed to instantiate GeoIP!"); return false; } + + g_pShareSys->AddNatives(myself, geoip_natives); + g_pSM->LogMessage(myself, "GeoIP database info: %s", GeoIP_database_info(gi)); + return true; } @@ -81,3 +86,11 @@ static cell_t sm_Geoip_Country(IPluginContext *pCtx, const cell_t *params) return 1; } + +const sp_nativeinfo_t geoip_natives[] = +{ + {"GeoipCode2", sm_Geoip_Code2}, + {"GeoipCode3", sm_Geoip_Code3}, + {"GeoipCountry", sm_Geoip_Country}, + {NULL, NULL}, +}; \ No newline at end of file diff --git a/extensions/geoip/extension.h b/extensions/geoip/extension.h index 4a025416..2a4f7ad7 100644 --- a/extensions/geoip/extension.h +++ b/extensions/geoip/extension.h @@ -58,4 +58,6 @@ public: #endif }; +extern const sp_nativeinfo_t geoip_natives[]; + #endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extensions/geoip/smsdk_ext.cpp b/extensions/geoip/smsdk_ext.cpp index 3bd1ffe2..01e3f42c 100644 --- a/extensions/geoip/smsdk_ext.cpp +++ b/extensions/geoip/smsdk_ext.cpp @@ -4,6 +4,7 @@ IShareSys *g_pShareSys = NULL; IExtension *myself = NULL; IHandleSys *g_pHandleSys = NULL; +ISourceMod *g_pSM = NULL; PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() { @@ -38,6 +39,7 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, #endif SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys); + SM_GET_IFACE(SOURCEMOD, g_pSM); if (SDK_OnLoad(error, err_max, late)) { diff --git a/extensions/geoip/smsdk_ext.h b/extensions/geoip/smsdk_ext.h index f4d30711..07362c78 100644 --- a/extensions/geoip/smsdk_ext.h +++ b/extensions/geoip/smsdk_ext.h @@ -6,6 +6,7 @@ #include #include #include +#include #if defined SMEXT_CONF_METAMOD #include @@ -121,6 +122,7 @@ extern SDKExtension *g_pExtensionIface; extern IShareSys *g_pShareSys; extern IExtension *myself; extern IHandleSys *g_pHandleSys; +extern ISourceMod *g_pSM; #if defined SMEXT_CONF_METAMOD PLUGIN_GLOBALVARS();