Difference between revisions of "MM:S API Differences"

From AlliedModders Wiki
Jump to: navigation, search
m
m
Line 72: Line 72:
 
SourceHook has many new changes, the greatest of which is "global hooks," which can hook a function on any number of instances of that derived class.  See [[SourceHook Development]] for more information.
 
SourceHook has many new changes, the greatest of which is "global hooks," which can hook a function on any number of instances of that derived class.  See [[SourceHook Development]] for more information.
  
Metamod:Source 1.6.0 provides an alternative method of implementing a plugin's loading and instantiation process.  This method allows authors to implement very simple loader interfaces which can pass different plugin implementations based on the current Metamod:Source version.
+
Metamod:Source 1.6.0 provides an alternative method of implementing a plugin's loading and instantiation process.  This method allows authors to implement very simple loader interfaces which can pass different plugin implementations based on the current Metamod:Source version.  For example, the loader can detect engine version A versus engine version B, and load an alternate library.
  
 
This interface is exposed in <tt>ISmmPluginExt.h</tt>, and to avoid linkage to any unnecessary externals, does not include any other Metamod:Source headers.  It is assumed that developers will know how to interpret the header file's specifications.
 
This interface is exposed in <tt>ISmmPluginExt.h</tt>, and to avoid linkage to any unnecessary externals, does not include any other Metamod:Source headers.  It is assumed that developers will know how to interpret the header file's specifications.

Revision as of 23:47, 9 October 2007

Metamod:Source 1.6.0 makes several API changes which may affect plugins. These changes are fully documented below.

Renamed Calls

Transparent

The following functions have received simple renamings, which should be transparent from the META_REGCMD and META_REGCVAR macros.

  • RegisterConCmdBase() -> RegisterConCommandBase()
  • UnregisterConCmdBase() -> UnregisterConCommandBase()

Breaking

oslink.h was renamed to metamod_oslink.h. This file is not a public file, however, it has some useful macros and a few plugins used it.

The following functions have received simple renamings, however, old code will be affected.

  • pGlobals() -> GetCClobals
  • engineFactory() -> GetEngineFactory()
  • serverFactory() -> GetServerFactory()
  • physicsFactory() -> GetPhysicsFactory()
  • fileSystemFactory() -> GetFileSystemFactory()

For example, GET_V_IFACE_CURRENT would change from this:

GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);

To this:

GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);


Removed Calls

A few API calls have been completely removed.

  • RemotePrintingAvailable() - Unused, no purpose.
  • GetCvarBaseAccessor() - Unused, no purpose.
  • SetLastMetaReturn() - Did nothing.
  • GetLastMetaReturn() - Did nothing.

SH_GET_CALLCLASS and SH_RELEASE_CALLCLASS have been removed. For more information, see the updated SH_CALL syntax.

Changed Calls

  • IPluginManager::Query() and IPluginManager::QueryHandle() now store return values using optional pointers instead of references. This change was requested by a few people.

SH_CALL and SH_MCALL are changed - the concept of "CallClasses" has been removed, and these macros are now much simpler. See the updated SH_CALL syntax.


Miscellaneous

PLAPI_VERSION has been renamed to METAMOD_PLAPI_VERSION. The version numbers for 1.1 to 1.4 can be described as:

  • API Major: 1
  • API Minor: 0, 1, 2, 3, 4, 5, or 6
  • Plugin API: 7, 8, 9, 10, 11, or 12
  • Plugin API Minimum: 7
  • SourceHook Interface: 4
  • SourceHook Implementation: 3 or 4
  • SourceHook Version: 4.3 or 4.4

Version 1.6.0 has the following version numbers:

  • API Major: 2
  • API Minor: 0
  • Plugin API: 14
  • Plugin API Minimum: 14
  • SourceHook Interface: 5
  • SourceHook Implementation: 5
  • SourceHook Version: 5.0

Major versions change only when the API is compatibly broken. Minor versions are incremented on non-breaking API changes. SourceHook's interface version is a major version, and its implementation version is a minor version. However, SourceHook's minor version is not reset to 0 on major increments.

Additionally, all Metamod:Source public headers are now in a namespace called SourceMM. This namespace is integrated by default. To disable this auto-integration, define METAMOD_NO_AUTO_NAMESPACE at compile time.


Additions

  • IMetamodListener now has a new OnUnlinkConCommandBase callback.
  • ISmmAPI::Format and ISmmAPI::FormatArgs are new platform-safe replacements for snprintf and vsnprintf.
  • ISmmAPI::GetSourceEngineBuild() returns a constant describing the Source engine version.
  • ISmmAPI::GetVSPInfo() returns information about Valve Server Plugin interface, if enabled through Metamod:Source.

SourceHook has many new changes, the greatest of which is "global hooks," which can hook a function on any number of instances of that derived class. See SourceHook Development for more information.

Metamod:Source 1.6.0 provides an alternative method of implementing a plugin's loading and instantiation process. This method allows authors to implement very simple loader interfaces which can pass different plugin implementations based on the current Metamod:Source version. For example, the loader can detect engine version A versus engine version B, and load an alternate library.

This interface is exposed in ISmmPluginExt.h, and to avoid linkage to any unnecessary externals, does not include any other Metamod:Source headers. It is assumed that developers will know how to interpret the header file's specifications.

Since earlier versions do not expose any such callback, it can be assumed that if the callback is called before CreateInterface is called, then the plugin is being loaded by a version of Metamod:Source less than 1.6.0.


Sample Port

An example of a plugin that has been fully ported to both Metamod:Source 1.6.0 is Stripper:Source (SVN here).

Note that this plugin uses the new "extended loading" API available in Metamod:Source 1.6.0. The thin-loader library runs on any Metamod:Source version, and will correctly pick one of 6 child plugins to load. This allows Stripper:Source to be distributed as one package with no configuration hassle.