Beispiel #1
0
        public static void ExtractAndDelete(string theserverfolder)
        {
            ClientAndServer.ExtractResourcesForBoth();

            ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(theserverfolder));
            ClientAndServer.DeleteVpks(ClientAndServer.Returnallvpks(theserverfolder));
            string resourceData = Resources.delete;

            // var words = resourceData.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();

            string[] items = resourceData.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            Parallel.ForEach(items, lines =>
            {
                string fun = Path.Combine(theserverfolder, lines);

                FileAttributes attr = 0;
                if (File.Exists(fun) || Directory.Exists(fun))
                {
                    attr = File.GetAttributes(fun);
                }
                if (attr.HasFlag(FileAttributes.Directory))
                {
                    MiscFunctions.DeleteDir(Path.Combine(theserverfolder, lines));
                }
                else
                {
                    MiscFunctions.DeleteFile(Path.Combine(theserverfolder, lines));
                }
            });
        }
 private static void Paralleloneachgame(string sourcesdk2007Installdir, IEnumerable <string> storedlocations,
                                        string ocinstalldir)
 {
     Parallel.ForEach(storedlocations, game =>
     {
         if (game == " ")
         {
         }
         else if (game.EndsWith("hl2"))
         {
             MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\hl2");
             ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir);
             NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\hl2", game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory);
         }
         else
         {
             string gamename = game.Split(Path.DirectorySeparatorChar).Last();
             MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\" + gamename);
             ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir);
             NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\" + gamename, game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory);
             if (gamename.Equals(@"cstrike"))
             {
                 File.Create(ocinstalldir + "\\mounts\\css");
             }
             else if (gamename.Equals(@"hl1"))
             {
                 File.Create(ocinstalldir + "\\mounts\\hls");
             }
             else
             {
                 File.Create(ocinstalldir + "\\mounts\\" + gamename);
             }
         }
     });
 }
