diff -r eca4db9206e4 -r 36bccf5df521 metamod/mlist.cpp --- a/metamod/mlist.cpp Mon Aug 16 21:40:37 2004 +0000 +++ b/metamod/mlist.cpp Mon Aug 16 21:44:02 2004 +0000 @@ -195,6 +195,33 @@ RETURN_ERRNO(NULL, ME_NOTFOUND); } + +// Find a plugin with same file, logtag, desc or significant +// prefix of file. Uses the platform_match() method of MPlugin. +// meta_errno values: +// - ME_ARGUMENT null prefix +// - ME_NOTFOUND couldn't find a matching plugin +MPlugin *MPluginList::find_match(MPlugin *pmatch) { + int i; + MPlugin *iplug, *pfound; + if(!pmatch) + RETURN_ERRNO(NULL, ME_ARGUMENT); + pfound=NULL; + for(i=0; i < endlist; i++) { + iplug=&plist[i]; + if(pmatch->platform_match(iplug)) { + pfound=iplug; + break; + } + } + + if(pfound) + return(pfound); + else + RETURN_ERRNO(NULL, ME_NOTFOUND); +} + + // Add a plugin to the list. // meta_errno values: // - ME_MAXREACHED reached max plugins @@ -245,6 +272,7 @@ FILE *fp; char line[MAX_STRBUF_LEN]; int n, ln; + MPlugin *pmatch; if(!valid_gamedir_file(inifile)) { META_ERROR("ini: Metamod plugins file empty or missing: %s", inifile); @@ -279,10 +307,23 @@ } // Check for a duplicate - an existing entry with this pathname. if(find(plist[n].pathname)) { + // Should we check platform specific level here? META_ERROR("ini: Skipping duplicate plugin, line %d of %s: %s", ln, inifile, plist[n].pathname); continue; } + // Check for a matching platform with different platform specifics + // level. + if(NULL != (pmatch=find_match(&plist[n]))) { + if(pmatch->pfspecific >= plist[n].pfspecific) { + META_DEBUG(1, ("ini: Skipping plugin, line %d of %s: plugin with higher platform specific level already exists. (%d >= %d)", + n, inifile, pmatch->pfspecific, plist[n].pfspecific)); + continue; + } + META_DEBUG(1, ("ini: Plugin in line %d overrides existing plugin with lower platform specific level %d, ours %d", + n, pmatch->pfspecific, plist[n].pfspecific)); + memset(pmatch, 0, sizeof(MPlugin)); + } plist[n].action=PA_LOAD; META_LOG("ini: Read plugin config for: %s", plist[n].desc); n++;