plugins/include/sdktools.inc
changeset 1952 b7aa2b626807
child 1958 4ad91ad970ac
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sdktools.inc	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,211 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 +
    1.36 +#if defined _sdktools_included
    1.37 +  #endinput
    1.38 +#endif
    1.39 +#define _sdktools_included
    1.40 +
    1.41 +#include <core>
    1.42 +#include <sdktools_engine>
    1.43 +#include <sdktools_functions>
    1.44 +#if !defined SDKTOOLS_DISABLE_SOUNDAPI
    1.45 +#include <sdktools_sound>
    1.46 +#endif
    1.47 +#include <sdktools_stringtables>
    1.48 +#include <sdktools_trace>
    1.49 +#include <sdktools_tempents>
    1.50 +#include <sdktools_tempents_stocks>
    1.51 +#include <sdktools_voice>
    1.52 +#include <sdktools_entinput>
    1.53 +
    1.54 +enum SDKCallType
    1.55 +{
    1.56 +	SDKCall_Static,		/**< Static call */
    1.57 +	SDKCall_Entity,		/**< CBaseEntity call */
    1.58 +	SDKCall_Player,		/**< CBasePlayer call */
    1.59 +	SDKCall_GameRules,	/**< CGameRules call */
    1.60 +	SDKCall_EntityList,	/**< CGlobalEntityList call */ 
    1.61 +};
    1.62 +
    1.63 +enum SDKLibrary
    1.64 +{
    1.65 +	SDKLibrary_Server,	/**< server.dll/server_i486.so */
    1.66 +	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
    1.67 +};
    1.68 +
    1.69 +enum SDKFuncConfSource
    1.70 +{
    1.71 +	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
    1.72 +	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
    1.73 +};
    1.74 +
    1.75 +enum SDKType
    1.76 +{
    1.77 +	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
    1.78 +	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
    1.79 +	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
    1.80 +	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
    1.81 +	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
    1.82 +	SDKType_Float,			/**< Float (any) */
    1.83 +	SDKType_Edict,			/**< edict_t (always as pointer) */
    1.84 +	SDKType_String,			/**< NULL-terminated string (always as pointer) */
    1.85 +	SDKType_Bool,			/**< Boolean (any) */
    1.86 +};
    1.87 +
    1.88 +enum SDKPassMethod
    1.89 +{
    1.90 +	SDKPass_Pointer,		/**< Pass as a pointer */
    1.91 +	SDKPass_Plain,			/**< Pass as plain data */
    1.92 +	SDKPass_ByValue,		/**< Pass an object by value */
    1.93 +	SDKPass_ByRef,			/**< Pass an object by reference */
    1.94 +};
    1.95 +
    1.96 +#define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
    1.97 +#define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
    1.98 +#define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
    1.99 +#define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
   1.100 +
   1.101 +#define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
   1.102 +
   1.103 +/**
   1.104 + * Starts the preparation of an SDK call.
   1.105 + *
   1.106 + * @param type			Type of function call this will be.
   1.107 + * @noreturn
   1.108 + */
   1.109 +native StartPrepSDKCall(SDKCallType:type);
   1.110 +
   1.111 +/**
   1.112 + * Sets the virtual index of the SDK call if it is virtual.
   1.113 + *
   1.114 + * @param vtblidx		Virtual table index.
   1.115 + * @noreturn
   1.116 + */
   1.117 +native PrepSDKCall_SetVirtual(vtblidx);
   1.118 +
   1.119 +/**
   1.120 + * Finds an address in a library and sets it as the address to use for the SDK call.
   1.121 + *
   1.122 + * @param lib			Library to use.
   1.123 + * @param signature		Binary data to search for in the library.  If it starts with '@',
   1.124 + *						the bytes parameter is ignored and the signature is interpreted
   1.125 + *						as a symbol lookup in the library.
   1.126 + * @param bytes			Number of bytes in the binary search string.
   1.127 + * @return				True on success, false if nothing was found.
   1.128 + */
   1.129 +native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
   1.130 +
   1.131 +/**
   1.132 + * Finds an address or virtual function index in a GameConfig file and sets it as
   1.133 + * the calling information for the SDK call.
   1.134 + *
   1.135 + * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
   1.136 + * @param source		Whether to look in Offsets or Signatures.
   1.137 + * @param name			Name of the property to find.
   1.138 + * @return				True on success, false if nothing was found.
   1.139 + */
   1.140 +native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
   1.141 +
   1.142 +/**
   1.143 + * Sets the return information of an SDK call.  Do not call this if there is no return data.
   1.144 + * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
   1.145 + * the data).
   1.146 + *
   1.147 + * @param type			Data type to convert to/from.
   1.148 + * @param pass			How the data is passed in C++.
   1.149 + * @param decflags		Flags on decoding from the plugin to C++.
   1.150 + * @param encflags		Flags on encoding from C++ to the plugin.
   1.151 + * @noreturn
   1.152 + */
   1.153 +native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   1.154 +
   1.155 +/**
   1.156 + * Adds a parameter to the calling convention.  This should be called in normal ascending order.
   1.157 + *
   1.158 + * @param type			Data type to convert to/from.
   1.159 + * @param pass			How the data is passed in C++.
   1.160 + * @param decflags		Flags on decoding from the plugin to C++.
   1.161 + * @param encflags		Flags on encoding from C++ to the plugin.
   1.162 + * @noreturn
   1.163 + */
   1.164 +native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   1.165 +
   1.166 +/**
   1.167 + * Finalizes an SDK call preparation and returns the resultant Handle.
   1.168 + *
   1.169 + * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
   1.170 + */
   1.171 +native Handle:EndPrepSDKCall();
   1.172 +
   1.173 +/**
   1.174 + * Calls an SDK function with the given parameters.
   1.175 + *
   1.176 + * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
   1.177 + * If the call type is GameRules, then nothing special needs to be passed.
   1.178 + * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
   1.179 + * If the return value is a string, the THIRD parameter must be a String buffer, and the
   1.180 + *  FOURTH parameter must be the maximum length.
   1.181 + * All parameters must be passed after the above is followed.  Failure to follow these 
   1.182 + *  rules will result in crashes or wildly unexpected behavior!
   1.183 + *
   1.184 + * If the return value is a float or integer, the return value will be this value.
   1.185 + * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
   1.186 + *   always be the entity index, or -1 for NULL.
   1.187 + *
   1.188 + * @param call			SDKCall Handle.
   1.189 + * @param ...			Call Parameters.
   1.190 + * @return				Simple return value, if any.
   1.191 + * @error				Invalid Handle or internal decoding error.
   1.192 + */
   1.193 +native any:SDKCall(Handle:call, any:...);
   1.194 +
   1.195 +#include <sdktools_stocks>
   1.196 +
   1.197 +/**
   1.198 + * Do not edit below this line!
   1.199 + */
   1.200 +public Extension:__ext_sdktools = 
   1.201 +{
   1.202 +	name = "SDKTools",
   1.203 +	file = "sdktools.ext",
   1.204 +#if defined AUTOLOAD_EXTENSIONS
   1.205 +	autoload = 1,
   1.206 +#else
   1.207 +	autoload = 0,
   1.208 +#endif
   1.209 +#if defined REQUIRE_EXTENSIONS
   1.210 +	required = 1,
   1.211 +#else
   1.212 +	required = 0,
   1.213 +#endif
   1.214 +};