sourcemm/sourcemm.h
author David Anderson <dvander@alliedmods.net>
Thu Oct 06 00:59:01 2005 +0000 (2005-10-06)
changeset 122 7c36121e2dfe
parent 104 a3f2126f71a8
child 124 b04971393ee4
permissions -rw-r--r--
Initial import of new GameDLL loading code
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 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 #define		SOURCEMM_VERSION	"1.10"
    30 #define		SOURCEMM_DATE		__DATE__
    31 
    32 #define	MIN_GAMEDLL_VERSION	3
    33 #define	MAX_GAMEDLL_VERSION	4
    34 
    35 /**
    36  * @brief Entry point for HL2 Engine
    37  */
    38 SMM_API void *CreateInterface(const char *name, int *code);
    39 
    40 /** @brief Wrapper to catch GameDLL calls */
    41 void *EngineFactory(const char *name, int *code);
    42 
    43 /** @brief Wrapper to catch GameDLL calls */
    44 void *PhysicsFactory(const char *name, int *code);
    45 
    46 /** @brief Wrapper to catch GameDLL calls */
    47 void *FileSystemFactory(const char *name, int *code);
    48 
    49 /** @brief Loads all plugins found in a file */
    50 int LoadPluginsFromFile(const char *file);
    51 
    52 /** @brief Logs a message to the standard log file */
    53 void LogMessage(const char *msg, ...);
    54 
    55 /** @brief Stores information about the GameDLL */
    56 struct GameDllInfo
    57 {
    58 	bool loaded;
    59 	HINSTANCE lib;
    60 	CreateInterfaceFn factory;
    61 	IServerGameDLL *pGameDLL;
    62 };
    63 
    64 /** @brief Stores information about the HL2 Engine pointers */
    65 struct EngineInfo
    66 {
    67 	EngineInfo() : loaded(false), 
    68 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    69 		pGlobals(NULL), icvar(NULL), engine(NULL)
    70 	{ };
    71 	bool loaded;
    72 	CreateInterfaceFn engineFactory;
    73 	CreateInterfaceFn physicsFactory;
    74 	CreateInterfaceFn fileSystemFactory;
    75 	CGlobalVars *pGlobals;
    76 	ICvar *icvar;
    77 	IVEngineServer *engine;
    78 };
    79 
    80 /** @brief Global variable for GameDLL info */
    81 extern GameDllInfo g_GameDll;
    82 
    83 /** @brief Global variable for Engine info */
    84 extern EngineInfo g_Engine;
    85 
    86 /** @brief Global singleton for SourceHook */
    87 extern SourceHook::CSourceHookImpl g_SourceHook;
    88 
    89 /** @brief Mod path (important!)*/
    90 extern SourceHook::String g_ModPath;
    91 
    92 /** @brief Path to server binary */
    93 extern SourceHook::String g_BinPath;
    94 
    95 /** @brief Global variable for SourceHook macros */
    96 extern SourceHook::ISourceHook *g_SHPtr;
    97 
    98 /** @brief We have our own internal plugin id... */
    99 extern PluginId g_PLID;
   100 
   101 #endif //_INCLUDE_SOURCEMM_H