Patch for ifvers 5:11 (new MM API), eliminates fakemeta like mm-pext
This commit is contained in:
parent
e1a1153018
commit
35ed810775
|
@ -137,6 +137,7 @@ struct fakecmd_t {
|
|||
bool fake;
|
||||
};
|
||||
|
||||
extern bool g_IsNewMM;
|
||||
extern pextension_funcs_t *gpMetaPExtFuncs;
|
||||
extern CLog g_log;
|
||||
extern CPluginMngr g_plugins;
|
||||
|
|
|
@ -92,7 +92,6 @@ void CLog::CreateNewFile()
|
|||
int i = 0;
|
||||
while (true)
|
||||
{
|
||||
char file[256];
|
||||
FILE *pTmpFile = fopen(m_LogFile.c_str(), "r"); // open for reading to check whether the file exists
|
||||
if (!pTmpFile)
|
||||
break;
|
||||
|
|
|
@ -2355,7 +2355,7 @@ void FakeMeta_New_CVarRegister(cvar_t *pCVar)
|
|||
int CFakeMeta::CFakeMetaPlugin::Query(mutil_funcs_t *pMetaUtilFuncs)
|
||||
{
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs)
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
//load plugins in meta_attach
|
||||
m_Status = PL_OPENED;
|
||||
|
@ -2429,18 +2429,33 @@ int CFakeMeta::CFakeMetaPlugin::Attach(PLUG_LOADTIME now, meta_globals_t *pMGlob
|
|||
{
|
||||
// evilspy's patch:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(PEXT_LOAD_PLUGIN_BY_NAME(PLID, m_Path.c_str(), now, (void**)&m_Handle) || !m_Handle) {
|
||||
if (gpMetaPExtFuncs)
|
||||
{
|
||||
if(PEXT_LOAD_PLUGIN_BY_NAME(PLID, m_Path.c_str(), now, (void**)&m_Handle) || !m_Handle)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "Can't Attach Module \"%s\".", m_Path.c_str());
|
||||
m_Status = PL_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_Status = PL_RUNNING;
|
||||
return 1;
|
||||
} else if (g_IsNewMM) {
|
||||
int err = 0;
|
||||
if ( (err = LOAD_PLUGIN(PLID, m_Path.c_str(), now, (void **)&m_Handle)) || !m_Handle)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "Can't Attach Module \"%s\".", m_Path.c_str());
|
||||
m_Status = PL_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_Status = PL_RUNNING;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!m_Handle)
|
||||
return 0;
|
||||
|
||||
META_ATTACH_FN attachFn = (META_ATTACH_FN)DLSYM(m_Handle, "Meta_Attach");
|
||||
if (!attachFn)
|
||||
{
|
||||
|
@ -2450,7 +2465,7 @@ int CFakeMeta::CFakeMetaPlugin::Attach(PLUG_LOADTIME now, meta_globals_t *pMGlob
|
|||
}
|
||||
if (attachFn(now, &m_MetaFuncTable, pMGlobals, pGameDllFuncs) != 1)
|
||||
{
|
||||
AMXXLOG_Log("[AMXX] Can't Attach Module \"%s\" (\"%s\").", m_Info->name, m_Path.c_str());
|
||||
LOG_MESSAGE(PLID, "Can't Attach Module \"%s\".", m_Path.c_str());
|
||||
m_Status = PL_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2466,7 +2481,8 @@ int CFakeMeta::CFakeMetaPlugin::Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reaso
|
|||
|
||||
// evilspy's patch:
|
||||
//using metamod p-extensions?
|
||||
if (gpMetaPExtFuncs) {
|
||||
if (gpMetaPExtFuncs)
|
||||
{
|
||||
if(PEXT_UNLOAD_PLUGIN_BY_HANDLE(PLID, (void*)m_Handle, now, reason)) {
|
||||
m_Status = PL_FAILED;
|
||||
return 0;
|
||||
|
@ -2474,6 +2490,15 @@ int CFakeMeta::CFakeMetaPlugin::Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reaso
|
|||
m_Status = PL_OPENED;
|
||||
m_Handle = NULL;
|
||||
return 1;
|
||||
} else if (g_IsNewMM) {
|
||||
if (UNLOAD_PLUGIN_BY_HANDLE(PLID, (void *)m_Handle, now, reason))
|
||||
{
|
||||
m_Status = PL_FAILED;
|
||||
return 0;
|
||||
}
|
||||
m_Status = PL_OPENED;
|
||||
m_Handle = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
META_DETACH_FN detachFn = (META_DETACH_FN)DLSYM(m_Handle, "Meta_Detach");
|
||||
|
@ -2568,7 +2593,7 @@ bool CFakeMeta::AddCorePlugin()
|
|||
{
|
||||
// evilspy:
|
||||
// not needed when using metamod p-extensions
|
||||
if(gpMetaPExtFuncs)
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
return true;
|
||||
|
||||
// Check whether there already is a core plugin
|
||||
|
@ -2595,7 +2620,7 @@ void CFakeMeta::Meta_Query(mutil_funcs_t *pMetaUtilFuncs)
|
|||
|
||||
// evilspy:
|
||||
// using metamod p-extensions?
|
||||
if(!gpMetaPExtFuncs)
|
||||
if(!gpMetaPExtFuncs && !g_IsNewMM)
|
||||
++iter; // Skip core
|
||||
|
||||
for (; iter; ++iter)
|
||||
|
@ -2613,7 +2638,7 @@ void CFakeMeta::Meta_Attach(PLUG_LOADTIME now, meta_globals_t *pMGlobals, gamedl
|
|||
CList<CFakeMetaPlugin>::iterator iter = m_Plugins.begin();
|
||||
// evilspy:
|
||||
// using metamod p-extensions?
|
||||
if(!gpMetaPExtFuncs)
|
||||
if(!gpMetaPExtFuncs && !g_IsNewMM)
|
||||
++iter; // Skip core
|
||||
|
||||
for (; iter; ++iter)
|
||||
|
@ -2629,7 +2654,7 @@ void CFakeMeta::Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||
CList<CFakeMetaPlugin>::iterator iter = m_Plugins.begin();
|
||||
// evilspy:
|
||||
// using metamod p-extensions?
|
||||
if(!gpMetaPExtFuncs)
|
||||
if(!gpMetaPExtFuncs && !g_IsNewMM)
|
||||
++iter; // Skip core
|
||||
|
||||
for (; iter; ++iter)
|
||||
|
@ -2650,7 +2675,8 @@ int CFakeMeta::GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable /*from metamod*/, int
|
|||
|
||||
// evilspy:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pFunctionTable, pAMXXFunctionTable, sizeof( DLL_FUNCTIONS ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2687,7 +2713,8 @@ int CFakeMeta::GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable /*from metamod*/
|
|||
|
||||
// evilspy
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pFunctionTable, pAMXXFunctionTable, sizeof( DLL_FUNCTIONS ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2724,7 +2751,8 @@ int CFakeMeta::GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inter
|
|||
|
||||
// evilspy:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pengfuncsFromEngine, pAMXXFunctionTable, sizeof( enginefuncs_t ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2760,7 +2788,8 @@ int CFakeMeta::GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *
|
|||
|
||||
// evilspy:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pengfuncsFromEngine, pAMXXFunctionTable, sizeof( enginefuncs_t ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2803,7 +2832,8 @@ int CFakeMeta::GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *int
|
|||
|
||||
// evilspy:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pNewFunctionTable, pAMXXFunctionTable, sizeof( NEW_DLL_FUNCTIONS ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2846,7 +2876,8 @@ int CFakeMeta::GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int
|
|||
|
||||
// evilspy:
|
||||
//using metamod p-extensions?
|
||||
if(gpMetaPExtFuncs) {
|
||||
if(gpMetaPExtFuncs || g_IsNewMM)
|
||||
{
|
||||
memcpy( pNewFunctionTable, pAMXXFunctionTable, sizeof( NEW_DLL_FUNCTIONS ) );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ float g_game_timeleft;
|
|||
float g_task_time;
|
||||
float g_auth_time;
|
||||
bool g_initialized = false;
|
||||
bool g_IsNewMM = false;
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
float g_next_memreport_time;
|
||||
|
@ -1025,26 +1026,44 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
|
|||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) {
|
||||
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
|
||||
{
|
||||
gpMetaUtilFuncs=pMetaUtilFuncs;
|
||||
*pPlugInfo=&Plugin_info;
|
||||
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);
|
||||
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
||||
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
|
||||
if(pmajor > mmajor || (pmajor==mmajor && pminor > mminor)) {
|
||||
if(pmajor > mmajor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
|
||||
return(FALSE);
|
||||
}
|
||||
else if(pmajor < mmajor) {
|
||||
} else if(pmajor < mmajor) {
|
||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||
return(FALSE);
|
||||
}
|
||||
else if(pmajor==mmajor && pminor < mminor)
|
||||
} else if (pmajor==mmajor) {
|
||||
if (mminor == 10)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "WARNING: metamod version is older than expected; consider finding a newer version");
|
||||
g_IsNewMM = false;
|
||||
//hack!
|
||||
Plugin_info.ifvers = "5:10";
|
||||
} 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");
|
||||
}
|
||||
LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this plugin");
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
g_IsNewMM = true;
|
||||
}
|
||||
|
||||
// We can set this to null here because Meta_PExtGiveFnptrs is called after this
|
||||
|
@ -1056,8 +1075,10 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
|
|||
|
||||
// evilspy's patch for mm-p ext support
|
||||
// this is called right after Meta_Query
|
||||
C_DLLEXPORT int Meta_PExtGiveFnptrs(int interfaceVersion, pextension_funcs_t *pMetaPExtFuncs) {
|
||||
if(interfaceVersion<META_PEXT_VERSION) {
|
||||
C_DLLEXPORT int Meta_PExtGiveFnptrs(int interfaceVersion, pextension_funcs_t *pMetaPExtFuncs)
|
||||
{
|
||||
if(interfaceVersion<META_PEXT_VERSION)
|
||||
{
|
||||
return(META_PEXT_VERSION);
|
||||
}
|
||||
gpMetaPExtFuncs = pMetaPExtFuncs;
|
||||
|
@ -1065,11 +1086,14 @@ C_DLLEXPORT int Meta_PExtGiveFnptrs(int interfaceVersion, pextension_funcs_t *pM
|
|||
}
|
||||
|
||||
static META_FUNCTIONS gMetaFunctionTable;
|
||||
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) {
|
||||
if(now > Plugin_info.loadable) {
|
||||
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
|
||||
{
|
||||
if(now > Plugin_info.loadable)
|
||||
{
|
||||
LOG_ERROR(PLID, "Can't load plugin right now");
|
||||
return(FALSE);
|
||||
}
|
||||
LOG_MESSAGE(PLID, "gpMetaPExtFuncs=%p, g_IsNewMM=%d", gpMetaPExtFuncs, g_IsNewMM);
|
||||
gpMetaGlobals=pMGlobals;
|
||||
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
|
||||
gMetaFunctionTable.pfnGetEntityAPI2_Post = GetEntityAPI2_Post;
|
||||
|
|
Loading…
Reference in New Issue
Block a user