Пример #1
0
        public bool CheckLeastVersion()
        {
            ConsoleFile.SetGamePath();

            string strFilePath = System.Environment.CurrentDirectory + @"\UpdateList.inf";

            if (!HttpDownloadFile(@"http://" + GetIp_By_Config() + ":60888/UpdateList.inf", strFilePath))
            {
                return(true);
            }

            if (!File.Exists(strFilePath))
            {
                return(false);
            }

            System.Text.StringBuilder sbText = new System.Text.StringBuilder(32);
            Code.API.GetPrivateProfileString("Config", "LeastFileVersion", "0", sbText, 32, strFilePath);
            float fLeastFileVersion = float.Parse(sbText.ToString());

            Code.API.GetPrivateProfileString("Config", "FileVersion", "0", sbText, 32, System.Environment.CurrentDirectory + @"\tmpDownload\UpdateList.inf");
            float fFileVersion = float.Parse(sbText.ToString());

            File.Delete(strFilePath);
            if (fFileVersion < fLeastFileVersion)
            {
                MessageBox.Show("最低版本要求是:" + fLeastFileVersion.ToString());
                return(false);
            }

            return(true);
        }
Пример #2
0
        private void ReadCardThread()
        {
            List <CCard> lst = new List <CCard>();

            if (!ConsoleFile.GetCard_By_File(ref lst))
            {
                Invoke(new MethodInvoker(delegate()
                {
                    this.Text = "本地保存的卡号数量=0";
                }));
            }
            else
            {
                Invoke(new MethodInvoker(delegate()
                {
                    this.dataGridView1.Rows.Clear();

                    // ShowData
                    for (int i = 0; i < lst.Count; i++)
                    {
                        this.dataGridView1.Rows.Add();
                        this.dataGridView1.Rows[i].Cells[0].Value = lst[i]._strCard;
                        this.dataGridView1.Rows[i].Cells[1].Value = "…………";
                    }
                }));

                CCardFunction.GetCardInfo_By_Server(lst);
                for (int i = 0; i < lst.Count; i++)
                {
                    var obj = Code.CGlobalVariable.g_WorkCardList.Where((CCard Card) => Card._strCard == lst[i]._strCard).ToList();
                    if (obj.Count > 0)
                    {
                        this.dataGridView1.Rows[i].Cells[1].Value = obj[0]._nCardAllHour;
                        this.dataGridView1.Rows[i].Cells[2].Value = obj[0]._strActiveDate;
                        this.dataGridView1.Rows[i].Cells[3].Value = obj[0]._nCardSurplusHour;
                    }
                }
                Invoke(new MethodInvoker(delegate()
                {
                    if (CGlobalVariable.g_WorkCardList != null && CGlobalVariable.g_WorkCardList.Count > 0)
                    {
                        this.Text = "有效卡号数量 = " + CGlobalVariable.g_WorkCardList.Where((CCard Card) => Card._nCardSurplusHour > 0).ToList().Count.ToString();
                    }
                    else
                    {
                        this.Text = "有效卡号数量 = 0";
                    }
                }));
            }

            Invoke(new MethodInvoker(delegate()
            {
                btnAddCard.Enabled = true;
                btnRefush.Enabled  = true;
            }));
        }
