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