core-legacy/sourcemm.h
author David Anderson <dvander@alliedmods.net>
Sun Nov 23 21:22:04 2008 -0600 (2008-11-23)
changeset 580 783e91c5f445
parent 558 0ed2a4a6e31d
child 583 dbdc331492b6
permissions -rw-r--r--
Initial import of core-legacy as a gameinfo provider.
     1 /* ======== SourceMM ========
     2  * Copyright (C) 2004-2008 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 "version.h"
    29 #include "loader_bridge.h"
    30 
    31 /**
    32  * Versioning
    33  *   increase api_major when API breaks
    34  *   increase api_minor when new functions are added (non-breaking)
    35  */
    36 #define		SOURCEMM_VERSION	SVN_FILE_VERSION_STRING
    37 #define		SOURCEMM_DATE		__DATE__
    38 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    39 #define		SM_VERS_API_MINOR	5		//increase this on a non-breaking API change
    40 
    41 //We need a good CServerGameDLL version to work properly.  We support these inclusively.
    42 #define	MIN_GAMEDLL_VERSION	3
    43 #define	MAX_GAMEDLL_VERSION	8
    44 
    45 /**
    46  * @brief Entry point for HL2 Engine
    47  */
    48 SMM_API void *CreateInterface(const char *name, int *code);
    49 
    50 /** @brief Wrapper to catch GameDLL calls */
    51 void *EngineFactory(const char *name, int *code);
    52 
    53 /** @brief Wrapper to catch GameDLL calls */
    54 void *PhysicsFactory(const char *name, int *code);
    55 
    56 /** @brief Wrapper to catch GameDLL calls */
    57 void *FileSystemFactory(const char *name, int *code);
    58 
    59 /** @brief Loads all plugins found in a file */
    60 int LoadPluginsFromFile(const char *file);
    61 
    62 /** @brief Logs a message to the standard log file */
    63 void LogMessage(const char *msg, ...);
    64 
    65 /** @brief Stores information about the GameDLL */
    66 struct GameDllInfo
    67 {
    68 	bool loaded;
    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), original(false),
    78 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    79 		pGlobals(NULL), icvar(NULL), engine(NULL)
    80 	{ };
    81 	bool loaded;
    82 	bool original;
    83 	CreateInterfaceFn engineFactory;
    84 	CreateInterfaceFn physicsFactory;
    85 	CreateInterfaceFn fileSystemFactory;
    86 	CGlobalVars *pGlobals;
    87 	ICvar *icvar;
    88 	IVEngineServer *engine;
    89 };
    90 
    91 bool AlternatelyLoadMetamod(CreateInterfaceFn ifaceFactory, CreateInterfaceFn serverFactory);
    92 
    93 extern IServerPluginCallbacks *g_pRealVspCallbacks;
    94 extern bool g_bIsBridgedAsVsp;
    95 
    96 /** @brief Global variable for GameDLL info */
    97 extern GameDllInfo g_GameDll;
    98 
    99 /** @brief Global variable for Engine info */
   100 extern EngineInfo g_Engine;
   101 
   102 /** @brief Global singleton for SourceHook */
   103 extern SourceHook::CSourceHookImpl g_SourceHook;
   104 
   105 /** @brief Mod path (important!)*/
   106 extern SourceHook::String g_ModPath;
   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 extern bool g_bGameInit;
   118 extern bool g_bLevelChanged;
   119 
   120 void UnloadMetamod(bool shutting_down);
   121 
   122 /** @brief Global CallClass for IServerGameDLL */
   123 extern SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
   124 
   125 void LoadAsGameDLL(const gamedll_bridge_info *info);
   126 
   127 /** @brief Global CallClass for ICvar */
   128 extern SourceHook::CallClass<ICvar> *g_CvarPatch;
   129 
   130 #endif //_INCLUDE_SOURCEMM_H
   131