/// <summary> /// Enables AI. /// </summary> protected override void ApplyAI() { string strPluginsPath = GameMode.PluginDirectory; foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Oblivion - *.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("DLC*.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Knights.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } string strIniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", strIniPath); FileUtil.ForceDelete(Path.Combine(strPluginsPath, "archiveinvalidation.txt")); FileUtil.ForceDelete(Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallationPath, "obmm"), AI_BSA)); File.WriteAllBytes(Path.Combine(strPluginsPath, AI_BSA), new byte[] { 0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 }); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", GetBSAList(true), strIniPath); }
/// <summary> /// Gets the list of BSA files in the Fallout INI file. /// </summary> /// <param name="p_booInsertAI">Whether to insert the AI BSA into the returned list.</param> /// <returns>The list of BSA files in the Fallout INI file.</returns> private string GetBSAList(bool p_booInsertAI) { string strFalloutIniPath = GameMode.SettingsFiles.IniPath; List <string> bsas = new List <string>(IniMethods.GetPrivateProfileString("Archive", "SArchiveList", null, strFalloutIniPath).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); List <string> lstNewBSAs = new List <string>(); for (int i = 0; i < bsas.Count; i++) { bsas[i] = bsas[i].Trim(' '); if (bsas[i] == OLD_AI_BSA) { continue; } if (bsas[i].Contains("Misc")) { lstNewBSAs.Insert(0, bsas[i]); } else if (bsas[i] != AI_BSA) { lstNewBSAs.Add(bsas[i]); } } if (p_booInsertAI) { lstNewBSAs.Insert(0, AI_BSA); } return(string.Join(", ", lstNewBSAs.ToArray())); }
/// <summary> /// Disables AI. /// </summary> protected override void RemoveAI() { string strIniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "ArchiveInvalidation.txt", strIniPath); FileUtil.ForceDelete(Path.Combine(GameMode.PluginDirectory, AI_BSA)); FileUtil.ForceDelete(Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallationPath, "obmm"), AI_BSA)); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", GetBSAList(false), strIniPath); }
/// <summary> /// Writes the given value to both the Fallout INI file and the default Fallout INI file. /// </summary> /// <param name="p_strSection">The section containing the key whose value is to be written.</param> /// <param name="p_strValueKey">The key whose value is to be written.</param> /// <param name="p_strValue">The value to write.</param> private void WriteIniString(string p_strSection, string p_strValueKey, string p_strValue) { IniMethods.WritePrivateProfileString(p_strSection, p_strValueKey, p_strValue, GameMode.SettingsFiles.IniPath); string strIniPath = ((FalloutNVSettingsFiles)GameMode.SettingsFiles).FODefaultIniPath; if (File.Exists(strIniPath)) { IniMethods.WritePrivateProfileString(p_strSection, p_strValueKey, p_strValue, strIniPath); } }
/// <summary> /// Gets whether AI is enabled. /// </summary> /// <returns><c>true</c> if AI is enabled; /// <c>false</c> otherwise.</returns> public override bool IsActive() { string strFalloutIniPath = GameMode.SettingsFiles.IniPath; if (!File.Exists(strFalloutIniPath)) { return(false); } return(IniMethods.GetPrivateProfileInt32("Archive", "bInvalidateOlderFiles", 0, strFalloutIniPath) != 0); }
/// <summary> /// Disables AI. /// </summary> protected override void RemoveAI() { string strFalloutIniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 0, strFalloutIniPath); IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 0, strFalloutIniPath); IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "ArchiveInvalidation.txt", strFalloutIniPath); File.Delete(Path.Combine(GameMode.PluginDirectory, AI_BSA)); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", GetBSAList(), strFalloutIniPath); }
/// <summary> /// Gets the list of BSA files in the INI file. /// </summary> /// <returns>The list of BSA files in the INI file.</returns> private List <string> GetBSAList() { string strIniPath = ((OblivionGameMode)GameMode).SettingsFiles.IniPath; List <string> lstBsas = new List <string>(IniMethods.GetPrivateProfileString("Archive", "SArchiveList", null, strIniPath).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); for (int i = 0; i < lstBsas.Count; i++) { lstBsas[i] = lstBsas[i].Trim(' '); } return(lstBsas); }
/// <summary> /// Gets whether AI is enabled. /// </summary> /// <returns><c>true</c> if AI is enabled; /// <c>false</c> otherwise.</returns> public override bool IsActive() { string strFalloutIniPath = GameMode.SettingsFiles.IniPath; if (!File.Exists(strFalloutIniPath)) { return(false); } List <string> bsas = new List <string>((IniMethods.GetPrivateProfileString("Archive", "SArchiveList", null, strFalloutIniPath) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); Int32 intInvalidate = IniMethods.GetPrivateProfileInt32("Archive", "bInvalidateOlderFiles", 0, strFalloutIniPath); return(bsas.Contains(AI_BSA) || (intInvalidate != 0)); }
/// <summary> /// Registers the BSA in the game's BSA list. /// </summary> /// <param name="p_strBsaPath">The BSA to register.</param> public void RegisterBSA(string p_strBsaPath) { List <string> lstBsas = GetBSAList(); string strFixedPath = GameMode.GetModFormatAdjustedPath(Mod.Format, p_strBsaPath); if (lstBsas.Contains(strFixedPath, StringComparer.OrdinalIgnoreCase)) { return; } lstBsas.Add(strFixedPath); string strIniPath = ((OblivionGameMode)GameMode).SettingsFiles.IniPath; IniMethods.WritePrivateProfileString("Archive", "SArchiveList", String.Join(", ", lstBsas.ToArray()), strIniPath); }
/// <summary> /// Unregisters the BSA in the game's BSA list. /// </summary> /// <param name="p_strBsaPath">The BSA to unregister.</param> public void UnregisterBSA(string p_strBsaPath) { List <string> lstBsas = GetBSAList(); string strFixedPath = GameMode.GetModFormatAdjustedPath(Mod.Format, p_strBsaPath, true); Int32 intIndex = lstBsas.IndexOf(strFixedPath, StringComparer.OrdinalIgnoreCase); if (intIndex < 0) { return; } lstBsas.RemoveAt(intIndex); string strIniPath = ((OblivionGameMode)GameMode).SettingsFiles.IniPath; IniMethods.WritePrivateProfileString("Archive", "SArchiveList", String.Join(", ", lstBsas.ToArray()), strIniPath); }
/// <summary> /// Gets the list of BSA files in the Fallout INI file. /// </summary> /// <returns>he list of BSA files in the Fallout INI file.</returns> private string GetBSAList() { string strFalloutIniPath = GameMode.SettingsFiles.IniPath; List <string> bsas = new List <string>(IniMethods.GetPrivateProfileString("Archive", "SArchiveList", null, strFalloutIniPath).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); for (int i = 0; i < bsas.Count; i++) { bsas[i] = bsas[i].Trim(' '); if (bsas[i] == AI_BSA) { bsas.RemoveAt(i--); } } return(string.Join(", ", bsas.ToArray())); }
/// <summary> /// Enables AI. /// </summary> protected override void ApplyAI() { var pluginsPath = GameMode.PluginDirectory; try { foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Oblivion - *.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("DLC*.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Knights.bsa")) { fi.LastWriteTime = new DateTime(2005, 10, 1); } var iniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", iniPath); FileUtil.ForceDelete(Path.Combine(pluginsPath, "archiveinvalidation.txt")); FileUtil.ForceDelete( Path.Combine(Path.Combine(GameMode.GameModeEnvironmentInfo.InstallationPath, "obmm"), AI_BSA)); File.WriteAllBytes(Path.Combine(pluginsPath, AI_BSA), new byte[] { 0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 }); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", GetBSAList(true), iniPath); } catch (Exception ex) { Trace.TraceError("ApplyAI - Could not apply ArchiveInvalidation."); TraceUtil.TraceException(ex); MessageBox.Show( "Could not apply Archive Invalidation, at least one file could not be modified.\n" + "Please try again, or check trace log for more info.\n\n" + ex.Message, "Archive Invalidation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Enables AI. /// </summary> protected override void ApplyAI() { string strPluginsPath = GameMode.PluginDirectory; foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Fallout - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 1); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Anchorage - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 2); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("ThePitt - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 3); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("BrokenSteel - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 4); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("PointLookout - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 5); } foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Zeta - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 6); } string strFalloutIniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 1, strFalloutIniPath); IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 1, strFalloutIniPath); IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", strFalloutIniPath); File.Delete(Path.Combine(strPluginsPath, "archiveinvalidation.txt")); File.WriteAllBytes(Path.Combine(strPluginsPath, AI_BSA), new byte[] { 0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x61, 0x00, 0x01, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00 }); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", AI_BSA + ", " + GetBSAList(), strFalloutIniPath); }
/// <summary> /// Enables AI. /// </summary> protected override void ApplyAI() { var pluginsPath = GameMode.PluginDirectory; try { foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Fallout - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 1); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Anchorage - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 2); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("ThePitt - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 3); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("BrokenSteel - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 4); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("PointLookout - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 5); } foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Zeta - *.bsa")) { fi.LastWriteTime = new DateTime(2008, 10, 6); } var falloutIniPath = GameMode.SettingsFiles.IniPath; IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 1, falloutIniPath); IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 1, falloutIniPath); IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", falloutIniPath); File.Delete(Path.Combine(pluginsPath, "archiveinvalidation.txt")); File.WriteAllBytes(Path.Combine(pluginsPath, AI_BSA), new byte[] { 0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x61, 0x00, 0x01, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00 }); IniMethods.WritePrivateProfileString("Archive", "SArchiveList", AI_BSA + ", " + GetBSAList(), falloutIniPath); } catch (Exception ex) { Trace.TraceError("ApplyAI - Could not apply ArchiveInvalidation."); TraceUtil.TraceException(ex); MessageBox.Show( "Could not apply Archive Invalidation, at least one file could not be modified.\n" + "Please try again, or check trace log for more info.\n\n" + ex.Message, "Archive Invalidation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }