extensions/sdktools/tenatives.cpp
author Scott Ehlert <ds@alliedmods.net>
Wed Aug 15 06:19:30 2007 +0000 (2007-08-15)
changeset 1330 ab94316bb52b
parent 1262 843e9ed0ff29
child 1430 be0ed85786bb
permissions -rw-r--r--
Updated license headers on virtually all files with extremely minor changes in the name of some sort of strange consistency.
All plugin and include file headers also have been changed to say about GPL3 instead of GPL2.

(This day shall henceforth be known as the Eighty Column Massacre of '07)
faluco@1031
     1
/**
faluco@1031
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1233
     4
 * SourceMod SDKTools Extension
dvander@1233
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
faluco@1031
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1233
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1233
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1233
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
faluco@1031
    28
 *
faluco@1031
    29
 * Version: $Id$
faluco@1031
    30
 */
faluco@1031
    31
faluco@1031
    32
#include "tempents.h"
faluco@1031
    33
#include "CellRecipientFilter.h"
faluco@1255
    34
#include <IForwardSys.h>
faluco@1255
    35
faluco@1255
    36
SH_DECL_HOOK5_void(IVEngineServer, PlaybackTempEntity, SH_NOATTRIB, 0, IRecipientFilter &, float, const void *, const SendTable *, int);
faluco@1031
    37
faluco@1031
    38
CellRecipientFilter g_TERecFilter;
faluco@1031
    39
TempEntityInfo *g_CurrentTE = NULL;
faluco@1255
    40
int g_TEPlayers[256];
faluco@1255
    41
faluco@1255
    42
/*************************
faluco@1255
    43
*                        *
faluco@1255
    44
* Temp Entity Hook Class *
faluco@1255
    45
*                        *
faluco@1255
    46
**************************/
faluco@1255
    47
faluco@1255
    48
void TempEntHooks::Initialize()
faluco@1255
    49
{
faluco@1255
    50
	m_TEHooks = adtfactory->CreateBasicTrie();
faluco@1255
    51
}
faluco@1255
    52
faluco@1255
    53
void TempEntHooks::Shutdown()
faluco@1255
    54
{
faluco@1255
    55
	List<TEHookInfo *>::iterator iter;
faluco@1255
    56
	for (iter=m_HookInfo.begin(); iter!=m_HookInfo.end(); iter++)
faluco@1255
    57
	{
faluco@1255
    58
		delete (*iter);
faluco@1255
    59
	}
faluco@1255
    60
	if (m_HookCount)
faluco@1255
    61
	{
faluco@1255
    62
		m_HookCount = 1;
faluco@1255
    63
		_DecRefCounter();
faluco@1255
    64
	}
faluco@1255
    65
	m_TEHooks->Destroy();
faluco@1255
    66
}
faluco@1255
    67
faluco@1255
    68
void TempEntHooks::_IncRefCounter()
faluco@1255
    69
{
faluco@1255
    70
	if (m_HookCount++ == 0)
faluco@1255
    71
	{
faluco@1255
    72
		SH_ADD_HOOK_MEMFUNC(IVEngineServer, PlaybackTempEntity, engine, this, &TempEntHooks::OnPlaybackTempEntity, false);
faluco@1255
    73
	}
faluco@1255
    74
}
faluco@1255
    75
faluco@1255
    76
void TempEntHooks::_DecRefCounter()
faluco@1255
    77
{
faluco@1255
    78
	if (--m_HookCount == 0)
faluco@1255
    79
	{
faluco@1255
    80
		SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, PlaybackTempEntity, engine, this, &TempEntHooks::OnPlaybackTempEntity, false);
faluco@1255
    81
	}
faluco@1255
    82
}
faluco@1255
    83
faluco@1255
    84
