registered natives and removed todo's

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40326
This commit is contained in:
Borja Ferrer 2007-01-19 02:39:58 +00:00
parent 2ac8a6597f
commit 2b7776f075
4 changed files with 22 additions and 3 deletions

View File

@ -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},
};

View File

@ -58,4 +58,6 @@ public:
#endif
};
extern const sp_nativeinfo_t geoip_natives[];
#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_

View File

@ -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))
{

View File

@ -6,6 +6,7 @@
#include <IHandleSys.h>
#include <sp_vm_api.h>
#include <sm_platform.h>
#include <ISourceMod.h>
#if defined SMEXT_CONF_METAMOD
#include <ISmmPlugin.h>
@ -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();