plugins/include/sdktools.inc
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 4346 a2f9c923d545
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _sdktools_included
    34   #endinput
    35 #endif
    36 #define _sdktools_included
    37 
    38 #include <core>
    39 #include <sdktools_engine>
    40 #include <sdktools_functions>
    41 #if !defined SDKTOOLS_DISABLE_SOUNDAPI
    42 #include <sdktools_sound>
    43 #endif
    44 #include <sdktools_stringtables>
    45 #include <sdktools_trace>
    46 #include <sdktools_tempents>
    47 #include <sdktools_tempents_stocks>
    48 #include <sdktools_voice>
    49 #include <sdktools_entinput>
    50 #include <sdktools_entoutput>
    51 #include <sdktools_hooks>
    52 #include <sdktools_gamerules>
    53 #include <sdktools_client>
    54 
    55 enum SDKCallType
    56 {
    57 	SDKCall_Static,		/**< Static call */
    58 	SDKCall_Entity,		/**< CBaseEntity call */
    59 	SDKCall_Player,		/**< CBasePlayer call */
    60 	SDKCall_GameRules,	/**< CGameRules call */
    61 	SDKCall_EntityList,	/**< CGlobalEntityList call */ 
    62 	SDKCall_Raw,		/**< |this| pointer with an arbitrary address */ 
    63 };
    64 
    65 enum SDKLibrary
    66 {
    67 	SDKLibrary_Server,	/**< server.dll/server_i486.so */
    68 	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
    69 };
    70 
    71 enum SDKFuncConfSource
    72 {
    73 	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
    74 	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
    75 	SDKConf_Address = 2,	/**< Read an address from the Addresses section */
    76 };
    77 
    78 enum SDKType
    79 {
    80 	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
    81 	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
    82 	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
    83 	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
    84 	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
    85 	SDKType_Float,			/**< Float (any) */
    86 	SDKType_Edict,			/**< edict_t (always as pointer) */
    87 	SDKType_String,			/**< NULL-terminated string (always as pointer) */
    88 	SDKType_Bool,			/**< Boolean (any) */
    89 };
    90 
    91 enum SDKPassMethod
    92 {
    93 	SDKPass_Pointer,		/**< Pass as a pointer */
    94 	SDKPass_Plain,			/**< Pass as plain data */
    95 	SDKPass_ByValue,		/**< Pass an object by value */
    96 	SDKPass_ByRef,			/**< Pass an object by reference */
    97 };
    98 
    99 #define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
   100 #define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
   101 #define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
   102 #define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
   103 
   104 #define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
   105 
   106 /**
   107  * Starts the preparation of an SDK call.
   108  *
   109  * @param type			Type of function call this will be.
   110  * @noreturn
   111  */
   112 native StartPrepSDKCall(SDKCallType:type);
   113 
   114 /**
   115  * Sets the virtual index of the SDK call if it is virtual.
   116  *
   117  * @param vtblidx		Virtual table index.
   118  * @noreturn
   119  */
   120 native PrepSDKCall_SetVirtual(vtblidx);
   121 
   122 /**
   123  * Finds an address in a library and sets it as the address to use for the SDK call.
   124  *
   125  * @param lib			Library to use.
   126  * @param signature		Binary data to search for in the library.  If it starts with '@',
   127  *						the bytes parameter is ignored and the signature is interpreted
   128  *						as a symbol lookup in the library.
   129  * @param bytes			Number of bytes in the binary search string.
   130  * @return				True on success, false if nothing was found.
   131  */
   132 native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
   133 
   134 /**
   135  * Uses the given function address for the SDK call.
   136  *
   137  * @param addr			Address of function to use.
   138  * @return				True on success, false on failure.
   139  */
   140 native bool:PrepSDKCall_SetAddress(Address:addr);
   141 
   142 /**
   143  * Finds an address or virtual function index in a GameConfig file and sets it as
   144  * the calling information for the SDK call.
   145  *
   146  * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
   147  * @param source		Whether to look in Offsets or Signatures.
   148  * @param name			Name of the property to find.
   149  * @return				True on success, false if nothing was found.
   150  */
   151 native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
   152 
   153 /**
   154  * Sets the return information of an SDK call.  Do not call this if there is no return data.
   155  * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
   156  * the data).
   157  *
   158  * @param type			Data type to convert to/from.
   159  * @param pass			How the data is passed in C++.
   160  * @param decflags		Flags on decoding from the plugin to C++.
   161  * @param encflags		Flags on encoding from C++ to the plugin.
   162  * @noreturn
   163  */
   164 native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   165 
   166 /**
   167  * Adds a parameter to the calling convention.  This should be called in normal ascending order.
   168  *
   169  * @param type			Data type to convert to/from.
   170  * @param pass			How the data is passed in C++.
   171  * @param decflags		Flags on decoding from the plugin to C++.
   172  * @param encflags		Flags on encoding from C++ to the plugin.
   173  * @noreturn
   174  */
   175 native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
   176 
   177 /**
   178  * Finalizes an SDK call preparation and returns the resultant Handle.
   179  *
   180  * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
   181  */
   182 native Handle:EndPrepSDKCall();
   183 
   184 /**
   185  * Calls an SDK function with the given parameters.
   186  *
   187  * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
   188  * If the call type is GameRules, then nothing special needs to be passed.
   189  * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
   190  * If the return value is a string, the THIRD parameter must be a String buffer, and the
   191  *  FOURTH parameter must be the maximum length.
   192  * All parameters must be passed after the above is followed.  Failure to follow these 
   193  *  rules will result in crashes or wildly unexpected behavior!
   194  *
   195  * If the return value is a float or integer, the return value will be this value.
   196  * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
   197  *   always be the entity index, or -1 for NULL.
   198  *
   199  * @param call			SDKCall Handle.
   200  * @param ...			Call Parameters.
   201  * @return				Simple return value, if any.
   202  * @error				Invalid Handle or internal decoding error.
   203  */
   204 native any:SDKCall(Handle:call, any:...);
   205 
   206 /**
   207  * Returns the entity index of the player resource/manager entity.
   208  *
   209  * @return				Index of resource entity or -1 if not found.
   210  */
   211 native GetPlayerResourceEntity();
   212 
   213 #include <sdktools_stocks>
   214 
   215 /**
   216  * Do not edit below this line!
   217  */
   218 public Extension:__ext_sdktools = 
   219 {
   220 	name = "SDKTools",
   221 	file = "sdktools.ext",
   222 #if defined AUTOLOAD_EXTENSIONS
   223 	autoload = 1,
   224 #else
   225 	autoload = 0,
   226 #endif
   227 #if defined REQUIRE_EXTENSIONS
   228 	required = 1,
   229 #else
   230 	required = 0,
   231 #endif
   232 };