1.1 --- a/extensions/sdktools/vdecoder.h Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,151 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod SDKTools Extension
1.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#ifndef _INCLUDE_SOURCEMOD_VDECODER_H_
1.36 -#define _INCLUDE_SOURCEMOD_VDECODER_H_
1.37 -
1.38 -#include <sm_platform.h>
1.39 -#include <sp_vm_api.h>
1.40 -#include <extensions/IBinTools.h>
1.41 -
1.42 -using namespace SourceMod;
1.43 -using namespace SourcePawn;
1.44 -
1.45 -/**
1.46 - * @brief Encapsulates types from the SDK
1.47 - */
1.48 -enum ValveType
1.49 -{
1.50 - Valve_CBaseEntity, /**< CBaseEntity */
1.51 - Valve_CBasePlayer, /**< CBasePlayer (disallow normal ents) */
1.52 - Valve_Vector, /**< Vector */
1.53 - Valve_QAngle, /**< QAngle */
1.54 - Valve_POD, /**< Plain old data */
1.55 - Valve_Float, /**< Float */
1.56 - Valve_Edict, /**< Edict */
1.57 - Valve_String, /**< String */
1.58 - Valve_Bool, /**< Boolean */
1.59 -};
1.60 -
1.61 -enum DataStatus
1.62 -{
1.63 - Data_Fail = 0,
1.64 - Data_Okay = 1,
1.65 -};
1.66 -
1.67 -#define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
1.68 -#define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
1.69 -#define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
1.70 -#define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
1.71 -
1.72 -#define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data */
1.73 -
1.74 -#define PASSFLAG_ASPOINTER (1<<30) /**< Not an actual passflag, used internally */
1.75 -
1.76 -/**
1.77 - * @brief Valve pre-defined calling types
1.78 - */
1.79 -enum ValveCallType
1.80 -{
1.81 - ValveCall_Static, /**< Static call */
1.82 - ValveCall_Entity, /**< Thiscall (CBaseEntity implicit first parameter) */
1.83 - ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
1.84 - ValveCall_GameRules, /**< Thiscall (CGameRules implicit first paramater) */
1.85 - ValveCall_EntityList, /**< Thiscall (CGlobalEntityList implicit first paramater) */
1.86 -};
1.87 -
1.88 -/**
1.89 - * @brief Valve parameter info
1.90 - */
1.91 -struct ValvePassInfo
1.92 -{
1.93 - ValveType vtype; /**< IN: Valve type */
1.94 - unsigned int decflags; /**< IN: VDECODE_FLAG_* */
1.95 - unsigned int encflags; /**< IN: VENCODE_FLAG_* */
1.96 - PassType type; /**< IN: Pass information */
1.97 - unsigned int flags; /**< IN: Pass flags */
1.98 - size_t offset; /**< OUT: stack offset */
1.99 - size_t obj_offset; /**< OUT: object offset at end of the stack */
1.100 -};
1.101 -
1.102 -struct ValveCall;
1.103 -
1.104 -/**
1.105 - * @brief Converts a valve parameter to a bintools parameter.
1.106 - *
1.107 - * @param type Valve type.
1.108 - * @param pass Either basic or object.
1.109 - * @param flags Either BYVAL or BYREF.
1.110 - * @param info Buffer to store param info in.
1.111 - * @return Number of bytes this will use in the virtual stack,
1.112 - * or 0 if conversion was impossible.
1.113 - */
1.114 -size_t ValveParamToBinParam(ValveType type,
1.115 - PassType pass,
1.116 - unsigned int flags,
1.117 - PassInfo *info,
1.118 - bool &needs_extra);
1.119 -
1.120 -/**
1.121 - * @brief Decodes data from a plugin to native data.
1.122 - *
1.123 - * Note: If you're going to return false, make sure to
1.124 - * throw an error.
1.125 - *
1.126 - * @param pContext Plugin context.
1.127 - * @param param Parameter value from params array.
1.128 - * @param buffer Buffer space in the virutal stack.
1.129 - * @return True on success, false otherwise.
1.130 - */
1.131 -DataStatus DecodeValveParam(IPluginContext *pContext,
1.132 - cell_t param,
1.133 - const ValveCall *pCall,
1.134 - const ValvePassInfo *vdata,
1.135 - void *buffer);
1.136 -
1.137 -/**
1.138 - * @brief Encodes native data back into a plugin.
1.139 - *
1.140 - * Note: If you're going to return false, make sure to
1.141 - * throw an error.
1.142 - *
1.143 - * @param pContext Plugin context.
1.144 - * @param param Parameter value from params array.
1.145 - * @param buffer Buffer space in the virutal stack.
1.146 - * @return True on success, false otherwise.
1.147 - */
1.148 -DataStatus EncodeValveParam(IPluginContext *pContext,
1.149 - cell_t param,
1.150 - const ValveCall *pCall,
1.151 - const ValvePassInfo *vdata,
1.152 - const void *buffer);
1.153 -
1.154 -#endif //_INCLUDE_SOURCEMOD_VDECODER_H_