core-legacy/CSmmAPI.h
author David Anderson <dvander@alliedmods.net>
Wed Feb 25 20:26:19 2009 -0500 (2009-02-25)
changeset 649 a0e24af92af0
parent 545 07e5df11f9fc
child 666 acab40e6dbd7
permissions -rw-r--r--
Bumped all versions.
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2008 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 #include <tier1/utldict.h>
    21 
    22 struct UserMessage
    23 {
    24 	int size;
    25 	const char *name;
    26 };
    27 
    28 typedef CUtlDict<UserMessage *, int> UserMsgDict;
    29 
    30 typedef void (*CONPRINTF_FUNC)(const char *, ...);
    31 
    32 namespace SourceMM
    33 {
    34 	class CSmmAPI : public ISmmAPI
    35 	{
    36 	public:
    37 		CSmmAPI();
    38 		~CSmmAPI();
    39 	public:
    40 		void LogMsg(ISmmPlugin *pl, const char *msg, ...);
    41 	public:
    42 		CreateInterfaceFn engineFactory(bool syn=true);
    43 		CreateInterfaceFn physicsFactory(bool syn=true);
    44 		CreateInterfaceFn fileSystemFactory(bool syn=true);
    45 		CreateInterfaceFn serverFactory(bool syn=true);
    46 		CGlobalVars *pGlobals();
    47 		void SetLastMetaReturn(META_RES res);
    48 		META_RES GetLastMetaReturn();
    49 		IConCommandBaseAccessor *GetCvarBaseAccessor();
    50 		bool RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    51 		void UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    52 		void ConPrint(const char *fmt);
    53 		void ConPrintf(const char *fmt, ...);
    54 		bool RemotePrintingAvailable()
    55 		{
    56 			return CmdCacheSuccessful();
    57 		}
    58 		virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin);
    59 		virtual void GetShVersions(int &shvers, int &shimpl);
    60 		virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
    61 		virtual void *MetaFactory(const char *iface, int *ret, PluginId *id);
    62 		virtual int FormatIface(char buffer[], unsigned int maxlength);
    63 		virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
    64 		virtual const char *GetBaseDir();
    65 		virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
    66 		void ClientConPrintf(edict_t *client, const char *fmt, ...);
    67 		void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
    68 		void EnableVSPListener();
    69 		int GetGameDLLVersion();
    70 		int GetUserMessageCount();
    71 		int FindUserMessage(const char *name, int *size=NULL);
    72 		const char *GetUserMessage(int index, int *size=NULL);
    73 	public:
    74 		bool CacheCmds();
    75 		bool CmdCacheSuccessful();
    76 		void LoadAsVSP();
    77 		bool VSPEnabled()
    78 		{
    79 			return m_VSP;
    80 		}
    81 		bool CacheUserMessages();
    82 		bool MsgCacheSuccessful();
    83 	private:
    84 		META_RES m_Res;
    85 		CONPRINTF_FUNC m_ConPrintf;
    86 		bool m_CmdCache;
    87 		bool m_VSP;
    88 		int m_MsgCount;
    89 		UserMsgDict m_UserMessages;
    90 	};
    91 };
    92 
    93 extern SourceMM::CSmmAPI g_SmmAPI;
    94 
    95 #define	CONMSG			g_SmmAPI.ConPrintf
    96 #define CLIENT_CONMSG	g_SmmAPI.ClientConPrintf
    97 
    98 #endif //_INCLUDE_CSMM_API_H