extensions/sdktools/vdecoder.h
changeset 950 ac855ba24c7d
child 954 3dd58fa4ccdc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/sdktools/vdecoder.h	Sat Jun 16 08:36:34 2007 +0000
     1.3 @@ -0,0 +1,93 @@
     1.4 +#ifndef _INCLUDE_SOURCEMOD_VDECODER_H_
     1.5 +#define _INCLUDE_SOURCEMOD_VDECODER_H_
     1.6 +
     1.7 +#include <sm_platform.h>
     1.8 +#include <sp_vm_api.h>
     1.9 +#include <extensions/IBinTools.h>
    1.10 +
    1.11 +using namespace SourceMod;
    1.12 +using namespace SourcePawn;
    1.13 +
    1.14 +/**
    1.15 + * @brief Encapsulates types from the SDK
    1.16 + */
    1.17 +enum ValveType
    1.18 +{
    1.19 +	Valve_CBaseEntity,		/**< CBaseEntity */
    1.20 +	Valve_CBasePlayer,		/**< CBasePlayer (disallow normal ents) */
    1.21 +	Valve_Vector,			/**< Vector */
    1.22 +	Valve_QAngle,			/**< QAngle */
    1.23 +	Valve_POD,				/**< Plain old data */
    1.24 +	Valve_Float,			/**< Float */
    1.25 +	Valve_Edict,			/**< Edict */
    1.26 +	Valve_String,			/**< String */
    1.27 +};
    1.28 +
    1.29 +enum DataStatus
    1.30 +{
    1.31 +	Data_Fail = 0,
    1.32 +	Data_Okay = 1,
    1.33 +};
    1.34 +
    1.35 +#define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
    1.36 +#define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
    1.37 +#define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
    1.38 +#define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
    1.39 +
    1.40 +#define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data */
    1.41 +
    1.42 +/**
    1.43 + * @brief Converts a valve parameter to a bintools parameter.
    1.44 + *
    1.45 + * @param type			Valve type.
    1.46 + * @param pass			Either basic or object.
    1.47 + * @param flags			Either BYVAL or BYREF.
    1.48 + * @param info			Buffer to store param info in.
    1.49 + * @return				Number of bytes this will use in the virtual stack,
    1.50 + *						or 0 if conversion was impossible.
    1.51 + */
    1.52 +size_t ValveParamToBinParam(ValveType type, 
    1.53 +					  PassType pass,
    1.54 +					  unsigned int flags,
    1.55 +					  PassInfo *info);
    1.56 +
    1.57 +/**
    1.58 + * @brief Decodes data from a plugin to native data.
    1.59 + *
    1.60 + * Note: If you're going to return false, make sure to 
    1.61 + * throw an error.
    1.62 + *
    1.63 + * @param pContext		Plugin context.
    1.64 + * @param param			Parameter value from params array.
    1.65 + * @param type			Valve type.
    1.66 + * @param pass			Pass info from bin tools.
    1.67 + * @param buffer		Buffer space in the virutal stack.
    1.68 + * @return				True on success, false otherwise.
    1.69 + */
    1.70 +DataStatus DecodeValveParam(IPluginContext *pContext,
    1.71 +					  cell_t param,
    1.72 +					  ValveType type,
    1.73 +					  unsigned int vflags,
    1.74 +					  PassType pass,
    1.75 +					  void *buffer);
    1.76 +
    1.77 +/**
    1.78 + * @brief Encodes native data back into a plugin.
    1.79 + *
    1.80 + * Note: If you're going to return false, make sure to 
    1.81 + * throw an error.
    1.82 + *
    1.83 + * @param pContext		Plugin context.
    1.84 + * @param param			Parameter value from params array.
    1.85 + * @param type			Valve type.
    1.86 + * @param pass			Pass info from bin tools.
    1.87 + * @param buffer		Buffer space in the virutal stack.
    1.88 + * @return				True on success, false otherwise.
    1.89 + */
    1.90 +DataStatus EncodeValveParam(IPluginContext *pContext,
    1.91 +					  cell_t param,
    1.92 +					  ValveType type,
    1.93 +					  PassType pass,
    1.94 +					  const void *buffer);
    1.95 +
    1.96 +#endif //_INCLUDE_SOURCEMOD_VDECODER_H_