Beispiel #1
0
        private void btnAutoKillSwitchExecute_Click(object sender, EventArgs e)
        {
            RTC_NetCore.HugeOperationReset();

            showPanelForm(RTC_Core.csForm);

            RTC.RTC_RPC.Heartbeat = false;
            RTC.RTC_Core.coreForm.pbAutoKillSwitchTimeout.Value = RTC.RTC_Core.coreForm.pbAutoKillSwitchTimeout.Maximum;
            RTC.RTC_RPC.Freeze = true;

            RTC_NetCoreSettings.PlayCrashSound(true);

            switch (btnAutoKillSwitchExecute.Text.ToUpper())
            {
            case "KILL":
                Process.Start("KILLDETACHEDRTC.bat");
                break;

            case "KILL + RESTART":
                Process.Start("RESTARTDETACHEDRTC.bat");
                break;

            case "RESTART + RESET":
                Process.Start("RESETDETACHEDRTC.bat");
                break;
            }
        }
        public static bool ApplyStashkey(StashKey sk, bool _loadBeforeOperation = true)
        {
            PreApplyStashkey();

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

            if (loadBeforeOperation && _loadBeforeOperation)
            {
                if (!LoadStateAndBlastLayer(sk))
                {
                    RTC_NetCore.HugeOperationEnd(token);
                    return(isCorruptionApplied);
                }
            }
            else
            {
                RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.BLAST)
                {
                    blastlayer = sk.BlastLayer, isReplay = true
                });
            }


            RTC_NetCore.HugeOperationEnd(token);

            isCorruptionApplied = (sk.BlastLayer != null && sk.BlastLayer.Layer.Count > 0);

            PostApplyStashkey();
            return(isCorruptionApplied);
        }
Beispiel #3
0
        public static void LOAD_SAVESTATE_END()
        {
            if (DisableRTC)
            {
                return;
            }

            RTC_NetCore.HugeOperationEnd();
        }
Beispiel #4
0
        public static void LOAD_SAVESTATE_BEGIN()
        {
            if (DisableRTC)
            {
                return;
            }

            RTC_NetCore.HugeOperationStart();
        }
Beispiel #5
0
        public static void LOAD_GAME_FAILED()
        {
            if (DisableRTC)
            {
                return;
            }

            RTC_NetCore.HugeOperationEnd();
        }
Beispiel #6
0
        public static void LOAD_GAME_DONE()
        {
            if (DisableRTC)
            {
                return;
            }

            //RTC_HellgenieEngine.ClearCheats();
            //RTC_PipeEngine.ClearPipes();

            //Glitch Harvester warning for archives

            string uppercaseFilename = GlobalWin.MainForm.CurrentlyOpenRom.ToUpper();

            if (RTC_Core.ghForm.Visible && (uppercaseFilename.Contains(".ZIP") || uppercaseFilename.Contains(".7Z")))
            {
                MessageBox.Show($"The rom {RTC_Extensions.getShortFilenameFromPath(uppercaseFilename)} is in an archive and can't be added to a Stockpile");
            }

            //Load Game vars into RTC_Core
            PathEntry pathEntry = Global.Config.PathEntries[Global.Game.System, "Savestates"] ??
                                  Global.Config.PathEntries[Global.Game.System, "Base"];

            RTC_StockpileManager.currentGameSystem = RTC_Core.EmuFolderCheck(pathEntry.SystemDisplayName);
            RTC_StockpileManager.currentGameName   = PathManager.FilesystemSafeName(Global.Game);
            RTC_Core.lastOpenRom = GlobalWin.MainForm.CurrentlyOpenRom;
            RTC_RPC.RefreshPlugin();


            //prepare memory domains in advance on bizhawk side
            RTC_MemoryDomains.RefreshDomains(false);


            if (RTC_StockpileManager.currentGameName != lastGameName)
            {
                RTC_Core.SendCommandToRTC(new RTC_Command(CommandType.REMOTE_EVENT_LOADGAMEDONE_NEWGAME));
            }
            else
            {
                RTC_Core.SendCommandToRTC(new RTC_Command(CommandType.REMOTE_EVENT_LOADGAMEDONE_SAMEGAME));
            }



            lastGameName = RTC_StockpileManager.currentGameName;

            //RTC_Restore.SaveRestore();

            RTC_NetCore.HugeOperationEnd();
        }
