fixed amb728, precache slap sounds

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401268
This commit is contained in:
Borja Ferrer 2007-08-04 00:09:10 +00:00
parent b79f1f6df3
commit 5b564e15da
3 changed files with 44 additions and 0 deletions

View File

@ -42,6 +42,8 @@
* @brief Implements SDK Tools extension code.
*/
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
SDKTools g_SdkTools; /**< Global singleton for extension's main interface */
IServerGameEnts *gameents = NULL;
IEngineTrace *enginetrace = NULL;
@ -89,6 +91,8 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
ConCommandBaseMgr::OneTimeInit(this);
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
return true;
}
@ -123,6 +127,8 @@ void SDKTools::SDK_OnUnload()
gameconfs->CloseGameConfigFile(g_pGameConf);
playerhelpers->RemoveClientListener(&g_SdkTools);
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SDKTools::LevelInit, true);
}
bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
@ -185,3 +191,29 @@ bool SDKTools::RegisterConCommandBase(ConCommandBase *pVar)
{
return g_SMAPI->RegisterConCmdBase(g_PLAPI, pVar);
}
bool SDKTools::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
{
const char *name;
char key[32];
int count, n = 1;
if (!(name=g_pGameConf->GetKeyValue("SlapSoundCount")))
{
RETURN_META_VALUE(MRES_IGNORED, true);
}
count = atoi(name);
while (n <= count)
{
snprintf(key, sizeof(key), "SlapSound%d", n);
if ((name=g_pGameConf->GetKeyValue(key)))
{
engsound->PrecacheSound(name, true);
}
n++;
}
RETURN_META_VALUE(MRES_IGNORED, true);
}

View File

@ -80,6 +80,8 @@ public: //IClientListner
void OnClientDisconnecting(int client);
public: // IVoiceServer
bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
public:
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
};
extern SDKTools g_SdkTools;

View File

@ -428,6 +428,11 @@ static cell_t smn_AddTempEntHook(IPluginContext *pContext, const cell_t *params)
char *name;
IPluginFunction *pFunc;
if (!g_TEManager.IsAvailable())
{
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
}
pContext->LocalToString(params[1], &name);
pFunc = pContext->GetFunctionById(params[2]);
if (!pFunc)
@ -448,6 +453,11 @@ static cell_t smn_RemoveTempEntHook(IPluginContext *pContext, const cell_t *para
char *name;
IPluginFunction *pFunc;
if (!g_TEManager.IsAvailable())
{
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
}
pContext->LocalToString(params[1], &name);
pFunc = pContext->GetFunctionById(params[2]);
if (!pFunc)