Decompiled source of OldSaveDataFix v1.0.0

OldSaveDataFix.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WildSkies.Service;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OldSaveDataFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OldSaveDataFix")]
[assembly: AssemblyTitle("OldSaveDataFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OldSaveDataFix
{
	[BepInPlugin("OldSaveDataFix", "OldSaveDataFix", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("OldSaveDataFix");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		[HarmonyPatch(typeof(SteamPlatform), "LoadData")]
		[HarmonyPrefix]
		public static bool SteamPlatform_LoadData(SteamPlatform __instance, int saveslot, string key, Guid requestId)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			string saveData = default(string);
			if (!__instance.LoadFromFile(saveslot, key, ref saveData) && SteamPlatform_LoadFromFile(__instance, saveslot, key, out saveData))
			{
				__instance.WriteToFile(saveslot, key, saveData);
			}
			if (!string.IsNullOrEmpty(saveData))
			{
				PlatformLoadCallback saveDataLoaded = ((PlatformService)__instance).SaveDataLoaded;
				if (saveDataLoaded != null)
				{
					saveDataLoaded.Invoke(true, key, saveData, saveslot, requestId);
				}
			}
			else
			{
				PlatformLoadCallback saveDataLoaded2 = ((PlatformService)__instance).SaveDataLoaded;
				if (saveDataLoaded2 != null)
				{
					saveDataLoaded2.Invoke(false, key, string.Empty, saveslot, requestId);
				}
			}
			return false;
		}

		private static bool SteamPlatform_LoadFromFile(SteamPlatform __instance, int saveSlot, string key, out string saveData)
		{
			string text = __instance.GeneratePath(saveSlot, key);
			if (File.Exists(text))
			{
				try
				{
					saveData = File.ReadAllText(text);
					return true;
				}
				catch (Exception value)
				{
					saveData = string.Empty;
					Debug.LogError(Object.op_Implicit($"Failed to load from {text} with exception {value}"));
					return false;
				}
			}
			saveData = string.Empty;
			Debug.LogWarning(Object.op_Implicit("Failed to load from " + text));
			return false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "OldSaveDataFix";

		public const string PLUGIN_NAME = "OldSaveDataFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}