static bool ProcessVDF(const char *path, bool &skipped) { PluginId id; bool already; char alias[24], file[255], full_path[255], error[255]; if (!provider->ProcessVDF(path, file, sizeof(file), alias, sizeof(alias))) { skipped = false; return false; } if (alias[0] != '\0') g_PluginMngr.SetAlias(alias, file); g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path)); id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error)); skipped = already; if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused) { mm_LogMessage("[META] Failed to load plugin %s: %s", file, error); return false; } return true; }
static int LoadPluginsFromFile(const char *filepath, int &skipped) { FILE *fp; int total = 0; PluginId id; bool already; skipped = 0; fp = fopen(filepath, "rt"); if (!fp) { return 0; } char buffer[255], error[255], full_path[PATH_SIZE]; const char *file; size_t length; while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL) { UTIL_TrimLeft(buffer); UTIL_TrimRight(buffer); length = strlen(buffer); if (!length) { continue; } if (buffer[0] == '\0' || buffer[0] == ';' || strncmp(buffer, "//", 2) == 0) { continue; } file = buffer; if (buffer[0] == '"') { char *cptr = buffer; file = ++cptr; while (*cptr) { if (*cptr == '"') { *cptr = '\0'; break; } cptr++; } } else { char *cptr = buffer; while (*cptr) { if (isspace(*cptr)) { char *optr = cptr; while (*cptr && isspace(*cptr)) { cptr++; } *optr = '\0'; UTIL_TrimRight(cptr); if (*cptr && isalpha(*cptr)) { g_PluginMngr.SetAlias(buffer, cptr); file = cptr; } break; } cptr++; } } if (!file[0]) { continue; } g_Metamod.GetFullPluginPath(file, full_path, sizeof(full_path)); id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error)); if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused) { mm_LogMessage("[META] Failed to load plugin %s. %s", buffer, error); } else { if (already) skipped++; else total++; } } fclose(fp); return total; }