fix(loader): narrow IdentityWipe to UDID/VIEWER_ID/SHORT_UDID only

Calling PlayerPrefs.DeleteAll() in IdentityWipe.Execute wiped more
than the three account-keyed entries: it also took out RES_VER (the
Akamai manifest version path), the asset layer's cache-index metadata
in PlayerPrefs, language/sound prefs, and anything else CodeStage
ObscuredPrefs had stashed.

Two observable symptoms on every nuked launch against either a local
or a prod server:

- The client lost track of which asset bundles it had on disk, so
  ResourceDownloader.CheckAndStartNeedDownload prompted "Do you want
  to download the tutorial data? (15.8 MB)" even when the bundles
  were already cached.
- After saying yes, the follow-up
  ShowTutorialBgDownloadDialog prompted "Download data in background?
  (497.1 MB)" for the same reason against the post-tutorial assets.

Narrow IdentityWipe to call ObscuredPrefs.DeleteKey on exactly
"UDID", "VIEWER_ID", and "SHORT_UDID" — the three keys
Cute/Certification.InitializeFileds would clear in the game itself.
Everything else in PlayerPrefs survives, the cache index stays in
sync with the on-disk bundles, and a nuked relaunch behaves like a
Steam-account switch (fresh signup, intact downloads).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-28 18:04:44 -04:00
parent 8f2ddeab96
commit 8c79725869

View File

@@ -1,14 +1,45 @@
extern alias game; extern alias game;
using ObscuredPrefs = CodeStage.AntiCheat.ObscuredTypes.ObscuredPrefs;
using PlayerPrefs = game::UnityEngine.PlayerPrefs; using PlayerPrefs = game::UnityEngine.PlayerPrefs;
namespace SVSimLoader; namespace SVSimLoader;
/// <summary>
/// Narrow identity reset for the local-server test loop. Deletes ONLY the three
/// account-keyed entries in <c>Toolbox.SavedataManager</c>:
/// <list type="bullet">
/// <item>UDID — client-generated GUID identifying this install</item>
/// <item>VIEWER_ID — server-assigned viewer id</item>
/// <item>SHORT_UDID — server-assigned short id</item>
/// </list>
/// <para>
/// Calling <c>PlayerPrefs.DeleteAll()</c> would also wipe RES_VER (the asset manifest
/// version that drives the Akamai CDN path), language/sound prefs, and — most importantly
/// for the local-server loop — whatever cache-index metadata the asset layer stores in
/// PlayerPrefs. That made every nuked launch trigger the 15.8 MB tutorial-asset download
/// prompt followed by the 497 MB background-download prompt, even when the on-disk asset
/// bundles were already there. Narrowing to the three identity keys keeps the asset cache
/// in sync with what prod last served, so a wiped client behaves like a fresh signup
/// against the same RES_VER prod is currently on.
/// </para>
/// <para>
/// <c>ObscuredPrefs.DeleteKey</c> deletes both the obscured-key entry
/// (<c>PlayerPrefs[EncryptKey("UDID")]</c>) and the plain-key entry
/// (<c>PlayerPrefs["UDID"]</c>) for each key, matching how
/// <c>Cute/Certification.InitializeFileds</c> would clear them in the game itself.
/// </para>
/// </summary>
public static class IdentityWipe public static class IdentityWipe
{ {
private static readonly string[] IdentityKeys = { "UDID", "VIEWER_ID", "SHORT_UDID" };
public static void Execute() public static void Execute()
{ {
PlayerPrefs.DeleteAll(); foreach (var key in IdentityKeys)
{
ObscuredPrefs.DeleteKey(key);
}
PlayerPrefs.Save(); PlayerPrefs.Save();
} }
} }