diff --git a/PlayerDataDump/PlayerDataDump.cs b/PlayerDataDump/PlayerDataDump.cs
index b6f24c7..4e27a24 100644
--- a/PlayerDataDump/PlayerDataDump.cs
+++ b/PlayerDataDump/PlayerDataDump.cs
@@ -4,7 +4,6 @@
using System.Linq;
using Modding;
using WebSocketSharp.Server;
-using System.Net;
using System.Reflection;
namespace PlayerDataDump
@@ -15,58 +14,43 @@ namespace PlayerDataDump
///
public class PlayerDataDump : Mod
{
- public WebSocketServer Wss = new WebSocketServer(11420);
-
- public static string Version = FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(PlayerDataDump)).Location).FileVersion;
- public static string Current;
+ private readonly WebSocketServer _wss = new WebSocketServer(11420);
+ internal static PlayerDataDump Instance;
///
/// Fetches the list of the current mods installed.
///
public static string GetCurrentMods()
{
- List mods = ModHooks.Instance.loadedMods;
+ List mods = ModHooks.Instance.LoadedMods;
string output = mods.Aggregate("[", (current, mod) => current + $"\"{mod}\",");
output = output.TrimEnd(',') + "]";
return output;
}
///
- /// Fetches current version from the site
+ /// Fetches and compares the compiled version with the version from the site.
///
- /// Version #
- public string GetCurrentVersion()
+ /// Returns the current version. Includes additional text if the current version doesn't match the version of the site.
+ public override string GetVersion() => FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(PlayerDataDump)).Location).FileVersion;
+
+ public override bool IsCurrent()
{
try
{
- WebClient web = new WebClient
- {
- Headers =
- {
- [HttpRequestHeader.UserAgent] =
- "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2"
- },
-
- };
+ GithubVersionHelper helper = new GithubVersionHelper("iamwyza/HollowKnightRandomizerTracker");
+ Version currentVersion = new Version(GetVersion());
- return web.DownloadString("https://iamwyza.github.io/HollowKnightRandomizerTracker/version.txt");
- } catch(Exception e) {
- ModHooks.ModLog(e.ToString());
- return Version;
+ Version newVersion = new Version(helper.GetVersion());
+ LogDebug($"Comparing Versions: {newVersion} > {currentVersion}");
+ return newVersion.CompareTo(currentVersion) < 0;
+ }
+ catch (Exception ex)
+ {
+ LogError("Couldn't check version" + ex);
}
- }
- ///
- /// Fetches and compares the compiled version with the version from the site.
- ///
- /// Returns the current version. Includes additional text if the current version doesn't match the version of the site.
- public override string GetVersion()
- {
- if (Current == null)
- Current = GetCurrentVersion();
- if ( Current == Version )
- return Version;
- return Version + " | UPDATE REQUIRED";
+ return true;
}
///
@@ -74,10 +58,11 @@ public override string GetVersion()
///
public override void Initialize()
{
- ModHooks.ModLog("Initializing PlayerDataDump");
+ Instance = this;
+ Log("Initializing PlayerDataDump");
//Setup websockets server
- Wss.AddWebSocketService("/playerData", ss =>
+ _wss.AddWebSocketService("/playerData", ss =>
{
ModHooks.Instance.NewGameHook += ss.NewGame;
ModHooks.Instance.SavegameLoadHook += ss.LoadSave;
@@ -88,11 +73,11 @@ public override void Initialize()
});
//Setup ProfileStorage Server
- Wss.AddWebSocketService("/ProfileStorage", ss => { });
+ _wss.AddWebSocketService("/ProfileStorage", ss => { });
- Wss.Start();
+ _wss.Start();
- ModHooks.ModLog("Initialized PlayerDataDump");
+ Log("Initialized PlayerDataDump");
}
}
}
diff --git a/PlayerDataDump/PlayerDataDump.csproj b/PlayerDataDump/PlayerDataDump.csproj
index 160de00..e111efc 100644
--- a/PlayerDataDump/PlayerDataDump.csproj
+++ b/PlayerDataDump/PlayerDataDump.csproj
@@ -45,7 +45,7 @@
False
- ..\..\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Assembly-CSharp.dll
+ ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Assembly-CSharp.dll
False
@@ -76,100 +76,4 @@
<_PostBuildHookTimestamp>@(IntermediateAssembly->'%(FullPath).timestamp')
<_PostBuildHookHostPlatform>$(Platform)
-
-
- CommonBuildDefineModifiedAssemblyVersion;
- $(CompileDependsOn);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/PlayerDataDump/ProfileStorageServer.cs b/PlayerDataDump/ProfileStorageServer.cs
index 9713d62..c012cd7 100644
--- a/PlayerDataDump/ProfileStorageServer.cs
+++ b/PlayerDataDump/ProfileStorageServer.cs
@@ -1,5 +1,4 @@
-using Modding;
-using System;
+using System;
using System.IO;
using System.Text;
using UnityEngine;
@@ -21,7 +20,7 @@ public void Broadcast(string s)
protected override void OnMessage(MessageEventArgs e)
{
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] data:" + e.Data);
+ PlayerDataDump.Instance.Log("[ProfileStorage] data:" + e.Data);
if (e.Data.StartsWith("load"))
{
@@ -59,8 +58,8 @@ private static void SaveProfile(int profileId, string base64EncodedJson)
byte[] data = Convert.FromBase64String(base64EncodedJson);
string decodedString = Encoding.UTF8.GetString(data);
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] Path::" + path);
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] Decoded Data:" + decodedString);
+ PlayerDataDump.Instance.Log("[ProfileStorage] Path:" + path);
+ PlayerDataDump.Instance.Log("[ProfileStorage] Decoded Data:" + decodedString);
File.WriteAllText(path, decodedString);
@@ -68,19 +67,19 @@ private static void SaveProfile(int profileId, string base64EncodedJson)
protected override void OnError(WebSocketSharp.ErrorEventArgs e)
{
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] ERROR: " + e.Message);
+ PlayerDataDump.Instance.LogError("[ProfileStorage]:" + e.Message);
}
protected override void OnClose(CloseEventArgs e)
{
base.OnClose(e);
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] CLOSE: Code:" + e.Code + ", Reason:" + e.Reason);
+ PlayerDataDump.Instance.Log("[ProfileStorage] CLOSE: Code:" + e.Code + ", Reason:" + e.Reason);
}
protected override void OnOpen()
{
- ModHooks.ModLog("[PlayerDataDump.ProfileStorage] OPEN");
+ PlayerDataDump.Instance.Log("[ProfileStorage] OPEN");
}
}
}
diff --git a/PlayerDataDump/Properties/AssemblyInfo.cs b/PlayerDataDump/Properties/AssemblyInfo.cs
index b243cfb..1fd94a1 100644
--- a/PlayerDataDump/Properties/AssemblyInfo.cs
+++ b/PlayerDataDump/Properties/AssemblyInfo.cs
@@ -28,5 +28,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("2.3.0.0")]
+[assembly: AssemblyFileVersion("2.3.0.0")]
diff --git a/PlayerDataDump/SocketServer.cs b/PlayerDataDump/SocketServer.cs
index a5e0dd2..61b1878 100644
--- a/PlayerDataDump/SocketServer.cs
+++ b/PlayerDataDump/SocketServer.cs
@@ -42,7 +42,7 @@ protected override void OnMessage(MessageEventArgs e)
Send(PlayerDataDump.GetCurrentMods());
break;
case "version":
- Send(string.Format("{{ \"version\":\"{0}\" }}", PlayerDataDump.Version));
+ Send(string.Format("{{ \"version\":\"{0}\" }}", PlayerDataDump.Instance.GetVersion()));
break;
case "json":
Send(GetJson());
@@ -55,12 +55,12 @@ protected override void OnMessage(MessageEventArgs e)
{
if (e.Data.Split('|')[0] == "bool")
{
- string b = ModHooks.Instance.GetPlayerBool(e.Data.Split('|')[1]).ToString();
+ string b = PlayerData.instance.GetBool(e.Data.Split('|')[1]).ToString();
SendMessage(e.Data.Split('|')[1], b);
}
if (e.Data.Split('|')[0] == "int")
{
- string i = ModHooks.Instance.GetPlayerInt(e.Data.Split('|')[1]).ToString();
+ string i = PlayerData.instance.GetInt(e.Data.Split('|')[1]).ToString();
SendMessage(e.Data.Split('|')[1], i);
}
}
@@ -74,7 +74,7 @@ protected override void OnMessage(MessageEventArgs e)
protected override void OnError(WebSocketSharp.ErrorEventArgs e)
{
- ModHooks.ModLog("[PlayerDataDump] ERROR: " + e.Message);
+ PlayerDataDump.Instance.LogError(e.Message);
}
protected override void OnClose(CloseEventArgs e)
@@ -88,12 +88,12 @@ protected override void OnClose(CloseEventArgs e)
ModHooks.Instance.ApplicationQuitHook -= OnQuit;
- ModHooks.ModLog("[PlayerDataDump] CLOSE: Code:" + e.Code + ", Reason:" + e.Reason);
+ PlayerDataDump.Instance.Log("CLOSE: Code:" + e.Code + ", Reason:" + e.Reason);
}
protected override void OnOpen()
{
- ModHooks.ModLog("[PlayerDataDump] OPEN");
+ PlayerDataDump.Instance.Log("OPEN");
}
public void SendMessage(string var, string value)
@@ -128,9 +128,9 @@ public static string GetJson()
PlayerData playerData = PlayerData.instance;
string json = JsonUtility.ToJson(playerData);
- int randomFireballLevel = ModHooks.Instance.GetPlayerInt("_fireballLevel");
- int randomQuakeLevel = ModHooks.Instance.GetPlayerInt("_quakeLevel");
- int randomScreamLevel = ModHooks.Instance.GetPlayerInt("_screamLevel");
+ int randomFireballLevel = PlayerData.instance.GetInt("_fireballLevel");
+ int randomQuakeLevel = PlayerData.instance.GetInt("_quakeLevel");
+ int randomScreamLevel = PlayerData.instance.GetInt("_screamLevel");
if (randomFireballLevel >= 0)
{