Merge pull request #33 from alliedmodders/tf2-iservertools

Use updated IServerTools iface on TF2 for getting tempent list and FindEntityByClassname (PR #33, r=KyleS).
This commit is contained in:
Nicholas Hastings 2014-06-11 23:43:48 -04:00
commit 51a02652d8
2 changed files with 28 additions and 4 deletions

View File

@ -285,6 +285,9 @@ void TempEntityManager::Initialize()
int offset;
m_Loaded = false;
#if SOURCE_ENGINE == SE_TF2
m_ListHead = servertools->GetTempEntList();
#else
/*
* First try to lookup s_pTempEntities directly for platforms with symbols.
* If symbols aren't present (Windows or stripped Linux/Mac),
@ -311,6 +314,7 @@ void TempEntityManager::Initialize()
{
return;
}
#endif // == TF2
if (!g_pGameConf->GetOffset("GetTEName", &m_NameOffs))
{

View File

@ -714,7 +714,7 @@ static cell_t GetClientEyeAngles(IPluginContext *pContext, const cell_t *params)
return got_angles ? 1 : 0;
}
#if SOURCE_ENGINE >= SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX && SOURCE_ENGINE != SE_TF2
static cell_t NativeFindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
char *searchname;
@ -789,10 +789,29 @@ static cell_t NativeFindEntityByClassname(IPluginContext *pContext, const cell_t
return -1;
}
#endif
#endif // >= ORANGEBOX && != TF2
static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_TF2
CBaseEntity *pStartEnt = NULL;
if (params[1] != -1)
{
pStartEnt = gamehelpers->ReferenceToEntity(params[1]);
if (!pStartEnt)
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid",
gamehelpers->ReferenceToIndex(params[1]),
params[1]);
}
}
char *searchname;
pContext->LocalToString(params[2], &searchname);
CBaseEntity *pEntity = servertools->FindEntityByClassname(pStartEnt, searchname);
return gamehelpers->EntityToBCompatRef(pEntity);
#else
static ValveCall *pCall = NULL;
static bool bProbablyNoFEBC = false;
@ -801,7 +820,7 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para
{
return NativeFindEntityByClassname(pContext, params);
}
#endif
#endif // >= SE_ORANGEBOX
if (!pCall)
{
@ -838,7 +857,7 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para
return NativeFindEntityByClassname(pContext, params);
#else
return pContext->ThrowNativeError("%s", error);
#endif
#endif // >= ORANGEBOX
}
}
@ -850,6 +869,7 @@ static cell_t FindEntityByClassname(IPluginContext *pContext, const cell_t *para
FINISH_CALL_SIMPLE(&pEntity);
return gamehelpers->EntityToBCompatRef(pEntity);
#endif // == TF2
}
#if SOURCE_ENGINE >= SE_ORANGEBOX