plugins/include/sdktools.inc
author Scott Ehlert <ds@alliedmods.net>
Thu Jun 21 19:51:34 2007 +0000 (2007-06-21)
changeset 996 378358b53fd5
parent 955 c59162dec673
child 1031 d9cf44ddcd9c
permissions -rw-r--r--
Not sure how I did this, but fixed KickClient include
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _sdktools_included
    17   #endinput
    18 #endif
    19 #define _sdktools_included
    20 
    21 #include <core>
    22 #include <sdktools_functions>
    23 
    24 enum SDKCallType
    25 {
    26 	SDKCall_Static,		/**< Static call */
    27 	SDKCall_Entity,		/**< CBaseEntity call */
    28 	SDKCall_Player,		/**< CBasePlayer call */
    29 };
    30 
    31 enum SDKLibrary
    32 {
    33 	SDKLibrary_Server,	/**< server.dll/server_i486.so */
    34 	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
    35 };
    36 
    37 enum SDKFuncConfSource
    38 {
    39 	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
    40 	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
    41 };
    42 
    43 enum SDKType
    44 {
    45 	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
    46 	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
    47 	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
    48 	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
    49 	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
    50 	SDKType_Float,			/**< Float (any) */
    51 	SDKType_Edict,			/**< edict_t (always as pointer) */
    52 	SDKType_String,			/**< NULL-terminated string (always as pointer) */
    53 	SDKType_Bool,			/**< Boolean (any) */
    54 };
    55 
    56 enum SDKPassMethod
    57 {
    58 	SDKPass_Pointer,		/**< Pass as a pointer */
    59 	SDKPass_Plain,			/**< Pass as plain data */
    60 	SDKPass_ByValue,		/**< Pass an object by value */
    61 	SDKPass_ByRef,			/**< Pass an object by reference */
    62 };
    63 
    64 #define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
    65 #define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
    66 #define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
    67 #define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
    68 
    69 #define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
    70 
    71 /**
    72  * Starts the preparation of an SDK call.
    73  *
    74  * @param type			Type of function call this will be.
    75  * @noreturn
    76  */
    77 native StartPrepSDKCall(SDKCallType:type);
    78 
    79 /**
    80  * Sets the virtual index of the SDK call if it is virtual.
    81  *
    82  * @param vtblidx		Virtual table index.
    83  * @noreturn
    84  */
    85 native PrepSDKCall_SetVirtual(vtblidx);
    86 
    87 /**
    88  * Finds an address in a library and sets it as the address to use for the SDK call.
    89  *
    90  * @param lib			Library to use.
    91  * @param signature		Binary data to search for in the library.  If it starts with '@',
    92  *						the bytes parameter is ignored and the signature is interpreted
    93  *						as a symbol lookup in the library.
    94  * @param bytes			Number of bytes in the binary search string.
    95  * @return				True on success, false if nothing was found.
    96  */
    97 native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
    98 
    99 /**
   100  * Finds an address or virtual function index in a GameConfig file and sets it as
   101  * the calling information for the SDK call.
   102  *
   103  * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
   104  * @param source		Whether to look in Offsets or Signatures.
   105  * @param name			Name of the property to find.
   106  * @return				True on success, false if nothing was found.
   107  */
   108 native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
   109 
   110 /**
   111  * Sets the return information of an SDK call.  Do not call this if there is no return data.
   112  * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
   113  * the data).
   114  *
   115  * @param type			Data type to convert to/from.
   116  * @param pass			How the data is passed in C++.
   117  * @param decflags		Flags on decoding from the plugin to C++.
   118  * @param encflags		Flags on encoding from C++ to the plugin.
   119  * @noreturn
   120  */
   121 native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   122 
   123 /**
   124  * Adds a parameter to the calling convention.  This should be called in normal ascending order.
   125  *
   126  * @param type			Data type to convert to/from.
   127  * @param pass			How the data is passed in C++.
   128  * @param decflags		Flags on decoding from the plugin to C++.
   129  * @param encflags		Flags on encoding from C++ to the plugin.
   130  * @noreturn
   131  */
   132 native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   133 
   134 /**
   135  * Finalizes an SDK call preparation and returns the resultant Handle.
   136  *
   137  * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
   138  */
   139 native Handle:EndPrepSDKCall();
   140 
   141 /**
   142  * Calls an SDK function with the given parameters.
   143  *
   144  * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
   145  * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
   146  * If the return value is a string, the THIRD parameter must be a String buffer, and the
   147  *  FOURTH parameter must be the maximum length.
   148  * All parameters must be passed after the above is followed.  Failure to follow these 
   149  *  rules will result in crashes or wildly unexpected behavior!
   150  *
   151  * If the return value is a float or integer, the return value will be this value.
   152  * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
   153  *   always be the entity index, or -1 for NULL.
   154  *
   155  * @param call			SDKCall Handle.
   156  * @param ...			Call Parameters.
   157  * @return				Simple return value, if any.
   158  * @error				Invalid Handle or internal decoding error.
   159  */
   160 native any:SDKCall(Handle:call, any:...);
   161 
   162 
   163 /**
   164  * Do not edit below this line!
   165  */
   166 public Extension:__ext_sdktools = 
   167 {
   168 	name = "SDKTools",
   169 	file = "sdktools.ext",
   170 #if defined AUTOLOAD_EXTENSIONS
   171 	autoload = 1,
   172 #else
   173 	autoload = 0,
   174 #endif
   175 #if defined REQUIRE_EXTENSIONS
   176 	required = 1,
   177 #else
   178 	required = 0,
   179 #endif
   180 };