plugins/include/sdktools.inc
author David Anderson <dvander@alliedmods.net>
Mon Aug 13 01:46:58 2007 +0000 (2007-08-13)
changeset 1316 5d3283c02c54
parent 1240 79eebacc9d02
child 1330 ab94316bb52b
permissions -rw-r--r--
initial import of sql admins prefetch plugin and associated table schemas
dvander@954
     1
/**
dvander@954
     2
 * vim: set ts=4 :
dvander@954
     3
 * ===============================================================
dvander@954
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@954
     5
 * ===============================================================
dvander@954
     6
 *
dvander@954
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
dvander@954
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
dvander@954
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
dvander@954
    10
 * may change at any time.  To view the latest information, see:
dvander@954
    11
 *   http://www.sourcemod.net/license.php
dvander@954
    12
 *
dvander@954
    13
 * Version: $Id$
dvander@954
    14
 */
dvander@954
    15
dvander@954
    16
#if defined _sdktools_included
dvander@954
    17
  #endinput
dvander@954
    18
#endif
dvander@954
    19
#define _sdktools_included
dvander@954
    20
dvander@954
    21
#include <core>
dvander@1106
    22
#include <sdktools_engine>
dvander@954
    23
#include <sdktools_functions>
dvander@1063
    24
#if !defined SDKTOOLS_DISABLE_SOUNDAPI
dvander@1047
    25
#include <sdktools_sound>
dvander@1063
    26
#endif
ds@1114
    27
#include <sdktools_stringtables>
faluco@1075
    28
#include <sdktools_trace>
ds@1114
    29
#include <sdktools_tempents>
ds@1114
    30
#include <sdktools_tempents_stocks>
teame06@1235
    31
#include <sdktools_voice>
dvander@954
    32
dvander@954
    33
enum SDKCallType
dvander@954
    34
{
dvander@954
    35
	SDKCall_Static,		/**< Static call */
dvander@954
    36
	SDKCall_Entity,		/**< CBaseEntity call */
dvander@954
    37
	SDKCall_Player,		/**< CBasePlayer call */
ds@1065
    38
	SDKCall_GameRules,	/**< CGameRules call */
ds@1240
    39
	SDKCall_EntityList,	/**< CGlobalEntityList call */ 
dvander@954
    40
};
dvander@954
    41
dvander@954
    42
enum SDKLibrary
dvander@954
    43
{
dvander@954
    44
	SDKLibrary_Server,	/**< server.dll/server_i486.so */
dvander@954
    45
	SDKLibrary_Engine,	/**< engine.dll/engine_*.so */
dvander@954
    46
};
dvander@954
    47
dvander@954
    48
enum SDKFuncConfSource
dvander@954
    49
{
dvander@954
    50
	SDKConf_Virtual = 0,	/**< Read a virtual index from the Offsets section */
dvander@954
    51
	SDKConf_Signature = 1,	/**< Read a signature from the Signatures section */
dvander@954
    52
};
dvander@954
    53
dvander@954
    54
enum SDKType
dvander@954
    55
{
dvander@954
    56
	SDKType_CBaseEntity,	/**< CBaseEntity (always as pointer) */
dvander@954
    57
	SDKType_CBasePlayer,	/**< CBasePlayer (always as pointer) */
dvander@954
    58
	SDKType_Vector,			/**< Vector (pointer, byval, or byref) */
dvander@954
    59
	SDKType_QAngle,			/**< QAngles (pointer, byval, or byref) */
dvander@954
    60
	SDKType_PlainOldData,	/**< Integer/generic data <=32bit (any) */
dvander@954
    61
	SDKType_Float,			/**< Float (any) */
dvander@954
    62
	SDKType_Edict,			/**< edict_t (always as pointer) */
dvander@954
    63
	SDKType_String,			/**< NULL-terminated string (always as pointer) */
dvander@955
    64
	SDKType_Bool,			/**< Boolean (any) */
dvander@954
    65
};
dvander@954
    66
dvander@954
    67
enum SDKPassMethod
dvander@954
    68
{
dvander@954
    69
	SDKPass_Pointer,		/**< Pass as a pointer */
dvander@954
    70
	SDKPass_Plain,			/**< Pass as plain data */
dvander@954
    71
	SDKPass_ByValue,		/**< Pass an object by value */
dvander@954
    72
	SDKPass_ByRef,			/**< Pass an object by reference */
dvander@954
    73
};
dvander@954
    74
dvander@954
    75
#define VDECODE_FLAG_ALLOWNULL		(1<<0)		/**< Allow NULL for pointers */
dvander@954
    76
#define VDECODE_FLAG_ALLOWNOTINGAME	(1<<1)		/**< Allow players not in game */
dvander@954
    77
#define VDECODE_FLAG_ALLOWWORLD		(1<<2)		/**< Allow World entity */
dvander@954
    78
#define VDECODE_FLAG_BYREF			(1<<3)		/**< Floats/ints by reference */
dvander@954
    79
dvander@954
    80
#define VENCODE_FLAG_COPYBACK		(1<<0)		/**< Copy back data once done */
dvander@954
    81
dvander@954
    82
/**
dvander@954
    83
 * Starts the preparation of an SDK call.
dvander@954
    84
 *
dvander@954
    85
 * @param type			Type of function call this will be.
dvander@954
    86
 * @noreturn
dvander@954
    87
 */
dvander@954
    88
