removed old fakemeta #defines

added better mm version handling
This commit is contained in:
David Anderson 2006-01-27 09:07:04 +00:00
parent 82653094fb
commit 82cb94ab56
4 changed files with 26 additions and 3159 deletions

View File

@ -308,10 +308,9 @@ extern int FF_PluginEnd;
extern int FF_InconsistentFile; extern int FF_InconsistentFile;
extern int FF_ClientAuthorized; extern int FF_ClientAuthorized;
extern bool g_coloredmenus; extern bool g_coloredmenus;
extern int g_mm_vers;
#ifdef FAKEMETA #define MM_CVAR2_VERS 13
extern CFakeMeta g_FakeMeta;
#endif
struct func_s struct func_s
{ {

File diff suppressed because it is too large Load Diff

View File

@ -31,203 +31,7 @@
#ifndef __FAKEMETA_H__ #ifndef __FAKEMETA_H__
#define __FAKEMETA_H__ #define __FAKEMETA_H__
#ifndef FAKEMETA int UnloadMetamodPlugin(void *handle);
int UnloadMetamodPlugin(void *handle); int LoadMetamodPlugin(const char *path, void **handle, PLUG_LOADTIME now);
int LoadMetamodPlugin(const char *path, void **handle, PLUG_LOADTIME now);
#else
// Fake metamod api for modules
#include "CList.h"
// from mplugin.h (metamod)
// Flags to indicate current "load" state of plugin.
// NOTE: order is important, as greater/less comparisons are made.
typedef enum
{
PL_EMPTY = 0, // empty slot
PL_VALID, // has valid info in it
PL_BADFILE, // nonexistent file (open failed),
// or not a valid plugin file (query failed)
PL_OPENED, // dlopened and queried
PL_FAILED, // opened, but failed to attach or unattach
PL_RUNNING, // attached and running
PL_PAUSED, // attached but paused
} PLUG_STATUS;
// from h_export.h (metamod)
// Our GiveFnptrsToDll, called by engine.
typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals);
// *** CFakeMeta
class CFakeMeta
{
private:
// Core tables
/* DLL_FUNCTIONS m_CoreDllFuncTable;
enginefuncs_t m_CoreEngineFuncTable;
NEW_DLL_FUNCTIONS m_CoreNewDllFuncTable;
DLL_FUNCTIONS m_CoreDllFuncTable_Post;
enginefuncs_t m_CoreEngineFuncTable_Post;
NEW_DLL_FUNCTIONS m_CoreNewDllFuncTable_Post; */
bool AddCorePlugin(); // Adds the core plugin if needed
public:
class CFakeMetaPlugin
{
private:
// plugin info
String m_Path;
PLUG_STATUS m_Status;
plugin_info_t *m_Info;
// Function tables
META_FUNCTIONS m_MetaFuncTable;
DLL_FUNCTIONS m_DllFuncTable;
enginefuncs_t m_EngineFuncTable;
NEW_DLL_FUNCTIONS m_NewDllFuncTable;
DLL_FUNCTIONS m_DllFuncTable_Post;
enginefuncs_t m_EngineFuncTable_Post;
NEW_DLL_FUNCTIONS m_NewDllFuncTable_Post;
// OS dep handle
DLHANDLE m_Handle;
public:
inline PLUG_STATUS GetStatus() const
{ return m_Status; }
inline void SetStatus(PLUG_STATUS newStatus)
{ m_Status = newStatus; }
inline plugin_info_t * GetInfo()
{ return m_Info; }
inline const plugin_info_t * GetInfo() const
{ return m_Info; }
inline void SetInfo(plugin_info_t *newInfo)
{ m_Info = newInfo; }
inline const char * GetPath()
{ return m_Path.c_str(); }
inline const META_FUNCTIONS &GetMetaFunctions() const
{ return m_MetaFuncTable; }
// Get
inline DLL_FUNCTIONS &GetDllFuncTable()
{ return m_DllFuncTable; }
inline enginefuncs_t &GetEngineFuncTable()
{ return m_EngineFuncTable; }
inline NEW_DLL_FUNCTIONS &GetNewDllFuncTable()
{ return m_NewDllFuncTable; }
// Get const
inline const DLL_FUNCTIONS &GetDllFuncTable() const
{ return m_DllFuncTable; }
inline const enginefuncs_t &GetEngineFuncTable() const
{ return m_EngineFuncTable; }
inline const NEW_DLL_FUNCTIONS &GetNewDllFuncTable() const
{ return m_NewDllFuncTable; }
// Get post
inline DLL_FUNCTIONS &GetDllFuncTable_Post()
{ return m_DllFuncTable_Post; }
inline enginefuncs_t &GetEngineFuncTable_Post()
{ return m_EngineFuncTable_Post; }
inline NEW_DLL_FUNCTIONS &GetNewDllFuncTable_Post()
{ return m_NewDllFuncTable_Post; }
// Get post const
inline const DLL_FUNCTIONS &GetDllFuncTable_Post() const
{ return m_DllFuncTable_Post; }
inline const enginefuncs_t &GetEngineFuncTable_Post() const
{ return m_EngineFuncTable_Post; }
inline const NEW_DLL_FUNCTIONS &GetNewDllFuncTable_Post() const
{ return m_NewDllFuncTable_Post; }
int Query(mutil_funcs_t *pMetaUtilFuncs); // Also calls GiveFnPtrsToDll
int Attach(PLUG_LOADTIME now, meta_globals_t *pMGlobals, gamedll_funcs_t *pGameDllFuncs);
int Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
int GetEntityAPI2(int interfaceVersion);
int GetEntityAPI2_Post(int interfaceVersion);
int GetEngineFunctions(int interfaceVersion);
int GetEngineFunctions_Post(int interfaceVersion);
int GetNewDLLFunctions(int interfaceVersion);
int GetNewDLLFunctions_Post(int interfaceVersion);
CFakeMetaPlugin(const char *path);
~CFakeMetaPlugin();
}; // CFakeMetaPlugin
CFakeMeta();
~CFakeMeta();
bool AddPlugin(const char *path /*path relative to moddir*/);
void ReleasePlugins();
// This is public because i don't want to declare all the functions as friends :)
// :NOTE: The core is now a special, first plugin!
CList<CFakeMetaPlugin> m_Plugins;
// ****** Meta functions ******
// Query all added plugins
void Meta_Query(mutil_funcs_t *pMetaUtilFuncs);
// Attach all added plugins
void Meta_Attach(PLUG_LOADTIME now, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs);
// Detach all added plugins
void Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
// :NOTE: Meta_Init currently not supported
int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable /*from metamod*/, int *interfaceVersion /*from metamod*/,
DLL_FUNCTIONS *pAMXXFunctionTable /*Functions amxx needs*/);
int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable /*from metamod*/, int *interfaceVersion /*from metamod*/,
DLL_FUNCTIONS *pAMXXFunctionTable /*Functions amxx needs*/);
int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion,
enginefuncs_t *pAMXXFunctionTable /*Fucntions amxx needs*/);
int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion,
enginefuncs_t *pAMXXFunctionTable /*Fucntions amxx needs*/);
int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion,
NEW_DLL_FUNCTIONS *pAMXXFunctionTable);
int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion,
NEW_DLL_FUNCTIONS *pAMXXFunctionTable);
// Get
/*inline DLL_FUNCTIONS &GetDllFuncTable()
{ return m_CoreDllFuncTable; }
inline enginefuncs_t &GetEngineFuncTable()
{ return m_CoreEngineFuncTable; }
inline NEW_DLL_FUNCTIONS &GetNewDllFuncTable()
{ return m_CoreNewDllFuncTable; }
// Get const
inline const DLL_FUNCTIONS &GetDllFuncTable() const
{ return m_CoreDllFuncTable; }
inline const enginefuncs_t &GetEngineFuncTable() const
{ return m_CoreEngineFuncTable; }
inline const NEW_DLL_FUNCTIONS &GetNewDllFuncTable() const
{ return m_CoreNewDllFuncTable; }
// Get post
inline DLL_FUNCTIONS &GetDllFuncTable_Post()
{ return m_CoreDllFuncTable_Post; }
inline enginefuncs_t &GetEngineFuncTable_Post()
{ return m_CoreEngineFuncTable_Post; }
inline NEW_DLL_FUNCTIONS &GetNewDllFuncTable_Post()
{ return m_CoreNewDllFuncTable_Post; }
// Get post const
inline const DLL_FUNCTIONS &GetDllFuncTable_Post() const
{ return m_CoreDllFuncTable_Post; }
inline const enginefuncs_t &GetEngineFuncTable_Post() const
{ return m_CoreEngineFuncTable_Post; }
inline const NEW_DLL_FUNCTIONS &GetNewDllFuncTable_Post() const
{ return m_CoreNewDllFuncTable_Post; } */
}; // CFakeMeta
// Fake Metamod
// defined in meta_api.cpp
extern CFakeMeta g_FakeMeta;
#endif //FAKEMETA
#endif // #ifndef __FAKEMETA_H__ #endif // #ifndef __FAKEMETA_H__