Пример #3
0
        static void Main(string[] args)
        {
            List <CCard> CardList = new List <CCard>();

            if (!ConsoleFile.GetCard_By_File(ref CardList))
            {
                MessageBox.Show("木有卡号存在,先添加卡号!");
            }

            Process instance = RunningInstance(Process.GetCurrentProcess());

            if (instance != null)
            {
                MessageBox.Show("控制台进程已经存在,先打开任务管理器结束掉!");
                HandleRunningInstance(instance);
                return;
            }
            ;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // BnsLogin BL = new BnsLogin();
            // BL.strAccountName = "*****@*****.**";
            // BL.strAccountPass = "******";
            // BL.emBnsLoginType = em_BnsLoginType.em_BnsLoginType_ActiveCard;
            try
            {
                string strGamePath = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\plaync\BNS_KOR").GetValue("BaseDir").ToString();
                if (strGamePath.LastIndexOf(@"\") != 0)
                {
                    strGamePath += "\\";
                }
                if (strGamePath.ToLower().IndexOf("plaync\\bns") == -1)
                {
                    MessageBox.Show("注册表修复错误! 现在的路径是:" + strGamePath + @",正确注册表路径应该是:X:\\XX\\plaync\Bns");
                    return;
                }
                strGamePath += @"bin\";

                if (!File.Exists(strGamePath + "zlib1.dll") && File.Exists(System.Environment.CurrentDirectory + @"\CopyFile\zlib1.dll"))
                {
                    File.Copy(System.Environment.CurrentDirectory + @"\CopyFile\zlib1.dll", strGamePath + "zlib1.dll");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Main:" + ex.Message);
            }


            Application.Run(new Form1());


            // Application.Run(BL);

            /*while (true)
             * {
             *  string strCmd = Console.ReadLine();
             *  if (strCmd == "Show")
             *  {
             *      Application.EnableVisualStyles();
             *      Application.SetCompatibleTextRenderingDefault(false);
             *      Application.Run(new Form1());
             *      //new Form1().Show();
             *      continue;
             *  }
             *  else if (strCmd == "Exit" || strCmd == "Quit")
             *  {
             *      break;
             *  }
             * }*/
        }
Пример #4
0
        private void _PromptThread()
        {
            try
            {
                CheckGameClient();
                Invoke(new MethodInvoker(delegate() { lbPrompt.Text = "优化游戏中……"; }));
                Code.API.Init(Code.ConsoleFile.GetGamePath(), int.Parse(Form1.GetValue_By_Key_For_Config("Optimize")));
                Invoke(new MethodInvoker(delegate() { lbPrompt.Text = "获取公告中……"; }));
                if (!IsTestMode() && !CheckLeastVersion())
                {
                    API.SetGameRun(0x2);
                }
                Code.ConsoleFile.SetMaxFps();

                StringBuilder sbPrompt = new StringBuilder(1024);
                if (Code.API.GetServerTitle(sbPrompt) == 0)
                {
                    Code.API.SetGameRun(0x2);
                }

                Invoke(new MethodInvoker(delegate()
                {
                    lbPrompt.Text        = sbPrompt.ToString();
                    lbGetCardMsg.Visible = true;
                }));

                if (!File.Exists(System.Environment.CurrentDirectory + @"\\Setting\\Account.txt"))
                {
                    new StreamWriter(System.Environment.CurrentDirectory + @"\\Setting\\Account.txt", false, Encoding.Unicode).Close();
                }
                if (!File.Exists(System.Environment.CurrentDirectory + @"\\Setting\\Card.txt"))
                {
                    new StreamWriter(System.Environment.CurrentDirectory + @"\\Setting\\Card.txt", false, Encoding.Unicode).Close();
                }
                if (!File.Exists(System.Environment.CurrentDirectory + @"\\Setting\\TaskUpgradeSchedule.txt"))
                {
                    new StreamWriter(System.Environment.CurrentDirectory + @"\\Setting\\TaskUpgradeSchedule.txt", false, Encoding.Unicode).Close();
                }
                if (!File.Exists(System.Environment.CurrentDirectory + @"\\Setting\\AccountLog.txt"))
                {
                    new StreamWriter(System.Environment.CurrentDirectory + @"\\Setting\\AccountLog.txt", false, Encoding.Unicode).Close();
                }
                if (!File.Exists(System.Environment.CurrentDirectory + @"\\Setting\\PlayerDaily.txt"))
                {
                    new StreamWriter(System.Environment.CurrentDirectory + @"\\Setting\\PlayerDaily.txt", false, Encoding.Unicode).Close();
                }
                if (!Directory.Exists(System.Environment.CurrentDirectory + @"\\SaveLog"))
                {
                    Directory.CreateDirectory(System.Environment.CurrentDirectory + @"\\SaveLog");
                }
                if (!Directory.Exists(System.Environment.CurrentDirectory + @"\\Setting\\Screenshot\\"))
                {
                    Directory.CreateDirectory(System.Environment.CurrentDirectory + @"\\Setting\\Screenshot\\");
                }

                List <Code.CAccount> lst = new List <Code.CAccount>();
                if (!Code.ConsoleFile.GetAccount_By_File(ref lst))
                {
                    MessageBox.Show("木有帐号存在,先添加帐号!");
                    Process.Start(System.Environment.CurrentDirectory + @"\\Setting\\Account.txt");
                    System.Threading.Thread.Sleep(5000);
                    Code.API.SetGameRun(0x2);
                }

                List <CCard> CardList = new List <CCard>();
                if (!ConsoleFile.GetCard_By_File(ref CardList))
                {
                    MessageBox.Show("木有卡号存在,先添加卡号!");

                    Process.Start(System.Environment.CurrentDirectory + @"\\Setting\\Card.txt");
                    System.Threading.Thread.Sleep(5000);
                    Code.API.SetGameRun(0x2);
                }

                CCardFunction.GetCardInfo_By_Server(CardList);

                // 清理一下
                new SettingConfig().ClearConfig();
            }
            catch (Exception ex)
            {
                MessageBox.Show("_PromptThread:" + ex.Message);
            }
            Invoke(new MethodInvoker(delegate()
            {
                this.Close();
            }));
        }