1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core-1.4/sourcemm.h Fri Nov 14 04:25:40 2008 -0600
1.3 @@ -0,0 +1,131 @@
1.4 +/* ======== SourceMM ========
1.5 + * Copyright (C) 2004-2008 Metamod:Source Development Team
1.6 + * No warranties of any kind
1.7 + *
1.8 + * License: zlib/libpng
1.9 + *
1.10 + * Author(s): David "BAILOPAN" Anderson
1.11 + * ============================
1.12 + */
1.13 +
1.14 +#ifndef _INCLUDE_SOURCEMM_H
1.15 +#define _INCLUDE_SOURCEMM_H
1.16 +
1.17 +/**
1.18 + * @brief SourceMM main functionality for GameDLL interception
1.19 + * @file sourcemm.h
1.20 + */
1.21 +
1.22 +#include <string>
1.23 +#include <interface.h>
1.24 +#include <eiface.h>
1.25 +#include <sourcehook/sourcehook_impl.h>
1.26 +#include <sourcehook/sourcehook.h>
1.27 +#include "ISmmAPI.h"
1.28 +#include "CPlugin.h"
1.29 +#include "oslink.h"
1.30 +#include "util.h"
1.31 +#include "svn_version.h"
1.32 +
1.33 +/**
1.34 + * Versioning
1.35 + * increase api_major when API breaks
1.36 + * increase api_minor when new functions are added (non-breaking)
1.37 + */
1.38 +#define SOURCEMM_VERSION SVN_FILE_VERSION_STRING
1.39 +#define SOURCEMM_DATE __DATE__
1.40 +#define SM_VERS_API_MAJOR 1 //increase this on a breaking change
1.41 +#define SM_VERS_API_MINOR 5 //increase this on a non-breaking API change
1.42 +
1.43 +//We need a good CServerGameDLL version to work properly. We support these inclusively.
1.44 +#define MIN_GAMEDLL_VERSION 3
1.45 +#define MAX_GAMEDLL_VERSION 8
1.46 +
1.47 +/**
1.48 + * @brief Entry point for HL2 Engine
1.49 + */
1.50 +SMM_API void *CreateInterface(const char *name, int *code);
1.51 +
1.52 +/** @brief Wrapper to catch GameDLL calls */
1.53 +void *EngineFactory(const char *name, int *code);
1.54 +
1.55 +/** @brief Wrapper to catch GameDLL calls */
1.56 +void *PhysicsFactory(const char *name, int *code);
1.57 +
1.58 +/** @brief Wrapper to catch GameDLL calls */
1.59 +void *FileSystemFactory(const char *name, int *code);
1.60 +
1.61 +/** @brief Loads all plugins found in a file */
1.62 +int LoadPluginsFromFile(const char *file);
1.63 +
1.64 +/** @brief Logs a message to the standard log file */
1.65 +void LogMessage(const char *msg, ...);
1.66 +
1.67 +/** @brief Stores information about the GameDLL */
1.68 +struct GameDllInfo
1.69 +{
1.70 + bool loaded;
1.71 + HINSTANCE lib;
1.72 + CreateInterfaceFn factory;
1.73 + IServerGameDLL *pGameDLL;
1.74 + IServerGameClients *pGameClients;
1.75 +};
1.76 +
1.77 +/** @brief Stores information about the HL2 Engine pointers */
1.78 +struct EngineInfo
1.79 +{
1.80 + EngineInfo() : loaded(false), original(false),
1.81 + engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
1.82 + pGlobals(NULL), icvar(NULL), engine(NULL)
1.83 + { };
1.84 + bool loaded;
1.85 + bool original;
1.86 + CreateInterfaceFn engineFactory;
1.87 + CreateInterfaceFn physicsFactory;
1.88 + CreateInterfaceFn fileSystemFactory;
1.89 + CGlobalVars *pGlobals;
1.90 + ICvar *icvar;
1.91 + IVEngineServer *engine;
1.92 +};
1.93 +
1.94 +bool AlternatelyLoadMetamod(CreateInterfaceFn ifaceFactory, CreateInterfaceFn serverFactory);
1.95 +
1.96 +/** @brief Global variable for GameDLL info */
1.97 +extern GameDllInfo g_GameDll;
1.98 +
1.99 +/** @brief Global variable for Engine info */
1.100 +extern EngineInfo g_Engine;
1.101 +
1.102 +/** @brief Global singleton for SourceHook */
1.103 +extern SourceHook::CSourceHookImpl g_SourceHook;
1.104 +
1.105 +/** @brief Mod path (important!)*/
1.106 +extern SourceHook::String g_ModPath;
1.107 +
1.108 +/** @brief Path to server binary */
1.109 +extern SourceHook::String g_BinPath;
1.110 +
1.111 +/** @brief Path to SourceMM binary */
1.112 +extern SourceHook::String g_SmmPath;
1.113 +
1.114 +/** @brief Global variable for SourceHook macros */
1.115 +extern SourceHook::ISourceHook *g_SHPtr;
1.116 +
1.117 +/** @brief We have our own internal plugin id... */
1.118 +extern PluginId g_PLID;
1.119 +
1.120 +/** @brief ServerGameDLL version that is currently loaded */
1.121 +extern int g_GameDllVersion;
1.122 +
1.123 +extern bool bGameInit;
1.124 +extern bool g_bLevelChanged;
1.125 +
1.126 +void UnloadMetamod(bool shutting_down);
1.127 +
1.128 +/** @brief Global CallClass for IServerGameDLL */
1.129 +extern SourceHook::CallClass<IServerGameDLL> *g_GameDllPatch;
1.130 +
1.131 +/** @brief Global CallClass for ICvar */
1.132 +extern SourceHook::CallClass<ICvar> *g_CvarPatch;
1.133 +
1.134 +#endif //_INCLUDE_SOURCEMM_H