size_t TempEntHooks::_FillInPlayers(int *pl_array, IRecipientFilter *pFilter)
faluco@1255
    85
{
faluco@1255
    86
	size_t size = static_cast<size_t>(pFilter->GetRecipientCount());
faluco@1255
    87
faluco@1255
    88
	for (size_t i=0; i<size; i++)
faluco@1255
    89
	{
faluco@1255
    90
		pl_array[i] = pFilter->GetRecipientIndex(i);
faluco@1255
    91
	}
faluco@1255
    92
faluco@1255
    93
	return size;
faluco@1255
    94
}
faluco@1255
    95
faluco@1255
    96
bool TempEntHooks::AddHook(const char *name, IPluginFunction *pFunc)
faluco@1255
    97
{
faluco@1255
    98
	TEHookInfo *pInfo;
faluco@1255
    99
faluco@1255
   100
	if (m_TEHooks->Retrieve(name, reinterpret_cast<void **>(&pInfo)))
faluco@1255
   101
	{
faluco@1255
   102
		pInfo->lst.push_back(pFunc);
faluco@1255
   103
	} else {
faluco@1255
   104
		TempEntityInfo *te;
faluco@1255
   105
		if (!(te=g_TEManager.GetTempEntityInfo(name)))
faluco@1255
   106
		{
faluco@1255
   107
			return false;
faluco@1255
   108
		}
faluco@1255
   109
faluco@1255
   110
		pInfo = new TEHookInfo;
faluco@1255
   111
		pInfo->te = te;
faluco@1255
   112
		pInfo->lst.push_back(pFunc);
faluco@1255
   113
faluco@1255
   114
		m_TEHooks->Insert(name, reinterpret_cast<void *>(pInfo));
faluco@1255
   115
		m_HookInfo.push_back(pInfo);
faluco@1255
   116
	}
faluco@1255
   117
faluco@1255
   118
	_IncRefCounter();
faluco@1255
   119
faluco@1255
   120
	return true;
faluco@1255
   121
}
faluco@1255
   122
faluco@1255
   123
bool TempEntHooks::RemoveHook(const char *name, IPluginFunction *pFunc)
faluco@1255
   124
{
faluco@1255
   125
	TEHookInfo *pInfo;
faluco@1255
   126
faluco@1255
   127
	if (m_TEHooks->Retrieve(name, reinterpret_cast<void **>(&pInfo)))
faluco@1255
   128
	{
faluco@1255
   129
		List<IPluginFunction *>::iterator iter;
faluco@1255
   130
		if ((iter=pInfo->lst.find(pFunc)) != pInfo->lst.end())
faluco@1255
   131
		{
faluco@1255
   132
			pInfo->lst.erase(iter);
faluco@1255
   133
			if (pInfo->lst.empty())
faluco@1255
   134
			{
faluco@1255
   135
				m_HookInfo.remove(pInfo);
faluco@1255
   136
				m_TEHooks->Delete(name);
faluco@1255
   137
				delete pInfo;
faluco@1255
   138
			}
faluco@1255
   139
			_DecRefCounter();
faluco@1255
   140
		} else {
faluco@1255
   141
			return false;
faluco@1255
   142
		}
faluco@1255
   143
	} else {
faluco@1255
   144
		return false;
faluco@1255
   145
	}
faluco@1255
   146
faluco@1255
   147
	return true;
faluco@1255
   148
}
faluco@1255
   149
faluco@1255
   150
