Exemplo n.º 1
0
        public static Solution Load(string fileName)
        {
            var solution = SerializedObject.Deserialize <Solution>(fileName);

            solution.Location         = fileName.NormalizePath().ToPlatformPath();
            solution.CurrentDirectory = (Path.GetDirectoryName(fileName) + Platform.DirectorySeperator).ToPlatformPath();

            foreach (var projectReference in solution.ProjectReferences)
            {
                var proj = LoadProject(solution, projectReference);

                // todo null returned here we need a placeholder.
                if (proj != null)
                {
                    solution.Projects.InsertSorted(proj);
                }
            }

            foreach (var project in solution.Projects)
            {
                project.ResolveReferences();
            }

            solution.StartupProject = solution.Projects.SingleOrDefault(p => p.Name == solution.StartupItem);

            return(solution);
        }
Exemplo n.º 2
0
        public async Task <Repository> DownloadCatalog()
        {
            if (Directory.Exists(CatalogDirectory))
            {
                if (LibGit2Sharp.Repository.IsValid(CatalogGitDirectory))
                {
                    var repo = new LibGit2Sharp.Repository(CatalogGitDirectory);

                    await Task.Factory.StartNew(() => { LibGit2Sharp.Commands.Pull(repo, new Signature("AvalonStudio", "catalog@avalonstudio", new DateTimeOffset(DateTime.Now)), new PullOptions()); });
                }
                else
                {
                    Directory.Delete(CatalogDirectory, true);
                    Clone();
                }
            }
            else
            {
                Clone();
            }

            var result = SerializedObject.Deserialize <Repository>(Path.Combine(CatalogDirectory, Repository.PackagesFileName));

            result.Source = this;

            foreach (var package in result.Packages)
            {
                package.Repository = result;
            }

            return(result);
        }
