Exemplo n.º 1
0
        // Quartz.NET Job Executor
        public void Execute(IJobExecutionContext context)
        {
            _log.Debug("Checking all victims if they have bans on record.");

            _log.Information("Victims: {a}", _victims);

            foreach (var victim in _victims.ToArray())
            {
                var target = SteamUtil.FromSteamID64(victim.SteamID);
                var bans   = Titan.Instance.BanManager.GetBanInfoFor(target);
                var time   = DateTime.Now.Subtract(new DateTime(victim.Ticks));

                if (bans.GameBanCount > 0 || bans.VacBanned)
                {
                    var count = bans.GameBanCount == 0 ? bans.VacBanCount : bans.GameBanCount;
                    var id64  = target.ConvertToUInt64();

                    if (_victims.Remove(victim))
                    {
                        _log.Information("Your recently botted target {Target} received " +
                                         "{Count} ban(s) after {Delay}. Thank you for using Titan.",
                                         id64, count, time.Hours == 0 ? time.Minutes + " minute(s)" : time.Hours + " hour(s)");

                        Titan.Instance.UIManager.SendNotification(
                            "Titan - " + id64 + " banned",
                            "Your recently botted target " + id64 + " " +
                            "has been banned and has now " + count + " Ban(s) on record."
                            );
                    }
                }
            }
        }
Exemplo n.º 2
0
        public string Play()
        {
            if (!SteamUtil.IsSteamRunning())
            {
                MessageBox.Show("Steam must be opened to play Portal 2 splitScreen. Open it then click OK.");
            }

            // minimize everything
            User32.MinimizeEverything();

            // copy the correct xinput to the bin folder
            byte[] xdata = GamesResources.Portal_xinput1_3;
            xinputPath = Path.Combine(binFolder, "xinput1_3.dll");
            using (MemoryStream stream = new MemoryStream(xdata))
            {
                // write to bin folder
                using (FileStream file = new FileStream(xinputPath, FileMode.Create))
                {
                    stream.WriteTo(file);
                }
            }

            int pid = StartGameUtil.StartGame(executablePlace, "-novid", 0);

            proc = Process.GetProcessById(pid);

            loaded = true;
            return(string.Empty);
        }
Exemplo n.º 3
0
        private async void TsmiReDownload_Click(object sender, EventArgs e)
        {
            try {
                var existingIDs = ContentUtil.GetSubscribedItems();
                var steamItems  = ConfigWrapper.instance.SteamCache.Items;
                var ids         = steamItems
                                  .Where(item => item.Status.IsBroken() && existingIDs.Contains(item.PublishedFileId))
                                  .Select(item => item.ID)
                                  .Concat(ContentUtil.GetMissingDirItems()) // missing root dir
                                  .Distinct()
                                  .ToArray();
                SteamUtil.ReDownload(ids);

                var res = MessageBox.Show(
                    "You can monitor download progress in steam client. Wait for steam to finish downloading. Then press OK to refresh everything.\n" +
                    "should this not work the first time please try again", "Wait for download");
                ConfigWrapper.instance.CSCache.MissingDir             = new ulong[0];
                LoadOrderWindow.Instance.DownloadWarningLabel.Visible = false;
                foreach (var item in steamItems)
                {
                    if (item.Status.IsBroken() && item.DTO != null)
                    {
                        item.RefreshIsUpToDate();
                    }
                }
                await LoadOrderWindow.Instance.ReloadAll(); // reload to fix included/excluded, paths, ...
            } catch (Exception ex) { ex.Log(); }
        }
Exemplo n.º 4
0
    public void SetOpenSaveOrWorkshop(bool on)
    {
        if (!on)
        {
#if USE_STEAMWORKS
            workshopInfo.Close();
#endif
            saveMenu.SetOpen(false);
            return;
        }

        if (!ShowWorkshopInfo())
        {
            saveMenu.SetOpen(true);
        }
        else
        {
#if USE_STEAMWORKS
            SteamUtil.GetWorkShopItem(GetWorkshopFileID(), maybeItem =>
            {
                if (!maybeItem.IsEmpty())
                {
                    LapinerTools.Steam.Data.WorkshopItem item = maybeItem.Value;
                    workshopInfo.Open(maybeItem.Value);
                }
            });
#endif
        }
    }
Exemplo n.º 5
0
        public void SaveVictimsFile()
        {
            using (var writer = new StreamWriter(_file.ToString(), false))
            {
                // TODO: Change this ugly workaround

                if (_victims != null && _victims.Count > 0)
                {
                    var victims = new Victims
                    {
                        Array = (from victim in _victims
                                 let bans = Titan.Instance.BanManager.GetBanInfoFor(SteamUtil.FromSteamID64(victim.SteamID))
                                            where !(bans.GameBanCount > 0 || bans.VacBanned)
                                            select victim).ToArray()
                    };

                    writer.Write(JsonConvert.SerializeObject(victims, Formatting.Indented));
                }
                else
                {
                    writer.Write("{\"victims\":[]}");
                }
            }

            _log.Debug("Successfully wrote Victim file.");
        }
Exemplo n.º 6
0
        public void SaveVictimsFile()
        {
            using (var writer = new StreamWriter(_file.ToString(), false))
            {
                if (_victims != null && _victims.Count > 0)
                {
                    var victimList = new List <Victims.Victim>();

                    foreach (var victim in _victims)
                    {
                        if (Titan.Instance.WebHandle.RequestBanInfo(SteamUtil.FromSteamID64(victim.SteamID),
                                                                    out var banInfo))
                        {
                            if (!(banInfo.GameBanCount > 0 || banInfo.VacBanned))
                            {
                                victimList.Add(victim);
                            }
                        }
                    }

                    var victims = new Victims
                    {
                        Array = victimList.ToArray()
                    };

                    writer.Write(JsonConvert.SerializeObject(victims, Formatting.Indented));
                }
                else
                {
                    writer.Write("{\"victims\":[]}");
                }
            }

            _log.Debug("Successfully wrote Victim file.");
        }
Exemplo n.º 7
0
        public void TestCleanHistory()
        {
            Skip.If(_handle.GetKey() == null, "No valid Steam Web API key has been provided with this test case.");

            if (_handle.RequestBanInfo(SteamUtil.FromSteamID("STEAM_0:0:131983088"), out var banInfo))
            {
                Assert.True(!banInfo.VacBanned && banInfo.GameBanCount <= 0);
            }
        }
Exemplo n.º 8
0
        public void TestVacBan()
        {
            Skip.If(_handle.GetKey() == null, "No valid Steam Web API key has been provided with this test case.");

            if (_handle.RequestBanInfo(SteamUtil.FromSteamID("STEAM_0:0:19877565"), out var banInfo))
            {
                Assert.True(banInfo.VacBanned);
            }
        }
Exemplo n.º 9
0
        public void TestGameBan()
        {
            Skip.If(_handle.GetKey() == null, "No valid Steam Web API key has been provided with this test case.");

            if (_handle.RequestBanInfo(SteamUtil.FromSteamID("STEAM_0:0:208017504"), out var banInfo))
            {
                Assert.True(banInfo.GameBanCount > 0);
            }
        }
Exemplo n.º 10
0
 public void TestSteamIDParser()
 {
     if (SteamUtil.FromSteamID("STEAM_0:0:131983088").ConvertToUInt64() == 76561198224231904)
     {
         Assert.True(true, "Steam ID parsing successfull");
     }
     else
     {
         Assert.True(false);
     }
 }
Exemplo n.º 11
0
 public void TestSteamID3Parser()
 {
     if (SteamUtil.FromSteamID3("[U:1:263966176]").ConvertToUInt64() == 76561198224231904)
     {
         Assert.True(true, "Steam ID parsing successfull");
     }
     else
     {
         Assert.True(false);
     }
 }
Exemplo n.º 12
0
 public void TestAutoTypeParser(string id)
 {
     if (SteamUtil.Parse(id).ConvertToUInt64() == 76561198224231904)
     {
         Assert.True(true, "Steam ID parsing successfull");
     }
     else
     {
         Assert.True(false);
     }
 }
Exemplo n.º 13
0
    IEnumerator QueryResumeInfoCoroutine(ResumeOptionHandler handler)
    {
        if (PlayerPrefs.HasKey(NetworkingController.LastJoinedRoomPrefKey) &&
            !PlayerPrefs.GetString(NetworkingController.LastJoinedRoomPrefKey).IsNullOrEmpty())
        {
            handler.HandleJoinCode(PlayerPrefs.GetString(NetworkingController.LastJoinedRoomPrefKey));
            yield break;
        }

        if (!PlayerPrefs.HasKey(ResumeInfoPlayerPrefKey))
        {
            yield break;
        }

        // Hmm ideally this is done in GetWorkShopItem, but I need to make that a MonoBehaviour.
#if USE_STEAMWORKS
        while (!SteamManager.Initialized)
        {
            yield return(null);
        }
#endif

        ResumeInfo info = JsonUtility.FromJson <ResumeInfo>(PlayerPrefs.GetString(ResumeInfoPlayerPrefKey));
#if USE_STEAMWORKS
        if (info.steamWorkshopFileId != 0)
        {
            SteamUtil.GetWorkShopItem(info.steamWorkshopFileId, item =>
            {
                if (!item.IsEmpty())
                {
                    handler.HandleWorkshopItem(item.Value);
                }
            });
            yield break;
        }
        else
#endif
        if (info.bundleId != null)
        {
            handler.HandleBundleId(info.bundleId);
            yield break;
        }
        else
        {
            Util.LogError($"resume pref key exists, but it didn't have valid info. Json: {PlayerPrefs.GetString(ResumeInfoPlayerPrefKey)}");
        }
    }