void TempEntHooks::OnPlaybackTempEntity(IRecipientFilter &filter, float delay, const void *pSender, const SendTable *pST, int classID)
faluco@1255
   151
{
faluco@1255
   152
	TEHookInfo *pInfo;
faluco@1255
   153
	const char *name = g_TEManager.GetNameFromThisPtr(const_cast<void *>(pSender));
faluco@1255
   154
faluco@1255
   155
	if (m_TEHooks->Retrieve(name, reinterpret_cast<void **>(&pInfo)))
faluco@1255
   156
	{
faluco@1255
   157
		List<IPluginFunction *>::iterator iter;
faluco@1255
   158
		IPluginFunction *pFunc;
faluco@1255
   159
		size_t size;
faluco@1255
   160
		cell_t res = static_cast<ResultType>(Pl_Continue);
faluco@1255
   161
faluco@1255
   162
		TempEntityInfo *oldinfo = g_CurrentTE;
faluco@1255
   163
		g_CurrentTE = pInfo->te;
faluco@1255
   164
		size = _FillInPlayers(g_TEPlayers, &filter);
faluco@1255
   165
faluco@1255
   166
		for (iter=pInfo->lst.begin(); iter!=pInfo->lst.end(); iter++)
faluco@1255
   167
		{
faluco@1255
   168
			pFunc = (*iter);
faluco@1255
   169
			pFunc->PushString(name);
faluco@1255
   170
			pFunc->PushArray(g_TEPlayers, size);
faluco@1255
   171
			pFunc->PushCell(size);
faluco@1255
   172
			pFunc->PushFloat(delay);
faluco@1255
   173
			pFunc->Execute(&res);
faluco@1255
   174
faluco@1255
   175
			if (res != Pl_Continue)
faluco@1255
   176
			{
faluco@1255
   177
				g_CurrentTE = oldinfo;
faluco@1255
   178
				RETURN_META(MRES_SUPERCEDE);
faluco@1255
   179
			}
faluco@1255
   180
		}
faluco@1255
   181
faluco@1255
   182
		g_CurrentTE = oldinfo;
faluco@1255
   183
		RETURN_META(MRES_IGNORED);
faluco@1255
   184
	}
faluco@1255
   185
}
faluco@1255
   186
faluco@1255
   187
/**********************
faluco@1255
   188
*                     *
faluco@1255
   189
* Temp Entity Natives *
faluco@1255
   190
*                     *
faluco@1255
   191
***********************/
faluco@1255
   192
faluco@1255
   193
TempEntHooks s_TempEntHooks;
faluco@1031
   194
faluco@1031
   195
static cell_t smn_TEStart(IPluginContext *pContext, const cell_t *params)
faluco@1031
   196
{
faluco@1031
   197
	if (!g_TEManager.IsAvailable())
faluco@1031
   198
	{
faluco@1031
   199
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   200
	}
faluco@1031
   201
faluco@1031
   202
	char *name;
faluco@1031
   203
	pContext->LocalToString(params[1], &name);
faluco@1031
   204
faluco@1031
   205
	g_CurrentTE = g_TEManager.GetTempEntityInfo(name);
faluco@1031
   206
	if (!g_CurrentTE)
faluco@1031
   207
	{
faluco@1031
   208
		return pContext->ThrowNativeError("Invalid TempEntity name: \"%s\"", name);
faluco@1031
   209
	}
faluco@1031
   210
faluco@1031
   211
	return 1;
faluco@1031
   212
}
faluco@1031
   213
faluco@1031
   214
static cell_t smn_TEWriteNum(IPluginContext *pContext, const cell_t *params)
faluco@1031
   215
{
faluco@1031
   216
	if (!g_TEManager.IsAvailable())
faluco@1031
   217
	{
faluco@1031
   218
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   219
	}
faluco@1031
   220
	if (!g_CurrentTE)
faluco@1031
   221
	{
faluco@1031
   222
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1031
   223
	}
faluco@1031
   224
faluco@1031
   225
	char *prop;
faluco@1031
   226
	pContext->LocalToString(params[1], &prop);
faluco@1031
   227
faluco@1031
   228
	if (!g_CurrentTE->TE_SetEntData(prop, params[2]))
faluco@1031
   229
	{
faluco@1031
   230
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1031
   231
	}
faluco@1031
   232
faluco@1031
   233
	return 1;
faluco@1031
   234
}
faluco@1031
   235
faluco@1255
   236