View File

@ -40,9 +40,11 @@
#include "newmenus.h" #include "newmenus.h"
#include "natives.h" #include "natives.h"
#define MIN_COMPAT_MM_VERS "5:11"
plugin_info_t Plugin_info = plugin_info_t Plugin_info =
{ {
META_INTERFACE_VERSION, // ifvers MIN_COMPAT_MM_VERS, // ifvers
"AMX Mod X", // name "AMX Mod X", // name
AMX_VERSION, // version AMX_VERSION, // version
__DATE__, // date __DATE__, // date
@ -107,6 +109,7 @@ bool g_NeedsP = false;
bool g_coloredmenus; bool g_coloredmenus;
bool g_activated = false; bool g_activated = false;
bool g_NewDLL_Available = false; bool g_NewDLL_Available = false;
int g_mm_vers = 0;
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
float g_next_memreport_time; float g_next_memreport_time;
@ -147,11 +150,6 @@ int FF_InconsistentFile = -1;
int FF_ClientAuthorized = -1; int FF_ClientAuthorized = -1;
int FF_ChangeLevel = -1; int FF_ChangeLevel = -1;
// fake metamod api
#ifdef FAKEMETA
CFakeMeta g_FakeMeta;
#endif
// Precache stuff from force consistency calls // Precache stuff from force consistency calls
// or check for pointed files won't be done // or check for pointed files won't be done
int C_PrecacheModel(char *s) int C_PrecacheModel(char *s)
@ -1151,16 +1149,20 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
{ {
gpMetaUtilFuncs = pMetaUtilFuncs; gpMetaUtilFuncs = pMetaUtilFuncs;
*pPlugInfo = &Plugin_info; *pPlugInfo = &Plugin_info;
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
g_mm_vers = mminor;
if (strcmp(ifvers, Plugin_info.ifvers)) if (strcmp(ifvers, Plugin_info.ifvers))
{ {
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers); LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
if (pmajor > mmajor) if (pmajor > mmajor)
{ {
LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod"); LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
@ -1173,42 +1175,19 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
} }
else if (pmajor == mmajor) else if (pmajor == mmajor)
{ {
#ifdef FAKEMETA if (mminor < 11)
if (mminor == 10)
{ {
LOG_MESSAGE(PLID, "WARNING: metamod version is older than expected; consider finding a newer version"); g_NeedsP = true;
g_IsNewMM = false; } else if (pminor > mminor) {
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
//hack! return FALSE;
Plugin_info.ifvers = "5:10"; }
#else
if (mminor < 11)
{
g_NeedsP = true;
#endif
}
else if (mminor >= 11)
{
g_IsNewMM = true;
}
else if (pminor > mminor)
{
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
return FALSE;
}
else if (pminor < mminor)
{
LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this plugin");
if (mminor > 11)
g_IsNewMM = true;
}
} else { } else {
LOG_ERROR(PLID, "unexpected version comparison; metavers=%s, mmajor=%d, mminor=%d; plugvers=%s, pmajor=%d, pminor=%d", ifvers, mmajor, mminor, META_INTERFACE_VERSION, pmajor, pminor); LOG_ERROR(PLID, "unexpected version comparison; metavers=%s, mmajor=%d, mminor=%d; plugvers=%s, pmajor=%d, pminor=%d", ifvers, mmajor, mminor, META_INTERFACE_VERSION, pmajor, pminor);
} }
} else {
g_IsNewMM = true;
} }
if (!g_NeedsP)
g_IsNewMM = true;
// We can set this to null here because Meta_PExtGiveFnptrs is called after this // We can set this to null here because Meta_PExtGiveFnptrs is called after this
gpMetaPExtFuncs = NULL; gpMetaPExtFuncs = NULL;
@ -1253,10 +1232,6 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
gMetaFunctionTable.pfnGetEngineFunctions_Post = GetEngineFunctions_Post; gMetaFunctionTable.pfnGetEngineFunctions_Post = GetEngineFunctions_Post;
gMetaFunctionTable.pfnGetNewDLLFunctions = GetNewDLLFunctions; gMetaFunctionTable.pfnGetNewDLLFunctions = GetNewDLLFunctions;
#ifdef FAKEMETA
gMetaFunctionTable.pfnGetNewDLLFunctions_Post = GetNewDLLFunctions_Post;
#endif
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS)); memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
gpGamedllFuncs=pGamedllFuncs; gpGamedllFuncs=pGamedllFuncs;
@ -1346,12 +1321,6 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
detachModules(); detachModules();
// ###### Now detach metamod modules
#ifdef FAKEMETA
g_FakeMeta.Meta_Detach(now, reason);
g_FakeMeta.ReleasePlugins();
#endif
g_log.CloseFile(); g_log.CloseFile();
Module_UncacheFunctions(); Module_UncacheFunctions();
@ -1446,12 +1415,8 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
gFunctionTable.pfnInconsistentFile = C_InconsistentFile; gFunctionTable.pfnInconsistentFile = C_InconsistentFile;
gFunctionTable.pfnServerActivate = C_ServerActivate; gFunctionTable.pfnServerActivate = C_ServerActivate;
#ifdef FAKEMETA
return g_FakeMeta.GetEntityAPI2(pFunctionTable, interfaceVersion, &gFunctionTable);
#else
memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
return 1; return 1;
#endif
} }
DLL_FUNCTIONS gFunctionTable_Post; DLL_FUNCTIONS gFunctionTable_Post;
@ -1464,12 +1429,8 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
gFunctionTable_Post.pfnStartFrame = C_StartFrame_Post; gFunctionTable_Post.pfnStartFrame = C_StartFrame_Post;
gFunctionTable_Post.pfnServerDeactivate = C_ServerDeactivate_Post; gFunctionTable_Post.pfnServerDeactivate = C_ServerDeactivate_Post;
#ifdef FAKEMETA
return g_FakeMeta.GetEntityAPI2_Post(pFunctionTable, interfaceVersion, &gFunctionTable_Post);
#else
memcpy(pFunctionTable, &gFunctionTable_Post, sizeof(DLL_FUNCTIONS)); memcpy(pFunctionTable, &gFunctionTable_Post, sizeof(DLL_FUNCTIONS));
return 1; return 1;
#endif
} }
enginefuncs_t meta_engfuncs; enginefuncs_t meta_engfuncs;
@ -1491,12 +1452,8 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
meta_engfuncs.pfnPrecacheSound = C_PrecacheSound; meta_engfuncs.pfnPrecacheSound = C_PrecacheSound;
meta_engfuncs.pfnChangeLevel = C_ChangeLevel; meta_engfuncs.pfnChangeLevel = C_ChangeLevel;
#ifdef FAKEMETA
return g_FakeMeta.GetEngineFunctions(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs);
#else
memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t)); memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t));
return 1; return 1;
#endif
} }
enginefuncs_t meta_engfuncs_post; enginefuncs_t meta_engfuncs_post;
@ -1516,12 +1473,8 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
meta_engfuncs_post.pfnAlertMessage = C_AlertMessage_Post; meta_engfuncs_post.pfnAlertMessage = C_AlertMessage_Post;
meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post; meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post;
#ifdef FAKEMETA
return g_FakeMeta.GetEngineFunctions_Post(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs_post);
#else
memcpy(pengfuncsFromEngine, &meta_engfuncs_post, sizeof(enginefuncs_t)); memcpy(pengfuncsFromEngine, &meta_engfuncs_post, sizeof(enginefuncs_t));
return 1; return 1;
#endif
} }
NEW_DLL_FUNCTIONS gNewDLLFunctionTable; NEW_DLL_FUNCTIONS gNewDLLFunctionTable;
@ -1535,20 +1488,7 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
if (g_engfuncs.pfnQueryClientCvarValue) if (g_engfuncs.pfnQueryClientCvarValue)
gNewDLLFunctionTable.pfnCvarValue = C_CvarValue; gNewDLLFunctionTable.pfnCvarValue = C_CvarValue;
#ifdef FAKEMETA
return g_FakeMeta.GetNewDLLFunctions(pNewFunctionTable, interfaceVersion, &gNewDLLFunctionTable);
#else
memcpy(pNewFunctionTable, &gNewDLLFunctionTable, sizeof(NEW_DLL_FUNCTIONS)); memcpy(pNewFunctionTable, &gNewDLLFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
return 1; return 1;
#endif
} }
#ifdef FAKEMETA
NEW_DLL_FUNCTIONS gNewDLLFunctionTable_Post;
C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
{
return g_FakeMeta.GetNewDLLFunctions_Post(pNewFunctionTable, interfaceVersion, &gNewDLLFunctionTable_Post);
memcpy(pNewFunctionTable, &gNewDLLFunctionTable_Post, sizeof(NEW_DLL_FUNCTIONS));
return 1;
}
#endif