Exemplo n.º 14
0
        public void TestGameBan()
        {
            if (WebAPIKeyResolver.APIKey != null)
            {
                var banInfo = _banManager.GetBanInfoFor(SteamUtil.FromSteamID("STEAM_0:0:208017504"));

                if (banInfo != null && banInfo.GameBanCount > 0)
                {
                    Assert.True(true, "topkektux has game bans on record.");
                }
                else
                {
                    Assert.True(false);
                }
                // STEAM_0:0:208017504
                // https://steamcommunity.com/id/TopKekTux/
            }
        }
Exemplo n.º 15
0
        public void TestCleanHistory()
        {
            if (WebAPIKeyResolver.APIKey != null)
            {
                var banInfo = _banManager.GetBanInfoFor(SteamUtil.FromSteamID("STEAM_0:0:131983088"));

                if (banInfo != null && (!banInfo.VacBanned && banInfo.GameBanCount <= 0))
                {
                    Assert.True(true, "Marc3842h has no bans on record.");
                }
                else
                {
                    Assert.True(false);
                }
                // STEAM_0:0:131983088
                // https://steamcommunity.com/id/Marc3842h/
            }
        }
Exemplo n.º 16
0
        public void TestVacBan()
        {
            if (WebAPIKeyResolver.APIKey != null)
            {
                var banInfo = _banManager.GetBanInfoFor(SteamUtil.FromSteamID("STEAM_0:0:19877565"));

                if (banInfo != null && banInfo.VacBanned)
                {
                    Assert.True(true, "KQLY has VAC bans on record.");
                }
                else
                {
                    Assert.True(false);
                }
                // STEAM_0:0:19877565
                // https://steamcommunity.com/id/kqly/
            }
        }
Exemplo n.º 17
0
        // Quartz.NET Job Executor
        public Task Execute(IJobExecutionContext context)
        {
            return(Task.Run(() =>
            {
                _log.Debug("Checking all victims if they have bans on record.");

                _log.Information("Victims: {a}", _victims);

                foreach (var victim in _victims.ToArray())
                {
                    var target = SteamUtil.FromSteamID64(victim.SteamID);
                    var time = DateTime.Now.Subtract(victim.Timestamp.ToDateTime());

                    if (Titan.Instance.WebHandle.RequestBanInfo(target, out var banInfo))
                    {
                        if (banInfo.GameBanCount > 0 || banInfo.VacBanned)
                        {
                            var count = banInfo.GameBanCount == 0 ? banInfo.VacBanCount : banInfo.GameBanCount;
                            var id64 = target.ConvertToUInt64();

                            if (_victims.Remove(victim))
                            {
                                if (!Titan.Instance.Options.Secure)
                                {
                                    _log.Information("Your recently botted target {Target} received " +
                                                     "{Count} ban(s) after {Delay}. Thank you for using Titan.",
                                                     id64, count,
                                                     time.Hours == 0 ? time.Minutes + " minute(s)" : time.Hours + " hour(s)");

                                    Titan.Instance.UIManager.SendNotification(
                                        "Titan - " + id64 + " banned",
                                        "Your recently botted target " + id64 + " " +
                                        "has been banned and has now " + count + " Ban(s) on record.",
                                        () => Process.Start("http://steamcommunity.com/profiles/" + id64)
                                        );
                                }
                            }
                        }
                    }
                }
            }));
        }
Exemplo n.º 18
0
        // Quartz.NET Job Executor
        public void Execute(IJobExecutionContext context)
        {
            _log.Debug("Checking all victims if they have bans on record.");

            _log.Information("Victims: {a}", _victims);

            foreach (var victim in _victims.ToArray())
            {
                var target = SteamUtil.FromSteamID64(victim.SteamID);
                var bans   = Titan.Instance.BanManager.GetBanInfoFor(target);
                var time   = DateTime.Now.Subtract(new DateTime(victim.Ticks));

                if (bans.GameBanCount > 0 || bans.VacBanned)
                {
                    var count = bans.GameBanCount == 0 ? bans.VacBanCount : bans.GameBanCount;
                    var id64  = target.ConvertToUInt64();

                    if (_victims.Remove(victim))
                    {
                        _log.Information("Your recently botted target {Target} received " +
                                         "{Count} ban(s) after {Delay}. Thank you for using Titan.",
                                         id64, count, time.Hours == 0 ? time.Minutes + " minute(s)" : time.Hours + " hour(s)");

                        var notification = new Notification
                        {
                            Title   = "Titan - " + id64 + " banned",
                            Message = "Your recently botted target " + id64 + " " +
                                      "has been banned and has now " + count + " Ban(s) on record.",
                            Icon = Titan.Instance.UIManager.SharedResources.TITAN_ICON
                        };

                        notification.Activated += delegate
                        {
                            Process.Start("https://steamcommunity.com/profiles/" + id64 + "/");
                        };

                        Application.Instance.Invoke(() => notification.Show());
                    }
                }
            }
        }
Exemplo n.º 19
0
        public void OnBombButtonClick(object sender, EventArgs args)
        {
            var mode = (BotMode)_dropDown.SelectedIndex;

            if (!string.IsNullOrWhiteSpace(_targetBox.Text))
            {
                var matchid = string.IsNullOrWhiteSpace(_matchIDBox.Text) ? 8 : SharecodeUtil.Parse(_matchIDBox.Text);

                var steamId = SteamUtil.Parse(_targetBox.Text);

                if (steamId == null)
                {
                    MessageBox.Show("Titan - Error", "Could not parse Steam ID " +
                                    _targetBox.Text + " to Steam ID. Please provide a valid " +
                                    "SteamID, SteamID3 or SteamID64.", MessageBoxType.Error);

                    return;
                }

                var targetBanInfo = Titan.Instance.BanManager.GetBanInfoFor(steamId.ConvertToUInt64());
                if (targetBanInfo != null)
                {
                    if (targetBanInfo.VacBanned || targetBanInfo.GameBanCount > 0)
                    {
                        _log.Warning("The target has already been banned. Are you sure you " +
                                     "want to bot this player? Ignore this message if the " +
                                     "target has been banned in other games.");
                    }
                }

                _log.Information("Starting bombing of {Target} in Match {Match}.",
                                 _targetBox.Text, matchid);

                Titan.Instance.AccountManager.StartBotting(mode, steamId, matchid);
            }
            else
            {
                MessageBox.Show("Please provide a target.", MessageBoxType.Error);
            }
        }
Exemplo n.º 20
0
    IEnumerator GetRoutine(ulong fileId, System.Action <Util.Maybe <string> > onComplete, System.Action <float> onProgress, System.Action <WorkshopItem> handleItem)
    {
        yield return(null);

        // In the non-Steam cache?
        string cachedItemDir = Path.Combine(cacheDirectory ?? "", fileId.ToString());

        Util.Log($"Looking for cached {cachedItemDir} - cacherootDir: {cacheDirectory}");
        if (cacheDirectory != null && Directory.Exists(cachedItemDir))
        {
            Util.Log($"OK load asset from cache: {cachedItemDir}");
            onComplete(Util.Maybe <string> .CreateWith(cachedItemDir));
            yield break;
        }

        if (!SteamManager.Initialized)
        {
            onComplete(Util.Maybe <string> .CreateError("Steam Workshop not available. Are you logged in? Maybe it's down?"));
            yield break;
        }
        SteamUtil.GetWorkShopItem(fileId, maybeItem => GetWorkshopHandler(maybeItem, onComplete, onProgress, handleItem));
    }
Exemplo n.º 21
0
    //TO DO: Steam panel here...

    public void Open()
    {
        gameObject.SetActive(true);

#if USE_STEAMWORKS
        if (steamLoadedItemId == 0)
        {
            // saveMenu.Open();
        }
        else
        {
            SteamUtil.GetWorkShopItem(steamLoadedItemId, maybeItem =>
            {
                if (!maybeItem.IsEmpty())
                {
                    currentItem = maybeItem.Value;
                    steamDetailPanel.Open(maybeItem.Value);
                }
            });
        }
#endif

        UpdateMultiplayerAdminButtonsVisibility();
    }
Exemplo n.º 22
0
        public string Play()
        {
            if (!SteamUtil.IsSteamRunning())
            {
                MessageBox.Show("If you own the Steam Version, please open Steam, then click OK");
            }

            IniFile file = new IniFile(saveFile);

            file.IniWriteValue("WillowGame.WillowGameEngine", "bPauseLostFocusWindowed", "FALSE");
            file.IniWriteValue("WillowGame.WillowGameEngine", "bMuteAudioWhenNotInFocus", "False");
            file.IniWriteValue("Engine.Engine", "bPauseOnLossOfFocus", "False");

            Screen[]  all     = Screen.AllScreens;
            Screen    first   = all[0];
            Rectangle fbounds = first.Bounds;

            // minimize everything
            User32.MinimizeEverything();

            object playerKey      = options["keyboardPlayer"].Value;
            bool   playerKeyboard = (bool)playerKey;

            for (int i = 0; i < playas.Count; i++)
            {
                PlayerInfo player = playas[i];
                // Set Borderlands 2 Resolution and stuff to run
                Screen    screen = all[player.ScreenIndex];
                int       width  = 0;
                int       height = 0;
                Rectangle bounds = screen.Bounds;

                Point location = new Point();

                ViewportUtil.GetPlayerViewport(player, titleHeight, out width, out height, out location);

                file.IniWriteValue("SystemSettings", "ResX", width.ToString(CultureInfo.InvariantCulture));
                file.IniWriteValue("SystemSettings", "ResY", height.ToString(CultureInfo.InvariantCulture));

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName    = executablePlace;
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;

                // NEW
                object option = options["saveid" + i].Value;
                int    id     = (int)option;


                if (playerKeyboard)
                {
                    startInfo.Arguments = "-windowed -AlwaysFocus -NoController -ControllerOffset=" + (i - 1).ToString(CultureInfo.InvariantCulture) + " -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    startInfo.Arguments = "-windowed -AlwaysFocus -ControllerOffset=" + i.ToString(CultureInfo.InvariantCulture) + " -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture);
                }


                startInfo.UseShellExecute  = true;
                startInfo.WorkingDirectory = Path.GetDirectoryName(executablePlace);

                Process    proc = Process.Start(startInfo);
                HwndObject hwnd = new HwndObject(proc.Handle);

                ScreenData data = new ScreenData();
                data.Position  = location;
                data.HWND      = hwnd;
                data.Size      = new Size(width, height);
                player.Process = proc;
                player.Tag     = data;

                Thread.Sleep(delayTime);
            }

            return(string.Empty);
        }
