Provides methods for reading and writing to an INI file.
Пример #1
0
        private void CopyRequiredFiles(ServerInfo theServer)
        {
            //copy the files require to run the game

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.CreatingDirectory + " " + SWGANHPAth + theServer.SafeFolderName, true));
            }
            //make the directory
            if (!Directory.Exists(SWGANHPAth + theServer.SafeFolderName))
            {
                Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Created, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingSoundSystem, true));
            }

            //copy the miles directory across
            Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName + "\\miles");

            if (Directory.Exists(SWGANHPAth + "\\miles"))
            {
                foreach (string theFileName in Directory.GetFiles(SWGANHPAth + "\\miles"))
                {
                    File.Copy(theFileName, SWGANHPAth + theServer.SafeFolderName + "\\miles\\" + Path.GetFileName(theFileName));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingBinaries, true));
            }

            //copy the raw files in there

            //main executable
            File.Copy(SWGANHPAth + "swganh.exe", SWGANHPAth + theServer.SafeFolderName + "\\swganh.exe");

            //related DLLS
            File.Copy(SWGANHPAth + "dpvs.dll", SWGANHPAth + theServer.SafeFolderName + "\\dpvs.dll");
            File.Copy(SWGANHPAth + "Mss32.dll", SWGANHPAth + theServer.SafeFolderName + "\\Mss32.dll");
            File.Copy(SWGANHPAth + "s205_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s205_r.dll");
            File.Copy(SWGANHPAth + "s206_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s206_r.dll");
            File.Copy(SWGANHPAth + "s207_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s207_r.dll");

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyConfigFiles, true));
            }

            try
            {
                if (File.Exists(SWGANHPAth + "swg2uu_machineoptions.iff"))
                {
                    //one IFF
                    File.Copy(SWGANHPAth + "swg2uu_machineoptions.iff", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_machineoptions.iff");
                }
                //the pre-load CFG
                //File.Copy(SWGANHPAth + "preload.cfg", SWGANHPAth + theServer.ServerId.ToString() + "\\preload.cfg");

                //craft the login one to match
                File.Copy(SWGANHPAth + "swg2uu_login.cfg", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SettingServerAddress, true));
                }

                IniFiles myFiles = new IniFiles(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");
                myFiles.WriteValue("ClientGame", "loginServerPort0", theServer.Port);
                myFiles.WriteValue("ClientGame", "loginServerAddress0", theServer.Address);

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SetupLocalConfig, true));
                }

                //and make a main cfg which points to the central config files
                //and our local login
                TextWriter twOut = new StreamWriter(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu.cfg");
                twOut.WriteLine(".include \"swg2uu_login.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_live.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_preload.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_opt.cfg\"");
                twOut.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
            }
        }
Пример #2
0
        private void FinishedGettingTRE(IAsyncResult theResult)
        {
            CustomeTreCallObject theObject =  theResult.AsyncState as CustomeTreCallObject;
            List<LauncherData.CustomTre> lstCustomTres = theObject.TheClient.EndGetCustomTre(theResult);

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstCustomTres.Count.ToString(), false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CustomServerDir, true));
            }

            //does our directory even exist?
            if (!Directory.Exists(SWGANHPAth + theObject.Server.SafeFolderName))
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.NotFound, false));
                }
                CopyRequiredFiles(theObject.Server);
            }
            else
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Found, false));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.ValidatingFiles, true));
            }
            //now to check the files are correctly patched

            IniFiles myFiles = new IniFiles(SWGANHPAth + "\\swg2uu_live.cfg");
            List<KeyValuePair<string,string>> lstStandardFiles = myFiles.GetSectionValuesAsList("SharedFile");

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstStandardFiles.Count.ToString(), false));
            }

            bool blnSuccess = true;
            foreach (KeyValuePair<string,string> thePair in lstStandardFiles)
            {
                //prepare the filename
                string strFileName = thePair.Value.Substring(1, thePair.Value.Length - 2);

                //is it a file?
                if (File.Exists(strFileName))
                {
                    using (FileStream fileIn = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
                    {
                        byte[] arMD5Bytes = hashmd5.ComputeHash(fileIn);

                        //find the file in the Standard List
                        StandardTre theCurrentFile = myUserPreferences.CachedStandardTre.Find(st => st.Filename.Equals(Path.GetFileName(strFileName), StringComparison.InvariantCultureIgnoreCase));

                        if (theCurrentFile != null)
                        {
                            if (PatchStepFired != null)
                            {
                                PatchStepFired(this, new PatchingEventArgs(myVariables.Validating + " " + Path.GetFileName(strFileName), true));

                                if (BitConverter.ToString(arMD5Bytes).Replace("-", "") == theCurrentFile.MD5Hash)
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Passed, false));
                                }
                                else
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Failed, false));

                                    //something failed
                                    blnSuccess = false;
                                }
                            }
                        }
                    }
                }
            }

            if (PatchFunctionComplete != null)
            {
                string strPatchCompleteMessage = myVariables.ClientUpToDate;
                if(!blnSuccess)
                {
                    strPatchCompleteMessage = myVariables.ClientOutOfDate + Environment.NewLine + myVariables.PatchFromSWG;
                }
                PatchFunctionComplete(this, new PatchFunctionCompleteEventArgs(strPatchCompleteMessage, blnSuccess));
            }
        }
