bdf651634c
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40956
94 lines
2.6 KiB
C++
94 lines
2.6 KiB
C++
#ifndef _INCLUDE_SOURCEMOD_VDECODER_H_
|
|
#define _INCLUDE_SOURCEMOD_VDECODER_H_
|
|
|
|
#include <sm_platform.h>
|
|
#include <sp_vm_api.h>
|
|
#include <extensions/IBinTools.h>
|
|
|
|
using namespace SourceMod;
|
|
using namespace SourcePawn;
|
|
|
|
/**
|
|
* @brief Encapsulates types from the SDK
|
|
*/
|
|
enum ValveType
|
|
{
|
|
Valve_CBaseEntity, /**< CBaseEntity */
|
|
Valve_CBasePlayer, /**< CBasePlayer (disallow normal ents) */
|
|
Valve_Vector, /**< Vector */
|
|
Valve_QAngle, /**< QAngle */
|
|
Valve_POD, /**< Plain old data */
|
|
Valve_Float, /**< Float */
|
|
Valve_Edict, /**< Edict */
|
|
Valve_String, /**< String */
|
|
};
|
|
|
|
enum DataStatus
|
|
{
|
|
Data_Fail = 0,
|
|
Data_Okay = 1,
|
|
};
|
|
|
|
#define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
|
|
#define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
|
|
#define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
|
|
#define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
|
|
|
|
#define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data */
|
|
|
|
/**
|
|
* @brief Converts a valve parameter to a bintools parameter.
|
|
*
|
|
* @param type Valve type.
|
|
* @param pass Either basic or object.
|
|
* @param flags Either BYVAL or BYREF.
|
|
* @param info Buffer to store param info in.
|
|
* @return Number of bytes this will use in the virtual stack,
|
|
* or 0 if conversion was impossible.
|
|
*/
|
|
size_t ValveParamToBinParam(ValveType type,
|
|
PassType pass,
|
|
unsigned int flags,
|
|
PassInfo *info);
|
|
|
|
/**
|
|
* @brief Decodes data from a plugin to native data.
|
|
*
|
|
* Note: If you're going to return false, make sure to
|
|
* throw an error.
|
|
*
|
|
* @param pContext Plugin context.
|
|
* @param param Parameter value from params array.
|
|
* @param type Valve type.
|
|
* @param pass Pass info from bin tools.
|
|
* @param buffer Buffer space in the virutal stack.
|
|
* @return True on success, false otherwise.
|
|
*/
|
|
DataStatus DecodeValveParam(IPluginContext *pContext,
|
|
cell_t param,
|
|
ValveType type,
|
|
unsigned int vflags,
|
|
PassType pass,
|
|
void *buffer);
|
|
|
|
/**
|
|
* @brief Encodes native data back into a plugin.
|
|
*
|
|
* Note: If you're going to return false, make sure to
|
|
* throw an error.
|
|
*
|
|
* @param pContext Plugin context.
|
|
* @param param Parameter value from params array.
|
|
* @param type Valve type.
|
|
* @param pass Pass info from bin tools.
|
|
* @param buffer Buffer space in the virutal stack.
|
|
* @return True on success, false otherwise.
|
|
*/
|
|
DataStatus EncodeValveParam(IPluginContext *pContext,
|
|
cell_t param,
|
|
ValveType type,
|
|
PassType pass,
|
|
const void *buffer);
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_VDECODER_H_
|