static void DoInitialPluginLoads() { const char *pluginFile = provider->GetCommandLineValue("mm_pluginsfile", NULL); const char *mmBaseDir = provider->GetCommandLineValue("mm_basedir", NULL); if (!pluginFile) { pluginFile = provider->GetConVarString(mm_pluginsfile); if (pluginFile == NULL) { pluginFile = "addons/metamod/metaplugins.ini"; } } if (!mmBaseDir) { mmBaseDir = provider->GetConVarString(mm_basedir); if (mmBaseDir == NULL) { mmBaseDir = "addons/metamod"; } } char filepath[PATH_SIZE], vdfpath[PATH_SIZE]; g_Metamod.PathFormat(filepath, sizeof(filepath), "%s/%s", mod_path.c_str(), pluginFile); g_Metamod.PathFormat(vdfpath, sizeof(vdfpath), "%s/%s", mod_path.c_str(), mmBaseDir); mm_LoadPlugins(filepath, vdfpath); }
static void mm_HandleLevelShutdown() { #if SOURCE_ENGINE == SE_DOTA DevMsg("MMS: LevelShutdown\n"); #endif if (g_bIsVspBridged && !were_plugins_loaded) { DoInitialPluginLoads(); g_PluginMngr.SetAllLoaded(); were_plugins_loaded = true; in_first_level = true; } if (!in_first_level) { char filepath[PATH_SIZE], vdfpath[PATH_SIZE]; g_Metamod.PathFormat(filepath, sizeof(filepath), "%s/%s", mod_path.c_str(), provider->GetConVarString(mm_pluginsfile)); g_Metamod.PathFormat(vdfpath, sizeof(vdfpath), "%s/%s", mod_path.c_str(), provider->GetConVarString(mm_basedir)); mm_LoadPlugins(filepath, vdfpath); } else { in_first_level = false; } ITER_EVENT(OnLevelShutdown, ()); }
static void Handler_LevelShutdown(void) { if (g_bIsVspBridged && !were_plugins_loaded) { DoInitialPluginLoads(); g_PluginMngr.SetAllLoaded(); were_plugins_loaded = true; in_first_level = true; } if (!in_first_level) { char filepath[PATH_SIZE], vdfpath[PATH_SIZE]; g_Metamod.PathFormat(filepath, sizeof(filepath), "%s/%s", mod_path.c_str(), provider->GetConVarString(mm_pluginsfile)); g_Metamod.PathFormat(vdfpath, sizeof(vdfpath), "%s/%s", mod_path.c_str(), provider->GetConVarString(mm_basedir)); mm_LoadPlugins(filepath, vdfpath); } else { in_first_level = false; } ITER_EVENT(OnLevelShutdown, ()); RETURN_META(MRES_IGNORED); }
static int LoadVDFPluginsFromDir(const char *dir, int &skipped) { bool success, skip; int total = 0; char path[MAX_PATH]; char relpath[MAX_PATH * 2]; skipped = 0; #if defined _MSC_VER HANDLE hFind; WIN32_FIND_DATA fd; char error[255]; g_Metamod.PathFormat(path, sizeof(path), "%s\\*.vdf", dir); if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE) { DWORD dw = GetLastError(); if (dw == ERROR_FILE_NOT_FOUND) return 0; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error, sizeof(error), NULL); mm_LogMessage("[META] Could not open folder \"%s\" (%s)", dir, error); return 0; } do { g_Metamod.PathFormat(path, sizeof(path), "%s\\%s", dir, fd.cFileName); UTIL_Relatize(relpath, sizeof(relpath), mod_path.c_str(), path); success = ProcessVDF(relpath, skip); if (skip) skipped++; else if (success) total++; } while (FindNextFile(hFind, &fd)); FindClose(hFind); #else DIR *pDir; struct dirent *pEnt; int extidx; if ((pDir = opendir(dir)) == NULL) { mm_LogMessage("[META] Could not open folder \"%s\" (%s)", dir, strerror(errno)); return 0; } while ((pEnt = readdir(pDir)) != NULL) { if (strcmp(pEnt->d_name, ".") == 0 || strcmp(pEnt->d_name, "..") == 0) { continue; } extidx = strlen(pEnt->d_name) - 4; if (extidx < 0 || stricmp(&pEnt->d_name[extidx], ".vdf")) { continue; } g_Metamod.PathFormat(path, sizeof(path), "%s/%s", dir, pEnt->d_name); UTIL_Relatize(relpath, sizeof(relpath), mod_path.c_str(), path); success = ProcessVDF(relpath, skip); if (skip) skipped++; else if (success) total++; } closedir(pDir); #endif return total; }