plugins/include/core.inc
author Nicholas Hastings <skamonkey@gmail.com>
Fri Nov 04 10:01:33 2011 -0400 (2011-11-04)
changeset 3438 07a1b8a8a2ba
parent 2841 dde3dd0b4b8b
child 3743 a98686a77974
permissions -rw-r--r--
Updated TF2_OnIsHolidayActive ret behavior to match doc (bug 5155, r=fyren).
dvander@374
     1
/**
ds@475
     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@374
     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@374
    29
 *
dvander@374
    30
 * Version: $Id$
dvander@374
    31
 */
dvander@374
    32
dvander@298
    33
#if defined _core_included
dvander@298
    34
 #endinput
dvander@298
    35
#endif
dvander@298
    36
#define _core_included
dvander@298
    37
dvander@572
    38
#include <version>
dvander@572
    39
dvander@2342
    40
/** If this gets changed, you need to update Core's check. */
dvander@2636
    41
#define SOURCEMOD_PLUGINAPI_VERSION		5
dvander@2342
    42
dvander@298
    43
struct PlVers
dvander@298
    44
{
dvander@298
    45
	version,
dvander@572
    46
	String:filevers[],
dvander@2105
    47
	String:date[],
dvander@2105
    48
	String:time[]
dvander@298
    49
};
dvander@298
    50
dvander@483
    51
/**
ds@696
    52
 * Function helper values.
ds@621
    53
 */
ds@621
    54
enum Function
ds@621
    55
{
ds@621
    56
     INVALID_FUNCTION = -1,
ds@621
    57
};
ds@621
    58
ds@621
    59
/**
dvander@483
    60
 * Specifies what to do after a hook completes.
dvander@483
    61
 */
dvander@497
    62
enum Action
dvander@483
    63
{
dvander@483
    64
	Plugin_Continue = 0,	/**< Continue with the original action */
faluco@1735
    65
	Plugin_Changed = 1,		/**< Inputs or outputs have been overridden with new values */
dvander@483
    66
	Plugin_Handled = 3,		/**< Handle the action at the end (don't call it) */
dvander@483
    67
	Plugin_Stop = 4,		/**< Immediately stop the hook chain and handle the original */
dvander@815
    68
};
dvander@483
    69
dvander@1378
    70
/**
dvander@1378
    71
 * Specifies identity types.
dvander@1378
    72
 */
dvander@1378
    73
enum Identity
dvander@1378
    74
{
dvander@1378
    75
	Identity_Core = 0,
dvander@1378
    76
	Identity_Extension = 1,
dvander@1378
    77
	Identity_Plugin = 2
dvander@1378
    78
};
dvander@1378
    79
dvander@298
    80
public PlVers:__version = 
dvander@298
    81
{
dvander@298
    82
	version = SOURCEMOD_PLUGINAPI_VERSION,
dvander@2105
    83
	filevers = SOURCEMOD_VERSION,
dvander@2105
    84
	date = __DATE__,
dvander@2105
    85
	time = __TIME__
dvander@298
    86
};
dvander@298
    87
dvander@618
    88
/**
dvander@618
    89
 * Plugin status values.
dvander@618
    90
 */
dvander@618
    91
enum PluginStatus
dvander@618
    92
{
dvander@618
    93
	Plugin_Running=0,		/**< Plugin is running */
dvander@618
    94
	/* All states below are "temporarily" unexecutable */
dvander@618
    95
	Plugin_Paused,			/**< Plugin is loaded but paused */
dvander@618
    96
	Plugin_Error,			/**< Plugin is loaded but errored/locked */
dvander@618
    97
	/* All states below do not have all natives */
dvander@618
    98
	Plugin_Loaded,			/**< Plugin has passed loading and can be finalized */
dvander@618
    99
	Plugin_Failed,			/**< Plugin has a fatal failure */
dvander@618
   100
	Plugin_Created,			/**< Plugin is created but not initialized */
dvander@618
   101
	Plugin_Uncompiled,		/**< Plugin is not yet compiled by the JIT */
dvander@618
   102
	Plugin_BadLoad,			/**< Plugin failed to load */
dvander@618
   103
};
dvander@618
   104
