added precache natives
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40662
This commit is contained in:
parent
5c7381f11a
commit
fd1e3c4e97
@ -135,6 +135,78 @@ static cell_t GetCurrentMap(IPluginContext *pContext, const cell_t *params)
|
|||||||
return bytes;
|
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)
|
REGISTER_NATIVES(halflifeNatives)
|
||||||
{
|
{
|
||||||
{"CreateFakeClient", CreateFakeClient},
|
{"CreateFakeClient", CreateFakeClient},
|
||||||
@ -148,5 +220,14 @@ REGISTER_NATIVES(halflifeNatives)
|
|||||||
{"IsMapValid", IsMapValid},
|
{"IsMapValid", IsMapValid},
|
||||||
{"SetFakeClientConVar", SetFakeClientConVar},
|
{"SetFakeClientConVar", SetFakeClientConVar},
|
||||||
{"SetRandomSeed", SetRandomSeed},
|
{"SetRandomSeed", SetRandomSeed},
|
||||||
|
{"PrecacheModel", PrecacheModel},
|
||||||
|
{"PrecacheSentenceFile", PrecacheSentenceFile},
|
||||||
|
{"PrecacheDecal", PrecacheDecal},
|
||||||
|
{"PrecacheGeneric", PrecacheGeneric},
|
||||||
|
{"IsModelPrecached", IsModelPrecached},
|
||||||
|
{"IsDecalPrecached", IsDecalPrecached},
|
||||||
|
{"IsGenericPrecached", IsGenericPrecached},
|
||||||
|
{"PrecacheSound", PrecacheSound},
|
||||||
|
{"IsSoundPrecached", IsSoundPrecached},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,8 @@ IUniformRandomStream *engrandom = NULL;
|
|||||||
CallClass<IVEngineServer> *enginePatch = NULL;
|
CallClass<IVEngineServer> *enginePatch = NULL;
|
||||||
CallClass<IServerGameDLL> *gamedllPatch = NULL;
|
CallClass<IServerGameDLL> *gamedllPatch = NULL;
|
||||||
IPlayerInfoManager *playerinfo = NULL;
|
IPlayerInfoManager *playerinfo = NULL;
|
||||||
IBaseFileSystem *basefilesystem;
|
IBaseFileSystem *basefilesystem = NULL;
|
||||||
|
IEngineSound *enginesound = NULL;
|
||||||
|
|
||||||
PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
|
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, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
|
||||||
GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
|
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(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 [?] */
|
/* :TODO: Make this optional and... make it find earlier versions [?] */
|
||||||
GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
|
GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <iplayerinfo.h>
|
#include <iplayerinfo.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <filesystem.h>
|
#include <filesystem.h>
|
||||||
|
#include <IEngineSound.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file Contains wrappers around required Metamod:Source API exports
|
* @file Contains wrappers around required Metamod:Source API exports
|
||||||
@ -59,6 +60,7 @@ extern SourceHook::CallClass<IServerGameDLL> *gamedllPatch;
|
|||||||
extern IUniformRandomStream *engrandom;
|
extern IUniformRandomStream *engrandom;
|
||||||
extern IPlayerInfoManager *playerinfo;
|
extern IPlayerInfoManager *playerinfo;
|
||||||
extern IBaseFileSystem *basefilesystem;
|
extern IBaseFileSystem *basefilesystem;
|
||||||
|
extern IEngineSound *enginesound;
|
||||||
|
|
||||||
#define ENGINE_CALL(func) SH_CALL(enginePatch, &IVEngineServer::func)
|
#define ENGINE_CALL(func) SH_CALL(enginePatch, &IVEngineServer::func)
|
||||||
#define SERVER_CALL(func) SH_CALL(gamedllPatch, &IServerGameDLL::func)
|
#define SERVER_CALL(func) SH_CALL(gamedllPatch, &IServerGameDLL::func)
|
||||||
|
@ -310,5 +310,82 @@ native GetGameDescription(String:buffer[], maxlength, bool:original=false);
|
|||||||
*/
|
*/
|
||||||
native GetCurrentMap(String:buffer[], maxlength);
|
native GetCurrentMap(String:buffer[], maxlength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precaches a given model.
|
||||||
|
*
|
||||||
|
* @param model Name of the model to precache.
|
||||||
|
* @param preload If preload is true the file will be precached before level startup.
|
||||||
|
* @return Returns the model index, 0 for error.
|
||||||
|
*/
|
||||||
|
native PrecacheModel(const String:model[], bool:preload=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precaches a given sentence file.
|
||||||
|
*
|
||||||
|
* @param file Name of the sentence file to precache.
|
||||||
|
* @param preload If preload is true the file will be precached before level startup.
|
||||||
|
* @return Returns a sentence file index.
|
||||||
|
*/
|
||||||
|
native PrecacheSentenceFile(const String:file[], bool:preload=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precaches a given decal.
|
||||||
|
*
|
||||||
|
* @param decal Name of the decal to precache.
|
||||||
|
* @param preload If preload is true the file will be precached before level startup.
|
||||||
|
* @return Returns a decal index.
|
||||||
|
*/
|
||||||
|
native PrecacheDecal(const String:decal[], bool:preload=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precaches a given generic file.
|
||||||
|
*
|
||||||
|
* @param generic Name of the generic file to precache.
|
||||||
|
* @param preload If preload is true the file will be precached before level startup.
|
||||||
|
* @return Returns a generic file index.
|
||||||
|
*/
|
||||||
|
native PrecacheGeneric(const String:generic[], bool:preload=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a given model is precached.
|
||||||
|
*
|
||||||
|
* @param model Name of the model to check.
|
||||||
|
* @return True if precached, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsModelPrecached(const String:model[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a given decal is precached.
|
||||||
|
*
|
||||||
|
* @param decal Name of the decal to check.
|
||||||
|
* @return True if precached, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsDecalPrecached(const String:decal[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a given generic file is precached.
|
||||||
|
*
|
||||||
|
* @param decal Name of the generic file to check.
|
||||||
|
* @return True if precached, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsGenericPrecached(const String:generic[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precaches a given sound.
|
||||||
|
*
|
||||||
|
* @param sound Name of the sound to precache.
|
||||||
|
* @param preload If preload is true the file will be precached before level startup.
|
||||||
|
* @return True if successfully precached, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:PrecacheSound(const String:sound[], bool:preload=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a given sound is precached.
|
||||||
|
*
|
||||||
|
* @param sound Name of the sound to check.
|
||||||
|
* @return True if precached, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool:IsSoundPrecached(const String:sound[]);
|
||||||
|
|
||||||
#include <helpers>
|
#include <helpers>
|
||||||
#include <entity>
|
#include <entity>
|
||||||
|
Loading…
Reference in New Issue
Block a user