sourcemm/sourcemm.h
branchsourcemm-1.6.0
changeset 347 e82968c21606
child 348 716af2e7be78
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sourcemm/sourcemm.h	Tue Sep 18 20:03:47 2007 +0000
     1.3 @@ -0,0 +1,122 @@
     1.4 +/* ======== SourceMM ========
     1.5 + * Copyright (C) 2004-2007 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_SOURCEMM_H
    1.15 +#define _INCLUDE_SOURCEMM_H
    1.16 +
    1.17 +/**
    1.18 + * @brief SourceMM main functionality for GameDLL interception
    1.19 + * @file sourcemm.h
    1.20 + */
    1.21 +
    1.22 +#include <string>
    1.23 +#include <interface.h>
    1.24 +#include <eiface.h>
    1.25 +#include <sourcehook/sourcehook_impl.h>
    1.26 +#include <sourcehook/sourcehook.h>
    1.27 +#include "ISmmAPI.h"
    1.28 +#include "CPlugin.h"
    1.29 +#include "oslink.h"
    1.30 +#include "util.h"
    1.31 +#include "svn_version.h"
    1.32 +
    1.33 +/**
    1.34 + * Versioning
    1.35 + *   increase api_major when API breaks
    1.36 + *   increase api_minor when new functions are added (non-breaking)
    1.37 + */
    1.38 +#define		SOURCEMM_VERSION	SVN_FILE_VERSION_STRING
    1.39 +#define		SOURCEMM_DATE		__DATE__
    1.40 +#define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    1.41 +#define		SM_VERS_API_MINOR	5		//increase this on a non-breaking API change
    1.42 +
    1.43 +//We need a good CServerGameDLL version to work properly.  We support these inclusively.
    1.44 +#define	MIN_GAMEDLL_VERSION	3
    1.45 +#define	MAX_GAMEDLL_VERSION	8
    1.46 +
    1.47 +/**
    1.48 + * @brief Entry point for HL2 Engine
    1.49 + */
    1.50 +SMM_API void *CreateInterface(const char *name, int *code);
    1.51 +
    1.52 +/** @brief Wrapper to catch GameDLL calls */
    1.53 +void *EngineFactory(const char *name, int *code);
    1.54 +
    1.55 +/** @brief Wrapper to catch GameDLL calls */
    1.56 +void *PhysicsFactory(const char *name, int *code);
    1.57 +
    1.58 +/** @brief Wrapper to catch GameDLL calls */
    1.59 +void *FileSystemFactory(const char *name, int *code);
    1.60 +
    1.61 +/** @brief Loads all plugins found in a file */
    1.62 +int LoadPluginsFromFile(const char *file);
    1.63 +
    1.64 +/** @brief Logs a message to the standard log file */
    1.65 +void LogMessage(const char *msg, ...);
    1.66 +
    1.67 +/** @brief Stores information about the GameDLL */
    1.68 +struct GameDllInfo
    1.69 +{
    1.70 +	bool loaded;
    1.71 +	HINSTANCE lib;
    1.72 +	CreateInterfaceFn factory;
    1.73 +	IServerGameDLL *pGameDLL;
    1.74 +	IServerGameClients *pGameClients;
    1.75 +};
    1.76 +
    1.77 +/** @brief Stores information about the HL2 Engine pointers */
    1.78 +struct EngineInfo
    1.79 +{
    1.80 +	EngineInfo() : loaded(false), 
    1.81 +		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    1.82 +		pGlobals(NULL), icvar(NULL), engine(NULL)
    1.83 +	{ };
    1.84 +	bool loaded;
    1.85 +	CreateInterfaceFn engineFactory;
    1.86 +	CreateInterfaceFn physicsFactory;
    1.87 +	CreateInterfaceFn fileSystemFactory;
    1.88 +	CGlobalVars *pGlobals;
    1.89 +	ICvar *icvar;
    1.90 +	IVEngineServer *engine;
    1.91 +};
    1.92 +
    1.93 +/** @brief Global variable for GameDLL info */
    1.94 +extern GameDllInfo g_GameDll;
    1.95 +
    1.96 +/** @brief Global variable for Engine info */
    1.97 +extern EngineInfo g_Engine;
    1.98 +
    1.99 +/** @brief Global singleton for SourceHook */
   1.100 +extern SourceHook::CSourceHookImpl g_SourceHook;
   1.101 +
   1.102 +/** @brief Mod path (important!)*/
   1.103 +extern SourceHook::String g_ModPath;
   1.104 +
   1.105 +/** @brief Path to server binary */
   1.106 +extern SourceHook::String g_BinPath;
   1.107 +
   1.108 +/** @brief Path to SourceMM binary */
   1.109 +extern SourceHook::String g_SmmPath;
   1.110 +
   1.111 +/** @brief Global variable for SourceHook macros */
   1.112 +extern SourceHook::ISourceHook *g_SHPtr;
   1.113 +
   1.114 +/** @brief We have our own internal plugin id... */
   1.115 +extern PluginId g_PLID;
   1.116 +
   1.117 +/** @brief ServerGameDLL version that is currently loaded */
   1.118 +extern int g_GameDllVersion;
   1.119 +
   1.120 +extern bool bGameInit;
   1.121 +
   1.122 +/** @brief Global CallClass for IServerGameDLL */
   1.123 +extern SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
   1.124 +
   1.125 +#endif //_INCLUDE_SOURCEMM_H