plugins/include/sdktools.inc
changeset 954 3dd58fa4ccdc
child 955 c59162dec673
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sdktools.inc	Sat Jun 16 18:03:05 2007 +0000
     1.3 @@ -0,0 +1,179 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ===============================================================
     1.7 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 + * ===============================================================
     1.9 + *
    1.10 + *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
    1.11 + * or modified under the Terms and Conditions of its License Agreement, which is found 
    1.12 + * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    1.13 + * may change at any time.  To view the latest information, see:
    1.14 + *   http://www.sourcemod.net/license.php
    1.15 + *
    1.16 + * Version: $Id$
    1.17 + */
    1.18 +
    1.19 +#if defined _sdktools_included
    1.20 +  #endinput
    1.21 +#endif
    1.22 +#define _sdktools_included
    1.23 +
    1.24 +#include <core>
    1.25 +#include <sdktools_functions>
    1.26 +
    1.27 +enum SDKCallType
    1.28 +{
    1.29 +	SDKCall_Static,		/**< Static call */
    1.30 +	SDKCall_Entity,		/**< CBaseEntity call */
    1.31 +	SDKCall_Player,		/**< CBasePlayer call */
    1.32 +};
    1.33 +
    1.34 +enum SDKLibrary
    1.35 +{
    1.36 +	SDKLibrary_Server,	/**< server.dll/server_i486.so */
    1.37 +	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
    1.38 +};
    1.39 +
    1.40 +enum SDKFuncConfSource
    1.41 +{
    1.42 +	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
    1.43 +	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
    1.44 +};
    1.45 +
    1.46 +enum SDKType
    1.47 +{
    1.48 +	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
    1.49 +	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
    1.50 +	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
    1.51 +	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
    1.52 +	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
    1.53 +	SDKType_Float,			/**< Float (any) */
    1.54 +	SDKType_Edict,			/**< edict_t (always as pointer) */
    1.55 +	SDKType_String,			/**< NULL-terminated string (always as pointer) */
    1.56 +};
    1.57 +
    1.58 +enum SDKPassMethod
    1.59 +{
    1.60 +	SDKPass_Pointer,		/**< Pass as a pointer */
    1.61 +	SDKPass_Plain,			/**< Pass as plain data */
    1.62 +	SDKPass_ByValue,		/**< Pass an object by value */
    1.63 +	SDKPass_ByRef,			/**< Pass an object by reference */
    1.64 +};
    1.65 +
    1.66 +#define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
    1.67 +#define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
    1.68 +#define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
    1.69 +#define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
    1.70 +
    1.71 +#define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
    1.72 +
    1.73 +/**
    1.74 + * Starts the preparation of an SDK call.
    1.75 + *
    1.76 + * @param type			Type of function call this will be.
    1.77 + * @noreturn
    1.78 + */
    1.79 +native StartPrepSDKCall(SDKCallType:type);
    1.80 +
    1.81 +/**
    1.82 + * Sets the virtual index of the SDK call if it is virtual.
    1.83 + *
    1.84 + * @param vtblidx		Virtual table index.
    1.85 + * @noreturn
    1.86 + */
    1.87 +native PrepSDKCall_SetVirtual(vtblidx);
    1.88 +
    1.89 +/**
    1.90 + * Finds an address in a library and sets it as the address to use for the SDK call.
    1.91 + *
    1.92 + * @param lib			Library to use.
    1.93 + * @param signature		Binary data to search for in the library.  If it starts with '@',
    1.94 + *						the bytes parameter is ignored and the signature is interpreted
    1.95 + *						as a symbol lookup in the library.
    1.96 + * @param bytes			Number of bytes in the binary search string.
    1.97 + * @return				True on success, false if nothing was found.
    1.98 + */
    1.99 +native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
   1.100 +
   1.101 +/**
   1.102 + * Finds an address or virtual function index in a GameConfig file and sets it as
   1.103 + * the calling information for the SDK call.
   1.104 + *
   1.105 + * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
   1.106 + * @param source		Whether to look in Offsets or Signatures.
   1.107 + * @param name			Name of the property to find.
   1.108 + * @return				True on success, false if nothing was found.
   1.109 + */
   1.110 +native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
   1.111 +
   1.112 +/**
   1.113 + * Sets the return information of an SDK call.  Do not call this if there is no return data.
   1.114 + * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
   1.115 + * the data).
   1.116 + *
   1.117 + * @param type			Data type to convert to/from.
   1.118 + * @param pass			How the data is passed in C++.
   1.119 + * @param decflags		Flags on decoding from the plugin to C++.
   1.120 + * @param encflags		Flags on encoding from C++ to the plugin.
   1.121 + * @noreturn
   1.122 + */
   1.123 +native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   1.124 +
   1.125 +/**
   1.126 + * Adds a parameter to the calling convention.  This should be called in normal ascending order.
   1.127 + *
   1.128 + * @param type			Data type to convert to/from.
   1.129 + * @param pass			How the data is passed in C++.
   1.130 + * @param decflags		Flags on decoding from the plugin to C++.
   1.131 + * @param encflags		Flags on encoding from C++ to the plugin.
   1.132 + * @noreturn
   1.133 + */
   1.134 +native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   1.135 +
   1.136 +/**
   1.137 + * Finalizes an SDK call preparation and returns the resultant Handle.
   1.138 + *
   1.139 + * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
   1.140 + */
   1.141 +native Handle:EndPrepSDKCall();
   1.142 +
   1.143 +/**
   1.144 + * Calls an SDK function with the given parameters.
   1.145 + *
   1.146 + * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
   1.147 + * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
   1.148 + * If the return value is a string, the THIRD parameter must be a String buffer, and the
   1.149 + *  FOURTH parameter must be the maximum length.
   1.150 + * All parameters must be passed after the above is followed.  Failure to follow these 
   1.151 + *  rules will result in crashes or wildly unexpected behavior!
   1.152 + *
   1.153 + * If the return value is a float or integer, the return value will be this value.
   1.154 + * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
   1.155 + *   always be the entity index, or -1 for NULL.
   1.156 + *
   1.157 + * @param call			SDKCall Handle.
   1.158 + * @param ...			Call Parameters.
   1.159 + * @return				Simple return value, if any.
   1.160 + * @error				Invalid Handle or internal decoding error.
   1.161 + */
   1.162 +native any:SDKCall(Handle:call, any:...);
   1.163 +
   1.164 +
   1.165 +/**
   1.166 + * Do not edit below this line!
   1.167 + */
   1.168 +public Extension:__ext_sdktools = 
   1.169 +{
   1.170 +	name = "SDKTools",
   1.171 +	file = "sdktools.ext",
   1.172 +#if defined AUTOLOAD_EXTENSIONS
   1.173 +	autoload = 1,
   1.174 +#else
   1.175 +	autoload = 0,
   1.176 +#endif
   1.177 +#if defined REQUIRE_EXTENSIONS
   1.178 +	required = 1,
   1.179 +#else
   1.180 +	required = 0,
   1.181 +#endif
   1.182 +};