diff -r 05f955fe3af2 -r 03b4a9c4a70e extensions/sdktools/outputnatives.cpp --- a/extensions/sdktools/outputnatives.cpp Fri Apr 25 00:08:27 2008 +0000 +++ b/extensions/sdktools/outputnatives.cpp Fri Apr 25 05:20:17 2008 +0000 @@ -268,342 +268,11 @@ return 0; } -#if 0 -static cell_t GetVariantType(IPluginContext *pContext, const cell_t *params) -{ - Handle_t hndl = static_cast(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(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(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(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(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(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(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(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 +}; \ No newline at end of file