static cell_t smn_TEReadNum(IPluginContext *pContext, const cell_t *params)
faluco@1255
   237
{
faluco@1255
   238
	if (!g_TEManager.IsAvailable())
faluco@1255
   239
	{
faluco@1255
   240
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1255
   241
	}
faluco@1255
   242
	if (!g_CurrentTE)
faluco@1255
   243
	{
faluco@1255
   244
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1255
   245
	}
faluco@1255
   246
faluco@1255
   247
	char *prop;
faluco@1255
   248
	int val;
faluco@1255
   249
	pContext->LocalToString(params[1], &prop);
faluco@1255
   250
faluco@1255
   251
	if (!g_CurrentTE->TE_GetEntData(prop, &val))
faluco@1255
   252
	{
faluco@1255
   253
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1255
   254
	}
faluco@1255
   255
faluco@1255
   256
	return val;
faluco@1255
   257
}
faluco@1255
   258
faluco@1031
   259
static cell_t smn_TE_WriteFloat(IPluginContext *pContext, const cell_t *params)
faluco@1031
   260
{
faluco@1031
   261
	if (!g_TEManager.IsAvailable())
faluco@1031
   262
	{
faluco@1031
   263
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   264
	}
faluco@1031
   265
	if (!g_CurrentTE)
faluco@1031
   266
	{
faluco@1031
   267
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1031
   268
	}
faluco@1031
   269
faluco@1031
   270
	char *prop;
faluco@1031
   271
	pContext->LocalToString(params[1], &prop);
faluco@1031
   272
faluco@1031
   273
	if (!g_CurrentTE->TE_SetEntDataFloat(prop, sp_ctof(params[2])))
faluco@1031
   274
	{
faluco@1031
   275
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1031
   276
	}
faluco@1031
   277
faluco@1031
   278
	return 1;
faluco@1031
   279
}
faluco@1031
   280
faluco@1255
   281
static cell_t smn_TE_ReadFloat(IPluginContext *pContext, const cell_t *params)
faluco@1255
   282
{
faluco@1255
   283
	if (!g_TEManager.IsAvailable())
faluco@1255
   284
	{
faluco@1255
   285
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1255
   286
	}
faluco@1255
   287
	if (!g_CurrentTE)
faluco@1255
   288
	{
faluco@1255
   289
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1255
   290
	}
faluco@1255
   291
faluco@1255
   292
	char *prop;
faluco@1255
   293
	float val;
faluco@1255
   294
	pContext->LocalToString(params[1], &prop);
faluco@1255
   295
faluco@1255
   296
	if (!g_CurrentTE->TE_GetEntDataFloat(prop, &val))
faluco@1255
   297
	{
faluco@1255
   298
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1255
   299
	}
faluco@1255
   300
faluco@1255
   301
	return sp_ftoc(val);
faluco@1255
   302
}
faluco@1255
   303
faluco@1031
   304
static cell_t smn_TEWriteVector(IPluginContext *pContext, const cell_t *params)
faluco@1031
   305
{
faluco@1031
   306
	if (!g_TEManager.IsAvailable())
faluco@1031
   307
	{
faluco@1031
   308
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   309
	}
faluco@1031
   310
	if (!g_CurrentTE)
faluco@1031
   311
	{
faluco@1031
   312
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1031
   313
	}
faluco@1031
   314
faluco@1031
   315
	char *prop;
faluco@1031
   316
	pContext->LocalToString(params[1], &prop);
faluco@1031
   317
faluco@1031
   318
	cell_t *addr;
faluco@1031
   319
	pContext->LocalToPhysAddr(params[2], &addr);
faluco@1031
   320
	float vec[3] = {sp_ctof(addr[0]), sp_ctof(addr[1]), sp_ctof(addr[2])};
faluco@1031
   321
faluco@1031
   322
	if (!g_CurrentTE->TE_SetEntDataVector(prop, vec))
faluco@1031
   323
	{
faluco@1031
   324
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1031
   325
	}
faluco@1031
   326
faluco@1031
   327
	return 1;
faluco@1031
   328
}
faluco@1031
   329
faluco@1255
   330
