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