sourcemm/sourcemm.h
author David Anderson <dvander@alliedmods.net>
Fri Sep 21 18:03:57 2007 +0000 (2007-09-21)
branchsourcemm-1.6.0
changeset 351 7347be0355ae
parent 349 67d6f9cce139
permissions -rw-r--r--
- added an api call for finding source engine build
- random markup/doc changes
     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	7		//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 
    43 /* Maximum version of IServerPluginCallbacks that SourceMM supports */
    44 #define MAX_VSP_VERSION 2
    45 
    46 /** @brief Entry point for HL2 Engine */
    47 SMM_API void *CreateInterface(const char *name, int *code);
    48 
    49 /** @brief Wrapper to catch GameDLL calls */
    50 void *EngineFactory(const char *name, int *code);
    51 
    52 /** @brief Wrapper to catch GameDLL calls */
    53 void *PhysicsFactory(const char *name, int *code);
    54 
    55 /** @brief Wrapper to catch GameDLL calls */
    56 void *FileSystemFactory(const char *name, int *code);
    57 
    58 /** @brief Loads all plugins found in a file */
    59 int LoadPluginsFromFile(const char *file);
    60 
    61 /** @brief Logs a message to the standard log file */
    62 void LogMessage(const char *msg, ...);
    63 
    64 /** @brief Stores information about the GameDLL */
    65 struct GameDllInfo
    66 {
    67 	bool loaded;
    68 	HINSTANCE lib;
    69 	CreateInterfaceFn factory;
    70 	IServerGameDLL *pGameDLL;
    71 	IServerGameClients *pGameClients;
    72 };
    73 
    74 /** @brief Stores information about the HL2 Engine pointers */
    75 struct EngineInfo
    76 {
    77 	EngineInfo() : loaded(false), 
    78 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    79 		pGlobals(NULL), icvar(NULL), engine(NULL)
    80 	{ };
    81 	bool loaded;
    82 	CreateInterfaceFn engineFactory;
    83 	CreateInterfaceFn physicsFactory;
    84 	CreateInterfaceFn fileSystemFactory;
    85 	CGlobalVars *pGlobals;
    86 	ICvar *icvar;
    87 	IVEngineServer *engine;
    88 };
    89 
    90 /** @brief Global variable for GameDLL info */
    91 extern GameDllInfo g_GameDll;
    92 
    93 /** @brief Global variable for Engine info */
    94 extern EngineInfo g_Engine;
    95 
    96 /** @brief Global singleton for SourceHook */
    97 extern SourceHook::CSourceHookImpl g_SourceHook;
    98 
    99 /** @brief Mod path (important!)*/
   100 extern SourceHook::String g_ModPath;
   101 
   102 /** @brief Path to server binary */
   103 extern SourceHook::String g_BinPath;
   104 
   105 /** @brief Path to SourceMM binary */
   106 extern SourceHook::String g_SmmPath;
   107 
   108 /** @brief Global variable for SourceHook macros */
   109 extern SourceHook::ISourceHook *g_SHPtr;
   110 
   111 /** @brief We have our own internal plugin id... */
   112 extern PluginId g_PLID;
   113 
   114 /** @brief ServerGameDLL version that is currently loaded */
   115 extern int g_GameDllVersion;
   116 
   117 /** @brief Highest IServerPluginCallbacks version that is supported by engine */
   118 extern int g_VspVersion;
   119 
   120 /** @brief IServerGameClients version the mod uses */
   121 extern int g_GameClientsVersion;
   122 
   123 /** @brief Source Engine version */
   124 extern int g_SourceEngineVersion;
   125 
   126 extern bool bGameInit;
   127 
   128 /** @brief Global CallClass for IServerGameDLL */
   129 extern SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
   130 
   131 #endif //_INCLUDE_SOURCEMM_H