plugins/include/sdktools.inc
author Nicholas Hastings <skamonkey@gmail.com>
Sun Jan 10 17:29:32 2010 -0800 (2010-01-10)
changeset 2893 41e6bdba4712
parent 2711 858723415154
child 2901 f5a1cf24f505
permissions -rw-r--r--
Follow-up to bug 4194 (r=dvander).
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>
dvander@954
    52
dvander@954
    53
enum SDKCallType
dvander@954
    54
{
dvander@954
    55
	SDKCall_Static,		/**< Static call */
dvander@954
    56
	SDKCall_Entity,		/**< CBaseEntity call */
dvander@954
    57
	SDKCall_Player,		/**< CBasePlayer call */
ds@1065
    58
	SDKCall_GameRules,	/**< CGameRules call */
ds@1240
    59
	SDKCall_EntityList,	/**< CGlobalEntityList call */ 
dvander@954
    60
};
dvander@954
    61
dvander@954
    62
enum SDKLibrary
dvander@954
    63
{
dvander@954
    64
	SDKLibrary_Server,	/**< server.dll/server_i486.so */
dvander@954
    65
	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
dvander@954
    66
};
dvander@954
    67
dvander@954
    68
enum SDKFuncConfSource
dvander@954
    69
{
dvander@954
    70
	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
dvander@954
    71
	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
dvander@954
    72
};
dvander@954
    73
dvander@954
    74
enum SDKType
dvander@954
    75
{
dvander@954
    76
	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
dvander@954
    77
	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
dvander@954
    78
	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
dvander@954
    79
	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
dvander@954
    80
	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
dvander@954
    81
	SDKType_Float,			/**< Float (any) */
dvander@954
    82
	SDKType_Edict,			/**< edict_t (always as pointer) */
dvander@954
    83
	SDKType_String,			/**< NULL-terminated string (always as pointer) */
dvander@955
    84
	SDKType_Bool,			/**< Boolean (any) */
dvander@954
    85
};
dvander@954
    86
dvander@954
    87
enum SDKPassMethod
dvander@954
    88
{
dvander@954
    89
	SDKPass_Pointer,		/**< Pass as a pointer */
dvander@954
    90
	SDKPass_Plain,			/**< Pass as plain data */
dvander@954
    91
	SDKPass_ByValue,		/**< Pass an object by value */
dvander@954
    92
	SDKPass_ByRef,			/**< Pass an object by reference */
dvander@954
    93
};
dvander@954
    94
dvander@954
    95
#define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
dvander@954
    96
#define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
dvander@954
    97
#define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
dvander@954
    98
#define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
dvander@954
    99
dvander@954
   100
#define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
dvander@954
   101
dvander@954
   102
/**
dvander@954
   103
 * Starts the preparation of an SDK call.
dvander@954
   104
 *
dvander@954
   105
 * @param type			Type of function call this will be.
dvander@954
   106
 * @noreturn
dvander@954
   107
 */
dvander@954
   108
native StartPrepSDKCall(SDKCallType:type);
dvander@954
   109
dvander@954
   110
/**
dvander@954
   111
 * Sets the virtual index of the SDK call if it is virtual.
dvander@954
   112
 *
dvander@954
   113
 * @param vtblidx		Virtual table index.
dvander@954
   114
 * @noreturn
dvander@954
   115
 */
dvander@954
   116
native PrepSDKCall_SetVirtual(vtblidx);
dvander@954
   117
dvander@954
   118
/**
dvander@954
   119
 * Finds an address in a library and sets it as the address to use for the SDK call.
dvander@954
   120
 *
dvander@954
   121
 * @param lib			Library to use.
dvander@954
   122
 * @param signature		Binary data to search for in the library.  If it starts with '@',
dvander@954
   123
 *						the bytes parameter is ignored and the signature is interpreted
dvander@954
   124
 *						as a symbol lookup in the library.
dvander@954
   125
 * @param bytes			Number of bytes in the binary search string.
dvander@954
   126
 * @return				True on success, false if nothing was found.
dvander@954
   127
 */
dvander@954
   128
native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
dvander@954
   129
dvander@954
   130
