added precache natives

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40662
This commit is contained in:
Borja Ferrer
2007-03-25 22:25:45 +00:00
parent 5c7381f11a
commit fd1e3c4e97
4 changed files with 163 additions and 1 deletions
+81
View File
@@ -135,6 +135,78 @@ static cell_t GetCurrentMap(IPluginContext *pContext, const cell_t *params)
return bytes;
}
static cell_t PrecacheModel(IPluginContext *pContext, const cell_t *params)
{
char *model;
pContext->LocalToString(params[1], &model);
return engine->PrecacheModel(model, params[2] ? true : false);
}
static cell_t PrecacheSentenceFile(IPluginContext *pContext, const cell_t *params)
{
char *sentencefile;
pContext->LocalToString(params[1], &sentencefile);
return engine->PrecacheSentenceFile(sentencefile, params[2] ? true : false);
}
static cell_t PrecacheDecal(IPluginContext *pContext, const cell_t *params)
{
char *decal;
pContext->LocalToString(params[1], &decal);
return engine->PrecacheDecal(decal, params[2] ? true : false);
}
static cell_t PrecacheGeneric(IPluginContext *pContext, const cell_t *params)
{
char *generic;
pContext->LocalToString(params[1], &generic);
return engine->PrecacheGeneric(generic, params[2] ? true : false);
}
static cell_t IsModelPrecached(IPluginContext *pContext, const cell_t *params)
{
char *model;
pContext->LocalToString(params[1], &model);
return engine->IsModelPrecached(model) ? 1 : 0;
}
static cell_t IsDecalPrecached(IPluginContext *pContext, const cell_t *params)
{
char *decal;
pContext->LocalToString(params[1], &decal);
return engine->IsDecalPrecached(decal) ? 1 : 0;
}
static cell_t IsGenericPrecached(IPluginContext *pContext, const cell_t *params)
{
char *generic;
pContext->LocalToString(params[1], &generic);
return engine->IsGenericPrecached(generic) ? 1 : 0;
}
static cell_t PrecacheSound(IPluginContext *pContext, const cell_t *params)
{
char *sample;
pContext->LocalToString(params[1], &sample);
return enginesound->PrecacheSound(sample, params[2] ? true : false) ? 1 : 0;
}
static cell_t IsSoundPrecached(IPluginContext *pContext, const cell_t *params)
{
char *sample;
pContext->LocalToString(params[1], &sample);
return enginesound->IsSoundPrecached(sample) ? 1 : 0;
}
REGISTER_NATIVES(halflifeNatives)
{
{"CreateFakeClient", CreateFakeClient},
@@ -148,5 +220,14 @@ REGISTER_NATIVES(halflifeNatives)
{"IsMapValid", IsMapValid},
{"SetFakeClientConVar", SetFakeClientConVar},
{"SetRandomSeed", SetRandomSeed},
{"PrecacheModel", PrecacheModel},
{"PrecacheSentenceFile", PrecacheSentenceFile},
{"PrecacheDecal", PrecacheDecal},
{"PrecacheGeneric", PrecacheGeneric},
{"IsModelPrecached", IsModelPrecached},
{"IsDecalPrecached", IsDecalPrecached},
{"IsGenericPrecached", IsGenericPrecached},
{"PrecacheSound", PrecacheSound},
{"IsSoundPrecached", IsSoundPrecached},
{NULL, NULL},
};
+3 -1
View File
@@ -29,7 +29,8 @@ IUniformRandomStream *engrandom = NULL;
CallClass<IVEngineServer> *enginePatch = NULL;
CallClass<IServerGameDLL> *gamedllPatch = NULL;
IPlayerInfoManager *playerinfo = NULL;
IBaseFileSystem *basefilesystem;
IBaseFileSystem *basefilesystem = NULL;
IEngineSound *enginesound = NULL;
PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
@@ -44,6 +45,7 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(fileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(engineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
/* :TODO: Make this optional and... make it find earlier versions [?] */
GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
+2
View File
@@ -22,6 +22,7 @@
#include <iplayerinfo.h>
#include <random.h>
#include <filesystem.h>
#include <IEngineSound.h>
/**
* @file Contains wrappers around required Metamod:Source API exports
@@ -59,6 +60,7 @@ extern SourceHook::CallClass<IServerGameDLL> *gamedllPatch;
extern IUniformRandomStream *engrandom;
extern IPlayerInfoManager *playerinfo;
extern IBaseFileSystem *basefilesystem;
extern IEngineSound *enginesound;
#define ENGINE_CALL(func) SH_CALL(enginePatch, &IVEngineServer::func)
#define SERVER_CALL(func) SH_CALL(gamedllPatch, &IServerGameDLL::func)