Beispiel #7
0
        public static void LOAD_GAME_BEGIN()
        {
            if (DisableRTC)
            {
                return;
            }

            isNormalAdvance = false;

            RTC_NetCore.HugeOperationStart();

            RTC_HellgenieEngine.ClearCheats(true);
            RTC_PipeEngine.ClearPipes(true);
        }
Beispiel #8
0
        public static void SendCommandToRTC(RTC_Command cmd)
        {
            //This is a NetCore wrapper that guarantees a NetCore command is sent to RTC no matter which mode.
            //It CANNOT query a value

            if (RTC_Core.RemoteRTC == null)
            {
                RTC_NetCore tempNetCore            = new RTC_NetCore();
                LinkedList <RTC_Command> tempQueue = new LinkedList <RTC_Command>();
                tempQueue.AddLast(cmd);
                Console.WriteLine($"TEMP_NetCore -> {cmd.Type.ToString()}");
                //Console.WriteLine($"{RTC_Core.RemoteRTC.expectedSide.ToString()}:SendCommand -> {cmd.Type.ToString()}");
                tempNetCore.ProcessQueue(tempQueue);
            }
            else
            {
                RemoteRTC.SendCommand(cmd, false);
            }
        }
Beispiel #9
0
        public static object SendCommandToBizhawk(RTC_Command cmd, bool sync = false, bool priority = false)
        {
            //This is a NetCore wrapper that guarantees a NetCore command is sent to BizHawk no matter which mode.
            //It can query a value in sync or async

            if (RemoteRTC == null)
            {
                RTC_NetCore tempNetCore            = new RTC_NetCore();
                LinkedList <RTC_Command> tempQueue = new LinkedList <RTC_Command>();
                tempQueue.AddLast(cmd);
                Console.WriteLine($"TEMP_NetCore -> {cmd.Type.ToString()}");
                if (sync)
                {
                    cmd.requestGuid = Guid.NewGuid();
                }
                return(tempNetCore.ProcessQueue(tempQueue, true));
            }
            else
            {
                if ((!RTC_Hooks.isRemoteRTC && !RTC_Core.isStandalone) || RemoteRTC.side == NetworkSide.CLIENT)
                {
                    if (sync)
                    {
                        return(RemoteRTC.SendSyncCommand(cmd, true, priority));
                    }
                    else
                    {
                        return(RemoteRTC.SendCommand(cmd, true, priority));
                    }
                }
                else
                {
                    if (sync)
                    {
                        return(RemoteRTC.SendSyncCommand(cmd, false, priority));
                    }
                    else
                    {
                        return(RemoteRTC.SendCommand(cmd, false, priority));
                    }
                }
            }
        }
Beispiel #10
0
        public static void AddVMD(VirtualMemoryDomain VMD)
        {
            RTC_MemoryDomains.VmdPool[VMD.ToString()] = VMD;

            if (RTC_Core.isStandalone)
            {
                var token = RTC_NetCore.HugeOperationStart();

                RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.REMOTE_DOMAIN_VMD_ADD)
                {
                    objectValue = VMD.proto
                }, true);

                RTC_NetCore.HugeOperationEnd(token);
            }

            if (!RTC_Hooks.isRemoteRTC)
            {
                RTC_Core.ecForm.RefreshDomainsAndKeepSelected();
            }
        }