native StartPrepSDKCall(SDKCallType:type);
dvander@954
    89
dvander@954
    90
/**
dvander@954
    91
 * Sets the virtual index of the SDK call if it is virtual.
dvander@954
    92
 *
dvander@954
    93
 * @param vtblidx		Virtual table index.
dvander@954
    94
 * @noreturn
dvander@954
    95
 */
dvander@954
    96
native PrepSDKCall_SetVirtual(vtblidx);
dvander@954
    97
dvander@954
    98
/**
dvander@954
    99
 * Finds an address in a library and sets it as the address to use for the SDK call.
dvander@954
   100
 *
dvander@954
   101
 * @param lib			Library to use.
dvander@954
   102
 * @param signature		Binary data to search for in the library.  If it starts with '@',
dvander@954
   103
 *						the bytes parameter is ignored and the signature is interpreted
dvander@954
   104
 *						as a symbol lookup in the library.
dvander@954
   105
 * @param bytes			Number of bytes in the binary search string.
dvander@954
   106
 * @return				True on success, false if nothing was found.
dvander@954
   107
 */
dvander@954
   108
native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
dvander@954
   109
dvander@954
   110
/**
dvander@954
   111
 * Finds an address or virtual function index in a GameConfig file and sets it as
dvander@954
   112
 * the calling information for the SDK call.
dvander@954
   113
 *
dvander@954
   114
 * @param gameconf		GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
dvander@954
   115
 * @param source		Whether to look in Offsets or Signatures.
dvander@954
   116
 * @param name			Name of the property to find.
dvander@954
   117
 * @return				True on success, false if nothing was found.
dvander@954
   118
 */
dvander@954
   119
native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
dvander@954
   120
dvander@954
   121
/**
dvander@954
   122
 * Sets the return information of an SDK call.  Do not call this if there is no return data.
dvander@954
   123
 * This must be called if there is a return value (i.e. it is not necessarily safe to ignore 
dvander@954
   124
 * the data).
dvander@954
   125
 *
dvander@954
   126
 * @param type			Data type to convert to/from.
dvander@954
   127
 * @param pass			How the data is passed in C++.
dvander@954
   128
 * @param decflags		Flags on decoding from the plugin to C++.
dvander@954
   129
 * @param encflags		Flags on encoding from C++ to the plugin.
dvander@954
   130
 * @noreturn
dvander@954
   131
 */
dvander@954
   132
native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954
   133
dvander@954
   134
/**
dvander@954
   135
 * Adds a parameter to the calling convention.  This should be called in normal ascending order.
dvander@954
   136
 *
dvander@954
   137
 * @param type			Data type to convert to/from.
dvander@954
   138
 * @param pass			How the data is passed in C++.
dvander@954
   139
 * @param decflags		Flags on decoding from the plugin to C++.
dvander@954
   140
 * @param encflags		Flags on encoding from C++ to the plugin.
dvander@954
   141
 * @noreturn
dvander@954
   142
 */
dvander@954
   143
native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
dvander@954
   144
dvander@954
   145
/**
dvander@954
   146
 * Finalizes an SDK call preparation and returns the resultant Handle.
dvander@954
   147
 *
dvander@954
   148
 * @return				A new SDKCall Handle on success, or INVALID_HANDLE on failure.
dvander@954
   149
 */
dvander@954
   150
native Handle:EndPrepSDKCall();
dvander@954
   151
dvander@954
   152
/**
dvander@954
   153
 * Calls an SDK function with the given parameters.
dvander@954
   154
 *
dvander@954
   155
 * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
ds@1065
   156
 * If the call type is GameRules, then nothing special needs to be passed.
dvander@954
   157
 * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
dvander@954
   158
 * If the return value is a string, the THIRD parameter must be a String buffer, and the
dvander@954
   159
 *  FOURTH parameter must be the maximum length.
dvander@954
   160
 * All parameters must be passed after the above is followed.  Failure to follow these 
dvander@954
   161
 *  rules will result in crashes or wildly unexpected behavior!
dvander@954
   162
 *
dvander@954
   163
 * If the return value is a float or integer, the return value will be this value.
dvander@954
   164
 * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
dvander@954
   165
 *   always be the entity index, or -1 for NULL.
dvander@954
   166
 *
dvander@954
   167
 * @param call			SDKCall Handle.
dvander@954
   168
 * @param ...			Call Parameters.
dvander@954
   169
 * @return				Simple return value, if any.
dvander@954
   170
 * @error				Invalid Handle or internal decoding error.
dvander@954
   171
 */
dvander@954
   172
native any:SDKCall(Handle:call, any:...);
dvander@954
   173
dvander@954
   174
dvander@954
   175
/**
dvander@954
   176
 * Do not edit below this line!
dvander@954
   177
 */
dvander@954
   178
public Extension:__ext_sdktools = 
dvander@954
   179
{
dvander@954
   180
	name = "SDKTools",
dvander@954
   181
	file = "sdktools.ext",
dvander@954
   182
#if defined AUTOLOAD_EXTENSIONS
dvander@954
   183
	autoload = 1,
dvander@954
   184
#else
dvander@954
   185
	autoload = 0,
dvander@954
   186
#endif
dvander@954
   187
#if defined REQUIRE_EXTENSIONS
dvander@954
   188
	required = 1,
dvander@954
   189
#else
dvander@954
   190
	required = 0,
dvander@954
   191
#endif
dvander@954
   192
};