Пример #1
0
        public static bool InjectFromStashkey(StashKey sk, bool _loadBeforeOperation = true)
        {
            PreApplyStashkey();

            StashKey psk = RTC_StockpileManager.getCurrentSavestateStashkey();

            if (psk == null && loadBeforeOperation && _loadBeforeOperation)
            {
                RTC_Core.StopSound();
                MessageBox.Show("The Glitch Harvester could not perform the INJECT action\n\nEither no Savestate Box was selected in the Savestate Manager\nor the Savetate Box itself is empty.");
                RTC_Core.StartSound();
                return(false);
            }


            if (psk.SystemCore != sk.SystemCore && !RTC_Core.AllowCrossCoreCorruption)
            {
                MessageBox.Show("Merge attempt failed: Core mismatch\n\n" + $"{psk.GameName} -> {psk.SystemName} -> {psk.SystemCore}\n{sk.GameName} -> {sk.SystemName} -> {sk.SystemCore}");
                return(isCorruptionApplied);
            }


            currentStashkey             = new StashKey(RTC_Core.GetRandomKey(), psk.ParentKey, sk.BlastLayer);
            currentStashkey.RomFilename = psk.RomFilename;
            currentStashkey.SystemName  = psk.SystemName;
            currentStashkey.SystemCore  = psk.SystemCore;
            currentStashkey.GameName    = psk.GameName;

            if (loadBeforeOperation && _loadBeforeOperation)
            {
                if (!LoadStateAndBlastLayer(currentStashkey))
                {
                    return(false);
                }
            }
            else
            {
                RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.BLAST)
                {
                    blastlayer = sk.BlastLayer
                }, true);
            }

            isCorruptionApplied = (sk.BlastLayer != null);

            if (stashAfterOperation)
            {
                StashHistory.Add(currentStashkey);
                RTC_Core.ghForm.RefreshStashHistory();
            }

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
Пример #2
0
        public static bool Corrupt(bool _loadBeforeOperation = true)
        {
            PreApplyStashkey();

            var token = RTC_NetCore.HugeOperationStart("LAZY");

            StashKey psk = RTC_StockpileManager.getCurrentSavestateStashkey();

            if (psk == null)
            {
                RTC_Core.StopSound();
                MessageBox.Show("The Glitch Harvester could not perform the CORRUPT action\n\nEither no Savestate Box was selected in the Savestate Manager\nor the Savetate Box itself is empty.");
                RTC_Core.StartSound();
                RTC_NetCore.HugeOperationEnd(token);
                return(false);
            }

            string currentGame = (string)RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.REMOTE_KEY_GETGAMENAME), true);

            if (psk.GameName != currentGame)
            {
                RTC_Core.LoadRom(psk.RomFilename, true);
                RTC_Core.ecForm.RefreshDomains();
                RTC_Core.ecForm.setMemoryDomainsAllButSelectedDomains(RTC_MemoryDomains.GetBlacklistedDomains());
            }



            BlastLayer bl = (BlastLayer)RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.BLAST)
            {
                objectValue = RTC_MemoryDomains.SelectedDomains
            }, true);

            currentStashkey             = new StashKey(RTC_Core.GetRandomKey(), psk.ParentKey, bl);
            currentStashkey.RomFilename = psk.RomFilename;
            currentStashkey.SystemName  = psk.SystemName;
            currentStashkey.SystemCore  = psk.SystemCore;
            currentStashkey.GameName    = psk.GameName;

            if (loadBeforeOperation && _loadBeforeOperation)
            {
                if (!LoadStateAndBlastLayer(currentStashkey))
                {
                    RTC_NetCore.HugeOperationEnd(token);
                    return(isCorruptionApplied);
                }
            }
            else
            {
                RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.BLAST)
                {
                    blastlayer = bl
                });
            }

            isCorruptionApplied = (bl != null);

            if (stashAfterOperation && bl != null)
            {
                StashHistory.Add(currentStashkey);
                RTC_Core.ghForm.RefreshStashHistory();
                RTC_Core.ghForm.dgvStockpile.ClearSelection();
                RTC_Core.ghForm.DontLoadSelectedStash        = true;
                RTC_Core.ghForm.lbStashHistory.SelectedIndex = RTC_Core.ghForm.lbStashHistory.Items.Count - 1;
            }

            RTC_NetCore.HugeOperationEnd(token);

            PostApplyStashkey();
            return(isCorruptionApplied);
        }