static cell_t smn_TEReadVector(IPluginContext *pContext, const cell_t *params)
faluco@1255
   331
{
faluco@1255
   332
	if (!g_TEManager.IsAvailable())
faluco@1255
   333
	{
faluco@1255
   334
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1255
   335
	}
faluco@1255
   336
	if (!g_CurrentTE)
faluco@1255
   337
	{
faluco@1255
   338
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1255
   339
	}
faluco@1255
   340
faluco@1255
   341
	char *prop;
faluco@1255
   342
	pContext->LocalToString(params[1], &prop);
faluco@1255
   343
faluco@1255
   344
	cell_t *addr;
faluco@1255
   345
	float vec[3];
faluco@1255
   346
	pContext->LocalToPhysAddr(params[2], &addr);
faluco@1255
   347
faluco@1255
   348
	if (!g_CurrentTE->TE_GetEntDataVector(prop, vec))
faluco@1255
   349
	{
faluco@1255
   350
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1255
   351
	}
faluco@1255
   352
faluco@1255
   353
	addr[0] = sp_ftoc(vec[0]);
faluco@1255
   354
	addr[1] = sp_ftoc(vec[1]);
faluco@1255
   355
	addr[2] = sp_ftoc(vec[2]);
faluco@1255
   356
faluco@1255
   357
	return 1;
faluco@1255
   358
}
faluco@1255
   359
faluco@1039
   360
static cell_t smn_TEWriteFloatArray(IPluginContext *pContext, const cell_t *params)
faluco@1039
   361
{
faluco@1039
   362
	if (!g_TEManager.IsAvailable())
faluco@1039
   363
	{
faluco@1039
   364
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1039
   365
	}
faluco@1039
   366
	if (!g_CurrentTE)
faluco@1039
   367
	{
faluco@1039
   368
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1039
   369
	}
faluco@1039
   370
faluco@1039
   371
	char *prop;
faluco@1039
   372
	pContext->LocalToString(params[1], &prop);
faluco@1039
   373
faluco@1039
   374
	cell_t *addr;
faluco@1039
   375
	pContext->LocalToPhysAddr(params[2], &addr);
faluco@1039
   376
faluco@1039
   377
	if (!g_CurrentTE->TE_SetEntDataFloatArray(prop, addr, params[3]))
faluco@1039
   378
	{
faluco@1039
   379
		return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
faluco@1039
   380
	}
faluco@1039
   381
faluco@1039
   382
	return 1;
faluco@1039
   383
}
faluco@1039
   384
faluco@1031
   385
static cell_t smn_TESend(IPluginContext *pContext, const cell_t *params)
faluco@1031
   386
{
faluco@1031
   387
	if (!g_TEManager.IsAvailable())
faluco@1031
   388
	{
faluco@1031
   389
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   390
	}
faluco@1031
   391
	if (!g_CurrentTE)
faluco@1031
   392
	{
faluco@1031
   393
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1031
   394
	}
faluco@1031
   395
faluco@1031
   396
	cell_t *cl_array;
faluco@1031
   397
	pContext->LocalToPhysAddr(params[1], &cl_array);
faluco@1031
   398
faluco@1031
   399
	g_TERecFilter.Reset();
faluco@1031
   400
	g_TERecFilter.Initialize(cl_array, params[2]);
faluco@1031
   401
faluco@1031
   402
	g_CurrentTE->Send(g_TERecFilter, sp_ctof(params[3]));
faluco@1031
   403
	g_CurrentTE = NULL;
faluco@1031
   404
faluco@1031
   405
	return 1;
faluco@1031
   406
}
faluco@1031
   407
faluco@1031
   408
static cell_t smn_TEIsValidProp(IPluginContext *pContext, const cell_t *params)
faluco@1031
   409
{
faluco@1031
   410
	if (!g_TEManager.IsAvailable())
faluco@1031
   411
	{
faluco@1031
   412
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1031
   413
	}
faluco@1031
   414
	if (!g_CurrentTE)
faluco@1031
   415
	{
faluco@1031
   416
		return pContext->ThrowNativeError("No TempEntity call is in progress");
faluco@1031
   417
	}
faluco@1031
   418
faluco@1031
   419
	char *prop;
faluco@1031
   420
	pContext->LocalToString(params[1], &prop);
faluco@1031
   421
faluco@1031
   422
	return g_CurrentTE->IsValidProp(prop) ? 1 : 0;
faluco@1031
   423
}
faluco@1031
   424
