sourcemm/sourcemm.h
author Scott Ehlert <ds@alliedmods.net>
Mon Feb 19 13:17:07 2007 +0000 (2007-02-19)
changeset 286 4228d058d7cb
parent 282 7a237e9ea5a1
child 287 0492209c065f
permissions -rw-r--r--
Fixed linux build :o
     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 
    29 /**
    30  * Versioning
    31  *   increase api_major when API breaks
    32  *   increase api_minor when new functions are added (non-breaking)
    33  */
    34 #define		SOURCEMM_VERSION	"1.4"
    35 #define		SOURCEMM_DATE		__DATE__
    36 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    37 #define		SM_VERS_API_MINOR	5		//increase this on a non-breaking API change
    38 
    39 //We need a good CServerGameDLL version to work properly.  We support these inclusively.
    40 #define	MIN_GAMEDLL_VERSION	3
    41 #define	MAX_GAMEDLL_VERSION	8
    42 
    43 /**
    44  * @brief Entry point for HL2 Engine
    45  */
    46 SMM_API void *CreateInterface(const char *name, int *code);
    47 
    48 /** @brief Wrapper to catch GameDLL calls */
    49 void *EngineFactory(const char *name, int *code);
    50 
    51 /** @brief Wrapper to catch GameDLL calls */
    52 void *PhysicsFactory(const char *name, int *code);
    53 
    54 /** @brief Wrapper to catch GameDLL calls */
    55 void *FileSystemFactory(const char *name, int *code);
    56 
    57 /** @brief Loads all plugins found in a file */
    58 int LoadPluginsFromFile(const char *file);
    59 
    60 /** @brief Logs a message to the standard log file */
    61 void LogMessage(const char *msg, ...);
    62 
    63 /** @brief Stores information about the GameDLL */
    64 struct GameDllInfo
    65 {
    66 	bool loaded;
    67 	HINSTANCE lib;
    68 	CreateInterfaceFn factory;
    69 	IServerGameDLL *pGameDLL;
    70 	IServerGameClients *pGameClients;
    71 };
    72 
    73 /** @brief Stores information about the HL2 Engine pointers */
    74 struct EngineInfo
    75 {
    76 	EngineInfo() : loaded(false), 
    77 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    78 		pGlobals(NULL), icvar(NULL), engine(NULL)
    79 	{ };
    80 	bool loaded;
    81 	CreateInterfaceFn engineFactory;
    82 	CreateInterfaceFn physicsFactory;
    83 	CreateInterfaceFn fileSystemFactory;
    84 	CGlobalVars *pGlobals;
    85 	ICvar *icvar;
    86 	IVEngineServer *engine;
    87 };
    88 
    89 /** @brief Global variable for GameDLL info */
    90 extern GameDllInfo g_GameDll;
    91 
    92 /** @brief Global variable for Engine info */
    93 extern EngineInfo g_Engine;
    94 
    95 /** @brief Global singleton for SourceHook */
    96 extern SourceHook::CSourceHookImpl g_SourceHook;
    97 
    98 /** @brief Mod path (important!)*/
    99 extern SourceHook::String g_ModPath;
   100 
   101 /** @brief Path to server binary */
   102 extern SourceHook::String g_BinPath;
   103 
   104 /** @brief Global variable for SourceHook macros */
   105 extern SourceHook::ISourceHook *g_SHPtr;
   106 
   107 /** @brief We have our own internal plugin id... */
   108 extern PluginId g_PLID;
   109 
   110 /** @brief ServerGameDLL version that is currently loaded */
   111 extern int g_GameDllVersion;
   112 
   113 extern bool bGameInit;
   114 
   115 #endif //_INCLUDE_SOURCEMM_H