diff --git a/FinalSolution/App.config b/FinalSolution/App.config
index 6c9abe6..fb037fc 100644
--- a/FinalSolution/App.config
+++ b/FinalSolution/App.config
@@ -16,6 +16,12 @@
False
+
+ True
+
+
+ True
+
\ No newline at end of file
diff --git a/FinalSolution/Config.cs b/FinalSolution/Config.cs
index 1ccff3a..efabd56 100644
--- a/FinalSolution/Config.cs
+++ b/FinalSolution/Config.cs
@@ -18,7 +18,14 @@ namespace FinalSolution
{
if (File.Exists(path))
{
- return _instance = JsonConvert.DeserializeObject(File.ReadAllText(path));
+ var data = JsonConvert.DeserializeObject(File.ReadAllText(path));
+
+ // check if the currently running game path is equal to the config-ed one.
+ // need manually enable in the FinalSolution.exe.config!
+ // require ForceCreateNewFilter to work as intended!!
+ VerifyGamePath(data);
+
+ return _instance = data;
}
MessageBox.Show(Resources.Config_ReadConfig_Awareness, Resources.Config_ReadConfig_Awareness_Title);
@@ -81,12 +88,25 @@ namespace FinalSolution
Console.WriteLine(dialog.FileName);
appPath = dialog.FileName;
}
+
+ private static void VerifyGamePath(ConfigData data)
+ {
+ if (!Settings.Default.AutoUpdateGamePath) return;
+
+ // if the game path is not set; this must be something wrong!
+ if (data.Destiny2Path == null) return;
+
+ var curr = FindGameRunning();
+ if (curr == null || curr == data.Destiny2Path) return;
+
+ Console.WriteLine(Resources.Config_VerifyGamePath, data.Destiny2Path, curr);
+ data.Destiny2Path = curr;
+ }
}
public class ConfigData
{
public string Destiny2Path;
public Dictionary Hotkeys;
- public bool ShouldAllocConsole = false;
}
}
\ No newline at end of file
diff --git a/FinalSolution/MainForm.Designer.cs b/FinalSolution/MainForm.Designer.cs
index cd6f58b..4999e77 100644
--- a/FinalSolution/MainForm.Designer.cs
+++ b/FinalSolution/MainForm.Designer.cs
@@ -186,10 +186,12 @@ namespace FinalSolution
//
// positionWorker
//
+ this.positionWorker.WorkerSupportsCancellation = true;
this.positionWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.positionWorker_DoWork);
//
// timerWorker
//
+ this.timerWorker.WorkerSupportsCancellation = true;
this.timerWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.timerWorker_DoWork);
//
// MainForm
diff --git a/FinalSolution/NetLimiterBridge.cs b/FinalSolution/NetLimiterBridge.cs
index 54fc2f4..ab4bdc3 100644
--- a/FinalSolution/NetLimiterBridge.cs
+++ b/FinalSolution/NetLimiterBridge.cs
@@ -1,5 +1,7 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
+using FinalSolution.Properties;
using NetLimiter.Service;
namespace FinalSolution
@@ -27,15 +29,7 @@ namespace FinalSolution
{
var cli = GetClient();
var name = GetFilterNameFor(portName, upload);
- var filter = cli.Filters.FirstOrDefault(f => f.Name == name) ??
- cli.AddFilter(new Filter(name)
- {
- Functions =
- {
- new FFPathEqual(Config.Instance.Destiny2Path),
- new FFRemotePortInRange(new PortRangeFilterValue(portStart, portEnd))
- }
- });
+ var filter = GetOrCreateFilter(name, new PortRangeFilterValue(portStart, portEnd));
var hotkey = Config.Instance.Hotkeys[name];
return new FilterHandle(name, filter, cli, upload, 1, hotkey);
@@ -45,18 +39,39 @@ namespace FinalSolution
{
var cli = GetClient();
var name = GetFilterNameFor("fg");
- var filter = cli.Filters.FirstOrDefault(f => f.Name == name)
- ??
- cli.AddFilter(new Filter(name)
- {
- Functions = { new FFPathEqual(Config.Instance.Destiny2Path) }
- });
+ var filter = GetOrCreateFilter(name, null);
var hotkey = Config.Instance.Hotkeys[name];
return new FilterHandle(name, filter, cli, false, 811, hotkey);
}
+ private static Filter GetOrCreateFilter(string name, PortRangeFilterValue port)
+ {
+ var existing = GetClient().Filters.FirstOrDefault(f => f.Name == name);
+
+ // remove existing filter if required, or return
+ if (existing != null && Settings.Default.ForceCreateNewFilter) GetClient().RemoveFilter(existing);
+ else return existing;
+
+ if (port == null) // if port is null, create a full game filter
+ {
+ return GetClient().AddFilter(new Filter(name)
+ {
+ Functions = { new FFPathContains(Config.Instance.Destiny2Path) }
+ });
+ }
+
+ return GetClient().AddFilter(new Filter(name)
+ {
+ Functions =
+ {
+ new FFPathContains(Config.Instance.Destiny2Path),
+ new FFRemotePortInRange(port)
+ }
+ });
+ }
+
public static readonly FilterHandle F3074;
public static readonly FilterHandle F3074Ul;
public static readonly FilterHandle F7500;
@@ -66,6 +81,11 @@ namespace FinalSolution
static NetLimiterBridge()
{
+ if (Settings.Default.ForceCreateNewFilter)
+ {
+ Console.WriteLine(Resources.NetLimiterBridge_NetLimiterBridge_ForceNewFilter);
+ }
+
F3074 = CreateFilter("3074", 3074, 3074);
F3074Ul = CreateFilter("3074", 3074, 3074, true);
F7500 = CreateFilter("7500", 7500, 7509);
diff --git a/FinalSolution/Program.cs b/FinalSolution/Program.cs
index cdd69b1..4b81a4f 100644
--- a/FinalSolution/Program.cs
+++ b/FinalSolution/Program.cs
@@ -16,7 +16,7 @@ namespace FinalSolution
[STAThread]
static void Main()
{
- if (Config.Instance.ShouldAllocConsole || Settings.Default.AllocConsole) // should open a console box
+ if (Settings.Default.AllocConsole) // should open a console box
{
NativeUtils.AllocConsole();
Console.WriteLine(@"Hello from the Children of Planet Earth!");
diff --git a/FinalSolution/Properties/Resources.Designer.cs b/FinalSolution/Properties/Resources.Designer.cs
index 997a591..fd150d9 100644
--- a/FinalSolution/Properties/Resources.Designer.cs
+++ b/FinalSolution/Properties/Resources.Designer.cs
@@ -112,6 +112,24 @@ namespace FinalSolution.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Updated Game Path from {0} to {1}.
+ ///
+ internal static string Config_VerifyGamePath {
+ get {
+ return ResourceManager.GetString("Config_VerifyGamePath", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Forcedly Create New Filters.
+ ///
+ internal static string NetLimiterBridge_NetLimiterBridge_ForceNewFilter {
+ get {
+ return ResourceManager.GetString("NetLimiterBridge_NetLimiterBridge_ForceNewFilter", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Unexpected error occurred while you using Final Solution! A debug information is generated to {0}.
///
diff --git a/FinalSolution/Properties/Resources.resx b/FinalSolution/Properties/Resources.resx
index 821bb35..18556b5 100644
--- a/FinalSolution/Properties/Resources.resx
+++ b/FinalSolution/Properties/Resources.resx
@@ -140,4 +140,10 @@ Finally, Final Solution is closed-sourced but free-to-use. If you bought it from
Unexpected error occurred while you using Final Solution! A debug information is generated to {0}
+
+ Forcedly Create New Filters
+
+
+ Updated Game Path from {0} to {1}
+
\ No newline at end of file
diff --git a/FinalSolution/Properties/Resources.zh-hans.resx b/FinalSolution/Properties/Resources.zh-hans.resx
index 0b25187..a1f6a6b 100644
--- a/FinalSolution/Properties/Resources.zh-hans.resx
+++ b/FinalSolution/Properties/Resources.zh-hans.resx
@@ -37,4 +37,10 @@
执行最终解决方案时发生了未知错误,崩溃信息存储在{0}。
+
+ 强制创建新过滤规则
+
+
+ 更新了游戏路劲,旧路径 {0},新路径 {1}
+
\ No newline at end of file
diff --git a/FinalSolution/Properties/Settings.Designer.cs b/FinalSolution/Properties/Settings.Designer.cs
index cb094ff..b02fc7b 100644
--- a/FinalSolution/Properties/Settings.Designer.cs
+++ b/FinalSolution/Properties/Settings.Designer.cs
@@ -33,5 +33,29 @@ namespace FinalSolution.Properties {
this["AllocConsole"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool ForceCreateNewFilter {
+ get {
+ return ((bool)(this["ForceCreateNewFilter"]));
+ }
+ set {
+ this["ForceCreateNewFilter"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool AutoUpdateGamePath {
+ get {
+ return ((bool)(this["AutoUpdateGamePath"]));
+ }
+ set {
+ this["AutoUpdateGamePath"] = value;
+ }
+ }
}
}
diff --git a/FinalSolution/Properties/Settings.settings b/FinalSolution/Properties/Settings.settings
index 16942b9..79bccbc 100644
--- a/FinalSolution/Properties/Settings.settings
+++ b/FinalSolution/Properties/Settings.settings
@@ -7,6 +7,12 @@
False
+
+ True
+
+
+ True
+