2008-11-14 11:25:40 +01:00
|
|
|
/* ======== SourceMM ========
|
2009-11-23 06:54:55 +01:00
|
|
|
* Copyright (C) 2004-2009 Metamod:Source Development Team
|
2008-11-14 11:25:40 +01:00
|
|
|
* No warranties of any kind
|
|
|
|
*
|
|
|
|
* License: zlib/libpng
|
|
|
|
*
|
|
|
|
* Author(s): David "BAILOPAN" Anderson
|
|
|
|
* ============================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCEMM_H
|
|
|
|
#define _INCLUDE_SOURCEMM_H
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief SourceMM main functionality for GameDLL interception
|
|
|
|
* @file sourcemm.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <interface.h>
|
|
|
|
#include <eiface.h>
|
|
|
|
#include <sourcehook/sourcehook_impl.h>
|
|
|
|
#include <sourcehook/sourcehook.h>
|
|
|
|
#include "ISmmAPI.h"
|
|
|
|
#include "CPlugin.h"
|
|
|
|
#include "oslink.h"
|
2010-05-14 08:02:08 +02:00
|
|
|
#include <metamod_version.h>
|
2008-11-24 04:22:04 +01:00
|
|
|
#include "loader_bridge.h"
|
2008-11-14 11:25:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Versioning
|
|
|
|
* increase api_major when API breaks
|
|
|
|
* increase api_minor when new functions are added (non-breaking)
|
|
|
|
*/
|
|
|
|
#define SOURCEMM_VERSION SVN_FILE_VERSION_STRING
|
|
|
|
#define SOURCEMM_DATE __DATE__
|
|
|
|
#define SM_VERS_API_MAJOR 1 //increase this on a breaking change
|
|
|
|
#define SM_VERS_API_MINOR 5 //increase this on a non-breaking API change
|
|
|
|
|
|
|
|
//We need a good CServerGameDLL version to work properly. We support these inclusively.
|
|
|
|
#define MIN_GAMEDLL_VERSION 3
|
|
|
|
#define MAX_GAMEDLL_VERSION 8
|
|
|
|
|
|
|
|
|
2008-11-24 05:02:49 +01:00
|
|
|
void *ServerFactory(const char *name, int *code);
|
2008-11-14 11:25:40 +01:00
|
|
|
void *EngineFactory(const char *name, int *code);
|
|
|
|
void *PhysicsFactory(const char *name, int *code);
|
|
|
|
void *FileSystemFactory(const char *name, int *code);
|
|
|
|
|
2008-11-24 14:25:46 +01:00
|
|
|
/** @brief Loads all plugins found from the mm_pluginsfile file and from VDFs in mm_basedir */
|
|
|
|
int LoadPlugins(const char *filepath, const char *vdfdir);
|
2008-11-14 11:25:40 +01:00
|
|
|
|
|
|
|
/** @brief Logs a message to the standard log file */
|
|
|
|
void LogMessage(const char *msg, ...);
|
|
|
|
|
|
|
|
/** @brief Stores information about the GameDLL */
|
|
|
|
struct GameDllInfo
|
|
|
|
{
|
|
|
|
bool loaded;
|
|
|
|
CreateInterfaceFn factory;
|
|
|
|
IServerGameDLL *pGameDLL;
|
|
|
|
IServerGameClients *pGameClients;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @brief Stores information about the HL2 Engine pointers */
|
|
|
|
struct EngineInfo
|
|
|
|
{
|
|
|
|
EngineInfo() : loaded(false), original(false),
|
|
|
|
engineFactory(NULL), physicsFactory(NULL), fileSystemFactory(NULL),
|
|
|
|
pGlobals(NULL), icvar(NULL), engine(NULL)
|
|
|
|
{ };
|
|
|
|
bool loaded;
|
|
|
|
bool original;
|
|
|
|
CreateInterfaceFn engineFactory;
|
|
|
|
CreateInterfaceFn physicsFactory;
|
|
|
|
CreateInterfaceFn fileSystemFactory;
|
|
|
|
CGlobalVars *pGlobals;
|
|
|
|
ICvar *icvar;
|
|
|
|
IVEngineServer *engine;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool AlternatelyLoadMetamod(CreateInterfaceFn ifaceFactory, CreateInterfaceFn serverFactory);
|
|
|
|
|
2008-11-16 04:13:38 +01:00
|
|
|
extern IServerPluginCallbacks *g_pRealVspCallbacks;
|
|
|
|
extern bool g_bIsBridgedAsVsp;
|
|
|
|
|
2008-11-14 11:25:40 +01:00
|
|
|
/** @brief Global variable for GameDLL info */
|
|
|
|
extern GameDllInfo g_GameDll;
|
|
|
|
|
|
|
|
/** @brief Global variable for Engine info */
|
|
|
|
extern EngineInfo g_Engine;
|
|
|
|
|
|
|
|
/** @brief Global singleton for SourceHook */
|
|
|
|
extern SourceHook::CSourceHookImpl g_SourceHook;
|
|
|
|
|
|
|
|
/** @brief Mod path (important!)*/
|
|
|
|
extern SourceHook::String g_ModPath;
|
|
|
|
|
2009-11-23 06:54:55 +01:00
|
|
|
/** @brief Path to Metamod binary */
|
|
|
|
extern SourceHook::String g_MetamodPath;
|
|
|
|
|
2008-11-14 11:25:40 +01:00
|
|
|
/** @brief Global variable for SourceHook macros */
|
|
|
|
extern SourceHook::ISourceHook *g_SHPtr;
|
|
|
|
|
|
|
|
/** @brief We have our own internal plugin id... */
|
|
|
|
extern PluginId g_PLID;
|
|
|
|
|
|
|
|
/** @brief ServerGameDLL version that is currently loaded */
|
|
|
|
extern int g_GameDllVersion;
|
|
|
|
|
2008-11-24 04:22:04 +01:00
|
|
|
extern bool g_bGameInit;
|
2008-11-14 11:25:40 +01:00
|
|
|
extern bool g_bLevelChanged;
|
|
|
|
|
2009-10-29 08:52:39 +01:00
|
|
|
extern unsigned int g_vsp_version;
|
|
|
|
|
2008-11-14 11:25:40 +01:00
|
|
|
void UnloadMetamod(bool shutting_down);
|
|
|
|
|
2008-11-24 04:22:04 +01:00
|
|
|
void LoadAsGameDLL(const gamedll_bridge_info *info);
|
|
|
|
|
2008-11-14 11:25:40 +01:00
|
|
|
#endif //_INCLUDE_SOURCEMM_H
|
2008-11-24 04:22:04 +01:00
|
|
|
|