Exemplo n.º 1
0
        private static void Load(string pContents)
        {
            string[] lines = pContents.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < lines.Length; i += 2)
            {
                var firstLine    = lines[i];
                var semicolonPos = firstLine.IndexOf(':');
                var dotPos       = firstLine.IndexOf('.');

                Localisation localisation = (Localisation)(byte.Parse(firstLine.Substring(0, semicolonPos)));
                ushort       version      = ushort.Parse(firstLine.Substring(semicolonPos + 1, dotPos - (semicolonPos + 1)));
                byte         subVersion   = byte.Parse(firstLine.Substring(dotPos + 1));

                string tmpkey  = lines[i + 1];
                byte[] realkey = new byte[8];
                int    tmp     = 0;

                for (int j = 0; j < 4 * 8 * 2; j += 4 * 2)
                {
                    realkey[tmp++] = byte.Parse(tmpkey[j] + "" + tmpkey[j + 1], System.Globalization.NumberStyles.HexNumber);
                }

                MapleKeys.Add(localisation, version, subVersion, realkey);
            }
        }
Exemplo n.º 2
0
        public static void Initialize()
        {
            MapleKeys.Keys = new Dictionary <Localisation, Dictionary <KeyValuePair <ushort, byte>, byte[]> >();

            try
            {
                if (File.Exists("noupdate.txt"))
                {
                    throw new Exception(); // NOTE: Trigger offline-load.
                }

                HttpWebRequest req = WebRequest.Create("http://direct.craftnet.nl/app_updates/get_keys.php?source=SRK&version=4") as HttpWebRequest;

                req.Proxy = null;

                using (HttpWebResponse response = req.GetResponse() as HttpWebResponse)
                {
                    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                    {
                        string text = sr.ReadToEnd();

                        MapleKeys.Load(text);

                        File.AppendAllText("MapleKeys.txt", text);
                    }
                }
            }
            catch (Exception e)
            {
                if (File.Exists("MapleKeys.txt"))
                {
                    string text = File.ReadAllText("MapleKeys.txt");

                    MapleKeys.Load(text);
                }
                else
                {
                    throw new Exception("Unable to initialize MapleKeys.");
                }
            }

            MapleKeys.Add(Localisation.Global, 118, 1, new byte[] {
                0x5A, // Full key's lost
                0x22,
                0xFB,
                0xD1,
                0x8F,
                0x93,
                0xCD,
                0xE6,
            });
        }