dvander@954: /**
dvander@954: * vim: set ts=4 :
ds@1330: * =============================================================================
ds@1947: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
ds@1330: *
ds@1330: * This file is part of the SourceMod/SourcePawn SDK.
dvander@954: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
ds@1330: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
ds@1330: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
ds@1330: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@954: *
dvander@954: * Version: $Id$
dvander@954: */
dvander@954:
dvander@954: #if defined _sdktools_included
dvander@954: #endinput
dvander@954: #endif
dvander@954: #define _sdktools_included
dvander@954:
dvander@954: #include
dvander@1106: #include
dvander@954: #include
dvander@1063: #if !defined SDKTOOLS_DISABLE_SOUNDAPI
dvander@1047: #include
dvander@1063: #endif
ds@1114: #include
faluco@1075: #include
ds@1114: #include
ds@1114: #include
teame06@1235: #include
faluco@1498: #include
pred@1958: #include
pred@2711: #include
dvander@954:
dvander@954: enum SDKCallType
dvander@954: {
dvander@954: SDKCall_Static, /**< Static call */
dvander@954: SDKCall_Entity, /**< CBaseEntity call */
dvander@954: SDKCall_Player, /**< CBasePlayer call */
ds@1065: SDKCall_GameRules, /**< CGameRules call */
ds@1240: SDKCall_EntityList, /**< CGlobalEntityList call */
downtown1@2901: SDKCall_Raw, /**< Raw Address call */
dvander@954: };
dvander@954:
dvander@954: enum SDKLibrary
dvander@954: {
dvander@954: SDKLibrary_Server, /**< server.dll/server_i486.so */
dvander@954: SDKLibrary_Engine, /**< engine.dll/engine_*.so */
dvander@954: };
dvander@954:
dvander@954: enum SDKFuncConfSource
dvander@954: {
dvander@954: SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */
dvander@954: SDKConf_Signature = 1, /**< Read a signature from the Signatures section */
dvander@954: };
dvander@954:
dvander@954: enum SDKType
dvander@954: {
dvander@954: SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */
dvander@954: SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */
dvander@954: SDKType_Vector, /**< Vector (pointer, byval, or byref) */
dvander@954: SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */
dvander@954: SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */
dvander@954: SDKType_Float, /**< Float (any) */
dvander@954: SDKType_Edict, /**< edict_t (always as pointer) */
dvander@954: SDKType_String, /**< NULL-terminated string (always as pointer) */
dvander@955: SDKType_Bool, /**< Boolean (any) */
dvander@954: };
dvander@954:
dvander@954: enum SDKPassMethod
dvander@954: {
dvander@954: SDKPass_Pointer, /**< Pass as a pointer */
dvander@954: SDKPass_Plain, /**< Pass as plain data */
dvander@954: SDKPass_ByValue, /**< Pass an object by value */
dvander@954: SDKPass_ByRef, /**< Pass an object by reference */
dvander@954: };
dvander@954:
dvander@954: #define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
dvander@954: #define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
dvander@954: #define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
dvander@954: #define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
dvander@954:
dvander@954: #define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */
dvander@954:
dvander@954: /**
dvander@954: * Starts the preparation of an SDK call.
dvander@954: *
dvander@954: * @param type Type of function call this will be.
dvander@954: * @noreturn
dvander@954: */
dvander@954: native StartPrepSDKCall(SDKCallType:type);
dvander@954:
dvander@954: /**
dvander@954: * Sets the virtual index of the SDK call if it is virtual.
dvander@954: *
dvander@954: * @param vtblidx Virtual table index.
dvander@954: * @noreturn
dvander@954: */
dvander@954: native PrepSDKCall_SetVirtual(vtblidx);
dvander@954:
dvander@954: /**
dvander@954: * Finds an address in a library and sets it as the address to use for the SDK call.
dvander@954: *
dvander@954: * @param lib Library to use.
dvander@954: * @param signature Binary data to search for in the library. If it starts with '@',
dvander@954: * the bytes parameter is ignored and the signature is interpreted
dvander@954: * as a symbol lookup in the library.
dvander@954: * @param bytes Number of bytes in the binary search string.
dvander@954: * @return True on success, false if nothing was found.
dvander@954: */
dvander@954: native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
dvander@954:
dvander@954: /**
dvander@954: * Finds an address or virtual function index in a GameConfig file and sets it as
dvander@954: * the calling information for the SDK call.
dvander@954: *
dvander@954: * @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
dvander@954: * @param source Whether to look in Offsets or Signatures.
dvander@954: * @param name Name of the property to find.
dvander@954: * @return True on success, false if nothing was found.
dvander@954: */
dvander@954: native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
dvander@954:
dvander@954: /**
dvander@954: * Sets the return information of an SDK call. Do not call this if there is no return data.
dvander@954: * This must be called if there is a return value (i.e. it is not necessarily safe to ignore
dvander@954: * the data).
dvander@954: *
dvander@954: * @param type Data type to convert to/from.
dvander@954: * @param pass How the data is passed in C++.
dvander@954: * @param decflags Flags on decoding from the plugin to C++.
dvander@954: * @param encflags Flags on encoding from C++ to the plugin.
dvander@954: * @noreturn
dvander@954: */
dvander@954: native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954:
dvander@954: /**
dvander@954: * Adds a parameter to the calling convention. This should be called in normal ascending order.
dvander@954: *
dvander@954: * @param type Data type to convert to/from.
dvander@954: * @param pass How the data is passed in C++.
dvander@954: * @param decflags Flags on decoding from the plugin to C++.
dvander@954: * @param encflags Flags on encoding from C++ to the plugin.
dvander@954: * @noreturn
dvander@954: */
dvander@954: native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954:
dvander@954: /**
dvander@954: * Finalizes an SDK call preparation and returns the resultant Handle.
dvander@954: *
dvander@954: * @return A new SDKCall Handle on success, or INVALID_HANDLE on failure.
dvander@954: */
dvander@954: native Handle:EndPrepSDKCall();
dvander@954:
dvander@954: /**
dvander@954: * Calls an SDK function with the given parameters.
dvander@954: *
dvander@954: * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
ds@1065: * If the call type is GameRules, then nothing special needs to be passed.
dvander@954: * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
dvander@954: * If the return value is a string, the THIRD parameter must be a String buffer, and the
dvander@954: * FOURTH parameter must be the maximum length.
dvander@954: * All parameters must be passed after the above is followed. Failure to follow these
dvander@954: * rules will result in crashes or wildly unexpected behavior!
dvander@954: *
dvander@954: * If the return value is a float or integer, the return value will be this value.
dvander@954: * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
dvander@954: * always be the entity index, or -1 for NULL.
dvander@954: *
dvander@954: * @param call SDKCall Handle.
dvander@954: * @param ... Call Parameters.
dvander@954: * @return Simple return value, if any.
dvander@954: * @error Invalid Handle or internal decoding error.
dvander@954: */
dvander@954: native any:SDKCall(Handle:call, any:...);
dvander@954:
dvander@1616: #include
dvander@954:
dvander@954: /**
dvander@954: * Do not edit below this line!
dvander@954: */
dvander@954: public Extension:__ext_sdktools =
dvander@954: {
dvander@954: name = "SDKTools",
dvander@954: file = "sdktools.ext",
dvander@954: #if defined AUTOLOAD_EXTENSIONS
dvander@954: autoload = 1,
dvander@954: #else
dvander@954: autoload = 0,
dvander@954: #endif
dvander@954: #if defined REQUIRE_EXTENSIONS
dvander@954: required = 1,
dvander@954: #else
dvander@954: required = 0,
dvander@954: #endif
dvander@954: };