Skip to content

Commit e811cc1

Browse files
committed
Updated interops to 2.14.0.14524
1 parent 6c092b8 commit e811cc1

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

PolyMod.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
https://polymod.dev/nuget/v3/index.json;
1111
</RestoreAdditionalProjectSources>
1212
<Configurations>IL2CPP</Configurations>
13-
<Version>1.2.0-pre</Version>
14-
<PolytopiaVersion>2.13.0.14218</PolytopiaVersion>
13+
<Version>1.2.0-pre.1</Version>
14+
<PolytopiaVersion>2.14.0.14524</PolytopiaVersion>
1515
<Authors>PolyModdingTeam</Authors>
1616
<Description>The Battle of Polytopia's mod loader.</Description>
1717
<NoWarn>IDE0130</NoWarn>
@@ -24,7 +24,7 @@
2424
<PrivateAssets>all</PrivateAssets>
2525
</PackageReference>
2626
<PackageReference Include="Scriban" Version="6.2.1" />
27-
<PackageReference Include="TheBattleOfPolytopia" Version="$(PolytopiaVersion)-738" />
27+
<PackageReference Include="TheBattleOfPolytopia" Version="$(PolytopiaVersion)" />
2828
<EmbeddedResource Include="resources\*.*" />
2929
</ItemGroup>
3030

src/Managers/Compatibility.cs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using HarmonyLib;
2+
using Polytopia.IO;
23
using System.Text;
34
using UnityEngine;
45
using UnityEngine.EventSystems;
@@ -79,6 +80,32 @@ private static bool CheckSignatures(Action<int, BaseEventData> action, int id, B
7980
return true;
8081
}
8182

83+
/// <summary>
84+
/// Restores removed polytopia method which lets you get all guids of single player sessions.
85+
/// </summary>
86+
private static Il2CppSystem.Guid[] GetSinglePlayerSessions() // CHECKMATE MIDJIWAN
87+
{
88+
string saveDirectoryPath = Paths.GetSaveDirectoryPath("Singleplayer");
89+
if (PolytopiaDirectory.Exists(saveDirectoryPath))
90+
{
91+
string[] files = PolytopiaDirectory.GetFiles(saveDirectoryPath, "*.state");
92+
if (files != null && files.Length != 0)
93+
{
94+
List<Il2CppSystem.Guid> list = new List<Il2CppSystem.Guid>(files.Length);
95+
for (int i = 0; i < files.Length; i++)
96+
{
97+
Il2CppSystem.Guid guid;
98+
if (Il2CppSystem.Guid.TryParse(Path.GetFileNameWithoutExtension(files[i]), out guid))
99+
{
100+
list.Add(guid);
101+
}
102+
}
103+
return list.ToArray();
104+
}
105+
}
106+
return new Il2CppSystem.Guid[] { };
107+
}
108+
82109
/// <summary>
83110
/// Performs compatibility checks when the start screen is shown.
84111
/// </summary>
@@ -146,7 +173,7 @@ private static bool GameInfoPopup_OnMainButtonClicked(GameInfoPopup __instance,
146173
[HarmonyPatch(typeof(StartScreen), nameof(StartScreen.OnResumeButtonClick))]
147174
private static bool StartScreen_OnResumeButtonClick(StartScreen __instance, int id, BaseEventData eventData)
148175
{
149-
return CheckSignatures(__instance.OnResumeButtonClick, id, eventData, ClientBase.GetSinglePlayerSessions()[0]);
176+
return CheckSignatures(__instance.OnResumeButtonClick, id, eventData, GetSinglePlayerSessions()[0]);
150177
}
151178

152179
/// <summary>
@@ -159,19 +186,6 @@ private static void ClientBase_DeletePassAndPlayGame(GameInfoPopup __instance)
159186
File.Delete(Path.Combine(Application.persistentDataPath, $"{__instance.gameId}.signatures"));
160187
}
161188

162-
/// <summary>
163-
/// Deletes the signature files of all single-player games when they are deleted.
164-
/// </summary>
165-
[HarmonyPrefix]
166-
[HarmonyPatch(typeof(ClientBase), nameof(ClientBase.DeleteSinglePlayerGames))]
167-
private static void ClientBase_DeleteSinglePlayerGames()
168-
{
169-
foreach (var gameId in ClientBase.GetSinglePlayerSessions())
170-
{
171-
File.Delete(Path.Combine(Application.persistentDataPath, $"{gameId}.signatures"));
172-
}
173-
}
174-
175189
/// <summary>
176190
/// Deletes the signature file of a game when the match ends.
177191
/// </summary>

0 commit comments

Comments
 (0)