sourcemm/sourcemm.h
author Scott Ehlert <ds@alliedmods.net>
Mon Apr 17 19:42:55 2006 +0000 (2006-04-17)
changeset 187 d81c2fc9a708
parent 178 db1b448191c0
child 192 47649a1d49e3
permissions -rw-r--r--
Fixed a warning in stub and sample :|
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2006 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 
    29 /**
    30  * Versioning
    31  *   ?what the hell was I smoking when I wrote this
    32  *   increase api_major when API breaks
    33  *   increase api_minor when new functions are added (non-breaking)
    34  *   increase vers_release when bug fix releases are made
    35  *   never increase major
    36  */
    37 #define		SOURCEMM_VERSION	"1.2.1"
    38 #define		SOURCEMM_DATE		__DATE__
    39 #define		SM_MAJOR_VERSION	1		//never need to increase this
    40 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    41 #define		SM_VERS_API_MINOR	2		//increase this on a non-breaking API change
    42 #define		SM_VERS_RELEASE		1		//increase this on a bug-fix release.
    43 
    44 //We need a good CServerGameDLL version to work properly.  We support these inclusively.
    45 #define	MIN_GAMEDLL_VERSION	3
    46 #define	MAX_GAMEDLL_VERSION	4
    47 
    48 /**
    49  * @brief Entry point for HL2 Engine
    50  */
    51 SMM_API void *CreateInterface(const char *name, int *code);
    52 
    53 /** @brief Wrapper to catch GameDLL calls */
    54 void *EngineFactory(const char *name, int *code);
    55 
    56 /** @brief Wrapper to catch GameDLL calls */
    57 void *PhysicsFactory(const char *name, int *code);
    58 
    59 /** @brief Wrapper to catch GameDLL calls */
    60 void *FileSystemFactory(const char *name, int *code);
    61 
    62 /** @brief Loads all plugins found in a file */
    63 int LoadPluginsFromFile(const char *file);
    64 
    65 /** @brief Logs a message to the standard log file */
    66 void LogMessage(const char *msg, ...);
    67 
    68 /** @brief Stores information about the GameDLL */
    69 struct GameDllInfo
    70 {
    71 	bool loaded;
    72 	HINSTANCE lib;
    73 	CreateInterfaceFn factory;
    74 	IServerGameDLL *pGameDLL;
    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 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 #endif //_INCLUDE_SOURCEMM_H