public static bool MergeStashkeys(List <StashKey> sks, bool _stashAfterOperation = true) { if (sks != null && sks.Count > 1) { BlastLayer bl = new BlastLayer(); foreach (StashKey item in sks) { bl.Layer.AddRange(item.BlastLayer.Layer); } StashKey newSk = new StashKey(WGH_Core.GetRandomKey(), bl); WGH_Core.ghForm.lbStashHistory.Items.Add(newSk); WGH_Core.ghForm.RefreshStashHistory(); WGH_Core.RestoreTarget(); newSk.Run(); WGH_Executor.Execute(); return(true); } else { MessageBox.Show("You need 2 or more items for Merging"); return(false); } }
private void btnLeaveSubstractChanges_Click(object sender, EventArgs e) { BlastLayer changes = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); BlastLayer modified = (BlastLayer)originalBlastLayer.Clone(); foreach (var unit in changes.Layer) { var TargetUnit = modified.Layer.FirstOrDefault(it => it.Address == unit.Address && it.Domain == unit.Domain && it.ExecuteFrame == unit.ExecuteFrame && it.GeneratedUsingValueList == unit.GeneratedUsingValueList && it.InvertLimiter == unit.InvertLimiter && it.SourceAddress == unit.SourceAddress && it.SourceDomain == unit.SourceDomain && it.StoreLimiterSource == unit.StoreLimiterSource && it.StoreTime == unit.StoreTime && it.StoreType == unit.StoreType && it.TiltValue == unit.TiltValue && it.ValueString == unit.ValueString ); if (TargetUnit != null && !TargetUnit.IsLocked) { modified.Layer.Remove(TargetUnit); } } S.GET <RTC_NewBlastEditor_Form>().LoadBlastlayer(modified); this.Close(); }
private void btnYesEffect_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; S.GET <RTC_NewBlastEditor_Form>().btnRemoveDisabled_Click(null, null); S.GET <RTC_NewBlastEditor_Form>().dgvBlastEditor.ClearSelection(); S.GET <RTC_NewBlastEditor_Form>().btnDisable50_Click(null, null); S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); BlastLayer bl = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); lbSteps.Items.Add(new { Text = $"[{bl.Layer.Count(x => !x.IsLocked)} Units]", Value = bl }); lbCurrentLayerSize.Text = $"Current Layer size: {bl.Layer.Count(x => !x.IsLocked)}"; if (bl.Layer.Count(x => !x.IsLocked) == 1) { lbSanitizationText.Text = "1 Unit remaining, sanitization complete."; btnYesEffect.Visible = false; btnNoEffect.Visible = false; btnReroll.Visible = false; } pnBlastLayerSanitization.Visible = true; }
private void btnNoEffect_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; this.Refresh(); S.GET <RTC_NewBlastEditor_Form>().btnInvertDisabled_Click(null, null); S.GET <RTC_NewBlastEditor_Form>().btnRemoveDisabled_Click(null, null); RunSanitizeAlgo(); BlastLayer bl = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); lbSteps.Items.Add(new { Text = $"[{bl.Layer.Count(x => !x.IsLocked)} Units]", Value = bl }); UpdateSanitizeProgress(); if (bl.Layer.Count(x => !x.IsLocked) == 1) { lbSanitizationText.Text = "1 Unit remaining, sanitization complete."; btnYesEffect.Visible = false; btnNoEffect.Visible = false; btnReroll.Visible = false; } pnBlastLayerSanitization.Visible = true; }
public static void OpenAnalyticsTool(BlastLayer bl = null) { S.GET <RTC_AnalyticsTool_Form>().Close(); var stf = new RTC_AnalyticsTool_Form(); S.SET(stf); if (bl == null) { return; } if (bl.Layer.Count == 0) { MessageBox.Show("Sanitize Tool cannot sanitize BlastLayers that don't have any units."); return; } if (bl.Layer.Count == 1) { MessageBox.Show("Sanitize Tool cannot sanitize BlastLayers that only have one unit."); return; } BlastLayer clone = (BlastLayer)bl.Clone(); stf.lbDumps.DisplayMember = "Text"; stf.lbDumps.ValueMember = "Value"; stf.lbDumps.Items.Add(new { Text = $"Original Layer [{clone.Layer.Count} Units]", Value = clone }); stf.originalBlastLayer = clone; stf.ShowDialog(); }
private static void STEP_CORRUPT(bool _isRewinding, bool _isFastForwarding) //errors trapped by CPU_STEP { if (disableRTC) { return; } if (!_isRewinding) { StepActions.Execute(); } if (_isRewinding || _isFastForwarding) { return; } CPU_STEP_Count++; bool autoCorrupt = CorruptCore.AutoCorrupt; long errorDelay = CorruptCore.ErrorDelay; if (autoCorrupt && CPU_STEP_Count >= errorDelay) { CPU_STEP_Count = 0; BlastLayer bl = CorruptCore.GenerateBlastLayer((string[])RTCV.NetCore.AllSpec.UISpec["SELECTEDDOMAINS"]); if (bl != null) { bl.Apply(false, true); } } }
private void btnLoadCorrupt_Click(object sender, EventArgs e) { string saveStateWord = "Savestate"; object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE]; if (renameSaveStateWord != null && renameSaveStateWord is string s) { saveStateWord = s; } try { btnLoadCorrupt.Enabled = false; btnSendTo.Enabled = false; btnJustCorrupt.Enabled = false; StashKey newSk = null; if (sk == null) { StashKey psk = StockpileManager_UISide.CurrentSavestateStashKey; if (psk == null) { MessageBox.Show( $"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; } newSk = new StashKey(CorruptCore.RtcCore.GetRandomKey(), psk.ParentKey, null) { RomFilename = psk.RomFilename, SystemName = psk.SystemName, SystemCore = psk.SystemCore, GameName = psk.GameName, SyncSettings = psk.SyncSettings, StateLocation = psk.StateLocation }; } else { newSk = (StashKey)sk.Clone(); } BlastLayer bl = GenerateBlastLayers(true, true); if (bl == null) { return; } newSk.BlastLayer = bl; } finally { btnLoadCorrupt.Enabled = true; btnSendTo.Enabled = true; btnJustCorrupt.Enabled = true; } }
private void btnReplayLast_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); BlastLayer changes = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); pnBlastLayerSanitization.Visible = true; }
public static BlastLayer GetBlastLayer(IMemoryDomain[] Original, IMemoryDomain Corrupt, long skipBytes, bool useCustomPrecision) { BlastLayer bl = new BlastLayer(); long OriginalMaxAddress = Original.Sum(it => it.Size); long OriginalFirstDomainMaxAddress = Original[0].Size; if (Corrupt.Size != OriginalMaxAddress) { MessageBox.Show("ERROR, DOMAIN SIZE MISMATCH"); return(null); } int precision = (useCustomPrecision ? RtcCore.CurrentPrecision : 1); for (long i = 0; i < OriginalMaxAddress; i += precision) { byte[] originalBytes = getBytefromIMemoryDomainArray(Original, i, precision); byte[] corruptBytes = Corrupt.PeekBytes(i, precision); if (!originalBytes.SequenceEqual(corruptBytes) && i >= skipBytes) { if (Original[0].BigEndian) { corruptBytes = corruptBytes.FlipBytes(); } BlastUnit bu; if (i - skipBytes >= OriginalFirstDomainMaxAddress) { bu = RTC_NightmareEngine.GenerateUnit(getNamefromIMemoryDomainArray(Original, i - skipBytes), (i - skipBytes) - OriginalFirstDomainMaxAddress, precision, 0, corruptBytes); } else { bu = RTC_NightmareEngine.GenerateUnit(getNamefromIMemoryDomainArray(Original, i - skipBytes), i - skipBytes, precision, 0, corruptBytes); } bu.BigEndian = Original[0].BigEndian; bl.Layer.Add(bu); } } if (bl.Layer.Count == 0) { return(null); } else { return(bl); } }
private void btnReroll_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; S.GET <RTC_NewBlastEditor_Form>().dgvBlastEditor.ClearSelection(); S.GET <RTC_NewBlastEditor_Form>().btnDisable50_Click(null, null); S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); BlastLayer bl = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); lbCurrentLayerSize.Text = $"Current Layer size: {bl.Layer.Count(x => !x.IsLocked)}"; pnBlastLayerSanitization.Visible = true; }
private void btnBackPrevState_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; this.Refresh(); var lastItem = lbSteps.Items[lbSteps.Items.Count - 1]; if (lbSteps.Items.Count > 1) { lastItem = lbSteps.Items[lbSteps.Items.Count - 2]; } T Cast <T>(object obj, T type) { return((T)obj); } var modified = Cast(lastItem, new { Text = "", Value = new BlastLayer() }); BlastLayer bl = (BlastLayer)modified.Value.Clone(); S.GET <RTC_NewBlastEditor_Form>().LoadBlastlayer(bl); workBlastLayer = bl; UpdateSanitizeProgress(); if (lbSteps.Items.Count > 1) { lbSteps.Items.RemoveAt(lbSteps.Items.Count - 1); } S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); lbSanitizationText.Text = "Is the effect you are looking for still present?"; btnYesEffect.Visible = true; btnNoEffect.Visible = true; btnReroll.Visible = true; if (lbSteps.Items.Count == 1) { lbWorkingPleaseWait.Visible = false; pnBlastLayerSanitization.Visible = false; btnStartSanitizing.Visible = true; } else { pnBlastLayerSanitization.Visible = true; } }
private void btnReroll_Click(object sender, EventArgs e) { pnBlastLayerSanitization.Visible = false; this.Refresh(); S.GET <RTC_NewBlastEditor_Form>().dgvBlastEditor.ClearSelection(); S.GET <RTC_NewBlastEditor_Form>().btnDisable50_Click(null, null); S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); BlastLayer bl = (BlastLayer)S.GET <RTC_NewBlastEditor_Form>().currentSK.BlastLayer.Clone(); UpdateSanitizeProgress(); pnBlastLayerSanitization.Visible = true; }
public static BlastLayer GetAppliedBackupLayer(BlastLayer bl, StashKey sk) { //So basically due to how netcore handles synced commands, we can't actually call sk.Run() //from within emuhawk or else it'll apply the blastlayer AFTER this code completes //So we manually apply the blastlayer sk.RunOriginal(); sk.BlastLayer.Apply(false); //Fake advance a frame here to get it processed and the values set StepActions.Execute(); BlastLayer newBlastLayer = bl.GetBackup(); //Clear it all out StepActions.ClearStepBlastUnits(); return(newBlastLayer); }
public static BlastLayer GetBlastLayerFromDiff(byte[] Original, byte[] Corrupt) { BlastLayer bl = new BlastLayer(); string thisSystem = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.SYSTEM]; string romFilename = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.OPENROMFILENAME]; var rp = MemoryDomains.GetRomParts(thisSystem, romFilename); if (rp.Error != null) { MessageBox.Show(rp.Error); return(null); } if (Original.Length != Corrupt.Length) { MessageBox.Show("ERROR, ROM SIZE MISMATCH"); return(null); } MemoryInterface mi = MemoryDomains.GetInterface(rp.PrimaryDomain); long maxaddress = mi.Size; for (int i = 0; i < Original.Length; i++) { if (Original[i] != Corrupt[i] && i >= rp.SkipBytes) { if (i - rp.SkipBytes >= maxaddress) { bl.Layer.Add(new BlastUnit(new byte[] { Corrupt[i] }, rp.SecondDomain, (i - rp.SkipBytes) - maxaddress, 1, mi.BigEndian)); } else { bl.Layer.Add(new BlastUnit(new byte[] { Corrupt[i] }, rp.PrimaryDomain, (i - rp.SkipBytes), 1, mi.BigEndian)); } } } if (bl.Layer.Count == 0) { return(null); } return(bl); }
public static BlastLayer LoadBlastLayerFromFile(string filename = null) { BlastLayer bl = null; if (filename == null) { OpenFileDialog ofd = new OpenFileDialog { DefaultExt = "bl", Title = "Open BlastLayer File", Filter = "bl files|*.bl", RestoreDirectory = true }; if (ofd.ShowDialog() == DialogResult.OK) { filename = ofd.FileName.ToString(); } else { return(null); } } if (!File.Exists(filename)) { MessageBox.Show("The BlastLayer file wasn't found"); return(null); } try { using (FileStream fs = new FileStream(filename, FileMode.Open)) { bl = JsonHelper.Deserialize <BlastLayer>(fs); return(bl); } } catch { MessageBox.Show("The BlastLayer file could not be loaded"); return(null); } }
public static BlastLayer GenerateLayer(string note, string domain, long stepSize, long startAddress, long endAddress, ulong param1, ulong param2, int precision, int lifetime, int executeFrame, bool loop, int seed, BGStoreModes mode) { BlastLayer bl = new BlastLayer(); Random rand = new Random(seed); //We subtract 1 at the end as precision is 1,2,4, and we need to go 0,1,3 for (long address = startAddress; address < endAddress; address = address + stepSize + precision - 1) { BlastUnit bu = GenerateUnit(domain, address, param1, param2, stepSize, precision, lifetime, executeFrame, loop, mode, note, rand); if (bu != null) { bl.Layer.Add(bu); } } return(bl); }
public static BlastLayer GetRawBlastLayer() { lock (executeLock) { BlastLayer bl = new BlastLayer(); var tempList = new List <List <BlastUnit> >(); tempList.AddRange(appliedInfinite); tempList.AddRange(appliedLifetime); foreach (List <BlastUnit> buList in (buListCollection)) { foreach (BlastUnit bu in buList) { bl.Layer.Add(bu); } } return(bl); } }
private void btnLoadCorrupt_Click(object sender, EventArgs e) { BlastLayer bl = new BlastLayer(); foreach (var item in lbBlastLayer.Items) { BlastUnit bu = (item as BlastUnit); if (bu.IsEnabled) { bl.Layer.Add(bu); } } StashKey newSk = (StashKey)sk.Clone(); newSk.BlastLayer = bl; WGH_Core.RestoreTarget(); newSk.Run(); WGH_Executor.Execute(); }
public static bool LoadState_NET(StashKey sk, bool applyBlastLayer = true) { if (sk == null) { return(false); } bool useStates = (AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES] as bool? ?? false); if (useStates) { StashKey.SetCore(sk); string gameSystem = sk.SystemName; string gameName = CorruptCore_Extensions.MakeSafeFilename(sk.GameName, '-'); string key = sk.ParentKey; StashKeySavestateLocation stateLocation = sk.StateLocation; string theoreticalSaveStateFilename = Path.Combine(RtcCore.workingDir, stateLocation.ToString(), gameName + "." + key + ".timejump.State"); if (File.Exists(theoreticalSaveStateFilename)) { if (!LocalNetCoreRouter.QueryRoute <bool>(NetcoreCommands.VANGUARD, NetcoreCommands.LOADSAVESTATE, new object[] { theoreticalSaveStateFilename, stateLocation }, true)) { MessageBox.Show($"Error loading savestate : An internal error has occurred.\n Are you sure your savestate matches the game, your syncsettings match, and the savestate is supported by this version of {RtcCore.VanguardImplementationName}?"); return(false); } } else { MessageBox.Show($"Error loading savestate : (File {theoreticalSaveStateFilename} not found)"); return(false); } } if (applyBlastLayer && sk?.BlastLayer?.Layer?.Count > 0) { CorruptBL = sk.BlastLayer; sk.BlastLayer.Apply(true); } return(true); }
private void btnBackPrevState_Click(object sender, EventArgs e) { var lastItem = lbSteps.Items[lbSteps.Items.Count - 1]; if (lbSteps.Items.Count > 1) { lastItem = lbSteps.Items[lbSteps.Items.Count - 2]; } T Cast <T>(object obj, T type) { return((T)obj); } var modified = Cast(lastItem, new { Text = "", Value = new BlastLayer() });; BlastLayer bl = (BlastLayer)modified.Value.Clone(); S.GET <RTC_NewBlastEditor_Form>().LoadBlastlayer(bl); lbCurrentLayerSize.Text = $"Current Layer size: {bl.Layer.Count(x => !x.IsLocked)}"; if (lbSteps.Items.Count > 1) { lbSteps.Items.RemoveAt(lbSteps.Items.Count - 1); } S.GET <RTC_NewBlastEditor_Form>().btnLoadCorrupt_Click(null, null); lbSanitizationText.Text = "Is the effect you are looking for still present?"; btnYesEffect.Visible = true; btnNoEffect.Visible = true; btnReroll.Visible = true; if (lbSteps.Items.Count == 1) { pnBlastLayerSanitization.Visible = false; btnStartSanitizing.Visible = true; } }
public static bool SaveBlastLayerToFile(BlastLayer bl, string path = null) { string filename = path; if (bl.Layer.Count == 0) { MessageBox.Show("Can't save because the provided blastlayer is empty is empty"); return(false); } if (filename == null) { SaveFileDialog saveFileDialog1 = new SaveFileDialog { DefaultExt = "bl", Title = "Save BlastLayer File", Filter = "bl files|*.bl", RestoreDirectory = true }; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { filename = saveFileDialog1.FileName; } else { return(false); } } using (FileStream fs = new FileStream(filename, FileMode.Create)) { JsonHelper.Serialize(bl, fs, Formatting.Indented); } LastBlastLayerSavePath = filename; return(true); }
public static void OpenSanitizeTool(BlastLayer bl = null) { S.GET <RTC_SanitizeTool_Form>().Close(); var stf = new RTC_SanitizeTool_Form(); S.SET(stf); if (bl == null) { return; } if (!bl.Layer.Any(x => !x.IsLocked)) { MessageBox.Show("Sanitize Tool cannot sanitize BlastLayers that don't have any units."); return; } if (bl.Layer.Count(x => !x.IsLocked) == 1) { MessageBox.Show("Sanitize Tool cannot sanitize BlastLayers that only have one unit."); return; } BlastLayer clone = (BlastLayer)bl.Clone(); stf.lbOriginalLayerSize.Text = $"Original Layer size: {clone.Layer.Count(x => !x.IsLocked)}"; stf.lbSteps.DisplayMember = "Text"; stf.lbSteps.ValueMember = "Value"; stf.lbSteps.Items.Add(new { Text = $"Original Layer [{clone.Layer.Count(x => !x.IsLocked)} Units]", Value = clone }); stf.originalBlastLayer = clone; stf.workBlastLayer = bl; stf.UpdateSanitizeProgress(); stf.ShowDialog(); }
public static void STEP_CORRUPT(bool executeActions, bool performStep) { if (executeActions) { StepActions.Execute(); } if (performStep) { CPU_STEP_Count++; bool autoCorrupt = RtcCore.AutoCorrupt; long errorDelay = RtcCore.ErrorDelay; if (autoCorrupt && CPU_STEP_Count >= errorDelay) { CPU_STEP_Count = 0; BlastLayer bl = RtcCore.GenerateBlastLayer((string[])AllSpec.UISpec["SELECTEDDOMAINS"]); if (bl != null) { bl.Apply(false, false); } } } }
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); }
public object OnMessageReceived(object sender, NetCoreEventArgs e) { try { //Use setReturnValue to handle returns var message = e.message; var advancedMessage = message as NetCoreAdvancedMessage; switch (e.message.Type) { case "GETSPECDUMPS": StringBuilder sb = new StringBuilder(); sb.AppendLine("Spec Dump from CorruptCore"); sb.AppendLine(); sb.AppendLine("UISpec"); RTCV.NetCore.AllSpec.UISpec?.GetDump().ForEach(x => sb.AppendLine(x)); sb.AppendLine("CorruptCoreSpec"); RTCV.NetCore.AllSpec.CorruptCoreSpec?.GetDump().ForEach(x => sb.AppendLine(x)); sb.AppendLine("VanguardSpec"); RTCV.NetCore.AllSpec.VanguardSpec?.GetDump().ForEach(x => sb.AppendLine(x)); e.setReturnValue(sb.ToString()); break; //UI sent its spec case REMOTE_PUSHUISPEC: { SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.UISpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); }); break; } //UI sent a spec update case REMOTE_PUSHUISPECUPDATE: SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.UISpec?.Update((PartialSpec)advancedMessage.objectValue); }); break; //Vanguard sent a copy of its spec case REMOTE_PUSHVANGUARDSPEC: SyncObjectSingleton.FormExecute(() => { if (!RtcCore.Attached) { RTCV.NetCore.AllSpec.VanguardSpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); } }); break; //Vanguard sent a spec update case REMOTE_PUSHVANGUARDSPECUPDATE: RTCV.NetCore.AllSpec.VanguardSpec?.Update((PartialSpec)advancedMessage.objectValue, false); break; //UI sent a copy of the CorruptCore spec case REMOTE_PUSHCORRUPTCORESPEC: SyncObjectSingleton.FormExecute(() => { //So here's the deal. The UI doesn't actually have the full memory domains (md isn't sent across) so if we take them from it, it results in them going null //Instead, we stick with what we have, then tell the UI to use that. var temp = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); //Stick with what we have if it exists to prevent any exceptions if autocorrupt was on or something, then call refresh temp.Update("MEMORYINTERFACES", AllSpec.CorruptCoreSpec?["MEMORYINTERFACES"] ?? new Dictionary <string, MemoryDomainProxy>()); RTCV.NetCore.AllSpec.CorruptCoreSpec = new FullSpec(temp.GetPartialSpec(), !RtcCore.Attached); RTCV.NetCore.AllSpec.CorruptCoreSpec.SpecUpdated += (ob, eas) => { PartialSpec partial = eas.partialSpec; LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_PUSHCORRUPTCORESPECUPDATE, partial, true); }; RTCV.CorruptCore.MemoryDomains.RefreshDomains(); }); e.setReturnValue(true); break; //UI sent an update of the CorruptCore spec case REMOTE_PUSHCORRUPTCORESPECUPDATE: SyncObjectSingleton.FormExecute(() => { RTCV.NetCore.AllSpec.CorruptCoreSpec?.Update((PartialSpec)advancedMessage.objectValue, false); }); break; case REMOTE_EVENT_DOMAINSUPDATED: var domainsChanged = (bool)advancedMessage.objectValue; MemoryDomains.RefreshDomains(domainsChanged); break; case REMOTE_EVENT_RESTRICTFEATURES: { if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_SAVESTATES) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLESAVESTATESUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_REALTIME) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEREALTIMESUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_KILLSWITCH) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEKILLSWITCHSUPPORT); } if (!RTCV.NetCore.AllSpec.VanguardSpec?.Get <bool>(VSPEC.SUPPORTS_GAMEPROTECTION) ?? true) { LocalNetCoreRouter.Route(NetcoreCommands.UI, NetcoreCommands.REMOTE_DISABLEGAMEPROTECTIONSUPPORT); } break; } case REMOTE_EVENT_SHUTDOWN: { RtcCore.Shutdown(); break; } case REMOTE_OPENHEXEDITOR: { if ((bool?)AllSpec.VanguardSpec[VSPEC.USE_INTEGRATED_HEXEDITOR] ?? false) { LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_OPENHEXEDITOR, true); } else { //Route it to the plugin if loaded if (RtcCore.PluginHost.LoadedPlugins.Any(x => x.Name == "Hex Editor")) { LocalNetCoreRouter.Route("HEXEDITOR", NetcoreCommands.REMOTE_OPENHEXEDITOR, true); } else { MessageBox.Show("The current Vanguard implementation does not include a\n hex editor & the hex editor plugin isn't loaded. Aborting."); } } } break; case EMU_OPEN_HEXEDITOR_ADDRESS: { if ((bool?)AllSpec.VanguardSpec[VSPEC.USE_INTEGRATED_HEXEDITOR] ?? false) { LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.EMU_OPEN_HEXEDITOR_ADDRESS, advancedMessage.objectValue, true); } else { //Route it to the plugin if loaded if (RtcCore.PluginHost.LoadedPlugins.Any(x => x.Name == "Hex Editor")) { LocalNetCoreRouter.Route("HEXEDITOR", NetcoreCommands.EMU_OPEN_HEXEDITOR_ADDRESS, advancedMessage.objectValue, true); } else { MessageBox.Show("The current Vanguard implementation does not include a\n hex editor & the hex editor plugin isn't loaded. Aborting."); } } break; } case MANUALBLAST: { RtcCore.GenerateAndBlast(); } break; case GENERATEBLASTLAYER: { var val = advancedMessage.objectValue as object[]; StashKey sk = val[0] as StashKey; bool loadBeforeCorrupt = (bool)val[1]; bool applyBlastLayer = (bool)val[2]; bool backup = (bool)val[3]; BlastLayer bl = null; bool UseSavestates = (bool)AllSpec.VanguardSpec[VSPEC.SUPPORTS_SAVESTATES]; void a() { lock (loadLock) { //Load the game from the main thread if (UseSavestates && loadBeforeCorrupt) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } if (UseSavestates && loadBeforeCorrupt) { StockpileManager_EmuSide.LoadState_NET(sk, false); } //We pull the domains here because if the syncsettings changed, there's a chance the domains changed string[] domains = (string[])AllSpec.UISpec["SELECTEDDOMAINS"]; var cpus = Environment.ProcessorCount; if (cpus == 1 || AllSpec.VanguardSpec[VSPEC.SUPPORTS_MULTITHREAD] == null) { bl = RtcCore.GenerateBlastLayer(domains); } else { //if emulator supports multithreaded access of the domains, disregard the emulation thread and just span threads... long reminder = RtcCore.Intensity % (cpus - 1); long splitintensity = (RtcCore.Intensity - reminder) / (cpus - 1); Task <BlastLayer>[] tasks = new Task <BlastLayer> [cpus]; for (int i = 0; i < cpus; i++) { long requestedIntensity = splitintensity; if (i == 0 && reminder != 0) { requestedIntensity = reminder; } tasks[i] = Task.Factory.StartNew(() => RtcCore.GenerateBlastLayer(domains, requestedIntensity)); } Task.WaitAll(tasks); bl = tasks[0] .Result ?? new BlastLayer(); if (tasks.Length > 1) { for (int i = 1; i < tasks.Length; i++) { if (tasks[i] .Result != null) { bl.Layer.AddRange(tasks[i] .Result.Layer); } } } if (bl.Layer.Count == 0) { bl = null; } } if (applyBlastLayer) { bl?.Apply(backup); } } } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } else //We can just do everything on the emulation thread as it'll block { SyncObjectSingleton.EmuThreadExecute(a, true); } if (advancedMessage.requestGuid != null) { e.setReturnValue(bl); } break; } case APPLYBLASTLAYER: { var temp = advancedMessage.objectValue as object[]; BlastLayer bl = (BlastLayer)temp[0]; bool backup = (bool)temp[1]; void a() { bl.Apply(backup, true); } SyncObjectSingleton.EmuThreadExecute(a, true); break; } /* * case STASHKEY: * { * var temp = advancedMessage.objectValue as object[]; * * var sk = temp[0] as StashKey; * var romFilename = temp[1] as String; * var romData = temp[2] as Byte[]; * * if (!File.Exists(CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + romFilename)) * File.WriteAllBytes(CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + romFilename, romData); * * sk.RomFilename = CorruptCore.rtcDir + Path.DirectorySeparatorChar + "WORKING" + Path.DirectorySeparatorChar + "SKS" + Path.DirectorySeparatorChar + CorruptCore_Extensions.getShortFilenameFromPath(romFilename); * sk.DeployState(); * sk.Run(); * } * break; */ case REMOTE_PUSHRTCSPEC: RTCV.NetCore.AllSpec.CorruptCoreSpec = new FullSpec((PartialSpec)advancedMessage.objectValue, !RtcCore.Attached); e.setReturnValue(true); break; case REMOTE_PUSHRTCSPECUPDATE: RTCV.NetCore.AllSpec.CorruptCoreSpec?.Update((PartialSpec)advancedMessage.objectValue, false); break; case BLASTGENERATOR_BLAST: { List <BlastGeneratorProto> returnList = null; StashKey sk = (StashKey)(advancedMessage.objectValue as object[])[0]; List <BlastGeneratorProto> blastGeneratorProtos = (List <BlastGeneratorProto>)(advancedMessage.objectValue as object[])[1]; bool loadBeforeCorrupt = (bool)(advancedMessage.objectValue as object[])[2]; bool applyAfterCorrupt = (bool)(advancedMessage.objectValue as object[])[3]; bool resumeAfter = (bool)(advancedMessage.objectValue as object[])[4]; void a() { //Load the game from the main thread if (loadBeforeCorrupt) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } if (loadBeforeCorrupt) { StockpileManager_EmuSide.LoadState_NET(sk, false); } returnList = BlastTools.GenerateBlastLayersFromBlastGeneratorProtos(blastGeneratorProtos, sk); if (applyAfterCorrupt) { BlastLayer bl = new BlastLayer(); foreach (var p in returnList.Where(x => x != null)) { bl.Layer.AddRange(p.bl.Layer); } bl.Apply(true); } } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); if (resumeAfter) { e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } } else { SyncObjectSingleton.EmuThreadExecute(a, false); } e.setReturnValue(returnList); break; } case REMOTE_LOADSTATE: { lock (loadLock) { StashKey sk = (StashKey)(advancedMessage.objectValue as object[])[0]; bool reloadRom = (bool)(advancedMessage.objectValue as object[])[1]; bool runBlastLayer = (bool)(advancedMessage.objectValue as object[])[2]; bool returnValue = false; //Load the game from the main thread if (reloadRom) { SyncObjectSingleton.FormExecute(() => { StockpileManager_EmuSide.LoadRom_NET(sk); }); } void a() { returnValue = StockpileManager_EmuSide.LoadState_NET(sk, runBlastLayer); } //If the emulator uses callbacks, we do everything on the main thread and once we're done, we unpause emulation if ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false) { SyncObjectSingleton.FormExecute(a); e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true)); } else //We're loading on the emulator thread which'll block { SyncObjectSingleton.EmuThreadExecute(a, false); } e.setReturnValue(returnValue); } } break; case REMOTE_SAVESTATE: { StashKey sk = null; void a() { sk = StockpileManager_EmuSide.SaveState_NET(advancedMessage.objectValue as StashKey); //Has to be nullable cast } SyncObjectSingleton.EmuThreadExecute(a, false); e.setReturnValue(sk); } break; case REMOTE_SAVESTATELESS: { StashKey sk = null; void a() { sk = StockpileManager_EmuSide.SaveStateLess_NET(advancedMessage.objectValue as StashKey); //Has to be nullable cast } SyncObjectSingleton.EmuThreadExecute(a, false); e.setReturnValue(sk); } break; case REMOTE_BACKUPKEY_REQUEST: { //We don't store this in the spec as it'd be horrible to push it to the UI and it doesn't care //if (!LocalNetCoreRouter.QueryRoute<bool>(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_ISNORMALADVANCE)) //break; StashKey sk = null; //We send an unsynced command back SyncObjectSingleton.FormExecute(() => { sk = StockpileManager_EmuSide.SaveState_NET(); }); if (sk != null) { LocalNetCoreRouter.Route(NetcoreCommands.UI, REMOTE_BACKUPKEY_STASH, sk, false); } break; } case REMOTE_DOMAIN_GETDOMAINS: e.setReturnValue(LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_DOMAIN_GETDOMAINS, true)); break; case REMOTE_PUSHVMDPROTOS: MemoryDomains.VmdPool.Clear(); foreach (var proto in (advancedMessage.objectValue as VmdPrototype[])) { MemoryDomains.AddVMD(proto); } break; case REMOTE_DOMAIN_VMD_ADD: MemoryDomains.AddVMD_NET((advancedMessage.objectValue as VmdPrototype)); break; case REMOTE_DOMAIN_VMD_REMOVE: { StepActions.ClearStepBlastUnits(); MemoryDomains.RemoveVMD_NET((advancedMessage.objectValue as string)); } break; case REMOTE_DOMAIN_ACTIVETABLE_MAKEDUMP: { void a() { MemoryDomains.GenerateActiveTableDump((string)(advancedMessage.objectValue as object[])[0], (string)(advancedMessage.objectValue as object[])[1]); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_BLASTTOOLS_GETAPPLIEDBACKUPLAYER: { var bl = (BlastLayer)(advancedMessage.objectValue as object[])[0]; var sk = (StashKey)(advancedMessage.objectValue as object[])[1]; void a() { e.setReturnValue(BlastTools.GetAppliedBackupLayer(bl, sk)); } SyncObjectSingleton.EmuThreadExecute(a, false); break; } case REMOTE_LONGARRAY_FILTERDOMAIN: { lock (loadLock) { var objValues = (advancedMessage.objectValue as object[]); string domain = (string)objValues[0]; string LimiterListHash = (string)objValues[1]; StashKey sk = objValues[2] as StashKey; //Intentionally nullable void a() { if (sk != null) //If a stashkey was passed in, we want to load then profile { StockpileManager_EmuSide.LoadState_NET(sk, false); } MemoryInterface mi = MemoryDomains.MemoryInterfaces[domain]; List <long> allLegalAdresses = new List <long>(); int listItemSize = Filtering.GetPrecisionFromHash(LimiterListHash); for (long i = 0; i < mi.Size; i += listItemSize) { if (Filtering.LimiterPeekBytes(i, i + listItemSize, mi.Name, LimiterListHash, mi)) { for (int j = 0; j < listItemSize; j++) { allLegalAdresses.Add(i + j); } } } e.setReturnValue(allLegalAdresses.ToArray()); } //If the emulator uses callbacks and we're loading a state, we do everything on the main thread and once we're done, we unpause emulation if (sk != null && ((bool?)AllSpec.VanguardSpec[VSPEC.LOADSTATE_USES_CALLBACKS] ?? false)) { SyncObjectSingleton.FormExecute(a); LocalNetCoreRouter.Route(NetcoreCommands.VANGUARD, NetcoreCommands.REMOTE_RESUMEEMULATION, true); } else //We can just do everything on the emulation thread as it'll block { SyncObjectSingleton.EmuThreadExecute(a, true); } } } break; case REMOTE_KEY_GETRAWBLASTLAYER: { void a() { e.setReturnValue(StockpileManager_EmuSide.GetRawBlastlayer()); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_BL_GETDIFFBLASTLAYER: { string filename = (advancedMessage.objectValue as string); void a() { e.setReturnValue(BlastDiff.GetBlastLayer(filename)); } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_SET_APPLYUNCORRUPTBL: { void a() { if (StockpileManager_EmuSide.UnCorruptBL != null) { StockpileManager_EmuSide.UnCorruptBL.Apply(true); } } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_SET_APPLYCORRUPTBL: { void a() { if (StockpileManager_EmuSide.CorruptBL != null) { StockpileManager_EmuSide.CorruptBL.Apply(false); } } SyncObjectSingleton.EmuThreadExecute(a, false); } break; case REMOTE_CLEARSTEPBLASTUNITS: SyncObjectSingleton.FormExecute(() => { StepActions.ClearStepBlastUnits(); }); break; case REMOTE_LOADPLUGINS: SyncObjectSingleton.FormExecute(() => { string emuPluginDir = ""; try { emuPluginDir = System.IO.Path.Combine(RtcCore.EmuDir, "RTC", "PLUGINS"); } catch (Exception e) { RTCV.Common.Logging.GlobalLogger.Error(e, "Unable to find plugin dir in {dir}", RtcCore.EmuDir + "\\RTC" + "\\PLUGINS"); } RtcCore.LoadPlugins(new[] { RtcCore.pluginDir, emuPluginDir }); }); break; case REMOTE_REMOVEEXCESSINFINITESTEPUNITS: SyncObjectSingleton.FormExecute(() => { StepActions.RemoveExcessInfiniteStepUnits(); }); break; default: new object(); break; } return(e.returnMessage); } catch (Exception ex) { if (CloudDebug.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } return(e.returnMessage); } }
public static StashKey GetRawBlastlayer() { StashKey sk = SaveState_NET(); if (sk == null) { return(null); } BlastLayer bl = new BlastLayer(); bl.Layer.AddRange(StepActions.GetRawBlastLayer().Layer); string thisSystem = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.SYSTEM]; string romFilename = (string)RTCV.NetCore.AllSpec.VanguardSpec[VSPEC.OPENROMFILENAME]; var rp = MemoryDomains.GetRomParts(thisSystem, romFilename); if (rp.Error == null) { if (rp.PrimaryDomain != null) { List <byte> addData = new List <byte>(); if (rp.SkipBytes != 0) { byte[] padding = new byte[rp.SkipBytes]; for (int i = 0; i < rp.SkipBytes; i++) { padding[i] = 0; } addData.AddRange(padding); } addData.AddRange(MemoryDomains.GetDomainData(rp.PrimaryDomain)); if (rp.SecondDomain != null) { addData.AddRange(MemoryDomains.GetDomainData(rp.SecondDomain)); } byte[] corrupted = addData.ToArray(); byte[] original = File.ReadAllBytes(romFilename); //if (MemoryDomains.MemoryInterfaces.ContainsKey("32X FB")) //Flip 16-bit words on 32X rom //original = original.FlipWords(2); if (string.Equals(thisSystem, "N64", StringComparison.OrdinalIgnoreCase)) { original = MutateSwapN64(original); } else if (romFilename.IndexOf(".SMD", StringComparison.OrdinalIgnoreCase) >= 0) { original = DeInterleaveSMD(original); } for (int i = 0; i < rp.SkipBytes; i++) { original[i] = 0; } BlastLayer romBlast = BlastTools.GetBlastLayerFromDiff(original, corrupted); if (romBlast != null && romBlast.Layer.Count > 0) { bl.Layer.AddRange(romBlast.Layer); } } } sk.BlastLayer = bl; return(sk); }
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); }
//Generates or queries a blast layer then applies it. public static BlastLayer Blast(BlastLayer _layer) { try { if (_layer != null) { _layer.Apply(); //If the BlastLayer was provided, there's no need to generate a new one. currentMemoryInterface.ApplyWorkingFile(); return(_layer); } else { BlastLayer bl = new BlastLayer(); string TargetType; long StartingAddress; long BlastRange; long MaxAddress; long RandomAdress = 0; BlastUnit bu; TargetType = currentTargetType; StartingAddress = WGH_Core.StartingAddress; BlastRange = WGH_Core.BlastRange; MaxAddress = (long)(currentMemoryInterface.lastMemorySize ?? 0); if (!WGH_Core.useBlastRange) { BlastRange = MaxAddress - StartingAddress; } else if (StartingAddress + BlastRange > MaxAddress) { BlastRange = MaxAddress - StartingAddress; } for (int i = 0; i < Intensity; i++) { RandomAdress = StartingAddress + RandomLong(BlastRange - 1); bu = getBlastUnit(TargetType, RandomAdress); if (bu != null) { bl.Layer.Add(bu); } } bl.Apply(); currentMemoryInterface.ApplyWorkingFile(); if (bl.Layer.Count == 0) { return(null); } else { return(bl); } } } catch (Exception ex) { MessageBox.Show("Something went wrong in the WGH Core. \n\n" + ex.ToString()); return(null); } }
public BlastLayer GenerateBlastLayers(bool loadBeforeCorrupt = false, bool applyAfterCorrupt = false, bool resumeAfter = true) { string saveStateWord = "Savestate"; object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE]; if (renameSaveStateWord != null && renameSaveStateWord is String s) { saveStateWord = s; } StashKey newSk = null; try { RefreshDomains(); BlastLayer bl = new BlastLayer(); if (loadBeforeCorrupt) { //If opened from engine config, use the GH state if (!OpenedFromBlastEditor) { StashKey psk = StockpileManager_UISide.CurrentSavestateStashKey; if (psk == null) { MessageBox.Show( $"The Blast Generator 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(null); } newSk = new StashKey(CorruptCore.RtcCore.GetRandomKey(), psk.ParentKey, bl); newSk.RomFilename = psk.RomFilename; newSk.SystemName = psk.SystemName; newSk.SystemCore = psk.SystemCore; newSk.GameName = psk.GameName; newSk.StateLocation = psk.StateLocation; newSk.SyncSettings = psk.SyncSettings; } else { newSk = (StashKey)sk.Clone(); } } List <BlastGeneratorProto> protoList = new List <BlastGeneratorProto>(); foreach (DataGridViewRow row in dgvBlastGenerator.Rows) { BlastGeneratorProto proto = null; //Why the hell can't you get the checked state from a dgvCheckbox why do I need to make this a string aaaaaaaaaaa if (row.Cells["dgvEnabled"].Value.ToString() == "true" || row.Cells["dgvEnabled"].Value.ToString() == "True") { if ((bool)row.Cells["dgvRowDirty"].Value == true) { proto = CreateProtoFromRow(row); if (proto != null) { row.Cells["dgvBlastProtoReference"].Value = proto; } } else { proto = (BlastGeneratorProto)row.Cells["dgvBlastProtoReference"].Value; } } protoList.Add(proto); } List <BlastGeneratorProto> returnList = new List <BlastGeneratorProto>(); returnList = NetCore.LocalNetCoreRouter.QueryRoute <List <BlastGeneratorProto> >(NetCore.NetcoreCommands.CORRUPTCORE, NetCore.NetcoreCommands.BLASTGENERATOR_BLAST, new object[] { newSk, protoList, loadBeforeCorrupt, applyAfterCorrupt, resumeAfter }, true); if (returnList == null) { return(null); } if (returnList.Count != protoList.Count) { throw (new Exception("Got less protos back compared to protos sent. Aborting!")); } //The return list is in the same order as the original list so we can go by index here for (int i = 0; i < dgvBlastGenerator.RowCount; i++) { //Why the hell can't you get the checked state from a dgvCheckbox why do I need to make this a string aaaaaaaaaaa if (dgvBlastGenerator.Rows[i].Cells["dgvEnabled"].Value.ToString() == "true" || dgvBlastGenerator.Rows[i].Cells["dgvEnabled"].Value.ToString() == "True") { dgvBlastGenerator.Rows[i].Cells["dgvBlastProtoReference"].Value = returnList[i]; dgvBlastGenerator.Rows[i].Cells["dgvRowDirty"].Value = false; bl.Layer.AddRange(returnList[i].bl.Layer); } } S.GET <RTC_GlitchHarvesterBlast_Form>().IsCorruptionApplied = (applyAfterCorrupt && returnList.Count > 0); return(bl); } catch (Exception ex) { MessageBox.Show("Something went wrong when generating the blastlayers. \n" + "Are you sure your input is correct and you have the correct core loaded?\n\n" + ex.ToString() + ex.StackTrace); return(null); } finally { } }
private void btnSendTo_Click(object sender, EventArgs e) { string saveStateWord = "Savestate"; object renameSaveStateWord = AllSpec.VanguardSpec[VSPEC.RENAME_SAVESTATE]; if (renameSaveStateWord != null && renameSaveStateWord is String s) { saveStateWord = s; } btnLoadCorrupt.Enabled = false; btnSendTo.Enabled = false; btnJustCorrupt.Enabled = false; try { StashKey newSk = null; if (sk == null) { StashKey psk = StockpileManager_UISide.CurrentSavestateStashKey; if (psk == null) { MessageBox.Show($"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; } newSk = new StashKey(CorruptCore.RtcCore.GetRandomKey(), psk.ParentKey, null); newSk.RomFilename = psk.RomFilename; newSk.SystemName = psk.SystemName; newSk.SystemCore = psk.SystemCore; newSk.GameName = psk.GameName; newSk.SyncSettings = psk.SyncSettings; newSk.StateLocation = psk.StateLocation; } else { newSk = (StashKey)sk.Clone(); } BlastLayer bl = GenerateBlastLayers(true); if (bl == null) { return; } newSk.BlastLayer = bl; if (OpenedFromBlastEditor) { if (S.GET <RTC_NewBlastEditor_Form>() == null || S.GET <RTC_NewBlastEditor_Form>().IsDisposed) { S.SET(new RTC_NewBlastEditor_Form()); S.GET <RTC_NewBlastEditor_Form>().LoadStashkey((StashKey)newSk.Clone()); } else { S.GET <RTC_NewBlastEditor_Form>().ImportBlastLayer(newSk.BlastLayer); } { } S.GET <RTC_NewBlastEditor_Form>().Show(); } else { StockpileManager_UISide.StashHistory.Add(newSk); S.GET <RTC_StashHistory_Form>().RefreshStashHistory(); S.GET <RTC_StockpileManager_Form>().dgvStockpile.ClearSelection(); S.GET <RTC_StashHistory_Form>().lbStashHistory.ClearSelected(); S.GET <RTC_StashHistory_Form>().DontLoadSelectedStash = true; S.GET <RTC_StashHistory_Form>().lbStashHistory.SelectedIndex = S.GET <RTC_StashHistory_Form>().lbStashHistory.Items.Count - 1; StockpileManager_UISide.CurrentStashkey = StockpileManager_UISide.StashHistory[S.GET <RTC_StashHistory_Form>().lbStashHistory.SelectedIndex]; } } finally { btnLoadCorrupt.Enabled = true; btnSendTo.Enabled = true; btnJustCorrupt.Enabled = true; } }