sourcemm/ISmmAPI.h
author Scott Ehlert <ds@alliedmods.net>
Thu Jul 20 11:31:41 2006 +0000 (2006-07-20)
changeset 223 f44cad5df4e8
parent 192 47649a1d49e3
child 244 9be90b121b87
permissions -rw-r--r--
I shouldn't have touched this again in the first place
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2006 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #ifndef _INCLUDE_ISMM_API_H
    12 #define _INCLUDE_ISMM_API_H
    13 
    14 /**
    15  * @brief External API interface
    16  * @file ISmmAPI.h
    17  */
    18 
    19 #include <interface.h>
    20 #include <eiface.h>
    21 #include <convar.h>
    22 #include <sourcehook/sourcehook.h>
    23 #include "IPluginManager.h"
    24 
    25 #if defined __GNUC__
    26 #if ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) || (__GNUC__ < 3)
    27 #error "You must compile with at least GCC 3.4! If you know what you are doing, you can remove this message."
    28 #endif //version check
    29 #endif //__GNUC__
    30 
    31 class IMetamodListener;
    32 class ISmmPluginManager;
    33 class ISmmPlugin;
    34 
    35 #define	MMIFACE_SOURCEHOOK		"ISourceHook"
    36 #define	MMIFACE_PLMANAGER		"IPluginManager"	
    37 
    38 class ISmmAPI
    39 {
    40 public:
    41 	virtual void LogMsg(ISmmPlugin *pl, const char *msg, ...) =0;
    42 public:
    43 	virtual CreateInterfaceFn engineFactory(bool syn=true) =0;
    44 	virtual CreateInterfaceFn physicsFactory(bool syn=true) =0;
    45 	virtual CreateInterfaceFn fileSystemFactory(bool syn=true) =0;
    46 	virtual CreateInterfaceFn serverFactory(bool syn=true) =0;
    47 	virtual CGlobalVars *pGlobals() =0;
    48 	virtual void SetLastMetaReturn(META_RES res) =0;
    49 	virtual META_RES GetLastMetaReturn() =0;
    50 public:		//Added in 1.00-RC2 (0:0)
    51 	//solves concommand problems by keeping track for loading/unloading
    52 	virtual IConCommandBaseAccessor *GetCvarBaseAccessor() =0;
    53 	virtual bool RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
    54 	virtual void UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
    55 	//attempt fix at valve not exporting rcon printing
    56 	//these do not add newlines
    57 	virtual void ConPrint(const char *fmt) =0;
    58 	virtual void ConPrintf(const char *fmt, ...) =0;
    59 public:		//Added in 1.1.0 (1:0)
    60 	//added by request.  Checks if ConPrint/ConPrintf will mirror to rcon.
    61 	virtual bool RemotePrintingAvailable() =0;
    62 	//Returns the Metamod Version numbers as major version and minor (API) version.
    63 	//changes to minor version are guaranteed to be backwards compatible.
    64 	//changes to major version are not.
    65 	//Also returns current plugin version and minimum plugin version
    66 	virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0;
    67 	//Returns sourcehook API version and implementation version
    68 	virtual void GetShVersions(int &shvers, int &shimpl) =0;
    69 	//Binds an event listener to your plugin
    70 	virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener) =0;
    71 	/**
    72 	  * @brief Queries the metamod factory
    73 	  *
    74 	  * @param iface	String containing interface name
    75 	  * @param ret		Optional pointer to store return status
    76 	  * @param id		Optional pointer to store id of plugin that overrode interface, 0 if none
    77 	  * @return			Returned pointer
    78 	  */
    79 	virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0;
    80 public:		//Added in 1.1.2 (1:1)
    81 	/**
    82 	 * @brief Given a base interface name, such as ServerGameDLL or ServerGameDLL003, 
    83 	 * reformats the string to increase the number, then returns the new number.
    84 	 */
    85 	virtual int FormatIface(char iface[], unsigned int maxlength) =0;
    86 public:		//Added in 1.2 (1:2)
    87 	/**
    88 	 * @brief Searches for an interface for you.
    89 	 */
    90 	virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) =0;
    91 
    92 	/**
    93 	 * @brief Returns the base directory of the game/server, equivalent to IVEngineServer::GetGameDir
    94 	 */
    95 	virtual const char *GetBaseDir() =0;
    96 
    97 	/**
    98 	 * @brief Formats a file path to the local OS.  Does not include any base directories.
    99 	 */
   100 	virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
   101 public:		// Added in 1.2.2 (1:3)
   102 	/**
   103 	 * @brief Prints text in the specified client's console. Same as IVEngineServer::ClientPrintf 
   104 	 *  except that it allows for string formatting.
   105 	 */
   106 	virtual void ClientConPrintf(edict_t *client, const char *fmt, ...) =0;
   107 };
   108 
   109 
   110 /** Version history
   111  * 1.1.0 bumped API to 1:0.  The breaking changes occured in sourcehook and the plugin API.
   112  * 1.1.2 added API call for generating iface names.
   113  * 1.2   added API more helper functions and new SourceHook version.
   114  * 1.2.2 added API for printing to client console (with string formatting)
   115  */
   116 
   117 #endif //_INCLUDE_ISMM_API_H