Exemplo n.º 23
0
        public override TabPage GetTabPage()
        {
            var txtBoxSteamID = new TextBox {
                PlaceholderText = "STEAM_0:0:131983088"
            };
            var txtBoxMatchID = new TextBox {
                PlaceholderText = "CSGO-727c4-5oCG3-PurVX-sJkdn-LsXfE"
            };

            // CS:GO
            var cbAbusiveText = new CheckBox {
                Text = "Abusive Text Chat", Checked = true
            };
            var cbAbusiveVoice = new CheckBox {
                Text = "Abusive Voice Chat", Checked = true
            };
            var cbGriefing = new CheckBox {
                Text = "Griefing", Checked = true
            };
            var cbCheatAim = new CheckBox {
                Text = "Aim Hacking", Checked = true
            };
            var cbCheatWall = new CheckBox {
                Text = "Wall Hacking", Checked = true
            };
            var cbCheatOther = new CheckBox {
                Text = "Other Hacking", Checked = true
            };

            var csgoGroupBox = new GroupBox
            {
                Text    = "Options",
                Visible = true,
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows    =
                    {
                        new TableRow(
                            new TableCell(cbAbusiveText,  true),
                            new TableCell(cbAbusiveVoice, true),
                            new TableCell(cbGriefing,     true)
                            ),
                        new TableRow(
                            new TableCell(cbCheatAim),
                            new TableCell(cbCheatWall),
                            new TableCell(cbCheatOther)
                            )
                    }
                }
            };

            // TF2
            var dropReportReason = new DropDown
            {
                Items         = { "Cheating", "Idling", "Harassment", "Griefing" },
                SelectedIndex = 0
            };

            var tf2GroupBox = new GroupBox
            {
                Text    = "Options",
                Visible = false,
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows    =
                    {
                        new TableRow(
                            new TableCell(new Label {
                            Text = "Reason"
                        }, true),
                            new TableCell(dropReportReason, true)
                            )
                    }
                }
            };

            var dropIndexes = new DropDown();

            RefreshIndexesDropDown(dropIndexes);
            DropDownIndex.Add(dropIndexes);

            var cbAllIndexes = new CheckBox {
                Text = "Use all accounts", Checked = false
            };

            cbAllIndexes.CheckedChanged += (sender, args) =>
            {
                if (cbAllIndexes.Checked != null)
                {
                    dropIndexes.Enabled = (bool)!cbAllIndexes.Checked;
                }
                else
                {
                    cbAllIndexes.Checked = false;
                }
            };

            var dropGame = new DropDown
            {
                Items         = { "Counter-Strike: Global Offensive", "Team Fortress 2" },
                SelectedIndex = 0
            };

            dropGame.SelectedIndexChanged += (sender, args) =>
            {
                txtBoxMatchID.Enabled = dropGame.SelectedIndex == 0;

                csgoGroupBox.Visible = dropGame.SelectedIndex == 0;
                tf2GroupBox.Visible  = dropGame.SelectedIndex == 1;

                _log.Debug("Switched game to {game}.", dropGame.SelectedValue);
            };

            var btnReport = new Button {
                Text = "Report"
            };

            btnReport.Click += (sender, args) =>
            {
                if (!string.IsNullOrWhiteSpace(txtBoxSteamID.Text))
                {
                    var steamID = SteamUtil.Parse(txtBoxSteamID.Text);
                    var matchID = SharecodeUtil.Parse(txtBoxMatchID.Text);

                    if (steamID != null)
                    {
                        if (steamID.IsBlacklisted(dropGame.ToAppID()))
                        {
                            UIManager.SendNotification(
                                "Restriction applied",
                                "The target you are trying to report is blacklisted from botting " +
                                "in Titan.",
                                () => Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist")
                                );
                            return;
                        }

                        if (matchID == 8 && dropGame.SelectedIndex == 0)
                        {
                            _log.Warning("Could not convert {ID} to a valid Match ID. Trying to resolve the " +
                                         "the Match ID in which the target is playing at the moment.", matchID);

                            Titan.Instance.AccountManager.StartMatchIDResolving(
                                cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                                new LiveGameInfo
                            {
                                SteamID = steamID,
                                AppID   = TitanAccount.CSGO_APPID
                            });
                        }

                        if (Titan.Instance.WebHandle.RequestBanInfo(steamID.ConvertToUInt64(), out var banInfo))
                        {
                            if (banInfo.VacBanned || banInfo.GameBanCount > 0)
                            {
                                _log.Warning("The target has already been banned. Are you sure you " +
                                             "want to bot this player? Ignore this message if the " +
                                             "target has been banned in other games.");
                            }

                            if (Titan.Instance.VictimTracker.IsVictim(steamID))
                            {
                                _log.Warning("You already report botted this victim. " +
                                             "Are you sure you want to bot this player? " +
                                             "Ignore this message if the first report didn't have enough reports.");
                            }

                            _log.Information("Starting reporting of {Target} in Match {Match} in game {Game}.",
                                             steamID.ConvertToUInt64(), matchID, dropGame.SelectedValue);

                            Titan.Instance.AccountManager.StartReporting(
                                cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                                new ReportInfo {
                                SteamID = steamID,
                                MatchID = matchID,
                                AppID   = dropGame.ToAppID(),

                                AbusiveText  = cbAbusiveText.Checked != null && (bool)cbAbusiveText.Checked,
                                AbusiveVoice = cbAbusiveVoice.Checked != null && (bool)cbAbusiveVoice.Checked,
                                Griefing     = cbGriefing.Checked != null && (bool)cbGriefing.Checked,
                                AimHacking   = cbCheatAim.Checked != null && (bool)cbCheatAim.Checked,
                                WallHacking  = cbCheatWall.Checked != null && (bool)cbCheatWall.Checked,
                                OtherHacking = cbCheatOther.Checked != null && (bool)cbCheatOther.Checked,

                                Reason = dropReportReason.ToTF2ReportReason()
                            });
                        }
                    }
                    else
                    {
                        UIManager.SendNotification(
                            "Titan - Error", "Could not parse Steam ID " +
                            txtBoxSteamID.Text + " to Steam ID. Please provide a valid " +
                            "SteamID, SteamID3 or SteamID64."
                            );
                    }
                }
                else
                {
                    UIManager.SendNotification(
                        "Titan - Error", "Please provide a valid target."
                        );
                }
            };

            return(new TabPage
            {
                Text = "Report",
                Enabled = !Titan.Instance.DummyMode,
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows =
                    {
                        new GroupBox
                        {
                            Text = "Target",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Steam ID"
                                    }, true),
                                        new TableCell(txtBoxSteamID, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Match ID"
                                    }),
                                        new TableCell(txtBoxMatchID)
                                        )
                                }
                            }
                        },
                        csgoGroupBox,
                        tf2GroupBox,
                        new GroupBox
                        {
                            Text = "Bots",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Use Index"
                                    }, true),
                                        new TableCell(dropIndexes, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Panel()),
                                        new TableCell(cbAllIndexes)
                                        )
                                }
                            }
                        },
                        new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows =
                            {
                                new TableRow(
                                    new TableCell(dropGame),
                                    new TableCell(new Panel(),true),
                                    new TableCell(new Panel(),true),
                                    new TableCell(btnReport)
                                    ),
                                new TableRow                    {
                                    ScaleHeight = true
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 24
0
        public static int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            Instance = new Titan
            {
                Options = new Options()
            };

            Logger = LogCreator.Create();

            if (Environment.CurrentDirectory != Instance.Directory.ToString())
            {
                Logger.Debug("Run from {currentDir}, switching to work directory in {workingDir}.",
                             Environment.CurrentDirectory, Instance.Directory.ToString());
            }

            // Windows users run the program by double clicking Titan.exe (and then it opens a console window)
            // and in case of exception occurence, this window gets immediatly closed which is bad because
            // they're unable to attach the stacktrace then. Prevent it by waiting until the user presses a key.
            #if !__UNIX__
            AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) =>
            {
                if (eventArgs.IsTerminating)
                {
                    Logger.Error((Exception)eventArgs.ExceptionObject, "An error occured.");

                    // Don't use logging object here incase the exception was thrown by a logger
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                }
            };
            #endif

            // The bridge between Common Logging and Serilog uses the global Logger (Log.Logger).
            // As Quartz.NET is the only dependency using Common Logging (and because of our bridge the global logger)
            // we're creating the global logger as Quartz logger (which hides annoying debug messages).
            Log.Logger = LogCreator.CreateQuartzLogger();

            // Quartz.NET
            Instance.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
            Instance.Scheduler.Start();

            Instance.JsonSerializer = new JsonSerializer();

            Instance.HttpClient = new HttpClient();
            Instance.HttpClient.DefaultRequestHeaders.Add(
                "User-Agent", "Titan Report & Commend Bot (https://github.com/Marc3842h/Titan)"
                );

            var parser = new Parser(config =>
            {
                config.IgnoreUnknownArguments = true;
                config.EnableDashDash         = true;
                config.HelpWriter             = TextWriter.Null;
            });

            // Default
            parser.ParseArguments <Options>(args)
            .WithParsed(options =>
            {
                Instance.Options = options;
            });

            // Verbs
            parser.ParseArguments <ReportOptions, CommendOptions>(args)
            .WithParsed <ReportOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithParsed <CommendOptions>(options =>
            {
                Instance.EnableUI     = false;
                Instance.ParsedObject = options;
            })
            .WithNotParsed(error =>
            {
                if (Instance.ParsedObject == null)
                {
                    Instance.EnableUI = true;
                    Logger.Information("No valid verb has been provided while parsing. Opening UI...");
                }
            });

            new Config.Config().Load();

            // Reinitialize logger with new parsed debug option
            Logger = LogCreator.Create();

            #if __UNIX__
            Instance.IsAdmin = Linux.getuid() == 0;     // UID of root is always 0
            #else
            Instance.IsAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent())
                               .IsInRole(WindowsBuiltInRole.Administrator);
            #endif

            if (Instance.IsAdmin)
            {
                if (!Instance.Options.AllowAdmin)
                {
                    Logger.Error("Titan is running as administrator or root.");
                    Logger.Error("This is not supported. Titan will refuse to start until you start it as normal " +
                                 "user. If you are unable to do this for any reason, start Titan with the --admin " +
                                 "option to force the usage of administrator rights.");

                    #if !__UNIX__
                    Console.Write("Press any key to exit Titan...");
                    Console.Read();
                    #endif

                    Instance.Scheduler.Shutdown();
                    return((int)ExitCodes.RunningAsAdmin);
                }

                Logger.Warning("Titan has been started as Administrator but will continue to run as the " +
                               "--admin option has been passed. Please note that Steam also doesn't allow to be " +
                               "run from root and that it may be insecure.");
            }

            if (Instance.Options.Debug)
            {
                Instance.DebugDirectory = new DirectoryInfo(Path.Combine(Instance.Directory.ToString(), "debug"));

                if (!Instance.DebugDirectory.Exists)
                {
                    Instance.DebugDirectory.Create();
                }

                if (Instance.Options.SteamKitDebug)
                {
                    DebugLog.AddListener(new TitanListener());
                    DebugLog.Enabled = true;
                }
            }

            if (Instance.Options.Secure)
            {
                Logger.Debug("Secure mode has been enabled. Titan will output no sensitive data.");
            }

            if (Instance.Options.DisableBlacklist)
            {
                Logger.Debug("Blacklist has been disabled by passing the --noblacklist option.");
            }

            Instance.ProfileSaver = new ProfileSaver();

            if (Instance.EnableUI)
            {
                try
                {
                    Instance.UIManager = new UIManager();
                }
                catch (InvalidOperationException ex)
                {
                    if (!string.IsNullOrEmpty(ex.Message) && ex.Message.ToLower().Contains("could not detect platform"))
                    {
                        Logger.Error("---------------------------------------");
                        Logger.Error("A fatal error has been detected!");
                        Logger.Error("Eto.Forms could not detect your current operating system.");

                        #if __UNIX__
                        Logger.Error("Please install {0}, {1}, {2} and {3} before submitting a bug report.",
                                     "Mono (\u22655.4)",
                                     "Gtk 3",
                                     "libNotify",
                                     "libAppindicator3");
                        #else
                        Logger.Error("Please install {0} before submitting a bug report.",
                                     ".NET Framework (\u22654.6.1)");
                        #endif

                        Logger.Error("Contact {Marc} on Discord if the issue still persists after installing " +
                                     "the dependencies listed above.", "Marc3842h#7312");
                        Logger.Error("---------------------------------------");
                        Logger.Debug(ex, "Include the error below if you\'re contacting Marc on Discord.");

                        #if !__UNIX__
                        Console.Write("Press any key to exit Titan...");
                        Console.Read();
                        #endif

                        Instance.Scheduler.Shutdown();
                        return((int)ExitCodes.UIInitFailed);
                    }

                    Logger.Error(ex, "A error occured while loading UI.");
                    throw;
                }
            }


            Instance.AccountManager = new AccountManager(new FileInfo(
                                                             Path.Combine(Instance.Directory.ToString(), Instance.Options.AccountsFile))
                                                         );

            Instance.ThreadManager = new ThreadManager();

            Instance.WebHandle = new SWAHandle();

            Instance.VictimTracker = new VictimTracker();

            AppDomain.CurrentDomain.ProcessExit += OnShutdown;

            Instance.AccountManager.ParseAccountFile();

            Task.Run(() => TimeAligner.AlignTime());

            if (Instance.EnableUI)
            {
                Instance.UIManager.InitializeForms();
            }

            // Load after Forms were initialized
            Instance.WebHandle.Load();

            // VictimTracker depends on the web api key being loaded correctly.
            Instance.VictimTracker.InitTrigger();

            var attribute = Assembly.GetEntryAssembly().GetCustomAttribute <AssemblyInformationalVersionAttribute>();
            var version   = attribute != null ? attribute.InformationalVersion :
                            Assembly.GetEntryAssembly().GetName().Version.Major + "." +
                            Assembly.GetEntryAssembly().GetName().Version.Minor + "." +
                            Assembly.GetEntryAssembly().GetName().Version.Build;

            Logger.Information("Hello and welcome to Titan {version}.", "v" + version);

            if (Instance.EnableUI && Instance.ParsedObject == null || Instance.DummyMode)
            {
                Instance.UIManager.ShowForm(UIType.General);
            }
            else
            {
                if (Instance.ParsedObject.GetType() == typeof(ReportOptions))
                {
                    var opt = (ReportOptions)Instance.ParsedObject;

                    var steamID = SteamUtil.Parse(opt.Target);
                    if (steamID.IsBlacklisted(opt.Game.ToAppID()))
                    {
                        Instance.UIManager.SendNotification(
                            "Restriction applied",
                            "The target you are trying to report is blacklisted from botting " +
                            "in Titan.",
                            () => Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist")
                            );
                    }
                    else
                    {
                        Instance.AccountManager.StartReporting(Instance.AccountManager.Index,
                                                               new ReportInfo
                        {
                            SteamID = SteamUtil.Parse(opt.Target),
                            MatchID = SharecodeUtil.Parse(opt.Match),
                            AppID   = opt.Game.ToAppID(),

                            AbusiveText  = opt.AbusiveTextChat,
                            AbusiveVoice = opt.AbusiveVoiceChat,
                            Griefing     = opt.Griefing,
                            AimHacking   = opt.AimHacking,
                            WallHacking  = opt.WallHacking,
                            OtherHacking = opt.OtherHacking
                        });
                    }
                }
                else if (Instance.ParsedObject.GetType() == typeof(CommendOptions))
                {
                    var opt = (CommendOptions)Instance.ParsedObject;

                    Instance.AccountManager.StartCommending(Instance.AccountManager.Index,
                                                            new CommendInfo
                    {
                        SteamID = SteamUtil.Parse(opt.Target),
                        AppID   = TitanAccount.CSGO_APPID,

                        Friendly = opt.Friendly,
                        Leader   = opt.Leader,
                        Teacher  = opt.Teacher
                    });
                }
                else
                {
                    Instance.UIManager.ShowForm(UIType.General);
                }
            }

            Instance.Scheduler.ScheduleJob(Instance.VictimTracker.Job, Instance.VictimTracker.Trigger);

            Logger.Debug("Startup done. Active threads: {threads}", Process.GetCurrentProcess().Threads.Count + 1);

            Instance.StartMainLoop();

            // The Shutdown handler gets only called after the last thread finished.
            // Quartz runs a Watchdog until Scheduler#Shutdown is called, so we're calling it
            // before Titan will be calling the Shutdown Hook.
            Logger.Debug("Shutting down Quartz.NET Scheduler.");

            Instance.Scheduler.Shutdown();

            return((int)ExitCodes.Ok);
        }
