sourcemm/sourcemm.h
author David Anderson <dvander@alliedmods.net>
Tue Dec 06 07:59:18 2005 +0000 (2005-12-06)
changeset 152 179336f55ff6
parent 149 d928d48d7aec
child 166 e85ebcf21a7e
permissions -rw-r--r--
Added API call for guessing iface names
Added interface query overriding+sharing examples to stub+sample
     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 /**
    30  * Versioning
    31  *  First grouping is major release version (1)
    32  *  Second grouping is minor release version.
    33  *  Third grouping is release change version.
    34  * For an entire code rehaul, we would change major.
    35  * For a simple bug-fix release, we would change the third grouping.
    36  * For an API change, we would increase the second grouping by one.
    37  * For a breaking API change, we would increase the second group up to the next bracket.
    38  *  (example: 1.45 -> 1.50.  1.12 -> 1.20.  1.19 -> 1.20)
    39  *  minor changes can also roll over, but a big change should ALWAYS roll over.
    40  * Increasing one grouping should make the lesser ones reset back to zero.
    41  */
    42 #define		SOURCEMM_VERSION	"1.1.2"
    43 #define		SOURCEMM_DATE		__DATE__
    44 #define		SM_MAJOR_VERSION	1		//never need to increase this
    45 #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    46 #define		SM_VERS_API_MINOR	1		//increase this on a non-breaking API change
    47 #define		SM_VERS_RELEASE		0		//increase this on a bug-fix release.
    48 
    49 //We need a good CServerGameDLL version to work properly.  We support these inclusively.
    50 #define	MIN_GAMEDLL_VERSION	3
    51 #define	MAX_GAMEDLL_VERSION	4
    52 
    53 /**
    54  * @brief Entry point for HL2 Engine
    55  */
    56 SMM_API void *CreateInterface(const char *name, int *code);
    57 
    58 /** @brief Wrapper to catch GameDLL calls */
    59 void *EngineFactory(const char *name, int *code);
    60 
    61 /** @brief Wrapper to catch GameDLL calls */
    62 void *PhysicsFactory(const char *name, int *code);
    63 
    64 /** @brief Wrapper to catch GameDLL calls */
    65 void *FileSystemFactory(const char *name, int *code);
    66 
    67 /** @brief Loads all plugins found in a file */
    68 int LoadPluginsFromFile(const char *file);
    69 
    70 /** @brief Logs a message to the standard log file */
    71 void LogMessage(const char *msg, ...);
    72 
    73 /** @brief Stores information about the GameDLL */
    74 struct GameDllInfo
    75 {
    76 	bool loaded;
    77 	HINSTANCE lib;
    78 	CreateInterfaceFn factory;
    79 	IServerGameDLL *pGameDLL;
    80 };
    81 
    82 /** @brief Stores information about the HL2 Engine pointers */
    83 struct EngineInfo
    84 {
    85 	EngineInfo() : loaded(false), 
    86 		engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
    87 		pGlobals(NULL), icvar(NULL), engine(NULL)
    88 	{ };
    89 	bool loaded;
    90 	CreateInterfaceFn engineFactory;
    91 	CreateInterfaceFn physicsFactory;
    92 	CreateInterfaceFn fileSystemFactory;
    93 	CGlobalVars *pGlobals;
    94 	ICvar *icvar;
    95 	IVEngineServer *engine;
    96 };
    97 
    98 /** @brief Global variable for GameDLL info */
    99 extern GameDllInfo g_GameDll;
   100 
   101 /** @brief Global variable for Engine info */
   102 extern EngineInfo g_Engine;
   103 
   104 /** @brief Global singleton for SourceHook */
   105 extern SourceHook::CSourceHookImpl g_SourceHook;
   106 
   107 /** @brief Mod path (important!)*/
   108 extern SourceHook::String g_ModPath;
   109 
   110 /** @brief Path to server binary */
   111 extern SourceHook::String g_BinPath;
   112 
   113 /** @brief Global variable for SourceHook macros */
   114 extern SourceHook::ISourceHook *g_SHPtr;
   115 
   116 /** @brief We have our own internal plugin id... */
   117 extern PluginId g_PLID;
   118 
   119 #endif //_INCLUDE_SOURCEMM_H