core/metamod.h
changeset 539 db914129ae01
parent 523 6f1630519b81
child 552 4b73ffd6e176
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/metamod.h	Fri Nov 14 04:04:02 2008 -0600
     1.3 @@ -0,0 +1,120 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ======================================================
     1.7 + * Metamod:Source
     1.8 + * Copyright (C) 2004-2008 AlliedModders LLC and authors.
     1.9 + * All rights reserved.
    1.10 + * ======================================================
    1.11 + *
    1.12 + * This software is provided 'as-is', without any express or implied warranty.
    1.13 + * In no event will the authors be held liable for any damages arising from 
    1.14 + * the use of this software.
    1.15 + * 
    1.16 + * Permission is granted to anyone to use this software for any purpose, 
    1.17 + * including commercial applications, and to alter it and redistribute it 
    1.18 + * freely, subject to the following restrictions:
    1.19 + *
    1.20 + * 1. The origin of this software must not be misrepresented; you must not 
    1.21 + * claim that you wrote the original software. If you use this software in a 
    1.22 + * product, an acknowledgment in the product documentation would be 
    1.23 + * appreciated but is not required.
    1.24 + * 2. Altered source versions must be plainly marked as such, and must not be
    1.25 + * misrepresented as being the original software.
    1.26 + * 3. This notice may not be removed or altered from any source distribution.
    1.27 + *
    1.28 + * Version: $Id$
    1.29 + */
    1.30 +
    1.31 +#ifndef _INCLUDE_SOURCEMM_H
    1.32 +#define _INCLUDE_SOURCEMM_H
    1.33 +
    1.34 +/**
    1.35 + * @brief SourceMM main functionality for GameDLL interception
    1.36 + * @file sourcemm.h
    1.37 + */
    1.38 +
    1.39 +#include <string>
    1.40 +#include <interface.h>
    1.41 +#include <eiface.h>
    1.42 +#include <sourcehook/sourcehook_impl.h>
    1.43 +#include <sourcehook/sourcehook_hookmangen.h>
    1.44 +#include <sourcehook/sourcehook.h>
    1.45 +#include <ISmmPlugin.h>
    1.46 +#include "metamod_provider.h"
    1.47 +#include "svn_version.h"
    1.48 +
    1.49 +using namespace SourceMM;
    1.50 +
    1.51 +/**
    1.52 + * Versioning
    1.53 + *   increase api_major when API breaks
    1.54 + *   increase api_minor when new functions are added (non-breaking)
    1.55 + */
    1.56 +#define SOURCEMM_VERSION	SVN_FILE_VERSION_STRING
    1.57 +#define SOURCEMM_DATE		__DATE__
    1.58 +#define METAMOD_API_MAJOR	2		/* increase this on a breaking change */
    1.59 +#define METAMOD_API_MINOR	0		/* increase this on a non-breaking API change */
    1.60 +
    1.61 +class MetamodSource : public ISmmAPI
    1.62 +{
    1.63 +public:
    1.64 +	void LogMsg(ISmmPlugin *pl, const char *msg, ...);
    1.65 +	CreateInterfaceFn GetEngineFactory(bool syn=true);
    1.66 +	CreateInterfaceFn GetPhysicsFactory(bool syn=true);
    1.67 +	CreateInterfaceFn GetFileSystemFactory(bool syn=true);
    1.68 +	CreateInterfaceFn GetServerFactory(bool syn=true);
    1.69 +	CGlobalVars *GetCGlobals();
    1.70 +	void SetLastMetaReturn(META_RES res);
    1.71 +	META_RES GetLastMetaReturn();
    1.72 +	IConCommandBaseAccessor *GetCvarBaseAccessor();
    1.73 +	bool RegisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    1.74 +	void UnregisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
    1.75 +	void ConPrint(const char *str);
    1.76 +	void ConPrintf(const char *fmt, ...);
    1.77 +	bool RemotePrintingAvailable();
    1.78 +	void GetApiVersions(int &major, int &minor, int &plvers, int &plmin);
    1.79 +	void GetShVersions(int &shvers, int &shimpl);
    1.80 +	void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
    1.81 +	void *MetaFactory(const char *iface, int *ret, PluginId *id);
    1.82 +	int FormatIface(char iface[], unsigned int maxlength);
    1.83 +	void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
    1.84 +	const char *GetBaseDir();
    1.85 +	size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
    1.86 +	void ClientConPrintf(edict_t *client, const char *fmt, ...);
    1.87 +	void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
    1.88 +	void EnableVSPListener();
    1.89 +	int GetGameDLLVersion();
    1.90 +	int GetUserMessageCount();
    1.91 +	int FindUserMessage(const char *name, int *size=NULL);
    1.92 +	const char *GetUserMessage(int index, int *size=NULL);
    1.93 +	int GetVSPVersion();
    1.94 +	int GetSourceEngineBuild();
    1.95 +	IServerPluginCallbacks *GetVSPInfo(int *pVersion);
    1.96 +	size_t Format(char *buffer, size_t maxlength, const char *format, ...);
    1.97 +	size_t FormatArgs(char *buffer, size_t maxlength, const char *format, va_list ap);
    1.98 +public:
    1.99 +	bool IsLoadedAsGameDLL();
   1.100 +	const char *GetGameBinaryPath();
   1.101 +	const char *GetPluginsFile();
   1.102 +	void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
   1.103 +	void NotifyVSPListening(IServerPluginCallbacks *callbacks);
   1.104 +	void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version);
   1.105 +	bool IsAlternateLoadComplete();
   1.106 +};
   1.107 +
   1.108 +bool DetectGameInformation();
   1.109 +void LogMessage(const char *msg, ...);
   1.110 +int LoadPluginsFromFile(const char *_file);
   1.111 +void InitializeForLoad();
   1.112 +void InitializeGlobals(CreateInterfaceFn engineFactory, 
   1.113 +					   CreateInterfaceFn physicsFactory,
   1.114 +					   CreateInterfaceFn filesystemFactory,
   1.115 +					   CGlobalVars *pGlobals);
   1.116 +void StartupMetamod(bool is_vsp_load);
   1.117 +void UnloadMetamod();
   1.118 +
   1.119 +extern MetamodSource g_Metamod;
   1.120 +extern SourceHook::Impl::CSourceHookImpl g_SourceHook;
   1.121 +
   1.122 +#endif //_INCLUDE_SOURCEMM_H
   1.123 +