Exemplo n.º 3
0
        public void InitialiseSnippetsForSolution(ISolution solution)
        {
            if (!_solutionSnippets.ContainsKey(solution))
            {
                _solutionSnippets[solution] = new Dictionary <string, IDictionary <string, CodeSnippet> >();

                _solutionSnippets[solution].Clear();

                var snippetsDir = Platform.GetSolutionSnippetDirectory(solution);

                if (Directory.Exists(snippetsDir))
                {
                    var snippetFolders = Directory.EnumerateDirectories(snippetsDir);

                    foreach (var folder in snippetFolders)
                    {
                        foreach (var file in Directory.EnumerateFiles(folder))
                        {
                            try
                            {
                                var snippet = SerializedObject.Deserialize <CodeSnippet>(file);
                                AddSnippet(_solutionSnippets[solution], Path.GetFileName(folder), snippet);
                            }
                            catch (Exception e)
                            {
                                IoC.Get <IConsole>().WriteLine($"Error parsing snippet: {file}, {e.Message}");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static Solution Load(string fileName)
        {
            var solution = SerializedObject.Deserialize <Solution>(fileName);

            solution.CurrentDirectory = (Path.GetDirectoryName(fileName) + Platform.DirectorySeperator).ToPlatformPath();

            Console.WriteLine("Solution directory is " + solution.CurrentDirectory);

            foreach (var projectReference in solution.ProjectReferences)
            {
                var proj = LoadProject(solution, projectReference);

                // todo null returned here we need a placeholder.
                if (proj != null)
                {
                    solution.Projects.InsertSorted(proj);
                }
            }

            foreach (var project in solution.Projects)
            {
                project.ResolveReferences();
                project?.ToolChain?.ProvisionSettings(project);
            }

            solution.Name = Path.GetFileNameWithoutExtension(fileName);

            solution.StartupProject = solution.Projects.SingleOrDefault(p => p.Name == solution.StartupItem);

            return(solution);
        }
Exemplo n.º 5
0
        public void InitialiseSnippetsForProject(IProject project)
        {
            if (!_projectSnippets.ContainsKey(project) && !(project is UnresolvedReference))
            {
                _projectSnippets[project] = new Dictionary <string, IDictionary <string, CodeSnippet> >();

                var snippetsDir = Platform.GetProjectSnippetDirectory(project);

                if (Directory.Exists(snippetsDir))
                {
                    var snippetFolders = Directory.EnumerateDirectories(snippetsDir);

                    foreach (var folder in snippetFolders)
                    {
                        foreach (var file in Directory.EnumerateFiles(folder))
                        {
                            try
                            {
                                var snippet = SerializedObject.Deserialize <CodeSnippet>(file);
                                AddSnippet(_projectSnippets[project], Path.GetFileName(folder), snippet);
                            }
                            catch (Exception e)
                            {
                                IoC.Get <IConsole>().WriteLine($"Error parsing snippet: {file}, {e.Message}");
                            }
                        }
                    }
                }

                foreach (var reference in project.References)
                {
                    InitialiseSnippetsForProject(reference);
                }
            }
        }
Exemplo n.º 6
0
        public IObjectBase Clone()
        {
            SerializedObject objSerializedObject = ((ICustomSerializer)this).Serialize("Clone");
            IObjectBase      objClonedObject     = (IObjectBase)objSerializedObject.Deserialize();

            return(objClonedObject);
        }
Exemplo n.º 7
0
        public static CPlusPlusProject LoadFromFile(string filename)
        {
            if (!System.IO.File.Exists(filename))
            {
                Console.WriteLine("Unable for find project file: " + filename);

                return(null);
            }

            var project = SerializedObject.Deserialize <CPlusPlusProject>(filename);

            for (var i = 0; i < project.Includes.Count; i++)
            {
                project.Includes[i].Value = project.Includes[i].Value.ToAvalonPath();
            }

            for (var i = 0; i < project.ExcludedFiles.Count; i++)
            {
                project.ExcludedFiles[i] = project.ExcludedFiles[i].ToAvalonPath();
            }

            project.Project  = project;
            project.Location = filename;

            project.Items.InsertSorted(new ReferenceFolder(project));

            return(project);
        }
Exemplo n.º 8
0
        public static TObjectType DeserializeFromFile <TObjectType>(IFormatter objFormatter, string strFilePath)
            where TObjectType : ObjectBase
        {
            TObjectType objValue = default(TObjectType);

            if ((strFilePath == null) || (strFilePath.Trim().Length == 0))
            {
                throw new ArgumentException("strFilePath", "A valid non-null, non-empty string is required.");
            }
            if (File.Exists(strFilePath) == false)
            {
                throw new FileNotFoundException("The requested '" + typeof(TObjectType).FullName + "' file could not be found.", strFilePath);
            }

            try
            {
                SerializedObject objSerializedObject = objFormatter.DeserializeFromFile(strFilePath);
                objValue = (TObjectType)objSerializedObject.Deserialize();
            }
            catch (Exception objException)
            {
                throw new Exception("An error was encountered while attempting to load '" + strFilePath + "'.", objException);
            }

            return(objValue);
        }
Exemplo n.º 9
0
        public static PackageManifest Load(string file, string name)
        {
            var result = SerializedObject.Deserialize <PackageManifest>(file);

            result.Version = Path.GetFileName(Path.GetDirectoryName(file));
            result.Name    = name;

            return(result);
        }
        private static CustomGCCToolchainProfiles Load()
        {
            if (!File.Exists(ProfilesFile))
            {
                SerializedObject.Serialize(ProfilesFile, new CustomGCCToolchainProfiles());
            }

            return(SerializedObject.Deserialize <CustomGCCToolchainProfiles>(ProfilesFile));
        }
Exemplo n.º 11
0
 public static void Deserialize()
 {
     try {
         _recentProjects = SerializedObject.Deserialize <List <RecentProject> >(_savePath);
     }
     catch (Exception) {
         _recentProjects = new List <RecentProject>();
     }
 }
        private MenuSettings LoadMenuSettings()
        {
            if (File.Exists(MenuSettingsFilePath))
            {
                return(SerializedObject.Deserialize <MenuSettings>(MenuSettingsFilePath)
                       ?? new MenuSettings());
            }

            return(new MenuSettings());
        }
        private CommandSettings LoadCommandSettings()
        {
            if (File.Exists(CommandSettingsFilePath))
            {
                return(SerializedObject.Deserialize <CommandSettings>(CommandSettingsFilePath)
                       ?? new CommandSettings());
            }

            return(new CommandSettings());
        }
Exemplo n.º 14
0
        private static Settings Load()
        {
            if (File.Exists(GlobalSettingsFile))
            {
                return(SerializedObject.Deserialize <Settings>(GlobalSettingsFile));
            }

            var result = new Settings();

            result.Save();

            return(result);
        }
Exemplo n.º 15
0
        private static Settings Load()
        {
            if (File.Exists(GlobalSettingsFile))
            {
                var deserialized = SerializedObject.Deserialize <Settings>(GlobalSettingsFile);

                if (deserialized != null)
                {
                    return(deserialized);
                }
            }

            var result = new Settings();

            result.Save();

            return(result);
        }
Exemplo n.º 16
0
        public static void InitialisePackageSources()
        {
            if (!File.Exists(Platform.PackageSourcesFile))
            {
                var sources = new PackageSources();

                sources.Sources.Add(new PackageSource
                {
                    Name = "VitalElement",
                    Url  = "https://github.com/VitalElement/AvalonStudio.Repository"
                });

                SerializedObject.Serialize(Platform.PackageSourcesFile, sources);
            }

            var result = SerializedObject.Deserialize <PackageSources>(Platform.PackageSourcesFile);

            Instance = result;
        }
Exemplo n.º 17
0
        public SnippetManager()
        {
            var snippetFolders = Directory.EnumerateDirectories(Platform.SnippetsFolder).Concat(Directory.EnumerateDirectories(Platform.InBuiltSnippetsFolder));

            foreach (var folder in snippetFolders)
            {
                foreach (var file in Directory.EnumerateFiles(folder))
                {
                    try
                    {
                        var snippet = SerializedObject.Deserialize <CodeSnippet>(file);
                        AddSnippet(_snippets, Path.GetFileName(folder), snippet);
                    }
                    catch (Exception e)
                    {
                        IoC.Get <IConsole>().WriteLine($"Error parsing snippet: {file}, {e.Message}");
                    }
                }
            }
        }
Exemplo n.º 18
0
        public static TObjectType DeserializeFromStream <TObjectType>(IFormatter objFormatter, Stream objStream)
            where TObjectType : ObjectBase
        {
            TObjectType objValue = default(TObjectType);

            if (objStream == null)
            {
                throw new ArgumentException("objStream", "A valid non-null Stream is required.");
            }

            try
            {
                SerializedObject objSerializedObject = objFormatter.DeserializeFromStream(objStream);
                objValue = (TObjectType)objSerializedObject.Deserialize();
            }
            catch (Exception objException)
            {
                throw new Exception("An error was encountered while attempting to load the stream.", objException);
            }

            return(objValue);
        }
Exemplo n.º 19
0
        public static TObjectType DeserializeFromByteArray <TObjectType>(IFormatter objFormatter, byte[] bytData)
            where TObjectType : ObjectBase
        {
            TObjectType objValue = default(TObjectType);

            if (bytData == null)
            {
                throw new ArgumentException("bytData", "A valid non-null byte[] is required.");
            }

            try
            {
                SerializedObject objSerializedObject = objFormatter.DeserializeFromByteArray(bytData);
                objValue = (TObjectType)objSerializedObject.Deserialize();
            }
            catch (Exception objException)
            {
                throw new Exception("An error was encountered while attempting to load the string.", objException);
            }

            return(objValue);
        }
Exemplo n.º 20
0
 public static ColorScheme Load(string fileName)
 {
     return(SerializedObject.Deserialize <ColorScheme>(fileName));
 }
Exemplo n.º 21
0
        public void WaitForCommands()
        {
            string input = null;

            this.Start();
            LoadScripts();
            InitGameData();
            while (!IsConsoleShuttingDown)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.Write("\n[{Realm World Server}] ");
                Console.ResetColor();
                input = Console.ReadLine();
                string[] args = input.Split(' ');



                switch (args[0].ToLower())
                {
                case "pass":
                {
                    // we gonna hash passwords here man !!
                    string password = string.Empty;

                    if (args.Length >= 2)
                    {
                        // get the pass
                        password = args[1];
                        string hash = RealmOffline.Accounts.PasswordHash.CreateHash(password);
                        bool   back = RealmOffline.Accounts.PasswordHash.ValidatePassword(password, hash);
                        Console.WriteLine("We got password ({0}) and hash ({1}), they {2} match.", password, hash,
                                          back ? "do":" do not");
                    }
                }
                break;

                case "/mob":
                {
                    if (args.Length >= 2)
                    {
                        short id = 0;
                        if (short.TryParse(args[1], out id))
                        {
                            MobileType type = MobileType.None;
                            string     name = BaseMobile.MobNameFromID(id, out type);
                            Console.WriteLine("We found {0} for MobID {1}, its type is {2}",
                                              name, id, type);
                        }
                    }
                }
                break;

                case "/sm":
                {
                    if (args.Length >= 3)
                    {
                        //1 = topic 2 on = message
                        string topic = input.Split('|').First();
                        string msg   = input.Split('|').Last();
                        Console.WriteLine("Topic ({0}) Message ({1})", topic, msg);
                    }
                }
                break;

                case "terd":
                {
                    BaseMobile.Init();
                    string[] m = BaseMobile.NonHumanoid.Select(x => x.Value).ToArray();
                    foreach (string c in m)
                    {
                        Console.WriteLine(c);
                    }
                }
                break;

                case "fight":
                {
                    // We want stats 2 stats 2 skills for attack
                    //1 = str 2 = dex 3 = CS 4 = wepskill
                    if (args.Length >= 5)
                    {
                        int str = 0;
                        int dex = 0;
                        int cs  = 0;
                        int wep = 0;
                        if (int.TryParse(args[1], out str) &&
                            int.TryParse(args[2], out dex) &&
                            int.TryParse(args[3], out cs) &&
                            int.TryParse(args[4], out wep))
                        {
                            Console.WriteLine("We got STR:({0}) DEX:({1}) CS:({2}) Wep:({3})",
                                              str, dex, cs, wep);

                            // Lets formulate a chance
                            int[] attacker = { str, dex, cs, wep };
                            int[] oppn     = { 12, 12, 5, 5 };

                            // int hitpoints = 3000; // both have 3k hp
                            int aper = attacker.Sum();
                            int oper = oppn.Sum();

                            Console.WriteLine("We start with {0}% for Attacker and {1}% for opponent.", aper, oper);
                        }
                    }
                }
                break;

                case "id":
                {
                    if (args.Length == 2)
                    {
                        short id = 0;
                        if (short.TryParse(args[1], out id))
                        {
                            bool vali = Mob.IsValidID(id);
                            Console.WriteLine("{0} {1} a valid id.", id, vali ? "is" : "is not");
                        }
                    }
                }
                break;

                case "ts":
                {
                    byte[] t = new byte[] { 0x21, 0xFF, 0x00, 0x9C };
                    Array.Reverse(t);
                    double   d  = (double)BitConverter.ToInt32(t, 0);
                    DateTime dt = MagicMail.UnixTimeStampToDateTime(d);
                    Console.WriteLine(dt);
                }
                break;

                    #region Account Creation and Deletion
                case "account":
                {
                    string useage = "[Create an Account]\naccount create username password emailaddress secretword 3 \n" +
                                    "Last value is User Priv's\n" +
                                    "5 = Player, 4 = EventHost 3 = Guide 2 = Moderator 1 = Admin 0 = Owner \n" +
                                    "\n" +
                                    "[Delete an Account]\n" +
                                    "account delete username";
                    string createUseage = "[Create an Account]\naccount create username password emailaddress secretword 3 \n" +
                                          "Last value is User Priv's\n" +
                                          "5 = Player, 4 = EventHost 3 = Guide 2 = Moderator 1 = Admin 0 = Owner \n";
                    string deleteUsage = "[Delete an Account]\n" +
                                         "account delete username";

                    // create or delete
                    if (args.Length > 2)
                    {
                        if (args[1].ToLower() == "create")
                        {
                            if (args[2].ToLower() == "help" || args[2] == string.Empty)
                            {
                                Console.WriteLine(createUseage);
                            }
                            else
                            {
                                string error = string.Empty;
                                if (!MySqlManager.ValidateAccount(args, out error))
                                {
                                    if (error.Trim() != string.Empty)
                                    {
                                        Console.ForegroundColor = ConsoleColor.Red;
                                        Console.WriteLine(error);
                                        Console.ResetColor();
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("Account {0} Created.", args[2]);
                                }
                            }
                        }
                        else if (args[1].ToLower() == "delete")
                        {
                            if (args.Length != 3)
                            {
                                Console.WriteLine(deleteUsage);
                            }
                            else
                            {
                                bool delete = MySqlManager.DeleteUserAccount(args[2].ToLower());
                                if (delete)
                                {
                                    Console.WriteLine("Removed Account {0}.", args[2].ToLower());
                                }
                                else
                                {
                                    Console.WriteLine("Account {0} not found.", args[2].ToLower());
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("create or delete are the only valid options.");
                        }
                    }
                    else
                    {
                        Console.WriteLine(useage);
                    }
                    // Ok this will be the command to create a new account

                    /*
                     * We need
                     * 2: Username
                     * 3: Password
                     * 4: email address
                     * 5: secret word
                     * 6: Priv Level
                     * string string string string int
                     */
                }
                    #endregion
                    break;

                case "spell":
                {
                    List <Account> accts = ServerGlobals.GetAccountsInRoom(1310);
                    Console.WriteLine("Total in room 1310 {0}", accts.Count);
                }
                break;

                case "online":
                {
                    int online = 0;
                    if (ServerGlobals.LoggedInAccounts != null)
                    {
                        online = ServerGlobals.LoggedInAccounts.Count;
                    }
                    Console.WriteLine("Currently {0} accounts online.", online);
                }
                break;

                case "clear":
                    Console.Clear();
                    break;

                case "mem":
                {
                    // Returns the current memory usage
                    Console.WriteLine(MemoryUseDisplay);
                }
                break;

                case "q":
                {
                    TestObject t       = new TestObject();
                    string     fileloc = Path.Combine(ServerGlobals.BaseDirectory, "TestSerialize.xml");

                    SerializedObject.Serialize(t, fileloc);

                    TestObject t1 = SerializedObject.Deserialize <TestObject>(fileloc);
                    Console.WriteLine(t1.ID);
                }
                break;

                case "touint16":
                {
                    if (args.Length == 2)
                    {
                        // should be 4 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 4)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                byte[] f1     = blist.ToArray();
                                ushort result = BitConverter.ToUInt16(f1, 0);
                                Console.WriteLine("UInt16 result of bytes [{0}] [{1}] = {2}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }), result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "toint32":
                {
                    if (args.Length == 2)
                    {
                        // should be 8 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 8)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2, 2);
                            string      b3    = toParse.Substring(4, 2);
                            string      b4    = toParse.Substring(6);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                byte c;
                                byte d;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                c = Byte.Parse(b3, NumberStyles.HexNumber);
                                d = Byte.Parse(b4, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                blist.Add(c);
                                blist.Add(d);
                                byte[] f1 = blist.ToArray();
                                f1.Reverse();
                                Int32 result = BitConverter.ToInt32(f1, 0);
                                Console.WriteLine("Int32 result of bytes [{0}] [{1}] [{2}] [{3}]= {4}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }),
                                                  BitConverter.ToString(new byte[] { c }), BitConverter.ToString(new byte[] { d }),
                                                  result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "touint32":
                {
                    if (args.Length == 2)
                    {
                        // should be 8 letters / numbers
                        string toParse = args[1].Trim();
                        // split string in half
                        if (toParse.Length == 8)
                        {
                            string      b1    = toParse.Substring(0, 2);
                            string      b2    = toParse.Substring(2, 2);
                            string      b3    = toParse.Substring(4, 2);
                            string      b4    = toParse.Substring(6);
                            List <byte> blist = new List <byte>();

                            try
                            {
                                byte a;
                                byte b;
                                byte c;
                                byte d;
                                a = Byte.Parse(b1, NumberStyles.HexNumber);
                                b = Byte.Parse(b2, NumberStyles.HexNumber);
                                c = Byte.Parse(b3, NumberStyles.HexNumber);
                                d = Byte.Parse(b4, NumberStyles.HexNumber);
                                blist.Add(a);
                                blist.Add(b);
                                blist.Add(c);
                                blist.Add(d);
                                byte[] f1 = blist.ToArray();
                                f1.Reverse();
                                UInt32 result = BitConverter.ToUInt32(f1, 0);
                                Console.WriteLine("Int32 result of bytes [{0}] [{1}] [{2}] [{3}]= {4}",
                                                  BitConverter.ToString(new byte[] { a }), BitConverter.ToString(new byte[] { b }),
                                                  BitConverter.ToString(new byte[] { c }), BitConverter.ToString(new byte[] { d }),
                                                  result);
                            }
                            catch { Console.WriteLine("Bad Parse"); }
                        }
                    }
                }
                break;

                case "tobytes32":
                {
                    // the next value is a number
                    if (args.Length == 2)
                    {
                        int value = 0;
                        if (int.TryParse(args[1], out value))
                        {
                            byte[] conv = BitConverter.GetBytes(value);
                            Console.WriteLine(BitConverter.ToString(conv));
                        }
                    }
                }
                break;

                case "m2ushort":
                {
                    // we have 2 bytes space 2 bytes 0 1 2 args or 3 total

                    if (args.Length == 3)
                    {
                        try
                        {
                            string firstushort  = args[1].Trim();
                            string secondushort = args[2].Trim();

                            string      b1    = firstushort.Substring(0, 2);
                            string      b2    = firstushort.Substring(2, 2);
                            string      b3    = secondushort.Substring(0, 2);
                            string      b4    = secondushort.Substring(2, 2);
                            List <byte> blist = new List <byte>();


                            byte a;
                            byte b;
                            byte c;
                            byte d;
                            a = Byte.Parse(b1, NumberStyles.HexNumber);
                            b = Byte.Parse(b2, NumberStyles.HexNumber);
                            c = Byte.Parse(b3, NumberStyles.HexNumber);
                            d = Byte.Parse(b4, NumberStyles.HexNumber);
                            byte[] fArg = { a, b };
                            byte[] sArg = { c, d };
                            ushort vone = BitConverter.ToUInt16(fArg, 0);
                            ushort vtwo = BitConverter.ToUInt16(sArg, 0);
                            Console.WriteLine("We got {0} and {1} for a difference of {2} or {3}",
                                              vone, vtwo, vone - vtwo, vtwo - vone);
                        }
                        catch { Console.WriteLine("Bad Parse"); }
                    }
                }
                break;

                case "bc":
                {
                    if (args.Length > 2)
                    {
                        // get the rest of this string
                        StringBuilder build = new StringBuilder();
                        foreach (string s in args)
                        {
                            build.Append(s + " ");
                        }
                        string   first  = build.ToString().Remove(0, 3);
                        string[] parse2 = first.Split(' ');
                        // whats the color ?
                        int color = -1;
                        if (int.TryParse(parse2[0], out color))
                        {
                            // Fix the last string again then
                            build.Clear();
                            foreach (string s in parse2)
                            {
                                build.Append(s + " ");
                            }
                            string message       = build.ToString().Remove(0, parse2[0].Length + 1);
                            byte[] messagePacket = RealmPacketIO.BuildGossipPacket(color, message, "SERVER");
                            ServerGlobals.SendToAllClients(messagePacket);
                            byte[] messagePacket2 = Packet.ChatPacket(color, 1, message, "SERVER");
                            ServerGlobals.SendToAllClients(messagePacket2);
                            //Console.WriteLine(message);
                        }
                        else
                        {
                            Console.WriteLine("Bad color argument of {0}", parse2[0]);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Usage: bc 10 I want to say hi !!");
                    }
                }
                break;

                case "sta":
                {
                    //string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ServerPacket24Message.txt");
                    byte[] fake0 = RealmPacketIO.ServerMessageType1(
                        "A Topic Test", "A Very Nice Message, we couldnt have much nicer, so dont be a dick!");        //RealmPacketIO.GetByteArrayFromFile(fileLocation);

                    if (args.Length == 2)
                    {
                        if (args[1].ToLower() == "len")
                        {
                            Console.WriteLine("Message Packet Length {0}",
                                              BitConverter.ToString(BitConverter.GetBytes(fake0.Length - 8)));
                        }
                    }
                    else
                    {
                        //ServerPacket24Message.txt

                        ServerGlobals.SendToAllClients(fake0);
                    }
                }
                break;

                case "sta2":
                {
                    // ServerMessagePacket81.txt
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ServerMessagePacket81.txt");
                    byte[] fake0        = RealmPacketIO.ServerMessageType2(
                        "F**k you and da horse you roded in on foo!");        //RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    if (args.Length == 2)
                    {
                        if (args[1].ToLower() == "len")
                        {
                            Console.WriteLine("Message Packet Length {0}",
                                              BitConverter.ToString(BitConverter.GetBytes(fake0.Length - 8)));
                        }
                    }
                    else
                    {
                        // ServerMessagePacket81.txt

                        ServerGlobals.SendToAllClients(fake0);
                    }
                }
                break;

                case "switch":
                {
                    if (ServerGlobals.LoadFromSql)
                    {
                        ServerGlobals.LoadFromSql = false; Console.WriteLine("Loading from CharData.txt File.");
                    }
                    else
                    {
                        ServerGlobals.LoadFromSql = true; Console.WriteLine("Loading from MySql.");
                    }
                }
                break;

                case "croom":
                {
                    // Sends a packet derived from a filename in our debug dir
                    // args[1] is the filename
                    string fileLocation = string.Empty;
                    if (args.Length != 2)
                    {
                        Console.WriteLine("Please supply a filename with extention.");
                    }
                    else
                    {
                        if (args[1].Trim() == "off")
                        {
                            RealmPacketIO.CustomRoomLoad = false;
                            RealmPacketIO.CustomRoomFile = string.Empty;
                        }
                        else
                        {
                            fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), args[1].Trim());
                            if (!File.Exists(fileLocation))
                            {
                                Console.WriteLine("Unable to find file {0}", fileLocation);
                            }
                            else
                            {
                                RealmPacketIO.CustomRoomLoad = true;
                                RealmPacketIO.CustomRoomFile = args[1].Trim();
                                Console.WriteLine("CustomFile Atrrib = {0} for file {1}",
                                                  RealmPacketIO.CustomRoomLoad, RealmPacketIO.CustomRoomFile);
                            }
                        }
                    }
                }
                break;

                case "to":
                {
                }
                break;

                case "itempacket":
                {
                    for (int f = 0; f < 2001; f++)
                    {
                        Item i = new Item();
                        i.GraphicID = 1444;
                        i.Color     = 0x69;
                        //uint id = 0;
                        // byte[] r = i.Ser();
                        //byte[] item = i.Serialize(out id);
                        Console.Write("\rItem:{0}.          ", f);
                    }
                }
                break;

                case "send":
                {
                    // Sends a packet derived from a filename in our debug dir
                    // args[1] is the filename
                    string fileLocation = string.Empty;
                    if (args.Length != 2)
                    {
                        Console.WriteLine("Please supply a filename with extention.");
                    }
                    else
                    {
                        fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), args[1].Trim());
                        if (!File.Exists(fileLocation))
                        {
                            Console.WriteLine("Unable to find file {0}", fileLocation);
                        }
                        else
                        {
                            byte[] fileToArray = null;
                            try { fileToArray = RealmPacketIO.GetByteArrayFromFile(fileLocation); }
                            catch (Exception ex) { Console.WriteLine(ex.Message); }

                            if (fileToArray != null)
                            {
                                ServerGlobals.SendToAllClients(fileToArray);
                                Console.WriteLine("Sent {0}", fileLocation);
                            }
                        }
                    }
                }
                break;

                case "a":
                {
                }
                break;

                case "x":
                {
                    //byte[] p = RealmPacketIO.Test;
                    // ServerGlobals.SendToAllClients(p);
                }
                break;

                case "w":
                {
                    /*
                     * string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Lookat.txt");
                     * byte[] fake0 = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                     * byte[] len = BitConverter.GetBytes(fake0.Length);
                     * Console.WriteLine(BitConverter.ToString(len));
                     */
                }
                break;

                case "t":
                {
                    // try to get this room
                    Room found = null;
                    if (ScriptResolver.ImportedRooms.TryGetRoom(213, out found))
                    {
                        Console.WriteLine("Found room {0}", 213);
                        Console.WriteLine(BitConverter.ToString(found.GetRoomPacket(3)));
                    }
                }
                break;

                case "tt":
                {
                    // messin wit commands
                    if (ScriptResolver.ImportedCommands.Count == 0)
                    {
                        Console.WriteLine("WTF ?");
                    }
                    else
                    {
                        Console.WriteLine("{0} commands found.", ScriptResolver.ImportedCommands.Count);
                        foreach (Command cmd in ScriptResolver.ImportedCommands)
                        {
                            Console.WriteLine("Command Name {0}", cmd.CommandName);

                            Command[] cmds = ScriptResolver.ImportedCommands.CommandsByPrefix('/');
                            Console.WriteLine("Commands by Prefix returned {0}", cmds.Length);
                        }
                    }
                }
                break;

                case "lmob":
                {
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mobtest.txt");
                    byte[] fake0        = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    byte[] len          = BitConverter.GetBytes(fake0.Length);
                    Console.WriteLine(BitConverter.ToString(len));
                }
                break;

                case "mob":
                {
                    string fileLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mobtest.txt");
                    byte[] fake0        = RealmPacketIO.GetByteArrayFromFile(fileLocation);
                    Console.WriteLine("We have a packet {0} in length.", fake0.Length);
                    ServerGlobals.SendToAllClients(fake0);
                }
                break;

                case "s":
                {
                    string        fileLocation = Path.Combine(ServerGlobals.BaseDirectory, "Test.log");
                    RLog          log          = new RLog(fileLocation);
                    StringBuilder b            = new StringBuilder();
                    for (int i = 2000; i != 0; i--)
                    {
                        b.AppendLine(i.ToString());
                    }
                    log.LogMessage(b.ToString(), MessageType.Warning);
                }
                break;

                case "start":
                {
                    this.Start();
                }
                break;

                case "stop":
                    ThreadMgr.Stop();
                    srv.Stop();
                    break;

                case "exit":
                    this.Stop();
                    break;

                default:
                    Console.WriteLine("No Such Command: " + input + "\r\n");
                    break;
                }
            }
        }
Exemplo n.º 22
0
 public static GccToolchainDescription Load(string file)
 {
     return(SerializedObject.Deserialize <GccToolchainDescription>(file));
 }