sourcemm/CSmmAPI.h
author Scott Ehlert <ds@alliedmods.net>
Fri Apr 21 06:35:47 2006 +0000 (2006-04-21)
changeset 192 47649a1d49e3
parent 175 b497b7777f6b
child 231 1edd10b26450
permissions -rw-r--r--
Added client version of "meta" command in order to allow clients to view version information and a list of loaded plugins.
Added ClientConPrintf to API for printing text in a client's console. Same as IVEngineServer::ClientPrintf except that it allows string formatting.
Updated changelog for possible future version.
Version bumpage.

Feel free to kill me for doing a change of this almost massive scale :-\
At least none of this breaks plugins though.
     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_CSMM_API_H
    12 #define _INCLUDE_CSMM_API_H
    13 
    14 /**
    15  * @brief Header for CSmmAPI implementation
    16  * @file CSmmAPI.h
    17  */
    18 
    19 #include "ISmmAPI.h"
    20 
    21 typedef void (*CONPRINTF_FUNC)(const char *, ...);
    22 
    23 namespace SourceMM
    24 {
    25 	class CSmmAPI : public ISmmAPI
    26 	{
    27 	public:
    28 		CSmmAPI::CSmmAPI();
    29 	public:
    30 		void LogMsg(ISmmPlugin *pl, const char *msg, ...);
    31 	public:
    32 		CreateInterfaceFn engineFactory(bool syn=true);
    33 		CreateInterfaceFn physicsFactory(bool syn=true);
    34 		CreateInterfaceFn fileSystemFactory(bool syn=true);
    35 		CreateInterfaceFn serverFactory(bool syn=true);
    36 		CGlobalVars *pGlobals();
    37 		void SetLastMetaReturn(META_RES res);
    38 		META_RES GetLastMetaReturn();
    39 		IConCommandBaseAccessor *GetCvarBaseAccessor();
    40 		bool RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    41 		void UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    42 		void ConPrint(const char *fmt);
    43 		void ConPrintf(const char *fmt, ...);
    44 		bool CacheSuccessful();
    45 		bool RemotePrintingAvailable()
    46 		{
    47 			return CacheSuccessful();
    48 		}
    49 		virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin);
    50 		virtual void GetShVersions(int &shvers, int &shimpl);
    51 		virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
    52 		virtual void *MetaFactory(const char *iface, int *ret, PluginId *id);
    53 		virtual int FormatIface(char buffer[], unsigned int maxlength);
    54 		virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
    55 		virtual const char *GetBaseDir();
    56 		virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
    57 		void ClientConPrintf(edict_t *client, const char *fmt, ...);
    58 	public:
    59 		bool CacheCmds();
    60 	private:
    61 		META_RES m_Res;
    62 		CONPRINTF_FUNC m_ConPrintf;
    63 		bool m_Cache;
    64 	};
    65 };
    66 
    67 extern SourceMM::CSmmAPI g_SmmAPI;
    68 
    69 #define	CONMSG			g_SmmAPI.ConPrintf
    70 #define CLIENT_CONMSG	g_SmmAPI.ClientConPrintf
    71 
    72 #endif //_INCLUDE_CSMM_API_H