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