public static StashKey SaveStateLess_NET(StashKey _sk = null, bool threadSave = false) { string Key; //string statePath = ""; StashKey sk; if (_sk == null) { Key = RtcCore.GetRandomKey(); //statePath = LocalNetCoreRouter.QueryRoute<String>(NetcoreCommands.VANGUARD, NetcoreCommands.SAVESAVESTATE, Key, true); sk = new StashKey(Key, Key, null); } else { Key = _sk.Key; //statePath = _sk.StateFilename; sk = _sk; } //if (string.IsNullOrEmpty(statePath)) // return null; //sk.StateShortFilename = statePath.Substring(statePath.LastIndexOf(Path.DirectorySeparatorChar) + 1, statePath.Length - (statePath.LastIndexOf(Path.DirectorySeparatorChar) + 1)); sk.StateShortFilename = ""; sk.StateFilename = ""; return(sk); }
public static bool InjectFromStashkey(StashKey sk, bool _loadBeforeOperation = true) { string saveStateWord = "Savestate"; object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE]; if (renameSaveStateWord != null && renameSaveStateWord is String s) { saveStateWord = s; } PreApplyStashkey(); StashKey psk = CurrentSavestateStashKey; if (psk == null) { MessageBox.Show($"The Glitch Harvester could not perform the INJECT action\n\nEither no {saveStateWord} Box was selected in the {saveStateWord} Manager\nor the {saveStateWord} Box itself is empty."); return(false); } if (psk.SystemCore != sk.SystemCore && !RtcCore.AllowCrossCoreCorruption) { MessageBox.Show("Merge attempt failed: Core mismatch\n\n" + $"{psk.GameName} -> {psk.SystemName} -> {psk.SystemCore}\n{sk.GameName} -> {sk.SystemName} -> {sk.SystemCore}"); return(false); } CurrentStashkey = new StashKey(RtcCore.GetRandomKey(), psk.ParentKey, sk.BlastLayer) { RomFilename = psk.RomFilename, SystemName = psk.SystemName, SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, StateLocation = psk.StateLocation }; if (_loadBeforeOperation) { if (!LoadState(CurrentStashkey)) { return(false); } } else { LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.APPLYBLASTLAYER, new object[] { CurrentStashkey.BlastLayer, true }, true); } bool isCorruptionApplied = CurrentStashkey?.BlastLayer?.Layer?.Count > 0; if (StashAfterOperation) { StashHistory.Add(CurrentStashkey); } PostApplyStashkey(); return(isCorruptionApplied); }
public static bool Corrupt(bool _loadBeforeOperation = true) { string saveStateWord = "Savestate"; object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE]; if (renameSaveStateWord != null && renameSaveStateWord is string s) { saveStateWord = s; } PreApplyStashkey(); StashKey psk = CurrentSavestateStashKey; bool UseSavestates = (bool)AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES]; if (!UseSavestates) { psk = SaveState(); } if (psk == null && UseSavestates) { MessageBox.Show($"The Glitch Harvester could not perform the CORRUPT action\n\nEither no {saveStateWord} Box was selected in the {saveStateWord} Manager\nor the {saveStateWord} Box itself is empty."); return(false); } string currentGame = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.GAMENAME]; string currentCore = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.SYSTEMCORE]; if (UseSavestates && (currentGame == null || psk.GameName != currentGame || psk.SystemCore != currentCore)) { LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_LOADROM, psk.RomFilename, true); } //We make it without the blastlayer so we can send it across and use the cached version without needing a prototype CurrentStashkey = new StashKey(RtcCore.GetRandomKey(), psk.ParentKey, null) { RomFilename = psk.RomFilename, SystemName = psk.SystemName, SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, StateLocation = psk.StateLocation }; BlastLayer bl = LocalNetCoreRouter.QueryRoute <BlastLayer>(NetcoreCommands.CORRUPTCORE, NetcoreCommands.GENERATEBLASTLAYER, new object[] { CurrentStashkey, _loadBeforeOperation, true, true }, true); bool isCorruptionApplied = bl?.Layer?.Count > 0; CurrentStashkey.BlastLayer = bl; if (StashAfterOperation && bl != null) { StashHistory.Add(CurrentStashkey); } PostApplyStashkey(); return(isCorruptionApplied); }
public static bool MergeStashkeys(List <StashKey> sks, bool _loadBeforeOperation = true) { PreApplyStashkey(); if (sks != null && sks.Count > 1) { StashKey master = sks[0]; string masterSystemCore = master.SystemCore; bool allCoresIdentical = true; foreach (StashKey item in sks) { if (item.SystemCore != master.SystemCore) { allCoresIdentical = false; break; } } if (!allCoresIdentical && !RtcCore.AllowCrossCoreCorruption) { MessageBox.Show("Merge attempt failed: Core mismatch\n\n" + string.Join("\n", sks.Select(it => $"{it.GameName} -> {it.SystemName} -> {it.SystemCore}"))); return(false); } foreach (StashKey item in sks) { if (item.GameName != master.GameName) { MessageBox.Show("Merge attempt failed: game mismatch\n\n" + string.Join("\n", sks.Select(it => $"{it.GameName} -> {it.SystemName} -> {it.SystemCore}"))); return(false); } } BlastLayer bl = new BlastLayer(); foreach (StashKey item in sks) { bl.Layer.AddRange(item.BlastLayer.Layer); } bl.Layer = bl.Layer.Distinct().ToList(); CurrentStashkey = new StashKey(RtcCore.GetRandomKey(), master.ParentKey, bl) { RomFilename = master.RomFilename, SystemName = master.SystemName, SystemCore = master.SystemCore, GameName = master.GameName, SyncSettings = master.SyncSettings, StateLocation = master.StateLocation }; bool isCorruptionApplied = CurrentStashkey?.BlastLayer?.Layer?.Count > 0; if (_loadBeforeOperation) { if (!LoadState(CurrentStashkey)) { return(isCorruptionApplied); } } else { LocalNetCoreRouter.Route(NetcoreCommands.CORRUPTCORE, NetcoreCommands.APPLYBLASTLAYER, new object[] { CurrentStashkey.BlastLayer, true }, true); } if (StashAfterOperation) { StashHistory.Add(CurrentStashkey); } PostApplyStashkey(); return(true); } MessageBox.Show("You need 2 or more items for Merging"); return(false); }