Beispiel #3
0
 private static void InstallMountsFromnames(string mounts, string steamcmdbase, string basecmd, string endofcmd)
 {
     if (mounts == "" || !mounts.Contains("hl2"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "220" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("ep1"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "380" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("lostcoast"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "340" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("ep2"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "420" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("hl1"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "280" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("css"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "240" + endofcmd);
     }
     if (mounts == "" || !mounts.Contains("dod"))
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "300" + endofcmd);
     }
     if (true)
     {
         ClientAndServer.Performtasksi(steamcmdbase, basecmd + "310" + endofcmd);
     }
 }
Beispiel #4
0
        public static void InstallServer(string username, string password, string serverdirectory, bool steamauth,
                                         string mounts = "")
        {
            foreach (Process fub in Process.GetProcessesByName("steamcmd.exe"))
            {
                fub.Kill();
            }
            const string endofcmd = " validate +quit";
            string       basecmd  = " +login " + username + " " + password + " +force_install_dir " +
                                    NativeMethods.Otherstuff.GetShortPathName(serverdirectory) +
                                    " +app_update ";
            string currentdir   = Directory.GetCurrentDirectory();
            string steamcmdbase = Path.Combine(currentdir, "steamcmd\\steamcmd.exe");

            if (steamauth)
            {
                ClientAndServer.Performtasksi(steamcmdbase, " +login " + username + " " + password + " +quit");
            }
            Thread.Sleep(5000);

            if (InstallMountsFromintstring(mounts, steamcmdbase, basecmd, endofcmd) != 1)
            {
                InstallMountsFromnames(mounts, steamcmdbase, basecmd, endofcmd);
            }
        }
Beispiel #5
0
        public ConnectionHandler(ClientAndServer runner)
        {
            Runner = runner;

            clientReadTcs  = new TaskCompletionSource <bool> ();
            clientWriteTcs = new TaskCompletionSource <bool> ();
            serverReadTcs  = new TaskCompletionSource <bool> ();
            serverWriteTcs = new TaskCompletionSource <bool> ();
        }
Beispiel #6
0
        public static void ExtractServerResources(string ass)
        {
            File.WriteAllBytes("7za.exe", Resources._7za);
            ClientAndServer.Performtasks("7za.exe",
                                         "x steamcmd.zip -o" + MiscFunctions.PutIntoQuotes(Directory.GetCurrentDirectory() + "\\steamcmd") + " -aoa");
            File.WriteAllBytes("addons.zip", Resources.addons);

            ClientAndServer.Performtasks("7za.exe", "x mmsource.zip -o" + MiscFunctions.PutIntoQuotes(ass) + " -aoa");
            ClientAndServer.Performtasks("7za.exe", "x sourcemod.zip -o" + MiscFunctions.PutIntoQuotes(ass) + " -aoa");
            ClientAndServer.Performtasks("7za.exe", "x addons.zip -o" + MiscFunctions.PutIntoQuotes(ass) + " -aoa");
        }
        public static void ClientNohook(string fun = "-n", string imounts = "")
        {
            List <string> mounts = new List <string>();
            string        sourcesdk2007Installdir = "";
            string        ocinstalldir            = "";

            ClientAndServer.ExtractResourcesForBoth();
            mounts = OpenClientFormOrCheckForCommandLineMounts(fun, mounts, imounts);
            if (mounts == null)
            {
                mounts = new List <string>();
            }
            Tuple <string, string, List <string> > ocAnd2007AndLocations = NewWay.NewWayStart(mounts);

            if (ocAnd2007AndLocations != null)
            {
            }
            if (ocAnd2007AndLocations == null || (ocAnd2007AndLocations.Item1 == "" | ocAnd2007AndLocations.Item2 == "" | ocAnd2007AndLocations.Item3.Count == 0))
            {
                ocAnd2007AndLocations = OldWay.oldwaysetup(mounts);
            }

            if (ocAnd2007AndLocations != null)
            {
                List <string> storedlocations = ocAnd2007AndLocations.Item3;
                ocinstalldir            = ocAnd2007AndLocations.Item1;
                sourcesdk2007Installdir = ocAnd2007AndLocations.Item2;
                Console.WriteLine(@"Found The directories");
                Thread.Sleep(1000);
                Console.WriteLine(ocinstalldir);
                Console.WriteLine(sourcesdk2007Installdir);
                Console.WriteLine(string.Join(Environment.NewLine, storedlocations.Cast <string>().ToArray()));

                InstallClientMounts2(sourcesdk2007Installdir, storedlocations, ocinstalldir);
            }
            else
            {
                Console.WriteLine("Error Required Information not found");
                Console.WriteLine("Please make sure you have source SDK Base 2007 installed and try again.");
                Console.WriteLine("Press Any Key to close this window");
                Console.ReadKey();
                Environment.Exit(-1);
            }
        }
Beispiel #8
0
        private static int InstallMountsFromintstring(string mounts, string steamcmdbase, string basecmd,
                                                      string endofcmd)
        {
            if (!(mounts != "" & mounts.Contains(@"0")))
            {
                return(0);
            }

            string[] f****e = mounts.Split(',');
            if (!f****e[0].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "220" + endofcmd);
            }
            if (!f****e[1].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "380" + endofcmd);
            }
            if (!f****e[2].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "340" + endofcmd);
            }
            if (!f****e[3].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "420" + endofcmd);
            }
            if (!f****e[4].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "280" + endofcmd);
            }
            if (!f****e[5].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "240" + endofcmd);
            }
            if (!f****e[6].Contains("1"))
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "300" + endofcmd);
            }
            if (true)
            {
                ClientAndServer.Performtasks(steamcmdbase, basecmd + "310" + endofcmd);
            }
            return(1);
        }
Beispiel #9
0
 private void frmClient_Load(object sender, EventArgs e)
 {
     ip1.Text  = "127.000.000.001";
     myIP.Text = "127.000.000.003";
     myClient  = new ClientAndServer(this, this);
 }
Beispiel #10
0
 private void frmServer2_Load(object sender, EventArgs e)
 {
     ip2.Text = "127.000.000.002";
     myClient = new ClientAndServer(this, this);
 }
 public DefaultConnectionHandler(ClientAndServer runner)
     : base(runner)
 {
 }