1.1 --- a/metamod/mlist.cpp Mon Aug 16 21:40:37 2004 +0000
1.2 +++ b/metamod/mlist.cpp Mon Aug 16 21:44:02 2004 +0000
1.3 @@ -195,6 +195,33 @@
1.4 RETURN_ERRNO(NULL, ME_NOTFOUND);
1.5 }
1.6
1.7 +
1.8 +// Find a plugin with same file, logtag, desc or significant
1.9 +// prefix of file. Uses the platform_match() method of MPlugin.
1.10 +// meta_errno values:
1.11 +// - ME_ARGUMENT null prefix
1.12 +// - ME_NOTFOUND couldn't find a matching plugin
1.13 +MPlugin *MPluginList::find_match(MPlugin *pmatch) {
1.14 + int i;
1.15 + MPlugin *iplug, *pfound;
1.16 + if(!pmatch)
1.17 + RETURN_ERRNO(NULL, ME_ARGUMENT);
1.18 + pfound=NULL;
1.19 + for(i=0; i < endlist; i++) {
1.20 + iplug=&plist[i];
1.21 + if(pmatch->platform_match(iplug)) {
1.22 + pfound=iplug;
1.23 + break;
1.24 + }
1.25 + }
1.26 +
1.27 + if(pfound)
1.28 + return(pfound);
1.29 + else
1.30 + RETURN_ERRNO(NULL, ME_NOTFOUND);
1.31 +}
1.32 +
1.33 +
1.34 // Add a plugin to the list.
1.35 // meta_errno values:
1.36 // - ME_MAXREACHED reached max plugins
1.37 @@ -245,6 +272,7 @@
1.38 FILE *fp;
1.39 char line[MAX_STRBUF_LEN];
1.40 int n, ln;
1.41 + MPlugin *pmatch;
1.42
1.43 if(!valid_gamedir_file(inifile)) {
1.44 META_ERROR("ini: Metamod plugins file empty or missing: %s", inifile);
1.45 @@ -279,10 +307,23 @@
1.46 }
1.47 // Check for a duplicate - an existing entry with this pathname.
1.48 if(find(plist[n].pathname)) {
1.49 + // Should we check platform specific level here?
1.50 META_ERROR("ini: Skipping duplicate plugin, line %d of %s: %s",
1.51 ln, inifile, plist[n].pathname);
1.52 continue;
1.53 }
1.54 + // Check for a matching platform with different platform specifics
1.55 + // level.
1.56 + if(NULL != (pmatch=find_match(&plist[n]))) {
1.57 + if(pmatch->pfspecific >= plist[n].pfspecific) {
1.58 + META_DEBUG(1, ("ini: Skipping plugin, line %d of %s: plugin with higher platform specific level already exists. (%d >= %d)",
1.59 + n, inifile, pmatch->pfspecific, plist[n].pfspecific));
1.60 + continue;
1.61 + }
1.62 + META_DEBUG(1, ("ini: Plugin in line %d overrides existing plugin with lower platform specific level %d, ours %d",
1.63 + n, pmatch->pfspecific, plist[n].pfspecific));
1.64 + memset(pmatch, 0, sizeof(MPlugin));
1.65 + }
1.66 plist[n].action=PA_LOAD;
1.67 META_LOG("ini: Read plugin config for: %s", plist[n].desc);
1.68 n++;