Exemplo n.º 25
0
        public TabPage GetReportTab()
        {
            var txtBoxSteamID = new TextBox {
                PlaceholderText = "STEAM_0:0:131983088"
            };
            var txtBoxMatchID = new TextBox {
                PlaceholderText = "CSGO-727c4-5oCG3-PurVX-sJkdn-LsXfE"
            };

            var cbAbusiveText = new CheckBox {
                Text = "Abusive Text Chat", Checked = true
            };
            var cbAbusiveVoice = new CheckBox {
                Text = "Abusive Voice Chat", Checked = true
            };
            var cbGriefing = new CheckBox {
                Text = "Griefing", Checked = true
            };
            var cbCheatAim = new CheckBox {
                Text = "Aim Hacking", Checked = true
            };
            var cbCheatWall = new CheckBox {
                Text = "Wall Hacking", Checked = true
            };
            var cbCheatOther = new CheckBox {
                Text = "Other Hacking", Checked = true
            };

            var dropIndexes = new DropDown();

            foreach (var i in Titan.Instance.AccountManager.Accounts)
            {
                if (i.Key != -1)
                {
                    dropIndexes.Items.Add("#" + i.Key + " (" + i.Value.Count + " accounts)");
                }
            }
            dropIndexes.SelectedIndex = Titan.Instance.AccountManager.Index;

            var cbAllIndexes = new CheckBox {
                Text = "Use all accounts", Checked = false
            };

            cbAllIndexes.CheckedChanged += delegate
            {
                if (cbAllIndexes.Checked != null)
                {
                    dropIndexes.Enabled = (bool)!cbAllIndexes.Checked;
                }
                else
                {
                    cbAllIndexes.Checked = false;
                }
            };

            var btnReport = new Button {
                Text = "Report"
            };

            btnReport.Click += delegate
            {
                if (!string.IsNullOrWhiteSpace(txtBoxSteamID.Text))
                {
                    var steamID = SteamUtil.Parse(txtBoxSteamID.Text);
                    var matchID = SharecodeUtil.Parse(txtBoxMatchID.Text);

                    if (steamID != null)
                    {
                        if (matchID == 8)
                        {
                            _log.Warning("Could not convert {ID} to a valid Match ID. Trying to resolve the " +
                                         "the Match ID in which the target is playing at the moment.", matchID);

                            Titan.Instance.AccountManager.StartMatchIDResolving(
                                cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                                new LiveGameInfo {
                                SteamID = steamID
                            });
                        }

                        if (Blacklist.IsBlacklisted(steamID))
                        {
                            Titan.Instance.UIManager.SendNotification(
                                "Restriction applied",
                                "The target you are trying to report is blacklisted from botting " +
                                "in Titan.",
                                delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
                                );
                            return;
                        }

                        var targetBanInfo = Titan.Instance.BanManager.GetBanInfoFor(steamID.ConvertToUInt64());
                        if (targetBanInfo != null)
                        {
                            if (targetBanInfo.VacBanned || targetBanInfo.GameBanCount > 0)
                            {
                                _log.Warning("The target has already been banned. Are you sure you " +
                                             "want to bot this player? Ignore this message if the " +
                                             "target has been banned in other games.");
                            }

                            if (Titan.Instance.VictimTracker.IsVictim(steamID))
                            {
                                _log.Warning("You already report botted this victim. " +
                                             "Are you sure you want to bot this player? " +
                                             "Ignore this message if the first report didn't have enough reports.");
                            }

                            _log.Information("Starting reporting of {Target} in Match {Match}.",
                                             steamID.ConvertToUInt64(), matchID);

                            Titan.Instance.AccountManager.StartReporting(
                                cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                                new ReportInfo {
                                SteamID = steamID,
                                MatchID = matchID,

                                AbusiveText  = cbAbusiveText.Checked != null && (bool)cbAbusiveText.Checked,
                                AbusiveVoice = cbAbusiveVoice.Checked != null && (bool)cbAbusiveVoice.Checked,
                                Griefing     = cbGriefing.Checked != null && (bool)cbGriefing.Checked,
                                AimHacking   = cbCheatAim.Checked != null && (bool)cbCheatAim.Checked,
                                WallHacking  = cbCheatWall.Checked != null && (bool)cbCheatWall.Checked,
                                OtherHacking = cbCheatOther.Checked != null && (bool)cbCheatOther.Checked
                            });
                        }
                    }
                    else
                    {
                        Titan.Instance.UIManager.SendNotification(
                            "Titan - Error", "Could not parse Steam ID " +
                            txtBoxSteamID.Text + " to Steam ID. Please provide a valid " +
                            "SteamID, SteamID3 or SteamID64."
                            );
                    }
                }
                else
                {
                    Titan.Instance.UIManager.SendNotification(
                        "Titan - Error", "Please provide a valid target."
                        );
                }
            };

            return(new TabPage
            {
                Text = "Report",
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows =
                    {
                        new GroupBox
                        {
                            Text = "Target",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Steam ID"
                                    }, true),
                                        new TableCell(txtBoxSteamID, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Match ID"
                                    }),
                                        new TableCell(txtBoxMatchID)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Options",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(cbAbusiveText,  true),
                                        new TableCell(cbAbusiveVoice, true),
                                        new TableCell(cbGriefing,     true)
                                        ),
                                    new TableRow(
                                        new TableCell(cbCheatAim),
                                        new TableCell(cbCheatWall),
                                        new TableCell(cbCheatOther)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Bots",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Use Index"
                                    }, true),
                                        new TableCell(dropIndexes, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Panel()),
                                        new TableCell(cbAllIndexes)
                                        )
                                }
                            }
                        },
                        new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows =
                            {
                                new TableRow(
                                    new TableCell(new Panel(), true),
                                    new TableCell(new Panel(), true),
                                    new TableCell(btnReport)
                                    ),
                                new TableRow                    {
                                    ScaleHeight = true
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 26
0
        public TabPage GetCommendTab()
        {
            var txtBoxSteamID = new TextBox {
                PlaceholderText = "STEAM_0:0:131983088"
            };

            var cbLeader = new CheckBox {
                Text = "Leader", Checked = true
            };
            var cbFriendly = new CheckBox {
                Text = "Friendly", Checked = true
            };
            var cbTeacher = new CheckBox {
                Text = "Teacher", Checked = true
            };

            var dropIndexes = new DropDown();

            foreach (var i in Titan.Instance.AccountManager.Accounts)
            {
                if (i.Key != -1)
                {
                    dropIndexes.Items.Add("#" + i.Key + " (" + i.Value.Count + " accounts)");
                }
            }
            dropIndexes.SelectedIndex = Titan.Instance.AccountManager.Index;

            var cbAllIndexes = new CheckBox {
                Text = "Use all accounts", Checked = false
            };

            cbAllIndexes.CheckedChanged += delegate
            {
                if (cbAllIndexes.Checked != null)
                {
                    dropIndexes.Enabled = (bool)!cbAllIndexes.Checked;
                }
                else
                {
                    cbAllIndexes.Checked = false;
                }
            };

            var btnCommend = new Button {
                Text = "Commend"
            };

            btnCommend.Click += delegate
            {
                if (!string.IsNullOrWhiteSpace(txtBoxSteamID.Text))
                {
                    var steamID = SteamUtil.Parse(txtBoxSteamID.Text);

                    if (steamID != null)
                    {
                        if (Blacklist.IsBlacklisted(steamID))
                        {
                            Titan.Instance.UIManager.SendNotification(
                                "Restriction applied",
                                "The target you are trying to report is blacklisted from botting " +
                                "in Titan.",
                                delegate { Process.Start("https://github.com/Marc3842h/Titan/wiki/Blacklist"); }
                                );
                            return;
                        }

                        _log.Information("Starting commending of {Target}.",
                                         steamID.ConvertToUInt64());

                        Titan.Instance.AccountManager.StartCommending(
                            cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                            new CommendInfo {
                            SteamID = steamID,

                            Leader   = cbLeader.Checked != null && (bool)cbLeader.Checked,
                            Friendly = cbFriendly.Checked != null && (bool)cbFriendly.Checked,
                            Teacher  = cbTeacher.Checked != null && (bool)cbTeacher.Checked
                        });
                    }
                    else
                    {
                        Titan.Instance.UIManager.SendNotification(
                            "Titan - Error", "Could not parse Steam ID "
                            + txtBoxSteamID.Text + " to Steam ID. Please provide a valid " +
                            "SteamID, SteamID3 or SteamID64."
                            );
                    }
                }
                else
                {
                    Titan.Instance.UIManager.SendNotification(
                        "Titan - Error", "Please provide a valid target."
                        );
                }
            };

            return(new TabPage
            {
                Text = "Commend",
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows =
                    {
                        new GroupBox
                        {
                            Text = "Target",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Steam ID"
                                    }, true),
                                        new TableCell(txtBoxSteamID, true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Options",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(cbLeader,   true),
                                        new TableCell(cbFriendly, true),
                                        new TableCell(cbTeacher,  true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Bots",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Use Index"
                                    }, true),
                                        new TableCell(dropIndexes, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Panel()),
                                        new TableCell(cbAllIndexes)
                                        )
                                }
                            }
                        },
                        new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows =
                            {
                                new TableRow(
                                    new TableCell(new Panel(), true),
                                    new TableCell(new Panel(), true),
                                    new TableCell(btnCommend)
                                    ),
                                new TableRow
                                {
                                    ScaleHeight = true
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 27
0
        public string Play()
        {
            if (!SteamUtil.IsSteamRunning())
            {
                return("Steam must be opened to play Left 4 Dead 2 splitScreen");
            }

            using (Stream videoStream = new FileStream(videoFile, FileMode.Open))
            {
                videoCfg = new SourceCfgFile(videoStream);
            }
            string originalCFG = String.Copy(videoCfg.RawData);

            // minimize everything
            User32.MinimizeEverything();
            Screen[] allScreens = Screen.AllScreens;

            string folder    = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string l4dFolder = Path.GetDirectoryName(executablePlace);
            int    gamePadId = 0;


            if (instances)
            {
                for (int i = 0; i < players.Count; i++)
                {
                    PlayerInfo p = players[i];

                    Screen    screen   = allScreens[p.ScreenIndex];
                    int       width    = 0;
                    int       height   = 0;
                    Rectangle bounds   = screen.Bounds;
                    Point     location = new Point();

                    ViewportUtil.GetPlayerViewport(p, 0, out width, out height, out location);

                    CultureInfo c = CultureInfo.InvariantCulture;
                    UpdateVideoCfg(width.ToString(c), height.ToString(c), "0", "1");

                    if (i == 0)
                    {
                        MakeAutoExecServer();
                    }
                    else
                    {
                        MakeAutoExecClient();
                    }
                    MakeMakeSplit();

                    string execPlace = executablePlace;
                    string l4dBinFolder;
                    if (i == 0)
                    {
                        l4dBinFolder = Path.Combine(l4dFolder, "bin");
                    }
                    else
                    {
                        string l4d = Path.Combine(folder, "L4D2_" + (i + 1));
                        Directory.CreateDirectory(l4d);

                        int exitCode;
                        #region mklink
                        CmdUtil.ExecuteCommand(l4d, out exitCode,
                                               "mklink /d \"" + Path.Combine(l4d, "config") + "\" \"" + Path.Combine(l4dFolder, "config") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "hl2") + "\" \"" + Path.Combine(l4dFolder, "hl2") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "left4dead2") + "\" \"" + Path.Combine(l4dFolder, "left4dead2") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc1") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc1") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc2") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc2") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "left4dead2_dlc3") + "\" \"" + Path.Combine(l4dFolder, "left4dead2_dlc3") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "platform") + "\" \"" + Path.Combine(l4dFolder, "platform") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "RemStorage") + "\" \"" + Path.Combine(l4dFolder, "RemStorage") + "\"",
                                               "mklink /d \"" + Path.Combine(l4d, "update") + "\" \"" + Path.Combine(l4dFolder, "update") + "\"");
                        #endregion

                        // copy executable
                        File.Copy(Path.Combine(l4dFolder, "left4dead2.exe"), Path.Combine(l4d, "left4dead2.exe"), true);

                        // make bin folder now
                        l4dBinFolder = Path.Combine(l4d, "bin");
                        string originalBinFolder = Path.Combine(l4dFolder, "bin");
                        Directory.CreateDirectory(l4dBinFolder);

                        #region mklink
                        CmdUtil.ExecuteCommand(l4d, out exitCode,
                                               "mklink /d \"" + Path.Combine(l4dBinFolder, "dedicated") + "\"  \"" + Path.Combine(originalBinFolder, "dedicated") + "\"",
                                               "mklink /d \"" + Path.Combine(l4dBinFolder, "linux32") + "\"  \"" + Path.Combine(originalBinFolder, "linux32") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "addoninstaller.exe") + "\"  \"" + Path.Combine(originalBinFolder, "addoninstaller.exe") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "addoninstaller_osx") + "\"  \"" + Path.Combine(originalBinFolder, "addoninstaller_osx") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "adminserver.dll") + "\"  \"" + Path.Combine(originalBinFolder, "adminserver.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "binkw32.dll") + "\"  \"" + Path.Combine(originalBinFolder, "binkw32.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "bsppack.dll") + "\"  \"" + Path.Combine(originalBinFolder, "bsppack.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "bugreporter.dll") + "\"  \"" + Path.Combine(originalBinFolder, "bugreporter.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "bugreporter_public.dll") + "\"  \"" + Path.Combine(originalBinFolder, "bugreporter_public.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "chromehtml.dll") + "\"  \"" + Path.Combine(originalBinFolder, "chromehtml.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "config.SoftTHconfig") + "\"  \"" + Path.Combine(originalBinFolder, "config.SoftTHconfig") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "crashhandler.dll") + "\"  \"" + Path.Combine(originalBinFolder, "crashhandler.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "datacache.dll") + "\"  \"" + Path.Combine(originalBinFolder, "datacache.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport.cfg") + "\"  \"" + Path.Combine(originalBinFolder, "dxsupport.cfg") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport_episodic.cfg") + "\"  \"" + Path.Combine(originalBinFolder, "dxsupport_episodic.cfg") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "dxsupport_mac.cfg") + "\"  \"" + Path.Combine(originalBinFolder, "dxsupport_mac.cfg") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "engine.dll") + "\"  \"" + Path.Combine(originalBinFolder, "engine.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "export_entity_group.pl") + "\"  \"" + Path.Combine(originalBinFolder, "export_entity_group.pl") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "export_entity_layer.pl") + "\"  \"" + Path.Combine(originalBinFolder, "export_entity_layer.pl") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "filesystemopendialog.dll") + "\"  \"" + Path.Combine(originalBinFolder, "filesystemopendialog.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "filesystem_stdio.dll") + "\"  \"" + Path.Combine(originalBinFolder, "filesystem_stdio.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "GameOverlayRenderer.log") + "\"  \"" + Path.Combine(originalBinFolder, "GameOverlayRenderer.log") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "gameui.dll") + "\"  \"" + Path.Combine(originalBinFolder, "gameui.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "hl_ent.cnt") + "\"  \"" + Path.Combine(originalBinFolder, "hl_ent.cnt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "icudt.dll") + "\"  \"" + Path.Combine(originalBinFolder, "icudt.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "icudt42.dll") + "\"  \"" + Path.Combine(originalBinFolder, "icudt42.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "inputsystem.dll") + "\"  \"" + Path.Combine(originalBinFolder, "inputsystem.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "launcher.dll") + "\"  \"" + Path.Combine(originalBinFolder, "launcher.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "libcef.dll") + "\"  \"" + Path.Combine(originalBinFolder, "libcef.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "libmysql.dll") + "\"  \"" + Path.Combine(originalBinFolder, "libmysql.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "maplist_terror.txt") + "\"  \"" + Path.Combine(originalBinFolder, "maplist_terror.txt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "materialsystem.dll") + "\"  \"" + Path.Combine(originalBinFolder, "materialsystem.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mdllib.dll") + "\"  \"" + Path.Combine(originalBinFolder, "mdllib.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mss32.dll") + "\"  \"" + Path.Combine(originalBinFolder, "mss32.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mssdolby.flt") + "\"  \"" + Path.Combine(originalBinFolder, "mssdolby.flt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mssds3d.flt") + "\"  \"" + Path.Combine(originalBinFolder, "mssds3d.flt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mssdsp.flt") + "\"  \"" + Path.Combine(originalBinFolder, "mssdsp.flt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "msseax.flt") + "\"  \"" + Path.Combine(originalBinFolder, "msseax.flt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "mssmp3.asi") + "\"  \"" + Path.Combine(originalBinFolder, "mssmp3.asi") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "msssrs.flt") + "\"  \"" + Path.Combine(originalBinFolder, "msssrs.flt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "msvcr71.dll") + "\"  \"" + Path.Combine(originalBinFolder, "msvcr71.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "parsifal.dll") + "\"  \"" + Path.Combine(originalBinFolder, "parsifal.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "rdmwin32.dll") + "\"  \"" + Path.Combine(originalBinFolder, "rdmwin32.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "scenefilecache.dll") + "\"  \"" + Path.Combine(originalBinFolder, "scenefilecache.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "serverbrowser.dll") + "\"  \"" + Path.Combine(originalBinFolder, "serverbrowser.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "serverplugin_empty.dll") + "\"  \"" + Path.Combine(originalBinFolder, "serverplugin_empty.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "shaderapidx10.dll") + "\"  \"" + Path.Combine(originalBinFolder, "shaderapidx10.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "shaderapidx9.dll") + "\"  \"" + Path.Combine(originalBinFolder, "shaderapidx9.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "shaderapiempty.dll") + "\"  \"" + Path.Combine(originalBinFolder, "shaderapiempty.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "soundemittersystem.dll") + "\"  \"" + Path.Combine(originalBinFolder, "soundemittersystem.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "soundsystem.dll") + "\"  \"" + Path.Combine(originalBinFolder, "soundsystem.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "stats.bin") + "\"  \"" + Path.Combine(originalBinFolder, "stats.bin") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "stdshader_dbg.dll") + "\"  \"" + Path.Combine(originalBinFolder, "stdshader_dbg.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "stdshader_dx9.dll") + "\"  \"" + Path.Combine(originalBinFolder, "stdshader_dx9.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "Steam.dll") + "\"  \"" + Path.Combine(originalBinFolder, "Steam.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "steamclient.dll") + "\"  \"" + Path.Combine(originalBinFolder, "steamclient.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "steamclient_l4d2.dll") + "\"  \"" + Path.Combine(originalBinFolder, "steamclient_l4d2.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "steam_api.dll") + "\"  \"" + Path.Combine(originalBinFolder, "steam_api.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "steam_appid.txt") + "\"  \"" + Path.Combine(originalBinFolder, "steam_appid.txt") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "Steam_l4d2.dll") + "\"  \"" + Path.Combine(originalBinFolder, "Steam_l4d2.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "studiorender.dll") + "\"  \"" + Path.Combine(originalBinFolder, "studiorender.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "texturecompile_dll.dll") + "\"  \"" + Path.Combine(originalBinFolder, "texturecompile_dll.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "tier0.dll") + "\"  \"" + Path.Combine(originalBinFolder, "tier0.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "tier0_s.dll") + "\"  \"" + Path.Combine(originalBinFolder, "tier0_s.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "unicode.dll") + "\"  \"" + Path.Combine(originalBinFolder, "unicode.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "unicows.dll") + "\"  \"" + Path.Combine(originalBinFolder, "unicows.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "unitlib.dll") + "\"  \"" + Path.Combine(originalBinFolder, "unitlib.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "valve_avi.dll") + "\"  \"" + Path.Combine(originalBinFolder, "valve_avi.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vaudio_miles.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vaudio_miles.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vaudio_speex.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vaudio_speex.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vgui2.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vgui2.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vguimatsurface.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vguimatsurface.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vidcfg.bin") + "\"  \"" + Path.Combine(originalBinFolder, "vidcfg.bin") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vphysics.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vphysics.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vscript.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vscript.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vstdlib.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vstdlib.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vstdlib_s.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vstdlib_s.dll") + "\"",
                                               "mklink \"" + Path.Combine(l4dBinFolder, "vtex_dll.dll") + "\"  \"" + Path.Combine(originalBinFolder, "vtex_dll.dll") + "\"");
                        #endregion

                        execPlace = Path.Combine(l4d, "left4dead2.exe");
                    }

                    if ((int)keyboardId == i)
                    {
                        // delete if there are any xinput
                        string xinputPath = Path.Combine(l4dBinFolder, "xinput1_3.dll");
                        if (File.Exists(xinputPath))
                        {
                            File.Delete(xinputPath);
                        }
                    }
                    else
                    {
                        // copy the correct xinput to the bin folder
                        byte[] xdata = null;
                        switch (gamePadId)
                        {
                        case 0:
                            xdata = Nucleus.Coop.Games.GamesResources._1_xinput1_3;
                            break;

                        case 1:
                            xdata = Nucleus.Coop.Games.GamesResources._2_xinput1_3;
                            break;

                        case 2:
                            xdata = Nucleus.Coop.Games.GamesResources._3_xinput1_3;
                            break;

                        case 3:
                            xdata = Nucleus.Coop.Games.GamesResources._4_xinput1_3;
                            break;

                        default:
                            xdata = Nucleus.Coop.Games.GamesResources._4_xinput1_3;
                            break;
                        }
                        string xinputPath = Path.Combine(l4dBinFolder, "xinput1_3.dll");
                        using (MemoryStream stream = new MemoryStream(xdata))
                        {
                            // write to bin folder
                            using (FileStream file = new FileStream(xinputPath, FileMode.Create))
                            {
                                stream.CopyTo(file);
                            }
                        }
                        gamePadId++;
                    }


                    int pid = StartGameUtil.StartGame(execPlace,
                                                      "-novid -insecure", delayTime, "hl2_singleton_mutex", "steam_singleton_mutext");
                    Process proc = Process.GetProcessById(pid);

                    HwndObject hwnd = new HwndObject(proc.Handle);
                    ScreenData data = new ScreenData();
                    data.Position = location;
                    data.HWND     = hwnd;
                    data.Size     = new Size(width, height);
                    p.Process     = proc;
                    p.Tag         = data;

                    Thread.Sleep(delayTime);

                    //uint processHandle;
                    //IntPtr windowHandle = proc.MainWindowHandle;
                    //uint threadID = User32.GetWindowThreadProcessId(windowHandle, out processHandle);
                    //bool installed = InstallHook(threadID);
                }
            }
            else
            {
                List <DuetPlayerInfo> duets = ViewportUtil.GetPlayerDuets(players);
                for (int i = 0; i < duets.Count; i++)
                {
                    DuetPlayerInfo duet = duets[i];
                }
            }

            int  screenIndex = -1;
            bool twoScreens  = false;
            int  fullWidth   = 0;
            int  fullHeight  = 0;
            for (int i = 0; i < players.Count; i++)
            {
                PlayerInfo player = players[i];
                Screen     scr    = allScreens[player.ScreenIndex];

                if (screenIndex == -1)
                {
                    screenIndex = player.ScreenIndex;
                    fullWidth   = scr.Bounds.Width;
                    fullHeight  = scr.Bounds.Height;
                }
                else
                {
                    if (screenIndex != player.ScreenIndex)
                    {
                        twoScreens = true;
                        // Add 2nd monitor
                        fullWidth += scr.Bounds.Width;
                    }
                }
            }

            loaded = true;

            return("");

            string fWidth            = fullWidth.ToString();
            string fHeight           = fullHeight.ToString();
            string fullScr           = (0).ToString();
            string noWindowBorderStr = (1).ToString();

            //if (players.Count == 1)
            //{
            //    // 1 monitor
            //    Screen monitor = allScreens[players.First().Key];
            //    fWidth = monitor.Bounds.Width.ToString(CultureInfo.InvariantCulture);
            //    fHeight = monitor.Bounds.Height.ToString(CultureInfo.InvariantCulture);

            //    fullScr = (0).ToString();
            //    noWindowBorderStr = (1).ToString();
            //}
            //else
            //{
            //    // 2 or more monitors

            //    //??
            //    fullScr = (1).ToString();
            //    noWindowBorderStr = (0).ToString();
            //}

            fWidth  = "1920";// 960x540
            fHeight = "540";

            string d3d9Path = binFolder + @"\d3d9.dll";
            // SoftTH
            if (twoScreens)
            {
                // Copy SoftTH to the game folder
                // Get the SoftTH stream
                if (!File.Exists(d3d9Path))
                {
                    using (MemoryStream stream = new MemoryStream(Nucleus.Coop.Games.GamesResources.d3d9))
                    {
                        // write to bin folder
                        using (FileStream file = new FileStream(d3d9Path, FileMode.Create))
                        {
                            stream.CopyTo(file);
                        }
                    }
                }
            }
            else
            {
                // Delete SoftTH from the game folder
                FileInfo file = new FileInfo(d3d9Path);
                // Only delete if it's not read only
                if (File.Exists(d3d9Path))
                {
                    File.Delete(d3d9Path);
                }
            }

            // PAK hex edit
            if (twoScreens)
            {
                FileInfo f = new FileInfo(pak01_000_path);
                if (!f.IsReadOnly)
                {
                    // make a backup of pak01_000, if it isn't already made
                    string dir = Path.GetDirectoryName(backupPak);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    if (!File.Exists(backupPak))
                    {
                        File.Copy(pak01_000_path, backupPak);
                    }

                    using (FileStream str = File.OpenRead(backupPak))
                    {
                        // Now modify some stuff
                        // Eat Point that comes at 29.664.480
                        // The 8 is at position 29.664.483

                        // 29.675.904

                        byte one = 49;
                        byte six = 54;

                        using (FileStream stream = new FileStream(pak01_000_path, FileMode.Create))
                        {
                            byte[] buff = new byte[4096];

                            int point = 29664480;

                            while (str.Position < point)
                            {
                                int length = 4096;
                                if (point - str.Position < length)
                                {
                                    length = (int)(point - str.Position);
                                }

                                str.Read(buff, 0, length);
                                stream.Write(buff, 0, length);
                            }
                            // Jumps 1 byte
                            str.Position += 1;

                            str.Read(buff, 0, 2);
                            stream.Write(buff, 0, 2);

                            // Jumps the 8
                            str.Position += 1;

                            buff[0] = one;
                            buff[1] = six;
                            stream.Write(buff, 0, 2);

                            while (stream.Position < str.Length)
                            {
                                int length = 4096;
                                if (str.Length - str.Position < length)
                                {
                                    length = (int)(str.Length - str.Position);
                                }

                                str.Read(buff, 0, length);
                                stream.Write(buff, 0, length);
                            }
                        }
                    }

                    f.IsReadOnly = true;
                }
            }
            //else
            //{
            //    if (File.Exists(backupPak))
            //    {
            //        if (File.Exists(pak01_000))
            //        {
            //            FileInfo f = new FileInfo(pak01_000);
            //            f.IsReadOnly = false;
            //            File.Delete(pak01_000);
            //        }
            //        File.Copy(backupPak, pak01_000);
            //    }
            //}

            int splitMode = 1;
            for (int i = 0; i < players.Count; i++)
            {
                PlayerInfo player = players[i];
                if (player.ScreenType == ScreenType.HorizontalBottom ||
                    player.ScreenType == ScreenType.HorizontalTop)
                {
                    splitMode = 1;
                }
                else
                {
                    splitMode = 2;
                }
            }


            MakeAutoExecSplitscreen(splitMode.ToString(CultureInfo.InvariantCulture));
            MakeMakeSplit();


            /* if (player.ScreenType == ScreenType.VerticalLeft ||
             *      player.ScreenType == ScreenType.VerticalRight)*/

            //ss_splitmode 1 = horizontal
            //ss_splitmode 2 = vertical

            //ProcessStartInfo startInfo = new ProcessStartInfo();
            //startInfo.FileName = executablePlace;
            //startInfo.WindowStyle = ProcessWindowStyle.Hidden;

            //MessageBox.Show("Press the F8 key after the game is loaded to begin splitscreen!");

            //proc = Process.Start(startInfo);


            return(string.Empty);
        }
Exemplo n.º 28
0
        private TabPage GetCommendTab()
        {
            var txtBoxSteamID = new TextBox {
                PlaceholderText = "STEAM_0:0:131983088"
            };

            var cbLeader = new CheckBox {
                Text = "Leader", Checked = true
            };
            var cbFriendly = new CheckBox {
                Text = "Friendly", Checked = true
            };
            var cbTeacher = new CheckBox {
                Text = "Teacher", Checked = true
            };

            var dropIndexes = new DropDown();

            RefreshIndexesDropDown(dropIndexes);
            _indexDropDowns.Add(dropIndexes);

            var cbAllIndexes = new CheckBox {
                Text = "Use all accounts", Checked = false
            };

            cbAllIndexes.CheckedChanged += delegate
            {
                if (cbAllIndexes.Checked != null)
                {
                    dropIndexes.Enabled = (bool)!cbAllIndexes.Checked;
                }
                else
                {
                    cbAllIndexes.Checked = false;
                }
            };

            var btnCommend = new Button {
                Text = "Commend"
            };

            btnCommend.Click += delegate
            {
                if (!string.IsNullOrWhiteSpace(txtBoxSteamID.Text))
                {
                    var steamID = SteamUtil.Parse(txtBoxSteamID.Text);

                    if (steamID != null)
                    {
                        _log.Information("Starting commending of {Target}.",
                                         steamID.ConvertToUInt64());

                        Titan.Instance.AccountManager.StartCommending(
                            cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                            new CommendInfo {
                            SteamID = steamID,

                            Leader   = cbLeader.Checked != null && (bool)cbLeader.Checked,
                            Friendly = cbFriendly.Checked != null && (bool)cbFriendly.Checked,
                            Teacher  = cbTeacher.Checked != null && (bool)cbTeacher.Checked
                        });
                    }
                    else
                    {
                        Titan.Instance.UIManager.SendNotification(
                            "Titan - Error", "Could not parse Steam ID "
                            + txtBoxSteamID.Text + " to Steam ID. Please provide a valid " +
                            "SteamID, SteamID3 or SteamID64."
                            );
                    }
                }
                else
                {
                    Titan.Instance.UIManager.SendNotification(
                        "Titan - Error", "Please provide a valid target."
                        );
                }
            };

            return(new TabPage
            {
                Text = "Commend",
                Enabled = !Titan.Instance.DummyMode,
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows =
                    {
                        new GroupBox
                        {
                            Text = "Target",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Steam ID"
                                    }, true),
                                        new TableCell(txtBoxSteamID, true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Options",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(cbLeader,   true),
                                        new TableCell(cbFriendly, true),
                                        new TableCell(cbTeacher,  true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Bots",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Use Index"
                                    }, true),
                                        new TableCell(dropIndexes, true)
                                        ),
                                    new TableRow(
                                        new TableCell(new Panel()),
                                        new TableCell(cbAllIndexes)
                                        )
                                }
                            }
                        },
                        new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows =
                            {
                                new TableRow(
                                    new TableCell(new Panel(), true),
                                    new TableCell(new Panel(), true),
                                    new TableCell(btnCommend)
                                    ),
                                new TableRow
                                {
                                    ScaleHeight = true
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 29
0
        // Quartz.NET Job Executor
        public Task Execute(IJobExecutionContext context)
        {
            return(Task.Run(() =>
            {
                _log.Information("Checking all victims if they have bans on record.");
                _log.Debug("Victims: {a}", _victims);

                foreach (var victim in _victims.ToArray())
                {
                    var target = SteamUtil.FromSteamID64(victim.SteamID);
                    var time = DateTime.Now.Subtract(victim.Timestamp.ToDateTime());

                    if (Titan.Instance.WebHandle.RequestBanInfo(target, out var banInfo))
                    {
                        if (banInfo.GameBanCount > 0 || banInfo.VacBanned)
                        {
                            var count = banInfo.GameBanCount == 0 ? banInfo.VacBanCount : banInfo.GameBanCount;
                            var id64 = target.ConvertToUInt64();

                            if (_victims.Remove(victim))
                            {
                                if (!Titan.Instance.Options.Secure)
                                {
                                    _log.Information("Your recently botted target {Target} received " +
                                                     "{Count} ban(s) after {Delay}. Thank you for using Titan.",
                                                     id64, count,
                                                     time.Hours == 0 ? time.Minutes + " minute(s)" : time.Hours + " hour(s)");

                                    if (Titan.Instance.EnableUI)
                                    {
                                        Titan.Instance.UIManager.SendNotification(
                                            "Titan - " + id64 + " banned",
                                            "Your recently botted target " + id64 + " " +
                                            "has been banned and has now " + count + " Ban(s) on record.",
                                            () => Process.Start("http://steamcommunity.com/profiles/" + id64)
                                            );

                                        Task.Run(() => Titan.Instance.ProfileSaver.SaveSteamProfile(target));

                                        Application.Instance.Invoke(() =>
                                        {
                                            Titan.Instance.UIManager.ShowForm(UIType.Victim, new Form
                                            {
                                                Title = "Banned Victim - " + id64 + " - Titan",
                                                Icon = Titan.Instance.UIManager.SharedResources.TITAN_ICON,
                                                Resizable = false,
                                                Visible = true,
                                                ClientSize = new Size(1280, 720),
                                                Topmost = true,
                                                Content = new TableLayout
                                                {
                                                    Spacing = new Size(5, 5),
                                                    Padding = new Padding(10, 10, 10, 10),
                                                    Rows =
                                                    {
                                                        new TableRow(
                                                            new Label
                                                        {
                                                            Text = "Success! Your recently botted target has " +
                                                                   "been banned after " + time.Hours + " hours. " +
                                                                   "The profile has been saved to \"Titan/" +
                                                                   "victimprofiles/" + id64 + ".html\".",
                                                            TextAlignment = TextAlignment.Center
                                                        }
                                                            ),
                                                        new WebView
                                                        {
                                                            Url = new Uri("http://steamcommunity.com/profiles/" + id64)
                                                        }
                                                    }
                                                }
                                            });
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }));
        }
Exemplo n.º 30
0
        public override TabPage GetTabPage()
        {
            var txtBoxSteamID = new TextBox {
                PlaceholderText = "STEAM_0:0:131983088"
            };

            var cbLeader = new CheckBox {
                Text = "Leader", Checked = true
            };
            var cbFriendly = new CheckBox {
                Text = "Friendly", Checked = true
            };
            var cbTeacher = new CheckBox {
                Text = "Teacher", Checked = true
            };

            var dropIndexes = new DropDown();

            RefreshIndexesDropDown(dropIndexes);
            DropDownIndex.Add(dropIndexes);

            var labelWarning = new Label
            {
                Text = "All your indexes sum up to over 100 accounts.\n" +
                       "Titan will delay the botting process to\n" +
                       "prevent Steam rate limit issues.",
                Visible = false
            };

            var cbAllIndexes = new CheckBox {
                Text = "Use all accounts", Checked = false
            };

            cbAllIndexes.CheckedChanged += (sender, args) =>
            {
                if (cbAllIndexes.Checked != null)
                {
                    dropIndexes.Enabled = (bool)!cbAllIndexes.Checked;

                    if (Titan.Instance.AccountManager.Count() > 00)
                    {
                        labelWarning.Visible = (bool)cbAllIndexes.Checked;
                    }
                }
                else
                {
                    cbAllIndexes.Checked = false;
                }
            };

            var btnCommend = new Button {
                Text = "Commend"
            };

            btnCommend.Click += (sender, args) =>
            {
                if (!string.IsNullOrWhiteSpace(txtBoxSteamID.Text))
                {
                    var steamID = SteamUtil.Parse(txtBoxSteamID.Text);

                    if (steamID != null)
                    {
                        _log.Information("Starting commending of {Target}.",
                                         steamID.ConvertToUInt64());

                        Titan.Instance.AccountManager.StartCommending(
                            cbAllIndexes.Checked != null && (bool)cbAllIndexes.Checked ? -1 : dropIndexes.SelectedIndex,
                            new CommendInfo {
                            SteamID = steamID,
                            AppID   = TitanAccount.CSGO_APPID,

                            Leader   = cbLeader.Checked != null && (bool)cbLeader.Checked,
                            Friendly = cbFriendly.Checked != null && (bool)cbFriendly.Checked,
                            Teacher  = cbTeacher.Checked != null && (bool)cbTeacher.Checked
                        });
                    }
                    else
                    {
                        UIManager.SendNotification(
                            "Titan - Error", "Could not parse Steam ID "
                            + txtBoxSteamID.Text + " to Steam ID. Please provide a valid " +
                            "SteamID, SteamID3 or SteamID64."
                            );
                    }
                }
                else
                {
                    UIManager.SendNotification(
                        "Titan - Error", "Please provide a valid target."
                        );
                }
            };

            return(new TabPage
            {
                Text = "Commend",
                Enabled = !Titan.Instance.DummyMode,
                Content = new TableLayout
                {
                    Spacing = new Size(5, 5),
                    Padding = new Padding(10, 10, 10, 10),
                    Rows =
                    {
                        new GroupBox
                        {
                            Text = "Target",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Steam ID"
                                    }, true),
                                        new TableCell(txtBoxSteamID, true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Options",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(cbLeader,   true),
                                        new TableCell(cbFriendly, true),
                                        new TableCell(cbTeacher,  true)
                                        )
                                }
                            }
                        },
                        new GroupBox
                        {
                            Text = "Bots",
                            Content = new TableLayout
                            {
                                Spacing = new Size(5, 5),
                                Padding = new Padding(10, 10, 10, 10),
                                Rows =
                                {
                                    new TableRow(
                                        new TableCell(new Label {
                                        Text = "Use Index"
                                    }, true),
                                        new TableCell(dropIndexes, true)
                                        ),
                                    new TableRow(
                                        new TableCell(labelWarning),
                                        new TableCell(cbAllIndexes)
                                        )
                                }
                            }
                        },
                        new TableLayout
                        {
                            Spacing = new Size(5, 5),
                            Padding = new Padding(10, 10, 10, 10),
                            Rows =
                            {
                                new TableRow(
                                    new TableCell(new Panel(), true),
                                    new TableCell(new Panel(), true),
                                    new TableCell(btnCommend)
                                    ),
                                new TableRow
                                {
                                    ScaleHeight = true
                                }
                            }
                        }
                    }
                }
            });
        }