2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
2019-09-27 13:14:44 +02:00
|
|
|
* SourceMod (C)2004-2017 AlliedModders LLC. All rights reserved.
|
2008-10-04 22:59:11 +02:00
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This file is part of the SourceMod/SourcePawn SDK.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
2019-09-27 13:14:44 +02:00
|
|
|
*
|
2008-10-04 22:59:11 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
2009-04-14 23:40:48 +02:00
|
|
|
* Version: $Id$
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined _sdktools_included
|
2019-09-27 13:14:44 +02:00
|
|
|
#endinput
|
2008-10-04 22:59:11 +02:00
|
|
|
#endif
|
|
|
|
#define _sdktools_included
|
|
|
|
|
|
|
|
#include <core>
|
|
|
|
#include <sdktools_engine>
|
|
|
|
#include <sdktools_functions>
|
|
|
|
#if !defined SDKTOOLS_DISABLE_SOUNDAPI
|
|
|
|
#include <sdktools_sound>
|
|
|
|
#endif
|
|
|
|
#include <sdktools_stringtables>
|
|
|
|
#include <sdktools_trace>
|
|
|
|
#include <sdktools_tempents>
|
|
|
|
#include <sdktools_tempents_stocks>
|
|
|
|
#include <sdktools_voice>
|
2019-09-27 13:14:44 +02:00
|
|
|
#include <sdktools_variant_t>
|
2008-10-04 22:59:11 +02:00
|
|
|
#include <sdktools_entinput>
|
|
|
|
#include <sdktools_entoutput>
|
2010-07-25 20:58:18 +02:00
|
|
|
#include <sdktools_hooks>
|
2012-01-28 02:16:49 +01:00
|
|
|
#include <sdktools_gamerules>
|
|
|
|
#include <sdktools_client>
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
enum SDKCallType
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
SDKCall_Static, /**< Static call */
|
|
|
|
SDKCall_Entity, /**< CBaseEntity call */
|
|
|
|
SDKCall_Player, /**< CBasePlayer call */
|
|
|
|
SDKCall_GameRules, /**< CGameRules call */
|
|
|
|
SDKCall_EntityList, /**< CGlobalEntityList call */
|
|
|
|
SDKCall_Raw /**< |this| pointer with an arbitrary address */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SDKLibrary
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
SDKLibrary_Server, /**< server.dll/server_i486.so */
|
|
|
|
SDKLibrary_Engine /**< engine.dll/engine_*.so */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SDKFuncConfSource
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */
|
|
|
|
SDKConf_Signature = 1, /**< Read a signature from the Signatures section */
|
|
|
|
SDKConf_Address = 2 /**< Read an address from the Addresses section */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SDKType
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */
|
|
|
|
SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */
|
|
|
|
SDKType_Vector, /**< Vector (pointer, byval, or byref) */
|
|
|
|
SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */
|
|
|
|
SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */
|
|
|
|
SDKType_Float, /**< Float (any) */
|
|
|
|
SDKType_Edict, /**< edict_t (always as pointer) */
|
|
|
|
SDKType_String, /**< NULL-terminated string (always as pointer) */
|
|
|
|
SDKType_Bool /**< Boolean (any) */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SDKPassMethod
|
|
|
|
{
|
2019-09-27 13:14:44 +02:00
|
|
|
SDKPass_Pointer, /**< Pass as a pointer */
|
|
|
|
SDKPass_Plain, /**< Pass as plain data */
|
|
|
|
SDKPass_ByValue, /**< Pass an object by value */
|
|
|
|
SDKPass_ByRef /**< Pass an object by reference */
|
2008-10-04 22:59:11 +02:00
|
|
|
};
|
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
|
|
|
|
#define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
|
|
|
|
#define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
|
|
|
|
#define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2019-09-27 13:14:44 +02:00
|
|
|
#define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the preparation of an SDK call.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param type Type of function call this will be.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void StartPrepSDKCall(SDKCallType type);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the virtual index of the SDK call if it is virtual.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param vtblidx Virtual table index.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrepSDKCall_SetVirtual(int vtblidx);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds an address in a library and sets it as the address to use for the SDK call.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param lib Library to use.
|
|
|
|
* @param signature Binary data to search for in the library. If it starts with '@',
|
|
|
|
* the bytes parameter is ignored and the signature is interpreted
|
|
|
|
* as a symbol lookup in the library.
|
|
|
|
* @param bytes Number of bytes in the binary search string.
|
|
|
|
* @return True on success, false if nothing was found.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool PrepSDKCall_SetSignature(SDKLibrary lib, const char[] signature, int bytes);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2014-07-30 11:03:42 +02:00
|
|
|
/**
|
|
|
|
* Uses the given function address for the SDK call.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param addr Address of function to use.
|
|
|
|
* @return True on success, false on failure.
|
2014-07-30 11:03:42 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool PrepSDKCall_SetAddress(Address addr);
|
2014-07-30 11:03:42 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* Finds an address or virtual function index in a GameConfig file and sets it as
|
|
|
|
* the calling information for the SDK call.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
|
|
|
|
* @param source Whether to look in Offsets or Signatures.
|
|
|
|
* @param name Name of the property to find.
|
|
|
|
* @return True on success, false if nothing was found.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native bool PrepSDKCall_SetFromConf(Handle gameconf, SDKFuncConfSource source, const char[] name);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the return information of an SDK call. Do not call this if there is no return data.
|
2019-09-27 13:14:44 +02:00
|
|
|
* This must be called if there is a return value (i.e. it is not necessarily safe to ignore
|
2008-10-04 22:59:11 +02:00
|
|
|
* the data).
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param type Data type to convert to/from.
|
|
|
|
* @param pass How the data is passed in C++.
|
|
|
|
* @param decflags Flags on decoding from the plugin to C++.
|
|
|
|
* @param encflags Flags on encoding from C++ to the plugin.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrepSDKCall_SetReturnInfo(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a parameter to the calling convention. This should be called in normal ascending order.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param type Data type to convert to/from.
|
|
|
|
* @param pass How the data is passed in C++.
|
|
|
|
* @param decflags Flags on decoding from the plugin to C++.
|
|
|
|
* @param encflags Flags on encoding from C++ to the plugin.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native void PrepSDKCall_AddParameter(SDKType type, SDKPassMethod pass, int decflags=0, int encflags=0);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finalizes an SDK call preparation and returns the resultant Handle.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return A new SDKCall Handle on success, or INVALID_HANDLE on failure.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native Handle EndPrepSDKCall();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls an SDK function with the given parameters.
|
|
|
|
*
|
|
|
|
* If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
|
|
|
|
* If the call type is GameRules, then nothing special needs to be passed.
|
|
|
|
* If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
|
|
|
|
* If the return value is a string, the THIRD parameter must be a String buffer, and the
|
|
|
|
* FOURTH parameter must be the maximum length.
|
2019-09-27 13:14:44 +02:00
|
|
|
* All parameters must be passed after the above is followed. Failure to follow these
|
2008-10-04 22:59:11 +02:00
|
|
|
* rules will result in crashes or wildly unexpected behavior!
|
|
|
|
*
|
|
|
|
* If the return value is a float or integer, the return value will be this value.
|
|
|
|
* If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
|
2019-09-27 13:14:44 +02:00
|
|
|
* always be the entity index, or -1 for NULL.
|
2008-10-04 22:59:11 +02:00
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param call SDKCall Handle.
|
|
|
|
* @param ... Call Parameters.
|
|
|
|
* @return Simple return value, if any.
|
|
|
|
* @error Invalid Handle or internal decoding error.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native any SDKCall(Handle call, any ...);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2014-07-30 11:03:42 +02:00
|
|
|
/**
|
|
|
|
* Returns the entity index of the player resource/manager entity.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Index of resource entity or -1 if not found.
|
2014-07-30 11:03:42 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int GetPlayerResourceEntity();
|
2014-07-30 11:03:42 +02:00
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
#include <sdktools_stocks>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do not edit below this line!
|
|
|
|
*/
|
2019-09-27 13:14:44 +02:00
|
|
|
public Extension __ext_sdktools =
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
name = "SDKTools",
|
|
|
|
file = "sdktools.ext",
|
|
|
|
#if defined AUTOLOAD_EXTENSIONS
|
|
|
|
autoload = 1,
|
|
|
|
#else
|
|
|
|
autoload = 0,
|
|
|
|
#endif
|
|
|
|
#if defined REQUIRE_EXTENSIONS
|
|
|
|
required = 1,
|
|
|
|
#else
|
|
|
|
required = 0,
|
|
|
|
#endif
|
|
|
|
};
|