core-legacy/sourcemm.h
author Nicholas Hastings <skamonkey@gmail.com>
Wed May 21 17:26:09 2014 -0400 (2014-05-21)
changeset 917 95639ee45d3d
parent 887 e30d4a37f5e5
permissions -rw-r--r--
Trigger build for hl2sdk-l4d changes.
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2009 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 <interface.h>
    20 #include <eiface.h>
    21 #include <sourcehook/sourcehook_impl.h>
    22 #include <sourcehook/sourcehook.h>
    23 #include "ISmmAPI.h"
    24 #include "CPlugin.h"
    25 #include "oslink.h"
    26 #include "loader_bridge.h"
    27 
    28 /**
    29  * Versioning
    30  *   increase api_major when API breaks
    31  *   increase api_minor when new functions are added (non-breaking)
    32  */
    33 #define		SOURCEMM_VERSION	SVN_FILE_VERSION_STRING
    34 #define		SOURCEMM_DATE		__DATE__
    35 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    36 #define		SM_VERS_API_MINOR	5		//increase this on a non-breaking API change
    37 
    38 //We need a good CServerGameDLL version to work properly.  We support these inclusively.
    39 #define	MIN_GAMEDLL_VERSION	3
    40 #define	MAX_GAMEDLL_VERSION	8
    41 
    42 
    43 void *ServerFactory(const char *name, int *code);
    44 void *EngineFactory(const char *name, int *code);
    45 void *PhysicsFactory(const char *name, int *code);
    46 void *FileSystemFactory(const char *name, int *code);
    47 
    48 /** @brief Loads all plugins found from the mm_pluginsfile file and from VDFs in mm_basedir */
    49 int LoadPlugins(const char *filepath, const char *vdfdir);
    50 
    51 /** @brief Logs a message to the standard log file */
    52 void LogMessage(const char *msg, ...);
    53 
    54 /** @brief Stores information about the GameDLL */
    55 struct GameDllInfo
    56 {
    57 	bool loaded;
    58 	CreateInterfaceFn factory;
    59 	IServerGameDLL *pGameDLL;
    60 	IServerGameClients *pGameClients;
    61 };
    62 
    63 /** @brief Stores information about the HL2 Engine pointers */
    64 struct EngineInfo
    65 {
    66 	EngineInfo() : loaded(false), original(false),
    67 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    68 		pGlobals(NULL), icvar(NULL), engine(NULL)
    69 	{ };
    70 	bool loaded;
    71 	bool original;
    72 	CreateInterfaceFn engineFactory;
    73 	CreateInterfaceFn physicsFactory;
    74 	CreateInterfaceFn fileSystemFactory;
    75 	CGlobalVars *pGlobals;
    76 	ICvar *icvar;
    77 	IVEngineServer *engine;
    78 };
    79 
    80 bool AlternatelyLoadMetamod(CreateInterfaceFn ifaceFactory, CreateInterfaceFn serverFactory);
    81 
    82 extern IServerPluginCallbacks *g_pRealVspCallbacks;
    83 extern bool g_bIsBridgedAsVsp;
    84 
    85 /** @brief Global variable for GameDLL info */
    86 extern GameDllInfo g_GameDll;
    87 
    88 /** @brief Global variable for Engine info */
    89 extern EngineInfo g_Engine;
    90 
    91 /** @brief Global singleton for SourceHook */
    92 extern SourceHook::CSourceHookImpl g_SourceHook;
    93 
    94 /** @brief Mod path (important!)*/
    95 extern SourceHook::String g_ModPath;
    96 
    97 /** @brief Path to Metamod binary */
    98 extern SourceHook::String g_MetamodPath;
    99 
   100 /** @brief Global variable for SourceHook macros */
   101 extern SourceHook::ISourceHook *g_SHPtr;
   102 
   103 /** @brief We have our own internal plugin id... */
   104 extern PluginId g_PLID;
   105 
   106 /** @brief ServerGameDLL version that is currently loaded */
   107 extern int g_GameDllVersion;
   108 
   109 extern bool g_bGameInit;
   110 extern bool g_bLevelChanged;
   111 
   112 extern unsigned int g_vsp_version;
   113 
   114 void UnloadMetamod(bool shutting_down);
   115 
   116 void LoadAsGameDLL(const gamedll_bridge_info *info);
   117 
   118 #endif //_INCLUDE_SOURCEMM_H
   119