sourcemm/sourcemm.h
author Scott Ehlert <ds@alliedmods.net>
Tue Apr 24 22:07:00 2007 +0000 (2007-04-24)
changeset 318 d601b515c839
parent 314 7666e83ef566
child 335 5b6e54c9ed5f
permissions -rw-r--r--
Added ISmmAPI::GetVSPVersion() to get highest supported IServerPluginCallbacks interface version
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2007 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_SOURCEMM_H
    12 #define _INCLUDE_SOURCEMM_H
    13 
    14 /**
    15  * @brief SourceMM main functionality for GameDLL interception
    16  * @file sourcemm.h
    17  */
    18 
    19 #include <string>
    20 #include <interface.h>
    21 #include <eiface.h>
    22 #include <sourcehook/sourcehook_impl.h>
    23 #include <sourcehook/sourcehook.h>
    24 #include "ISmmAPI.h"
    25 #include "CPlugin.h"
    26 #include "oslink.h"
    27 #include "util.h"
    28 #include "svn_version.h"
    29 
    30 /**
    31  * Versioning
    32  *   increase api_major when API breaks
    33  *   increase api_minor when new functions are added (non-breaking)
    34  */
    35 #define		SOURCEMM_VERSION	SVN_FILE_VERSION_STRING
    36 #define		SOURCEMM_DATE		__DATE__
    37 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    38 #define		SM_VERS_API_MINOR	6		//increase this on a non-breaking API change
    39 
    40 /* We need a good CServerGameDLL version to work properly.  We support these inclusively. */
    41 #define	MIN_GAMEDLL_VERSION	3
    42 #define	MAX_GAMEDLL_VERSION	8
    43 
    44 /* Maximum version of IServerPluginCallbacks that SourceMM supports */
    45 #define MAX_VSP_VERSION 2
    46 
    47 /**
    48  * @brief Entry point for HL2 Engine
    49  */
    50 SMM_API void *CreateInterface(const char *name, int *code);
    51 
    52 /** @brief Wrapper to catch GameDLL calls */
    53 void *EngineFactory(const char *name, int *code);
    54 
    55 /** @brief Wrapper to catch GameDLL calls */
    56 void *PhysicsFactory(const char *name, int *code);
    57 
    58 /** @brief Wrapper to catch GameDLL calls */
    59 void *FileSystemFactory(const char *name, int *code);
    60 
    61 /** @brief Loads all plugins found in a file */
    62 int LoadPluginsFromFile(const char *file);
    63 
    64 /** @brief Logs a message to the standard log file */
    65 void LogMessage(const char *msg, ...);
    66 
    67 /** @brief Stores information about the GameDLL */
    68 struct GameDllInfo
    69 {
    70 	bool loaded;
    71 	HINSTANCE lib;
    72 	CreateInterfaceFn factory;
    73 	IServerGameDLL *pGameDLL;
    74 	IServerGameClients *pGameClients;
    75 };
    76 
    77 /** @brief Stores information about the HL2 Engine pointers */
    78 struct EngineInfo
    79 {
    80 	EngineInfo() : loaded(false), 
    81 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    82 		pGlobals(NULL), icvar(NULL), engine(NULL)
    83 	{ };
    84 	bool loaded;
    85 	CreateInterfaceFn engineFactory;
    86 	CreateInterfaceFn physicsFactory;
    87 	CreateInterfaceFn fileSystemFactory;
    88 	CGlobalVars *pGlobals;
    89 	ICvar *icvar;
    90 	IVEngineServer *engine;
    91 };
    92 
    93 /** @brief Global variable for GameDLL info */
    94 extern GameDllInfo g_GameDll;
    95 
    96 /** @brief Global variable for Engine info */
    97 extern EngineInfo g_Engine;
    98 
    99 /** @brief Global singleton for SourceHook */
   100 extern SourceHook::CSourceHookImpl g_SourceHook;
   101 
   102 /** @brief Mod path (important!)*/
   103 extern SourceHook::String g_ModPath;
   104 
   105 /** @brief Path to server binary */
   106 extern SourceHook::String g_BinPath;
   107 
   108 /** @brief Path to SourceMM binary */
   109 extern SourceHook::String g_SmmPath;
   110 
   111 /** @brief Global variable for SourceHook macros */
   112 extern SourceHook::ISourceHook *g_SHPtr;
   113 
   114 /** @brief We have our own internal plugin id... */
   115 extern PluginId g_PLID;
   116 
   117 /** @brief ServerGameDLL version that is currently loaded */
   118 extern int g_GameDllVersion;
   119 
   120 /** @brief Highest IServerPluginCallbacks version that is supported by engine */
   121 extern int g_VspVersion;
   122 
   123 extern bool bGameInit;
   124 
   125 /** @brief Global CallClass for IServerGameDLL */
   126 extern SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
   127 
   128 #endif //_INCLUDE_SOURCEMM_H