dvander@374: /**
ds@475: * vim: set ts=4 :
ds@1330: * =============================================================================
ds@1947: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
ds@1330: *
ds@1330: * This file is part of the SourceMod/SourcePawn SDK.
dvander@374: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
ds@1330: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
ds@1330: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
ds@1330: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@374: *
dvander@374: * Version: $Id$
dvander@374: */
dvander@374:
dvander@298: #if defined _core_included
dvander@298: #endinput
dvander@298: #endif
dvander@298: #define _core_included
dvander@298:
dvander@572: #include
dvander@572:
dvander@2342: /** If this gets changed, you need to update Core's check. */
dvander@2636: #define SOURCEMOD_PLUGINAPI_VERSION 5
dvander@2342:
dvander@298: struct PlVers
dvander@298: {
dvander@298: version,
dvander@572: String:filevers[],
dvander@2105: String:date[],
dvander@2105: String:time[]
dvander@298: };
dvander@298:
dvander@483: /**
ds@696: * Function helper values.
ds@621: */
ds@621: enum Function
ds@621: {
ds@621: INVALID_FUNCTION = -1,
ds@621: };
ds@621:
ds@621: /**
dvander@483: * Specifies what to do after a hook completes.
dvander@483: */
dvander@497: enum Action
dvander@483: {
dvander@483: Plugin_Continue = 0, /**< Continue with the original action */
faluco@1735: Plugin_Changed = 1, /**< Inputs or outputs have been overridden with new values */
dvander@483: Plugin_Handled = 3, /**< Handle the action at the end (don't call it) */
dvander@483: Plugin_Stop = 4, /**< Immediately stop the hook chain and handle the original */
dvander@815: };
dvander@483:
dvander@1378: /**
dvander@1378: * Specifies identity types.
dvander@1378: */
dvander@1378: enum Identity
dvander@1378: {
dvander@1378: Identity_Core = 0,
dvander@1378: Identity_Extension = 1,
dvander@1378: Identity_Plugin = 2
dvander@1378: };
dvander@1378:
dvander@298: public PlVers:__version =
dvander@298: {
dvander@298: version = SOURCEMOD_PLUGINAPI_VERSION,
dvander@2105: filevers = SOURCEMOD_VERSION,
dvander@2105: date = __DATE__,
dvander@2105: time = __TIME__
dvander@298: };
dvander@298:
dvander@618: /**
dvander@618: * Plugin status values.
dvander@618: */
dvander@618: enum PluginStatus
dvander@618: {
dvander@618: Plugin_Running=0, /**< Plugin is running */
dvander@618: /* All states below are "temporarily" unexecutable */
dvander@618: Plugin_Paused, /**< Plugin is loaded but paused */
dvander@618: Plugin_Error, /**< Plugin is loaded but errored/locked */
dvander@618: /* All states below do not have all natives */
dvander@618: Plugin_Loaded, /**< Plugin has passed loading and can be finalized */
dvander@618: Plugin_Failed, /**< Plugin has a fatal failure */
dvander@618: Plugin_Created, /**< Plugin is created but not initialized */
dvander@618: Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */
dvander@618: Plugin_BadLoad, /**< Plugin failed to load */
dvander@618: };
dvander@618:
dvander@618: /**
dvander@618: * Plugin information properties.
dvander@618: */
dvander@618: enum PluginInfo
dvander@618: {
dvander@618: PlInfo_Name, /**< Plugin name */
dvander@618: PlInfo_Author, /**< Plugin author */
dvander@618: PlInfo_Description, /**< Plugin description */
dvander@618: PlInfo_Version, /**< Plugin verison */
dvander@618: PlInfo_URL, /**< Plugin URL */
dvander@618: };
dvander@618:
dvander@619: /**
dvander@619: * Defines how an extension must expose itself for autoloading.
dvander@619: */
dvander@298: struct Extension
dvander@298: {
dvander@938: const String:name[], /**< Short name */
dvander@938: const String:file[], /**< Default file name */
dvander@938: bool:autoload, /**< Whether or not to auto-load */
dvander@938: bool:required, /**< Whether or not to require */
dvander@298: };
dvander@298:
dvander@1092: /**
dvander@1092: * Defines how a plugin must expose itself for native requiring.
dvander@1092: */
dvander@1092: struct SharedPlugin
dvander@1092: {
dvander@1092: const String:name[], /**< Short name */
dvander@1093: const String:file[], /**< File name */
dvander@1092: bool:required, /**< Whether or not to require */
dvander@1092: };
dvander@1092:
dvander@1000: public Float:NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
dvander@1000: public const String:NULL_STRING[1]; /**< pass this into certain functions to act as a C++ NULL */
dvander@938:
dvander@2342: /**
dvander@2342: * Horrible compatibility shim.
dvander@2342: */
dvander@2342: public Extension:__ext_core =
dvander@2342: {
dvander@2342: name = "Core",
dvander@2342: file = "core",
dvander@2342: autoload = 0,
dvander@2342: required = 0,
dvander@2342: };
dvander@2342:
dvander@2342: native VerifyCoreVersion();
dvander@2342:
dvander@2841: /**
dvander@2841: * Sets a native as optional, such that if it is unloaded, removed,
dvander@2841: * or otherwise non-existent, the plugin will still work. Calling
dvander@2841: * removed natives results in a run-time error.
dvander@2841: *
dvander@2841: * @param name Native name.
dvander@2841: * @noreturn
dvander@2841: */
dvander@2841: native MarkNativeAsOptional(const String:name[]);
dvander@2841:
dvander@2342: public __ext_core_SetNTVOptional()
dvander@2342: {
dvander@2841: MarkNativeAsOptional("GetFeatureStatus");
dvander@2841: MarkNativeAsOptional("RequireFeature");
dvander@2841: MarkNativeAsOptional("AddCommandListener");
dvander@2841: MarkNativeAsOptional("RemoveCommandListener");
dvander@2342: VerifyCoreVersion();
dvander@2342: }
dvander@2342:
dvander@2342:
dvander@298: #define AUTOLOAD_EXTENSIONS
dvander@298: #define REQUIRE_EXTENSIONS
dvander@1092: #define REQUIRE_PLUGIN