dvander@618
   105
/**
dvander@618
   106
 * Plugin information properties.
dvander@618
   107
 */
dvander@618
   108
enum PluginInfo
dvander@618
   109
{
dvander@618
   110
	PlInfo_Name,			/**< Plugin name */
dvander@618
   111
	PlInfo_Author,			/**< Plugin author */
dvander@618
   112
	PlInfo_Description,		/**< Plugin description */
dvander@618
   113
	PlInfo_Version,			/**< Plugin verison */
dvander@618
   114
	PlInfo_URL,				/**< Plugin URL */
dvander@618
   115
};
dvander@618
   116
dvander@619
   117
/**
dvander@619
   118
 * Defines how an extension must expose itself for autoloading.
dvander@619
   119
 */
dvander@298
   120
struct Extension
dvander@298
   121
{
dvander@938
   122
	const String:name[],	/**< Short name */
dvander@938
   123
	const String:file[],	/**< Default file name */
dvander@938
   124
	bool:autoload,			/**< Whether or not to auto-load */
dvander@938
   125
	bool:required,			/**< Whether or not to require */
dvander@298
   126
};
dvander@298
   127
dvander@1092
   128
/**
dvander@1092
   129
 * Defines how a plugin must expose itself for native requiring.
dvander@1092
   130
 */
dvander@1092
   131
struct SharedPlugin
dvander@1092
   132
{
dvander@1092
   133
	const String:name[],	/**< Short name */
dvander@1093
   134
	const String:file[],	/**< File name */
dvander@1092
   135
	bool:required,			/**< Whether or not to require */
dvander@1092
   136
};
dvander@1092
   137
dvander@1000
   138
public Float:NULL_VECTOR[3];		/**< Pass this into certain functions to act as a C++ NULL */
dvander@1000
   139
public const String:NULL_STRING[1];	/**< pass this into certain functions to act as a C++ NULL */
dvander@938
   140
dvander@2342
   141
/**
dvander@2342
   142
 * Horrible compatibility shim.
dvander@2342
   143
 */
dvander@2342
   144
public Extension:__ext_core = 
dvander@2342
   145
{
dvander@2342
   146
	name = "Core",
dvander@2342
   147
	file = "core",
dvander@2342
   148
	autoload = 0,
dvander@2342
   149
	required = 0,
dvander@2342
   150
};
dvander@2342
   151
dvander@2342
   152
native VerifyCoreVersion();
dvander@2342
   153
dvander@2841
   154
/**
dvander@2841
   155
 * Sets a native as optional, such that if it is unloaded, removed,
dvander@2841
   156
 * or otherwise non-existent, the plugin will still work.  Calling
dvander@2841
   157
 * removed natives results in a run-time error.
dvander@2841
   158
 *
dvander@2841
   159
 * @param name			Native name.
dvander@2841
   160
 * @noreturn
dvander@2841
   161
 */
dvander@2841
   162
native MarkNativeAsOptional(const String:name[]);
dvander@2841
   163
dvander@2342
   164
public __ext_core_SetNTVOptional()
dvander@2342
   165
{
dvander@2841
   166
	MarkNativeAsOptional("GetFeatureStatus");
dvander@2841
   167
	MarkNativeAsOptional("RequireFeature");
dvander@2841
   168
	MarkNativeAsOptional("AddCommandListener");
dvander@2841
   169
	MarkNativeAsOptional("RemoveCommandListener");
dvander@2342
   170
	VerifyCoreVersion();
dvander@2342
   171
}
dvander@2342
   172
dvander@2342
   173
dvander@298
   174
#define AUTOLOAD_EXTENSIONS
dvander@298
   175
#define REQUIRE_EXTENSIONS
dvander@1092
   176
#define REQUIRE_PLUGIN