Пример #3
0
        private void FinishedGettingTRE(IAsyncResult theResult)
        {
            CustomeTreCallObject          theObject     = theResult.AsyncState as CustomeTreCallObject;
            List <LauncherData.CustomTre> lstCustomTres = theObject.TheClient.EndGetCustomTre(theResult);

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstCustomTres.Count.ToString(), false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CustomServerDir, true));
            }


            //does our directory even exist?
            if (!Directory.Exists(SWGANHPAth + theObject.Server.SafeFolderName))
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.NotFound, false));
                }
                CopyRequiredFiles(theObject.Server);
            }
            else
            {
                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Found, false));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.ValidatingFiles, true));
            }
            //now to check the files are correctly patched

            IniFiles myFiles = new IniFiles(SWGANHPAth + "\\swg2uu_live.cfg");
            List <KeyValuePair <string, string> > lstStandardFiles = myFiles.GetSectionValuesAsList("SharedFile");


            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Found + " " + lstStandardFiles.Count.ToString(), false));
            }

            bool blnSuccess = true;

            foreach (KeyValuePair <string, string> thePair in lstStandardFiles)
            {
                //prepare the filename
                string strFileName = thePair.Value.Substring(1, thePair.Value.Length - 2);

                //is it a file?
                if (File.Exists(strFileName))
                {
                    using (FileStream fileIn = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
                    {
                        byte[] arMD5Bytes = hashmd5.ComputeHash(fileIn);

                        //find the file in the Standard List
                        StandardTre theCurrentFile = myUserPreferences.CachedStandardTre.Find(st => st.Filename.Equals(Path.GetFileName(strFileName), StringComparison.InvariantCultureIgnoreCase));

                        if (theCurrentFile != null)
                        {
                            if (PatchStepFired != null)
                            {
                                PatchStepFired(this, new PatchingEventArgs(myVariables.Validating + " " + Path.GetFileName(strFileName), true));

                                if (BitConverter.ToString(arMD5Bytes).Replace("-", "") == theCurrentFile.MD5Hash)
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Passed, false));
                                }
                                else
                                {
                                    PatchStepFired(this, new PatchingEventArgs(myVariables.Failed, false));

                                    //something failed
                                    blnSuccess = false;
                                }
                            }
                        }
                    }
                }
            }

            if (PatchFunctionComplete != null)
            {
                string strPatchCompleteMessage = myVariables.ClientUpToDate;
                if (!blnSuccess)
                {
                    strPatchCompleteMessage = myVariables.ClientOutOfDate + Environment.NewLine + myVariables.PatchFromSWG;
                }
                PatchFunctionComplete(this, new PatchFunctionCompleteEventArgs(strPatchCompleteMessage, blnSuccess));
            }
        }
Пример #4
0
        private void CopyRequiredFiles(ServerInfo theServer)
        {
            //copy the files require to run the game

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.CreatingDirectory + " " + SWGANHPAth + theServer.SafeFolderName, true));
            }
            //make the directory
            if (!Directory.Exists(SWGANHPAth + theServer.SafeFolderName))
            {
                Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Created, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingSoundSystem, true));
            }

            //copy the miles directory across
            Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName + "\\miles");

            if (Directory.Exists(SWGANHPAth + "\\miles"))
            {
                foreach (string theFileName in Directory.GetFiles(SWGANHPAth + "\\miles"))
                {
                    File.Copy(theFileName, SWGANHPAth + theServer.SafeFolderName + "\\miles\\" + Path.GetFileName(theFileName));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingBinaries, true));
            }

            //copy the raw files in there

            //main executable
            File.Copy(SWGANHPAth + "swganh.exe", SWGANHPAth + theServer.SafeFolderName+ "\\swganh.exe");

            //related DLLS
            File.Copy(SWGANHPAth + "dpvs.dll", SWGANHPAth + theServer.SafeFolderName + "\\dpvs.dll");
            File.Copy(SWGANHPAth + "Mss32.dll", SWGANHPAth + theServer.SafeFolderName + "\\Mss32.dll");
            File.Copy(SWGANHPAth + "s205_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s205_r.dll");
            File.Copy(SWGANHPAth + "s206_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s206_r.dll");
            File.Copy(SWGANHPAth + "s207_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s207_r.dll");

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyConfigFiles, true));
            }

            try
            {

                if (File.Exists(SWGANHPAth + "swg2uu_machineoptions.iff"))
                {
                    //one IFF
                    File.Copy(SWGANHPAth + "swg2uu_machineoptions.iff", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_machineoptions.iff");
                }
                //the pre-load CFG
                //File.Copy(SWGANHPAth + "preload.cfg", SWGANHPAth + theServer.ServerId.ToString() + "\\preload.cfg");

                //craft the login one to match
                File.Copy(SWGANHPAth + "swg2uu_login.cfg", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SettingServerAddress, true));
                }

                IniFiles myFiles = new IniFiles(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");
                myFiles.WriteValue("ClientGame", "loginServerPort0", theServer.Port);
                myFiles.WriteValue("ClientGame", "loginServerAddress0", theServer.Address);

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SetupLocalConfig, true));
                }

                //and make a main cfg which points to the central config files
                //and our local login
                TextWriter twOut = new StreamWriter(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu.cfg");
                twOut.WriteLine(".include \"swg2uu_login.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_live.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_preload.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_opt.cfg\"");
                twOut.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
            }
        }