/**
dvander@954
   131
 * Finds an address or virtual function index in a GameConfig file and sets it as
dvander@954
   132
 * the calling information for the SDK call.
dvander@954
   133
 *
dvander@954
   134
 * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
dvander@954
   135
 * @param source		Whether to look in Offsets or Signatures.
dvander@954
   136
 * @param name			Name of the property to find.
dvander@954
   137
 * @return				True on success, false if nothing was found.
dvander@954
   138
 */
dvander@954
   139
native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
dvander@954
   140
dvander@954
   141
/**
dvander@954
   142
 * Sets the return information of an SDK call.  Do not call this if there is no return data.
dvander@954
   143
 * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
dvander@954
   144
 * the data).
dvander@954
   145
 *
dvander@954
   146
 * @param type			Data type to convert to/from.
dvander@954
   147
 * @param pass			How the data is passed in C++.
dvander@954
   148
 * @param decflags		Flags on decoding from the plugin to C++.
dvander@954
   149
 * @param encflags		Flags on encoding from C++ to the plugin.
dvander@954
   150
 * @noreturn
dvander@954
   151
 */
dvander@954
   152
native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954
   153
dvander@954
   154
/**
dvander@954
   155
 * Adds a parameter to the calling convention.  This should be called in normal ascending order.
dvander@954
   156
 *
dvander@954
   157
 * @param type			Data type to convert to/from.
dvander@954
   158
 * @param pass			How the data is passed in C++.
dvander@954
   159
 * @param decflags		Flags on decoding from the plugin to C++.
dvander@954
   160
 * @param encflags		Flags on encoding from C++ to the plugin.
dvander@954
   161
 * @noreturn
dvander@954
   162
 */
dvander@954
   163
native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954
   164
dvander@954
   165
/**
dvander@954
   166
 * Finalizes an SDK call preparation and returns the resultant Handle.
dvander@954
   167
 *
dvander@954
   168
 * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
dvander@954
   169
 */
dvander@954
   170
native Handle:EndPrepSDKCall();
dvander@954
   171
dvander@954
   172
/**
dvander@954
   173
 * Calls an SDK function with the given parameters.
dvander@954
   174
 *
dvander@954
   175
 * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
ds@1065
   176
 * If the call type is GameRules, then nothing special needs to be passed.
dvander@954
   177
 * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
dvander@954
   178
 * If the return value is a string, the THIRD parameter must be a String buffer, and the
dvander@954
   179
 *  FOURTH parameter must be the maximum length.
dvander@954
   180
 * All parameters must be passed after the above is followed.  Failure to follow these 
dvander@954
   181
 *  rules will result in crashes or wildly unexpected behavior!
dvander@954
   182
 *
dvander@954
   183
 * If the return value is a float or integer, the return value will be this value.
dvander@954
   184
 * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
dvander@954
   185
 *   always be the entity index, or -1 for NULL.
dvander@954
   186
 *
dvander@954
   187
 * @param call			SDKCall Handle.
dvander@954
   188
 * @param ...			Call Parameters.
dvander@954
   189
 * @return				Simple return value, if any.
dvander@954
   190
 * @error				Invalid Handle or internal decoding error.
dvander@954
   191
 */
dvander@954
   192
native any:SDKCall(Handle:call, any:...);
dvander@954
   193
dvander@1616
   194
#include <sdktools_stocks>
dvander@954
   195
dvander@954
   196
/**
dvander@954
   197
 * Do not edit below this line!
dvander@954
   198
 */
dvander@954
   199
public Extension:__ext_sdktools = 
dvander@954
   200
{
dvander@954
   201
	name = "SDKTools",
dvander@954
   202
	file = "sdktools.ext",
dvander@954
   203
#if defined AUTOLOAD_EXTENSIONS
dvander@954
   204
	autoload = 1,
dvander@954
   205
#else
dvander@954
   206
	autoload = 0,
dvander@954
   207
#endif
dvander@954
   208
#if defined REQUIRE_EXTENSIONS
dvander@954
   209
	required = 1,
dvander@954
   210
#else
dvander@954
   211
	required = 0,
dvander@954
   212
#endif
dvander@954
   213
};