1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core-1.4/CSmmAPI.h Fri Nov 14 04:25:40 2008 -0600
1.3 @@ -0,0 +1,98 @@
1.4 +/* ======== SourceMM ========
1.5 + * Copyright (C) 2004-2008 Metamod:Source Development Team
1.6 + * No warranties of any kind
1.7 + *
1.8 + * License: zlib/libpng
1.9 + *
1.10 + * Author(s): David "BAILOPAN" Anderson
1.11 + * ============================
1.12 + */
1.13 +
1.14 +#ifndef _INCLUDE_CSMM_API_H
1.15 +#define _INCLUDE_CSMM_API_H
1.16 +
1.17 +/**
1.18 + * @brief Header for CSmmAPI implementation
1.19 + * @file CSmmAPI.h
1.20 + */
1.21 +
1.22 +#include "ISmmAPI.h"
1.23 +#include <tier1/utldict.h>
1.24 +
1.25 +struct UserMessage
1.26 +{
1.27 + int size;
1.28 + const char *name;
1.29 +};
1.30 +
1.31 +typedef CUtlDict<UserMessage *, int> UserMsgDict;
1.32 +
1.33 +typedef void (*CONPRINTF_FUNC)(const char *, ...);
1.34 +
1.35 +namespace SourceMM
1.36 +{
1.37 + class CSmmAPI : public ISmmAPI
1.38 + {
1.39 + public:
1.40 + CSmmAPI();
1.41 + ~CSmmAPI();
1.42 + public:
1.43 + void LogMsg(ISmmPlugin *pl, const char *msg, ...);
1.44 + public:
1.45 + CreateInterfaceFn engineFactory(bool syn=true);
1.46 + CreateInterfaceFn physicsFactory(bool syn=true);
1.47 + CreateInterfaceFn fileSystemFactory(bool syn=true);
1.48 + CreateInterfaceFn serverFactory(bool syn=true);
1.49 + CGlobalVars *pGlobals();
1.50 + void SetLastMetaReturn(META_RES res);
1.51 + META_RES GetLastMetaReturn();
1.52 + IConCommandBaseAccessor *GetCvarBaseAccessor();
1.53 + bool RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
1.54 + void UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
1.55 + void ConPrint(const char *fmt);
1.56 + void ConPrintf(const char *fmt, ...);
1.57 + bool RemotePrintingAvailable()
1.58 + {
1.59 + return CmdCacheSuccessful();
1.60 + }
1.61 + virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin);
1.62 + virtual void GetShVersions(int &shvers, int &shimpl);
1.63 + virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
1.64 + virtual void *MetaFactory(const char *iface, int *ret, PluginId *id);
1.65 + virtual int FormatIface(char buffer[], unsigned int maxlength);
1.66 + virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
1.67 + virtual const char *GetBaseDir();
1.68 + virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
1.69 + void ClientConPrintf(edict_t *client, const char *fmt, ...);
1.70 + void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
1.71 + void EnableVSPListener();
1.72 + int GetGameDLLVersion();
1.73 + int GetUserMessageCount();
1.74 + int FindUserMessage(const char *name, int *size=NULL);
1.75 + const char *GetUserMessage(int index, int *size=NULL);
1.76 + public:
1.77 + bool CacheCmds();
1.78 + bool CmdCacheSuccessful();
1.79 + void LoadAsVSP();
1.80 + bool VSPEnabled()
1.81 + {
1.82 + return m_VSP;
1.83 + }
1.84 + bool CacheUserMessages();
1.85 + bool MsgCacheSuccessful();
1.86 + private:
1.87 + META_RES m_Res;
1.88 + CONPRINTF_FUNC m_ConPrintf;
1.89 + bool m_CmdCache;
1.90 + bool m_VSP;
1.91 + int m_MsgCount;
1.92 + UserMsgDict m_UserMessages;
1.93 + };
1.94 +};
1.95 +
1.96 +extern SourceMM::CSmmAPI g_SmmAPI;
1.97 +
1.98 +#define CONMSG g_SmmAPI.ConPrintf
1.99 +#define CLIENT_CONMSG g_SmmAPI.ClientConPrintf
1.100 +
1.101 +#endif //_INCLUDE_CSMM_API_H