Beispiel #11
0
        //This is the entry point of RTC. Without this method, nothing will load.
        public static void Start(Form _standaloneForm = null)
        {
            //Timed releases. Only for exceptionnal cases.
            bool     Expires      = false;
            DateTime ExpiringDate = DateTime.Parse("2017-03-03");

            if (Expires && DateTime.Now > ExpiringDate)
            {
                RTC_RPC.SendToKillSwitch("CLOSE");
                MessageBox.Show("This version has expired");
                GlobalWin.MainForm.Close();
                RTC_Core.coreForm.Close();
                RTC_Core.ghForm.Close();
                Application.Exit();
                return;
            }

            coreForm = new RTC_Core_Form();
            ecForm   = new RTC_EngineConfig_Form();
            spForm   = new RTC_StockpilePlayer_Form();
            ghForm   = new RTC_GlitchHarvester_Form();
            sForm    = new RTC_Settings_Form();

            multiForm           = new RTC_Multiplayer_Form();
            multipeerpopoutForm = new RTC_MultiPeerPopout_Form();
            sbForm      = new RTC_StockpileBlastBoard_Form();
            beForm      = new RTC_BlastEditor_Form();
            vmdPoolForm = new RTC_VmdPool_Form();
            vmdGenForm  = new RTC_VmdGen_Form();
            vmdActForm  = new RTC_VmdAct_Form();

            standaloneForm = _standaloneForm;


            if (!Directory.Exists(RTC_Core.rtcDir + "\\TEMP\\"))
            {
                Directory.CreateDirectory(RTC_Core.rtcDir + "\\TEMP\\");
            }

            if (!Directory.Exists(RTC_Core.rtcDir + "\\TEMP2\\"))
            {
                Directory.CreateDirectory(RTC_Core.rtcDir + "\\TEMP2\\");
            }

            if (!Directory.Exists(RTC_Core.rtcDir + "\\TEMP3\\"))
            {
                Directory.CreateDirectory(RTC_Core.rtcDir + "\\TEMP3\\");
            }

            if (!Directory.Exists(RTC_Core.rtcDir + "\\TEMP4\\"))
            {
                Directory.CreateDirectory(RTC_Core.rtcDir + "\\TEMP4\\");
            }


            //Loading RTC PArams
            RTC_Params.LoadRTCColor();
            RTC_Core.sForm.cbDisableBizhawkOSD.Checked        = !RTC_Params.IsParamSet("ENABLE_BIZHAWK_OSD");
            RTC_Core.sForm.cbAllowCrossCoreCorruption.Checked = RTC_Params.IsParamSet("ALLOW_CROSS_CORE_CORRUPTION");

            //Initiation of loopback TCP, only in DETACHED MODE
            if (RTC_Hooks.isRemoteRTC || RTC_Core.isStandalone)
            {
                RemoteRTC         = new RTC_NetCore();
                RemoteRTC.port    = 42042;
                RemoteRTC.address = "";
            }

            //Initialize RemoteRTC server
            if (RTC_Hooks.isRemoteRTC && !RTC_Core.isStandalone)
            {
                //Bizhawk has started in REMOTERTC mode, no RTC form will be loaded
                RemoteRTC.StartNetworking(NetworkSide.CLIENT, true);
                RemoteRTC.SendCommand(new RTC_Command(CommandType.REMOTE_EVENT_BIZHAWKSTARTED), false, true);
            }
            else
            {
                //Setup of Detached-exclusive features
                if (RTC_Core.isStandalone)
                {
                    coreForm.Text = "RTC : Detached Mode";

                    if (csForm == null)
                    {
                        csForm = new RTC_ConnectionStatus_Form();
                    }

                    RTC_Core.coreForm.showPanelForm(csForm);

                    RemoteRTC.ServerStarted += new EventHandler((ob, ev) =>
                    {
                        RemoteRTC_SupposedToBeConnected = false;
                        Console.WriteLine("RemoteRTC.ServerStarted");


                        if (csForm != null && !csForm.IsDisposed)
                        {
                            if (RTC_Core.csForm == null)
                            {
                                csForm = new RTC_ConnectionStatus_Form();
                            }

                            RTC_Core.coreForm.showPanelForm(csForm);
                        }

                        if (ghForm != null && !ghForm.IsDisposed)
                        {
                            ghForm.pnHideGlitchHarvester.BringToFront();
                            ghForm.pnHideGlitchHarvester.Show();
                        }
                    });

                    RemoteRTC.ServerConnected += new EventHandler((ob, ev) =>
                    {
                        RemoteRTC_SupposedToBeConnected = true;
                        Console.WriteLine("RemoteRTC.ServerConnected");
                        csForm.lbConnectionStatus.Text = "Connection status: Connected";

                        if (FirstConnection)
                        {
                            FirstConnection = false;
                            coreForm.btnEngineConfig_Click(ob, ev);
                        }
                        else
                        {
                            coreForm.showPanelForm(coreForm.previousForm, false);
                        }

                        ghForm.pnHideGlitchHarvester.Hide();
                        csForm.btnStartEmuhawkDetached.Text = "Restart BizHawk";

                        RTC_RPC.Heartbeat = true;
                        RTC_RPC.Freeze    = false;
                    });


                    RemoteRTC.ServerConnectionLost += new EventHandler((ob, ev) =>
                    {
                        RemoteRTC_SupposedToBeConnected = false;
                        Console.WriteLine("RemoteRTC.ServerConnectionLost");


                        if (csForm != null && !csForm.IsDisposed)
                        {
                            csForm.lbConnectionStatus.Text = "Connection status: Bizhawk timed out";
                            coreForm.showPanelForm(csForm);
                        }

                        if (ghForm != null && !ghForm.IsDisposed)
                        {
                            ghForm.lbConnectionStatus.Text = "Connection status: Bizhawk timed out";
                            ghForm.pnHideGlitchHarvester.BringToFront();
                            ghForm.pnHideGlitchHarvester.Show();
                        }

                        RTC_GameProtection.Stop();
                    });

                    RemoteRTC.ServerDisconnected += new EventHandler((ob, ev) =>
                    {
                        RemoteRTC_SupposedToBeConnected = false;
                        Console.WriteLine("RemoteRTC.ServerDisconnected");
                        csForm.lbConnectionStatus.Text = "Connection status: NetCore Shutdown";
                        ghForm.lbConnectionStatus.Text = "Connection status: NetCore Shutdown";
                        coreForm.showPanelForm(csForm);

                        ghForm.pnHideGlitchHarvester.BringToFront();
                        ghForm.pnHideGlitchHarvester.Show();

                        RTC_GameProtection.Stop();
                    });

                    RemoteRTC.StartNetworking(NetworkSide.SERVER, false, false);
                }
                else if (RTC_Hooks.isRemoteRTC)
                {                 //WILL THIS EVER HAPPEN? TO BE REMOVED IF NOT
                    RemoteRTC.StartNetworking(NetworkSide.SERVER, false, true);
                }

                // Show the main RTC Form
                coreForm.Show();
            }

            //Starting UDP loopback for Killswitch and External Rom Plugins
            RTC_RPC.Start();


            //Refocus on Bizhawk
            if (GlobalWin.MainForm != null)
            {
                GlobalWin.MainForm.Focus();
            }


            //Force create bizhawk config file if it doesn't exist
            if (!File.Exists(RTC_Core.bizhawkDir + "\\config.ini"))
            {
                RTC_Hooks.BIZHAWK_SAVE_CONFIG();
            }

            //Fetch NetCore aggressiveness
            if (RTC_Hooks.isRemoteRTC)
            {
                RTC_Core.SendCommandToRTC(new RTC_Command(CommandType.GETAGGRESSIVENESS));
            }
        }
        private void track_Intensity_MouseUp(object sender, MouseEventArgs e)
        {
            RTC_NetCore.HugeOperationEnd();

            track_Intensity_Scroll(sender, e);
        }
 private void track_Intensity_MouseDown(object sender, MouseEventArgs e)
 {
     RTC_NetCore.HugeOperationStart("LAZY");
 }
        public static bool MergeStashkeys(List <StashKey> sks, bool _stashAfterOperation = true)
        {
            PreApplyStashkey();

            if (sks != null && sks.Count > 1)
            {
                var token = RTC_NetCore.HugeOperationStart();


                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 && !RTC_Core.AllowCrossCoreCorruption)
                {
                    MessageBox.Show("Merge attempt failed: Core mismatch\n\n" + string.Join("\n", sks.Select(it => $"{it.GameName} -> {it.SystemName} -> {it.SystemCore}")));
                    RTC_NetCore.HugeOperationEnd(token);

                    return(false);
                }

                BlastLayer bl = new BlastLayer();

                foreach (StashKey item in sks)
                {
                    bl.Layer.AddRange(item.BlastLayer.Layer);
                }



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

                //RTC_NetCore.HugeOperationEnd(token);
                token = RTC_NetCore.HugeOperationStart("LAZY");

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

                isCorruptionApplied = (currentStashkey.BlastLayer != null && currentStashkey.BlastLayer.Layer.Count > 0);

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

                RTC_NetCore.HugeOperationEnd(token);

                PostApplyStashkey();
                return(true);
            }
            else
            {
                MessageBox.Show("You need 2 or more items for Merging");
                return(false);
            }
        }
        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);
        }