Cleaned up a few sdktools files.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402097
This commit is contained in:
parent
0c22ab3972
commit
f41aefc525
@ -118,8 +118,6 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
|
||||
spengine = g_pSM->GetScriptingEngine();
|
||||
|
||||
//g_OutputManager.VariantHandle = handlesys->CreateType("Variant", &g_OutputManager, 0, NULL, NULL, myself->GetIdentity(), NULL);
|
||||
|
||||
plsys->AddPluginsListener(&g_OutputManager);
|
||||
|
||||
g_OutputManager.Init();
|
||||
|
@ -118,20 +118,13 @@ bool EntityOutputManager::CreateFireEventDetour()
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
|
||||
/* variant_t doesnt do anything so i'll disable this bit */
|
||||
//IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
//IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
//IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
//IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
//IA32_Push_Rm_Disp8_ESP(jit, 32);
|
||||
|
||||
IA32_Push_Reg(jit, REG_ECX);
|
||||
|
||||
#elif defined PLATFORM_LINUX
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 20);
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 20);
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 20);
|
||||
// We miss the variant_t pointer
|
||||
|
||||
IA32_Push_Rm_Disp8_ESP(jit, 16);
|
||||
#endif
|
||||
|
||||
@ -265,22 +258,6 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator
|
||||
|
||||
if (hook->entity_filter == -1 || hook->entity_filter == serial) // Global classname hook
|
||||
{
|
||||
/*
|
||||
Handle_t handle;
|
||||
|
||||
if (Value.FieldType() == FIELD_VOID)
|
||||
{
|
||||
handle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
varhandle_t *varhandle = new varhandle_t;
|
||||
memmove ((void *)&varhandle->crab, (void *)&Value, sizeof(variant_t));
|
||||
|
||||
handle = handlesys->CreateHandle(VariantHandle, (void *)varhandle, hook->pf->GetParentContext()->GetIdentity(), myself->GetIdentity(), NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
//fire the forward to hook->pf
|
||||
hook->pf->PushString(pOutputName->Name);
|
||||
hook->pf->PushCell(engine->IndexOfEdict(pEdict));
|
||||
@ -356,8 +333,6 @@ void EntityOutputManager::OnHookRemoved()
|
||||
|
||||
if (HookCount == 0)
|
||||
{
|
||||
//we need to check if we are inside a detour. easy.
|
||||
//if we are how do we
|
||||
ShutdownFireEventDetour();
|
||||
}
|
||||
}
|
||||
@ -477,88 +452,6 @@ const char *EntityOutputManager::FindOutputName(void *pOutput, CBaseEntity *pCal
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Almost identical copy of this function from cbase.cpp - FIELD_EHANDLE changed to remove dependencies
|
||||
const char *variant_t::ToString( void ) const
|
||||
{
|
||||
COMPILE_TIME_ASSERT( sizeof(string_t) == sizeof(int) );
|
||||
|
||||
static char szBuf[512];
|
||||
|
||||
switch (fieldType)
|
||||
{
|
||||
case FIELD_STRING:
|
||||
{
|
||||
return(STRING(iszVal));
|
||||
}
|
||||
|
||||
case FIELD_BOOLEAN:
|
||||
{
|
||||
if (bVal == 0)
|
||||
{
|
||||
Q_strncpy(szBuf, "false",sizeof(szBuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy(szBuf, "true",sizeof(szBuf));
|
||||
}
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_INTEGER:
|
||||
{
|
||||
Q_snprintf( szBuf, sizeof( szBuf ), "%i", iVal );
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_FLOAT:
|
||||
{
|
||||
Q_snprintf(szBuf,sizeof(szBuf), "%g", flVal);
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_COLOR32:
|
||||
{
|
||||
Q_snprintf(szBuf,sizeof(szBuf), "%d %d %d %d", (int)rgbaVal.r, (int)rgbaVal.g, (int)rgbaVal.b, (int)rgbaVal.a);
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_VECTOR:
|
||||
{
|
||||
Q_snprintf(szBuf,sizeof(szBuf), "[%g %g %g]", (double)vecVal[0], (double)vecVal[1], (double)vecVal[2]);
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_VOID:
|
||||
{
|
||||
szBuf[0] = '\0';
|
||||
return(szBuf);
|
||||
}
|
||||
|
||||
case FIELD_EHANDLE:
|
||||
{
|
||||
CBaseHandle temp = eVal;
|
||||
|
||||
const char *pszName = g_OutputManager.BaseHandleToEdict(temp)->GetClassName();
|
||||
|
||||
if (pszName == NULL)
|
||||
{
|
||||
Q_strncpy( szBuf, "<<null entity>>", 512 );
|
||||
return (szBuf);
|
||||
}
|
||||
|
||||
Q_strncpy( szBuf, pszName, 512 );
|
||||
return (szBuf);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return("No conversion to string");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Thanks SM core
|
||||
edict_t *EntityOutputManager::BaseHandleToEdict(CBaseHandle &hndl)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
#include <jit/jit_helpers.h>
|
||||
#include <jit/x86/x86_macros.h>
|
||||
//#include "variant_t.h"
|
||||
#include "sh_list.h"
|
||||
#include "sh_stack.h"
|
||||
#include "sm_trie_tpl.h"
|
||||
|
@ -268,342 +268,11 @@ cell_t UnHookSingleEntityOutput(IPluginContext *pContext, const cell_t *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static cell_t GetVariantType(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
return pInfo->crab.FieldType();
|
||||
}
|
||||
|
||||
static cell_t GetVariantInt(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_INTEGER)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not an integer");
|
||||
}
|
||||
|
||||
return pInfo->crab.Int();
|
||||
}
|
||||
|
||||
static cell_t GetVariantBool(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_BOOLEAN)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not a boolean");
|
||||
}
|
||||
|
||||
return pInfo->crab.Bool();
|
||||
}
|
||||
|
||||
static cell_t GetVariantEntity(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_EHANDLE)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not an entity");
|
||||
}
|
||||
|
||||
edict_t *pEdict = g_OutputManager.BaseHandleToEdict((CBaseHandle)pInfo->crab.Entity());
|
||||
|
||||
return engine->IndexOfEdict(pEdict);
|
||||
}
|
||||
|
||||
static cell_t GetVariantFloat(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_FLOAT)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not a float");
|
||||
}
|
||||
|
||||
return sp_ftoc(pInfo->crab.Float());
|
||||
}
|
||||
|
||||
static cell_t GetVariantVector(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_VECTOR)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not a vector");
|
||||
}
|
||||
|
||||
cell_t *r;
|
||||
pContext->LocalToPhysAddr(params[2], &r);
|
||||
|
||||
Vector temp;
|
||||
pInfo->crab.Vector3D(temp);
|
||||
|
||||
r[0] = sp_ftoc(temp[0]);
|
||||
r[1] = sp_ftoc(temp[1]);
|
||||
r[2] = sp_ftoc(temp[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell_t GetVariantColour(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
if (pInfo->crab.FieldType() != FIELD_COLOR32)
|
||||
{
|
||||
return pContext->ThrowNativeError("Variant is not a colour");
|
||||
}
|
||||
|
||||
cell_t *r;
|
||||
pContext->LocalToPhysAddr(params[2], &r);
|
||||
|
||||
color32 temp = pInfo->crab.Color32();
|
||||
|
||||
r[0] = temp.r;
|
||||
r[1] = temp.g;
|
||||
r[2] = temp.b;
|
||||
r[4] = temp.a;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell_t GetVariantString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||
HandleError err;
|
||||
varhandle_t *pInfo;
|
||||
HandleSecurity sec;
|
||||
|
||||
sec.pOwner = NULL;
|
||||
sec.pIdentity = myself->GetIdentity();
|
||||
|
||||
if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
|
||||
}
|
||||
|
||||
char *dest;
|
||||
const char *src = pInfo->crab.String();
|
||||
size_t len;
|
||||
|
||||
pContext->LocalToString(params[2], &dest);
|
||||
|
||||
/* Perform bounds checking */
|
||||
len = strlen(src);
|
||||
if (len >= (unsigned)params[3])
|
||||
{
|
||||
len = params[3] - 1;
|
||||
} else {
|
||||
len = params[3];
|
||||
}
|
||||
|
||||
/* Copy */
|
||||
memmove(dest, src, len);
|
||||
|
||||
dest[len] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
sp_nativeinfo_t g_EntOutputNatives[] =
|
||||
{
|
||||
{"HookEntityOutput", HookEntityOutput},
|
||||
{"UnhookEntityOutput", UnHookEntityOutput},
|
||||
{"HookSingleEntityOutput", HookSingleEntityOutput},
|
||||
{"UnhookSingleEntityOutput", UnHookSingleEntityOutput},
|
||||
#if 0 //Removed because we don't need them
|
||||
{"GetVariantType", GetVariantType},
|
||||
{"GetVariantInt", GetVariantInt},
|
||||
{"GetVariantFloat", GetVariantFloat},
|
||||
{"GetVariantBool", GetVariantBool},
|
||||
{"GetVariantString", GetVariantString},
|
||||
{"GetVariantEntity", GetVariantEntity},
|
||||
{"GetVariantVector", GetVariantVector},
|
||||
{"GetVariantColour", GetVariantColour},
|
||||
#endif
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
#if 0
|
||||
//Include file stuff that wasn't needed:
|
||||
|
||||
enum FieldType
|
||||
{
|
||||
FieldType_Float = 1,
|
||||
FieldType_String = 2,
|
||||
FieldType_Vector = 3,
|
||||
FieldType_Int = 5,
|
||||
FieldType_Bool = 6,
|
||||
FieldType_Colour = 9,
|
||||
FieldType_Entity = 13
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current type of a variant handle
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @return Current type of the variant.
|
||||
*/
|
||||
native FieldType:GetVariantType(Handle:variant);
|
||||
|
||||
/**
|
||||
* Retreives a Float from a variant handle.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @return Float value.
|
||||
* @error Variant handle is not type FieldType_Float
|
||||
*/
|
||||
native Float:GetVariantFloat(Handle:variant);
|
||||
|
||||
/**
|
||||
* Retreives an Integer from a variant handle.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @return Int value.
|
||||
* @error Variant handle is not type FieldType_Int
|
||||
*/
|
||||
native GetVariantInt(Handle:variant);
|
||||
|
||||
/**
|
||||
* Retreives a bool from a variant handle.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @return bool value.
|
||||
* @error Variant handle is not type FieldType_Bool
|
||||
*/
|
||||
native bool:GetVariantBool(Handle:variant);
|
||||
|
||||
/**
|
||||
* Retreives an entity from a variant handle.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @return Entity Index.
|
||||
* @error Variant handle is not type FieldType_Entity
|
||||
*/
|
||||
native GetVariantEntity(Handle:variant);
|
||||
|
||||
/**
|
||||
* Retreives a Vector from a variant handle.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @param vec buffer to store the Vector.
|
||||
* @noreturn
|
||||
* @error Variant handle is not type FieldType_Vector
|
||||
*/
|
||||
native GetVariantVector(Handle:variant, Float:vec[3]);
|
||||
|
||||
/**
|
||||
* Retreives a String from a variant handle.
|
||||
*
|
||||
* @note This native does not require the variant to be FieldType_String,
|
||||
* It can convert any type into a string representation.
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @param buffer buffer to store the string in
|
||||
* @param maxlen Maximum length of buffer.
|
||||
* @noreturn
|
||||
*/
|
||||
native GetVariantString(Handle:variant, String:buffer[], maxlen);
|
||||
|
||||
/**
|
||||
* Retreives a Colour from a variant handle.
|
||||
*
|
||||
* @note Colour is in format r,g,b,a
|
||||
*
|
||||
* @param variant A variant handle.
|
||||
* @param colour buffer array to store the colour in.
|
||||
* @noreturn
|
||||
* @error Variant handle is not type FieldType_Colour
|
||||
*/
|
||||
native GetVariantColour(Handle:variant, colour[4]);
|
||||
#endif
|
||||
};
|
Loading…
Reference in New Issue
Block a user