mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
Implemented factory hooks
Added commands: clear, load, pause, unload, unpause Rewrote headers --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4010
This commit is contained in:
parent
aed73ffa76
commit
4dc43f3d08
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,26 +0,0 @@
|
||||
#ifndef _INCLUDE_CSMM_API_H
|
||||
#define _INCLUDE_CSMM_API_H
|
||||
|
||||
#include "ISmmAPI.h"
|
||||
|
||||
class CSmmAPI : public ISmmAPI
|
||||
{
|
||||
public:
|
||||
ISmmPluginManager *PluginManager();
|
||||
SourceHook::ISourceHook *SourceHook();
|
||||
void LogMsg(ISmmPlugin *pl, const char *msg, ...);
|
||||
public:
|
||||
CreateInterfaceFn engineFactory(bool syn=true);
|
||||
CreateInterfaceFn physicsFactory(bool syn=true);
|
||||
CreateInterfaceFn fileSystemFactory(bool syn=true);
|
||||
CreateInterfaceFn serverFactory(bool syn=true);
|
||||
CGlobalVars *pGlobals();
|
||||
void SetLastMetaReturn(META_RES res);
|
||||
META_RES GetLastMetaReturn();
|
||||
private:
|
||||
META_RES m_Res;
|
||||
};
|
||||
|
||||
extern CSmmAPI g_SmmAPI;
|
||||
|
||||
#endif //_INCLUDE_CSMM_API_H
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -9,7 +9,8 @@
|
||||
*/
|
||||
|
||||
#include "CPlugin.h"
|
||||
#include "CISmmAPI.h"
|
||||
#include "CSmmAPI.h"
|
||||
#include "sourcemm.h"
|
||||
|
||||
/**
|
||||
* @brief Implements functions from CPlugin.h
|
||||
@ -36,6 +37,7 @@ CPluginManager::~CPluginManager()
|
||||
|
||||
CPluginManager::CPlugin::CPlugin() : m_Lib(NULL), m_API(NULL), m_Id(0), m_Source(0)
|
||||
{
|
||||
memset(&fac_list, 0, sizeof(factories));
|
||||
}
|
||||
|
||||
PluginId CPluginManager::Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen)
|
||||
@ -108,17 +110,17 @@ bool CPluginManager::Unpause(PluginId id, char *error, size_t maxlen)
|
||||
return _Unpause(pl, error, maxlen);
|
||||
}
|
||||
|
||||
bool CPluginManager::Unload(PluginId id, char *error, size_t maxlen)
|
||||
bool CPluginManager::Unload(PluginId id, bool force, char *error, size_t maxlen)
|
||||
{
|
||||
CPlugin *pl = FindById(id);
|
||||
|
||||
if (!pl)
|
||||
{
|
||||
snprintf(error, maxlen, "Plugin id not found");
|
||||
snprintf(error, maxlen, "Plugin %d not found", id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return _Unload(pl, error, maxlen);
|
||||
return _Unload(pl, force, error, maxlen);
|
||||
}
|
||||
|
||||
CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source, char *error, size_t maxlen)
|
||||
@ -196,14 +198,19 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
|
||||
return pl;
|
||||
}
|
||||
|
||||
bool CPluginManager::_Unload(CPluginManager::CPlugin *pl, char *error, size_t maxlen)
|
||||
bool CPluginManager::_Unload(CPluginManager::CPlugin *pl, bool force, char *error, size_t maxlen)
|
||||
{
|
||||
if (error)
|
||||
*error = '\0';
|
||||
if (pl->m_API && pl->m_Lib)
|
||||
{
|
||||
if (pl->m_API->Unload(error, maxlen))
|
||||
//Note, we'll always tell the plugin it will be unloading...
|
||||
if (pl->m_API->Unload(error, maxlen) || force)
|
||||
{
|
||||
//Make sure to detach it from sourcehook!
|
||||
g_SourceHook.UnloadPlugin(pl->m_Id);
|
||||
|
||||
//Clean up the DLL
|
||||
dlclose(pl->m_Lib);
|
||||
pl->m_Lib = NULL;
|
||||
pl->m_API = NULL;
|
||||
@ -218,6 +225,7 @@ bool CPluginManager::_Unload(CPluginManager::CPlugin *pl, char *error, size_t ma
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Free its memory
|
||||
delete pl;
|
||||
|
||||
return true;
|
||||
@ -250,7 +258,10 @@ bool CPluginManager::_Pause(CPluginManager::CPlugin *pl, char *error, size_t max
|
||||
if (error)
|
||||
snprintf(error, maxlen, "Plugin cannot be paused");
|
||||
} else {
|
||||
return pl->m_API->Pause(error, maxlen);
|
||||
if (pl->m_API->Pause(error, maxlen))
|
||||
{
|
||||
g_SourceHook.PausePlugin(pl->m_Id);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -266,13 +277,15 @@ bool CPluginManager::_Unpause(CPluginManager::CPlugin *pl, char *error, size_t m
|
||||
if (error)
|
||||
snprintf(error, maxlen, "Plugin cannot be unpaused");
|
||||
} else {
|
||||
return pl->m_API->Unpause(error, maxlen);
|
||||
if (pl->m_API->Unpause(error, maxlen))
|
||||
{
|
||||
g_SourceHook.UnpausePlugin(pl->m_Id);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::UnloadAll()
|
||||
{
|
||||
PluginIter i;
|
||||
@ -287,6 +300,10 @@ bool CPluginManager::UnloadAll()
|
||||
if ( (*i)->m_API->Unload(NULL, 0) )
|
||||
status = false;
|
||||
|
||||
//Unlink from SourceHook
|
||||
g_SourceHook.UnloadPlugin( (*i)->m_Id );
|
||||
|
||||
//Free the DLL
|
||||
dlclose( (*i)->m_Lib );
|
||||
}
|
||||
delete (*i);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -49,7 +49,7 @@ namespace SourceMM
|
||||
~CPluginManager();
|
||||
public:
|
||||
PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen);
|
||||
bool Unload(PluginId id, char *error, size_t maxlen);
|
||||
bool Unload(PluginId id, bool force, char *error, size_t maxlen);
|
||||
bool Pause(PluginId id, char *error, size_t maxlen);
|
||||
bool Unpause(PluginId id, char *error, size_t maxlen);
|
||||
bool UnloadAll();
|
||||
@ -70,7 +70,7 @@ namespace SourceMM
|
||||
private:
|
||||
//These are identical internal functions for the wrappers above.
|
||||
CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
|
||||
bool _Unload(CPlugin *pl, char *error, size_t maxlen);
|
||||
bool _Unload(CPlugin *pl, bool force, char *error, size_t maxlen);
|
||||
bool _Pause(CPlugin *pl, char *error, size_t maxlen);
|
||||
bool _Unpause(CPlugin *pl, char *error, size_t maxlen);
|
||||
private:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,6 +1,21 @@
|
||||
#include "CISmmAPI.h"
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
*
|
||||
* Author(s): David "BAILOPAN" Anderson
|
||||
* ============================
|
||||
*/
|
||||
|
||||
#include "CSmmAPI.h"
|
||||
#include "sourcemm.h"
|
||||
|
||||
/**
|
||||
* @brief Implementation of main API interface
|
||||
* @file CSmmAPI.cpp
|
||||
*/
|
||||
|
||||
CSmmAPI g_SmmAPI;
|
||||
|
||||
ISmmPluginManager *CSmmAPI::PluginManager()
|
||||
|
@ -1,6 +1,21 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
*
|
||||
* Author(s): David "BAILOPAN" Anderson
|
||||
* ============================
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_PLUGINMANAGER_H
|
||||
#define _INCLUDE_PLUGINMANAGER_H
|
||||
|
||||
/**
|
||||
* @brief Plugin Manager interface
|
||||
* @file IPluginManager.h
|
||||
*/
|
||||
|
||||
#include "ISmmPlugin.h"
|
||||
|
||||
/**
|
||||
@ -53,7 +68,7 @@ public:
|
||||
* @param maxlen Maximum length of buffer
|
||||
* @return True on success, false otherwise
|
||||
*/
|
||||
virtual bool Unload(PluginId id, char *error, size_t maxlen) =0;
|
||||
virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
|
||||
|
||||
/**
|
||||
* @brief Pauses a plugin
|
||||
@ -69,6 +84,7 @@ public:
|
||||
* @brief Unpauses a plugin
|
||||
*
|
||||
* @param id Id of plugin
|
||||
* @param force If true, forces the plugin to unload
|
||||
* @param error String buffer for error messages
|
||||
* @param maxlen Maximum length of buffer
|
||||
* @return True on success, false otherwise
|
||||
|
@ -1,6 +1,21 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
*
|
||||
* Author(s): David "BAILOPAN" Anderson
|
||||
* ============================
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_ISMM_API_H
|
||||
#define _INCLUDE_ISMM_API_H
|
||||
|
||||
/**
|
||||
* @brief External API interface
|
||||
* @file ISmmAPI.h
|
||||
*/
|
||||
|
||||
#include <interface.h>
|
||||
#include <eiface.h>
|
||||
#include <sourcehook/sourcehook.h>
|
||||
@ -22,6 +37,7 @@ public:
|
||||
virtual CreateInterfaceFn serverFactory(bool syn=true) =0;
|
||||
virtual CGlobalVars *pGlobals() =0;
|
||||
virtual void SetLastMetaReturn(META_RES res) =0;
|
||||
virtual META_RES GetLastMetaReturn() =0;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_ISMM_API_H
|
||||
|
@ -1,6 +1,21 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
*
|
||||
* Author(s): David "BAILOPAN" Anderson
|
||||
* ============================
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_ISMM_PLUGIN_H
|
||||
#define _INCLUDE_ISMM_PLUGIN_H
|
||||
|
||||
/**
|
||||
* @brief Plugin API interface
|
||||
* @file ISmmPlugin.h
|
||||
*/
|
||||
|
||||
#include <interface.h>
|
||||
#include <sourcehook/sourcehook.h>
|
||||
#include "ISmmAPI.h"
|
||||
@ -21,11 +36,13 @@ typedef unsigned int PluginId;
|
||||
|
||||
class ISmmPlugin
|
||||
{
|
||||
public:
|
||||
virtual int GetApiVersion() { return PLAPI_VERSION; }
|
||||
public:
|
||||
/**
|
||||
* @brief Called on plugin load.
|
||||
*
|
||||
* @param id Internal id of plugin.
|
||||
* @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
|
||||
* @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
|
||||
* @param list Contains a list of factories. Hook a factory call by setting one equal to your own function.
|
||||
* @param error Error message buffer
|
||||
@ -57,8 +74,6 @@ public:
|
||||
* @return True on success, return false to request no unpause.
|
||||
*/
|
||||
virtual bool Unpause(char *error, size_t maxlen) =0;
|
||||
public:
|
||||
virtual int GetApiVersion() { return PLAPI_VERSION; }
|
||||
public:
|
||||
virtual const char *GetAuthor() =0;
|
||||
virtual const char *GetName() =0;
|
||||
@ -76,7 +91,8 @@ public:
|
||||
|
||||
#define PLUGIN_EXPOSE(name, var) \
|
||||
ISmmAPI *g_SMAPI = NULL; \
|
||||
ISmmPlugin *g_PLID = NULL; \
|
||||
ISmmPlugin *g_PLAPI = NULL; \
|
||||
PluginId g_PLID = (PluginId)0; \
|
||||
SourceHook::ISourceHook *g_SHPtr = NULL; \
|
||||
SMM_API void *PL_EXPOSURE(const char *name, int *code) { \
|
||||
if (name && !strcmp(name, PLAPI_NAME)) { \
|
||||
@ -88,12 +104,14 @@ public:
|
||||
#define PLUGIN_GLOBALVARS() \
|
||||
extern SourceHook::ISourceHook *g_SHPtr; \
|
||||
extern ISmmAPI *g_SMAPI; \
|
||||
extern ISmmPlugin *g_PLID;
|
||||
extern ISmmPlugin *g_PLAPI; \
|
||||
extern PluginId g_PLID;
|
||||
|
||||
#define PLUGIN_SAVEVARS() \
|
||||
g_SMAPI = ismm; \
|
||||
g_SHPtr = ismm->SourceHook(); \
|
||||
g_PLID = static_cast<ISmmPlugin *>(this);
|
||||
g_PLAPI = static_cast<ISmmPlugin *>(this); \
|
||||
g_PLID = id;
|
||||
|
||||
#define FACTORY_RETURN(mres, value) \
|
||||
g_SMAPI->SetLastMetaReturn(mres); \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -75,7 +75,7 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
PluginIter i;
|
||||
const char *status="";
|
||||
|
||||
Msg("[Id] %-16.15s %-8.7s %-12.11s %-8.7s\n", "Name", "Version", "Author", "Status");
|
||||
Msg("-Id- %-16.15s %-8.7s %-12.11s %-8.7s\n", "Name", "Version", "Author", "Status");
|
||||
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
|
||||
{
|
||||
pl = (*i);
|
||||
@ -133,15 +133,181 @@ CON_COMMAND(meta, "Metamod:Source Menu")
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "pause") == 0) {
|
||||
if (args >= 3)
|
||||
{
|
||||
int id = atoi(e->Cmd_Argv(2));
|
||||
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
||||
if (!pl)
|
||||
{
|
||||
Msg("Plugin %d not found.\n", id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pl->m_Status != Pl_Running)
|
||||
{
|
||||
Msg("Plugin %d is not pausable.\n", pl->m_Id);
|
||||
return;
|
||||
}
|
||||
|
||||
char error[255]={0};
|
||||
if (!pl->m_API->Pause(error, sizeof(error)-1))
|
||||
{
|
||||
Msg("Plugin %d refused pause: %s\n", pl->m_Id, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_SourceHook.PausePlugin(pl->m_Id);
|
||||
Msg("\"%s\" has been paused.\n", pl->m_API->GetName());
|
||||
|
||||
return;
|
||||
} else {
|
||||
Msg("Usage: meta pause <id>\n");
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "unpause") == 0) {
|
||||
if (args >= 3)
|
||||
{
|
||||
int id = atoi(e->Cmd_Argv(2));
|
||||
SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
|
||||
if (!pl)
|
||||
{
|
||||
Msg("Plugin %d not found.\n", id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pl->m_Status != Pl_Paused)
|
||||
{
|
||||
Msg("Plugin %d is not unpausable.\n", pl->m_Id);
|
||||
return;
|
||||
}
|
||||
|
||||
char error[255]={0};
|
||||
if (!pl->m_API->Pause(error, sizeof(error)-1))
|
||||
{
|
||||
Msg("Plugin %d refused unpause: %s\n", pl->m_Id, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_SourceHook.UnpausePlugin(pl->m_Id);
|
||||
Msg("\"%s\" has been unpaused.\n", pl->m_API->GetName());
|
||||
|
||||
return;
|
||||
} else {
|
||||
Msg("Usage: meta unpause <id>\n");
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "load") == 0) {
|
||||
if (args >= 3)
|
||||
{
|
||||
const char *file = e->Cmd_Argv(2);
|
||||
char full_path[255];
|
||||
|
||||
if (file[0] == '/' || strcmp(&(file[1]), ":\\") == 0)
|
||||
{
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s", file);
|
||||
} else {
|
||||
const char *ext = UTIL_GetExtension(file);
|
||||
#if defined WIN32 || defined _WIN32
|
||||
ext ? "" : ".dll";
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s\\%s%s", g_ModPath.c_str(), file, ext);
|
||||
#else
|
||||
ext ? "" : "_i486.so";
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s/%s%s", g_ModPath.c_str(), file, ext);
|
||||
#endif
|
||||
}
|
||||
|
||||
char error[255]={0};
|
||||
bool already;
|
||||
SourceMM::CPluginManager::CPlugin *pl;
|
||||
|
||||
PluginId id = g_PluginMngr.Load(full_path, Pl_Console, already, error, sizeof(error)-1);
|
||||
pl = g_PluginMngr.FindById(id);
|
||||
if (!pl || id < Pl_MinId || (pl->m_Status < Pl_Paused))
|
||||
{
|
||||
Msg("Failed to load plugin %s. %s\n", file, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!already)
|
||||
{
|
||||
Msg("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
|
||||
} else {
|
||||
Msg("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
Msg("Usage: meta load <path>\n");
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "unload") == 0) {
|
||||
if (args >= 3)
|
||||
{
|
||||
int id = atoi(e->Cmd_Argv(2));
|
||||
char error[255]={0};
|
||||
|
||||
if (!g_PluginMngr.Unload(id, false, error, sizeof(error)-1))
|
||||
{
|
||||
Msg("Unload failed: %s\n", error);
|
||||
return;
|
||||
}
|
||||
|
||||
Msg("Plugin %d unloaded.\n", id);
|
||||
|
||||
return;
|
||||
} else {
|
||||
Msg("Usage: meta unload <id>\n");
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "force_unload") == 0) {
|
||||
if (args >= 3)
|
||||
{
|
||||
int id = atoi(e->Cmd_Argv(2));
|
||||
char error[255]={0};
|
||||
|
||||
if (!g_PluginMngr.Unload(id, false, error, sizeof(error)-1))
|
||||
{
|
||||
Msg("Force unload failed: %s\n", error);
|
||||
return;
|
||||
}
|
||||
|
||||
Msg("Plugin %d force unloaded.\n", id);
|
||||
|
||||
return;
|
||||
} else {
|
||||
Msg("Usage: meta force_unload <id>\n");
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(command, "clear") == 0) {
|
||||
if (!g_PluginMngr.UnloadAll())
|
||||
{
|
||||
Msg("One or more plugins resisted removal (cleaned anyway).\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Msg("All plugins unloaded.\n");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Msg("Metamod:Source Menu\n");
|
||||
Msg("usage: meta <command> [arguments]\n");
|
||||
Msg(" clear - Unload all plugins forcefully\n");
|
||||
Msg(" credits - About Metamod:Source\n");
|
||||
Msg(" game - Information about GameDLL\n");
|
||||
Msg(" info - Information about a plugin\n");
|
||||
Msg(" list - List plugins\n");
|
||||
Msg(" load - Load a plugin\n");
|
||||
Msg(" pause - Pause a running plugin\n");
|
||||
Msg(" refresh - Reparse plugins file\n");
|
||||
Msg(" unload - Unload a loaded plugin\n");
|
||||
Msg(" unpause - Unpause a paused plugin\n");
|
||||
Msg(" version - Version information\n");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -16,6 +16,8 @@
|
||||
#include "CServerGameClients.h"
|
||||
#include "CHLTVDirector.h"
|
||||
#include "concommands.h"
|
||||
#include "CSmmAPI.h"
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
* @brief Implementation of main SourceMM GameDLL functionality
|
||||
@ -84,9 +86,7 @@ SMM_API void *CreateInterface(const char *name, int *ret)
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
void *d = (g_GameDll.factory)(name, ret);
|
||||
|
||||
return d;
|
||||
META_INTERFACE_MACRO(server, g_GameDll.factory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,6 +179,7 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
return false;
|
||||
}
|
||||
|
||||
//Retrieve the pointers we'll need from the GameDLL
|
||||
IServerGameEnts *serverEnts;
|
||||
IServerGameClients *serverClients;
|
||||
IHLTVDirector *serverHLTV;
|
||||
@ -346,21 +347,21 @@ int LoadPluginsFromFile(const char *file)
|
||||
// the engine's real engineFactory.
|
||||
void *EngineFactory(const char *name, int *ret)
|
||||
{
|
||||
return (g_Engine.engineFactory)(name, ret);
|
||||
META_INTERFACE_MACRO(engine, g_Engine.engineFactory);
|
||||
}
|
||||
|
||||
//Wrapper function. This is called when the GameDLL thinks it's using
|
||||
// the engine's real physicsFactory.
|
||||
void *PhysicsFactory(const char *name, int *ret)
|
||||
{
|
||||
return (g_Engine.physicsFactory)(name, ret);
|
||||
META_INTERFACE_MACRO(physics, g_Engine.physicsFactory);
|
||||
}
|
||||
|
||||
//Wrapper function. This is called when the GameDLL thinks it's using
|
||||
// the engine's real fileSystemFactory.
|
||||
void *FileSystemFactory(const char *name, int *ret)
|
||||
{
|
||||
return (g_Engine.fileSystemFactory)(name, ret);
|
||||
META_INTERFACE_MACRO(fileSystem, g_Engine.fileSystemFactory);
|
||||
}
|
||||
|
||||
void LogMessage(const char *msg, ...)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -25,7 +25,7 @@
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
@ -136,6 +136,12 @@
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sourcemm.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Detect64BitPortabilityProblems="FALSE"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\util.cpp">
|
||||
@ -148,9 +154,6 @@
|
||||
<File
|
||||
RelativePath=".\CHLTVDirector.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CISmmAPI.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\concommands.h">
|
||||
</File>
|
||||
@ -166,6 +169,9 @@
|
||||
<File
|
||||
RelativePath=".\CServerGameEnts.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CSmmAPI.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\oslink.h">
|
||||
</File>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ======== SourceMM ========
|
||||
* Copyright (C) 2004-2005 SourceMM Development Team
|
||||
* Copyright (C) 2004-2005 Metamod:Source Development Team
|
||||
* No warranties of any kind
|
||||
*
|
||||
* License: zlib/libpng
|
||||
@ -18,4 +18,31 @@
|
||||
|
||||
const char *UTIL_GetExtension(const char *file);
|
||||
|
||||
#define META_INTERFACE_MACRO(type, final) \
|
||||
PluginIter i; \
|
||||
void *mret=NULL, *d; \
|
||||
META_RES mres, high=MRES_IGNORED; \
|
||||
g_SmmAPI.SetLastMetaReturn(MRES_IGNORED); \
|
||||
for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++) \
|
||||
{ \
|
||||
if ( (*i) && (*i)->fac_list.##type ) \
|
||||
{ \
|
||||
d = ((*i)->fac_list.##type)(name, ret); \
|
||||
mres = g_SmmAPI.GetLastMetaReturn(); \
|
||||
if (mres > high) \
|
||||
high = mres; \
|
||||
if (mres >= MRES_OVERRIDE) \
|
||||
mret = d; \
|
||||
} \
|
||||
} \
|
||||
if (high == MRES_OVERRIDE) \
|
||||
{ \
|
||||
(final)(name, ret); \
|
||||
return mret; \
|
||||
} else if (high == MRES_SUPERCEDE) { \
|
||||
return mret; \
|
||||
} else { \
|
||||
return (final)(name, ret); \
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_UTIL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user