faluco@1255
   425
static cell_t smn_AddTempEntHook(IPluginContext *pContext, const cell_t *params)
faluco@1255
   426
{
faluco@1255
   427
	char *name;
faluco@1255
   428
	IPluginFunction *pFunc;
faluco@1255
   429
faluco@1262
   430
	if (!g_TEManager.IsAvailable())
faluco@1262
   431
	{
faluco@1262
   432
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1262
   433
	}
faluco@1262
   434
faluco@1255
   435
	pContext->LocalToString(params[1], &name);
faluco@1255
   436
	pFunc = pContext->GetFunctionById(params[2]);
faluco@1255
   437
	if (!pFunc)
faluco@1255
   438
	{
faluco@1255
   439
		return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
faluco@1255
   440
	}
faluco@1255
   441
faluco@1255
   442
	if (!s_TempEntHooks.AddHook(name, pFunc))
faluco@1255
   443
	{
faluco@1255
   444
		return pContext->ThrowNativeError("Invalid TempEntity name: \"%s\"", name);
faluco@1255
   445
	}
faluco@1255
   446
faluco@1255
   447
	return 1;
faluco@1255
   448
}
faluco@1255
   449
faluco@1255
   450
static cell_t smn_RemoveTempEntHook(IPluginContext *pContext, const cell_t *params)
faluco@1255
   451
{
faluco@1255
   452
	char *name;
faluco@1255
   453
	IPluginFunction *pFunc;
faluco@1255
   454
faluco@1262
   455
	if (!g_TEManager.IsAvailable())
faluco@1262
   456
	{
faluco@1262
   457
		return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
faluco@1262
   458
	}
faluco@1262
   459
faluco@1255
   460
	pContext->LocalToString(params[1], &name);
faluco@1255
   461
	pFunc = pContext->GetFunctionById(params[2]);
faluco@1255
   462
	if (!pFunc)
faluco@1255
   463
	{
faluco@1255
   464
		return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
faluco@1255
   465
	}
faluco@1255
   466
faluco@1255
   467
	if (!s_TempEntHooks.RemoveHook(name, pFunc))
faluco@1255
   468
	{
faluco@1255
   469
		return pContext->ThrowNativeError("Invalid hooked TempEntity name or function");
faluco@1255
   470
	}
faluco@1255
   471
faluco@1255
   472
	return 1;
faluco@1255
   473
}
faluco@1255
   474
faluco@1031
   475
sp_nativeinfo_t g_TENatives[] = 
faluco@1031
   476
{
faluco@1031
   477
	{"TE_Start",				smn_TEStart},
faluco@1031
   478
	{"TE_WriteNum",				smn_TEWriteNum},
faluco@1255
   479
	{"TE_ReadNum",				smn_TEReadNum},
faluco@1031
   480
	{"TE_WriteFloat",			smn_TE_WriteFloat},
faluco@1255
   481
	{"TE_ReadFloat",			smn_TE_ReadFloat},
faluco@1031
   482
	{"TE_WriteVector",			smn_TEWriteVector},
faluco@1255
   483
	{"TE_ReadVector",			smn_TEReadVector},
faluco@1031
   484
	{"TE_WriteAngles",			smn_TEWriteVector},
faluco@1031
   485
	{"TE_Send",					smn_TESend},
faluco@1031
   486
	{"TE_IsValidProp",			smn_TEIsValidProp},
faluco@1039
   487
	{"TE_WriteFloatArray",		smn_TEWriteFloatArray},
faluco@1255
   488
	{"AddTempEntHook",			smn_AddTempEntHook},
faluco@1255
   489
	{"RemoveTempEntHook",		smn_RemoveTempEntHook},
faluco@1031
   490
	{NULL,						NULL}
faluco@1031
   491
};