Ejemplo n.º 1
0
 internal static string GetWowDirectory(WowVersionEnum _WowVersion)
 {
     if (_WowVersion == WowVersionEnum.TBC && HaveTBC == true)
     {
         return(WowTBCDirectory);
     }
     else
     {
         return(WowDirectory);
     }
 }
Ejemplo n.º 2
0
        public AccountAddons(string _Account, WowVersionEnum _WowVersion)
        {
            m_Account    = _Account;
            m_WowVersion = _WowVersion;
            var realms = Utility.GetDirectoriesInDirectory(AccountFolder);

            foreach (var realm in realms)
            {
                m_RealmAddons.Add(new RealmAddons(this, realm));
            }
        }
Ejemplo n.º 3
0
        public static AddonsWTF LoadAllAccountAddons(WowVersionEnum _WowVersion)
        {
            var addonsWTF = new AddonsWTF();
            var accounts  = Utility.GetDirectoriesInDirectory(Settings.GetWowDirectory(_WowVersion) + "WTF\\Account");

            foreach (var account in accounts)
            {
                addonsWTF.m_AccountAddons.Add(new AccountAddons(account, _WowVersion));
            }
            return(addonsWTF);
        }
Ejemplo n.º 4
0
        internal static void ReinstallAddon(string _AddonName, WowVersionEnum _WowVersion)
        {
            //Delete WTF files
            var savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(_AddonName, _WowVersion);

            savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(_AddonName, _WowVersion));
            foreach (string savedVariableFile in savedVariableFiles)
            {
                Utility.DeleteFile(savedVariableFile);
            }
            //Delete WTF files
        }
Ejemplo n.º 5
0
        public static List <string> GetSavedVariableFilePaths(string _AddonName, WowVersionEnum _WowVersion)
        {
            List <string> returnPaths = new List <string>();
            var           accounts    = GetAccounts(_WowVersion);

            foreach (var account in accounts)
            {
                string savedVariableFilePath = GetSavedVariableFilePath(account, _AddonName, _WowVersion);
                if (System.IO.File.Exists(savedVariableFilePath))
                {
                    returnPaths.Add(savedVariableFilePath);
                }
            }
            return(returnPaths);
        }
Ejemplo n.º 6
0
        internal static string BackupAddons(List <string> _AddonNames, WowVersionEnum _WowVersion, AddonBackupMode _BackupMode = AddonBackupMode.BackupWTF_And_AddonFiles)
        {
            int    fileID         = System.Threading.Interlocked.Increment(ref g_UniqueFileIDCounter);
            string backupFileName = StaticValues.LauncherBackupsDirectory + DateTime.Now.ToString("yyyy_MM_dd") + "/BackupAddons_" + DateTime.Now.ToString("HH_mm_ss") + "." + fileID + ".zip";

            Utility.AssertFilePath(backupFileName);

            ZipFile zipFile;

            if (System.IO.File.Exists(backupFileName) == true)
            {
                backupFileName = Utility.ConvertToUniqueFilename(backupFileName, '.');
            }
            if (System.IO.File.Exists(backupFileName) == true)
            {
                throw new Exception("Backup file already exists");
            }

            zipFile = ZipFile.Create(backupFileName);

            zipFile.BeginUpdate();

            foreach (var addonName in _AddonNames)
            {
                if (_BackupMode.HasFlag(AddonBackupMode.BackupWTF))
                {
                    string wtfAccStartPath    = Settings.GetWowDirectory(_WowVersion);
                    var    savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(addonName, _WowVersion);
                    savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(addonName, _WowVersion));

                    foreach (string savedVariableFile in savedVariableFiles)
                    {
                        zipFile.Add(savedVariableFile, savedVariableFile.Substring(wtfAccStartPath.Length));
                    }
                }
                if (_BackupMode.HasFlag(AddonBackupMode.BackupAddonFiles))
                {
                    if (System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addonName))
                    {
                        zipFile.AddDirectoryFilesRecursive(Settings.GetWowDirectory(_WowVersion), Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addonName);
                    }
                }
            }
            zipFile.CommitUpdate();
            zipFile.Close();
            return(backupFileName);
        }
Ejemplo n.º 7
0
        internal static bool UninstallAddon(string _AddonName, WowVersionEnum _WowVersion)
        {
            if (System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName))
            {
                Utility.DeleteDirectory(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName);

                //Delete WTF files
                var savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(_AddonName, _WowVersion);
                savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(_AddonName, _WowVersion));
                foreach (string savedVariableFile in savedVariableFiles)
                {
                    Utility.DeleteFile(savedVariableFile);
                }
                //Delete WTF files
            }
            return(System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName) == false);
        }
Ejemplo n.º 8
0
 private void InitData(string _HonorDataString, WowVersionEnum _WowVersion)
 {
     try
     {
         if (_HonorDataString == "")
         {
             return;
         }
         string[] honorData = _HonorDataString.Split(new char[] { ':' });
         if (_WowVersion == WowVersionEnum.Vanilla)
         {
             CurrentRank         = int.Parse(honorData[0]);
             CurrentRankProgress = Single.Parse(honorData[1].Replace('.', ','));
             ThisWeekHK          = int.Parse(honorData[2]);
             ThisWeekHonor       = int.Parse(honorData[3]);
             LastWeekHK          = int.Parse(honorData[4]);
             LastWeekHonor       = int.Parse(honorData[5]);
             LastWeekStanding    = int.Parse(honorData[6]);
             if (LastWeekStanding == 0)
             {
                 LastWeekStanding = int.MaxValue;
             }
             LifetimeHK          = int.Parse(honorData[7]);
             LifetimeDK          = int.Parse(honorData[8]);
             LifetimeHighestRank = int.Parse(honorData[9]);
             TodayHK             = int.Parse(honorData[10]);
             TodayDK             = int.Parse(honorData[11]);
             YesterdayHK         = int.Parse(honorData[12]);
             YesterdayHonor      = int.Parse(honorData[13]);
         }
         else if (_WowVersion == WowVersionEnum.TBC)
         {
             TodayHK        = int.Parse(honorData[0]);
             TodayHonorTBC  = int.Parse(honorData[1]);
             YesterdayHK    = int.Parse(honorData[2]);
             YesterdayHonor = int.Parse(honorData[3]);
             LifetimeHK     = int.Parse(honorData[4]);
         }
         else
         {
             throw new Exception("Error, unknown WowVersion: \"" + _WowVersion.ToString() + "\"");
         }
     }
     catch (Exception)
     { }
 }
Ejemplo n.º 9
0
        internal static void ModifyInstalledAddon(string _AddonName, WowVersionEnum _WowVersion, string _VariableName, string _VariableValue)
        {
            string addonFile = Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName + "\\" + _AddonName + ".lua";

            if (System.IO.File.Exists(addonFile) == true)
            {
                string addonCode = System.IO.File.ReadAllText(addonFile, Encoding.UTF8);
                int    index     = addonCode.IndexOf("\r\n" + _VariableName + " = ");
                if (index < 0)
                {
                    System.IO.File.AppendText(addonFile).Write("\r\n" + _VariableName + " = " + _VariableValue + ";");
                }
                else
                {
                    int endIndex = addonCode.IndexOf(';', index);
                    System.IO.File.WriteAllText(addonFile, addonCode.Substring(0, index) + "\r\n" + _VariableName + " = " + _VariableValue + addonCode.Substring(endIndex));
                }
            }
        }
Ejemplo n.º 10
0
 public static int GetMaxLevel(WowVersionEnum _WowVersion)
 {
     if (_WowVersion == WowVersionEnum.Vanilla)
     {
         return(60);
     }
     else if (_WowVersion == WowVersionEnum.TBC)
     {
         return(70);
     }
     else if (_WowVersion == WowVersionEnum.WOTLK)
     {
         return(80);
     }
     else
     {
         return(1);
     }
 }
Ejemplo n.º 11
0
        internal static List <string> GetInstalledAddons(WowVersionEnum _WowVersion)
        {
            var addons = Utility.GetDirectoriesInDirectory(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\");

            for (int i = 0; i < addons.Count; ++i)
            {
                string addonDirectory = Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addons[i] + "\\";
                if (System.IO.File.Exists(addonDirectory + addons[i] + ".toc") == false)
                {
                    addons.RemoveAt(i);
                    --i;
                }
                //if (addons[i].StartsWith("Blizzard_"))
                //{
                //    addons.RemoveAt(i);
                //    --i;
                //}
            }
            return(addons);
        }
Ejemplo n.º 12
0
        public bool AddContribution(RPPContribution _Contribution)
        {
            int loggedExceptions = 0;

            try
            {
                SavedVariablesParser.Document doc = new SavedVariablesParser.Document(_Contribution.GetFilename());
                var xmlDoc = doc.ConvertToXMLDocument();

                WowVersionEnum wowVersion = WowVersionEnum.Unknown;
                try
                {
                    string addonVersion = XMLUtility.GetChildValue(xmlDoc.DocumentElement, "VF_RealmPlayersVersion", "0.0");
                    if (addonVersion.Split('.').Length == 2) //VF_RealmPlayers
                    {
                        if (Utility.ParseDouble(addonVersion) <= 1.58)
                        {
                            return(false);
                        }
                        wowVersion = WowVersionEnum.Vanilla;
                    }
                    else //VF_RealmPlayersTBC
                    {
                        wowVersion = WowVersionEnum.TBC;
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
#if UPDATE_SQL_DB
                List <VF.SQLUploadID> uploadIDs = new List <VF.SQLUploadID>();
#endif
                var dataNode = XMLUtility.GetChild(xmlDoc.DocumentElement, "VF_RealmPlayersData");
                int wowVersionWrongGuessCount = 0;
                foreach (System.Xml.XmlNode playerNode in dataNode.ChildNodes)
                {
                    try
                    {
                        if (PlayerData.DataParser.ParsePlayerName(playerNode) == "OnlineData")
                        {
                            foreach (System.Xml.XmlNode onlineDataNode in playerNode.ChildNodes)
                            {
                                int loggedStrangeDataException = 0;

                                string   onlineData = onlineDataNode.Attributes["value"].Value;
                                var      dataParts  = onlineData.Split(new char[] { ';' }, 5);
                                string   realmStr   = dataParts[1];
                                WowRealm realm      = StaticValues.ConvertRealm(realmStr);
                                if (realm == WowRealm.Unknown)
                                {
                                    realmStr = realmStr.Substring(0, 1) + realmStr.Substring(2);
                                    realm    = StaticValues.ConvertRealm(realmStr);
                                }

                                string   dateTimeStartStr = dataParts[2];
                                string   dateTimeEndStr   = dataParts[3];
                                string[] playersDatas     = dataParts[4].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                DateTime dateTimeStart;
                                DateTime dateTimeEnd;
                                if (System.DateTime.TryParse(dateTimeStartStr, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out dateTimeStart) == true &&
                                    System.DateTime.TryParse(dateTimeEndStr, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out dateTimeEnd) == true)
                                {
                                    PlayersOnlineDB playersOnlineDB = m_Realms[realm].PlayersOnlineData;

                                    var onlineEntry = playersOnlineDB.GetOnlineEntry(dateTimeStart, dateTimeEnd);
                                    if (onlineEntry == null && (dateTimeEnd - dateTimeStart).TotalMinutes < 5)
                                    {
                                        //Widen the online-span to approx 5 minutes since we are creating a new entry anyways...
                                        double addMinutes = 5.0 - (dateTimeEnd - dateTimeStart).TotalMinutes;
                                        double halfMins   = addMinutes / 2;
                                        dateTimeStart = dateTimeStart.AddMinutes(-halfMins);
                                        dateTimeEnd   = dateTimeEnd.AddMinutes(halfMins);
                                    }
                                    onlineEntry = playersOnlineDB.CreateOnlineEntry(dateTimeStart, dateTimeEnd);

                                    foreach (var playerData in playersDatas)
                                    {
                                        var data = playerData.Split(':');
                                        if (data.Length == 6)
                                        {
                                            PlayersOnlineDB.OnlinePlayerEntry onlinePlayer = new PlayersOnlineDB.OnlinePlayerEntry();
                                            onlinePlayer.Name  = data[0];
                                            onlinePlayer.Race  = (PlayerRace)int.Parse(data[1]);
                                            onlinePlayer.Class = (PlayerClass)int.Parse(data[2]);
                                            onlinePlayer.Guild = data[3];
                                            onlinePlayer.Level = int.Parse(data[4]);
                                            onlinePlayer.Zone  = (WorldZone)int.Parse(data[5]);
                                            onlineEntry.AddOnlinePlayer(onlinePlayer);
                                        }
                                        else if (loggedStrangeDataException < 5)
                                        {
                                            Logger.ConsoleWriteLine("Strange data in OnlineData segment! \"" + playerData + "\"");
                                            ++loggedStrangeDataException;
                                        }
                                    }
                                    m_Realms[realm].Updated = true;
                                    Logger.ConsoleWriteLine(onlineEntry.OnlinePlayers.Count + " players online " + dateTimeStart.ToDateTimeStr());
                                }
                            }
                        }
                        else if (XMLUtility.GetChild(playerNode, "PlayerData") != null)
                        {
                            string   realmStr = PlayerData.DataParser.ParseRealm(playerNode);
                            WowRealm realm    = StaticValues.ConvertRealm(realmStr);
                            if (realm == WowRealm.Unknown)
                            {
                                realmStr = realmStr.Substring(0, 1) + realmStr.Substring(2);
                                realm    = StaticValues.ConvertRealm(realmStr);
                            }
                            if (StaticValues.DeadRealms.Contains(realm) == true ||
                                StaticValues.Disabled_UploadRealmNames.Contains(realmStr) == true)
                            {
                                Logger.ConsoleWriteLine("RealmStr: \"" + realmStr + "\" was recognized as a dead realm");
                                continue;
                            }
                            if ((StaticValues.GetWowVersion(realm) != wowVersion))
                            {
                                ++wowVersionWrongGuessCount;
                            }

                            if (realm == WowRealm.Unknown || m_Realms.ContainsKey(realm) == false)
                            {
                                Logger.ConsoleWriteLine("RealmStr: \"" + realmStr + "\" was not recognized as a realm");
                            }
                            else
                            {
#if UPDATE_SQL_DB
                                Func <int, VF.SQLUploadID> getUploadID = (int _Index) =>
                                {
                                    while (uploadIDs.Count <= _Index)
                                    {
                                        using (VF.SQLComm comm = new VF.SQLComm())
                                        {
                                            var uploadID = comm.GenerateNewUploadEntry(_Contribution.GetContributor(), DateTime.UtcNow);
                                            uploadIDs.Add(uploadID);
                                        }
                                    }
                                    return(uploadIDs[_Index]);
                                };
                                RealmDatabase realmDB = m_Realms[realm];
                                realmDB.UpdatePlayer(playerNode, _Contribution.GetContributor(), getUploadID);
#else
                                RealmDatabase realmDB = m_Realms[realm];
                                realmDB.UpdatePlayer(playerNode, _Contribution.GetContributor(), null);
#endif
                            }
                        }
                    }
                    catch (Npgsql.NpgsqlException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        if (loggedExceptions < 5)
                        {
                            Logger.LogException(ex);
                        }
                        ++loggedExceptions;
                    }
                }
                if (wowVersionWrongGuessCount > 0)
                {
                    Logger.ConsoleWriteLine("RealmPlayers WoWversion guess was wrong " + wowVersionWrongGuessCount + " times!!!", ConsoleColor.Red);
                }
                Logger.ConsoleWriteLine(_Contribution.GetContributor().GetFilename() + " just updated database successfully!");
                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(false);
        }
Ejemplo n.º 13
0
        public bool Update(System.Xml.XmlNode _PlayerNode, UploadID _Uploader /*Contains LastSeen*/, DateTime _LastSeen, PlayerHistory _PlayerHistory, WowVersionEnum _WowVersion)
        {
            var newCharacter = new PlayerData.CharacterData(_PlayerNode);
            var newGuild     = new PlayerData.GuildData(_PlayerNode);
            var newGear      = new PlayerData.GearData(_PlayerNode, _WowVersion);
            var newHonor     = new PlayerData.HonorData(_PlayerNode, _WowVersion);

            if (newGear.Items.Count == 0 && newGuild.GuildName == "nil" && newGuild.GuildRank == "nil" && newHonor.CurrentRank == 0 && _WowVersion == WowVersionEnum.Vanilla)
            {
                return(true);
            }

            PlayerData.ArenaData newArena = null;
            string newTalentPointsData    = null;

            if (_WowVersion == WowVersionEnum.TBC)
            {
                newArena = new PlayerData.ArenaData(_PlayerNode);
                _PlayerHistory.AddToHistory(newArena, _Uploader);
                newTalentPointsData = XMLUtility.GetChildValue(_PlayerNode, "TalentsData", "");
                _PlayerHistory.AddTalentsToHistory(newTalentPointsData, _Uploader);
            }

            _PlayerHistory.AddToHistory(newCharacter, _Uploader);
            _PlayerHistory.AddToHistory(newGuild, _Uploader);
            if (newGear.Items.Count > 0)
            {
                _PlayerHistory.AddToHistory(newGear, _Uploader);
            }
            _PlayerHistory.AddToHistory(newHonor, _Uploader);
            if (_LastSeen > LastSeen)
            {
                Uploader  = _Uploader;
                LastSeen  = _LastSeen;
                Character = newCharacter;
                Guild     = newGuild;
                if (newGear.Items.Count > 0)
                {
                    Gear = newGear;
                }
                Honor            = newHonor;
                Arena            = newArena;
                TalentPointsData = newTalentPointsData;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 14
0
        public bool AddContribution(RPPContribution _Contribution)
        {
            int loggedExceptions = 0;

            try
            {
                SavedVariablesParser.Document doc = new SavedVariablesParser.Document(_Contribution.GetFilename());
                var xmlDoc = doc.ConvertToXMLDocument();

                WowVersionEnum wowVersion = WowVersionEnum.Unknown;
                try
                {
                    string addonVersion = XMLUtility.GetChildValue(xmlDoc.DocumentElement, "VF_RealmPlayersVersion", "0.0");
                    if (addonVersion.Split('.').Length == 2) //VF_RealmPlayers
                    {
                        if (Utility.ParseDouble(addonVersion) <= 1.58)
                        {
                            return(false);
                        }
                        wowVersion = WowVersionEnum.Vanilla;
                    }
                    else //VF_RealmPlayersTBC
                    {
                        wowVersion = WowVersionEnum.TBC;
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
                List <VF.SQLUploadID> uploadIDs = new List <VF.SQLUploadID>();
                var dataNode = XMLUtility.GetChild(xmlDoc.DocumentElement, "VF_RealmPlayersData");
                int wowVersionWrongGuessCount = 0;
                foreach (System.Xml.XmlNode playerNode in dataNode.ChildNodes)
                {
                    try
                    {
                        if (XMLUtility.GetChild(playerNode, "PlayerData") != null)
                        {
                            string   realmStr = PlayerData.DataParser.ParseRealm(playerNode);
                            WowRealm realm    = StaticValues.ConvertRealm(realmStr);
                            if ((StaticValues.GetWowVersion(realm) != wowVersion))
                            {
                                ++wowVersionWrongGuessCount;
                            }

                            if (realm == WowRealm.Unknown || m_Realms.ContainsKey(realm) == false)
                            {
                                Logger.ConsoleWriteLine("RealmStr: \"" + realmStr + "\" was not recognized as a realm");
                            }
                            else
                            {
                                Func <int, VF.SQLUploadID> getUploadID = (int _Index) =>
                                {
                                    while (uploadIDs.Count <= _Index)
                                    {
                                        using (VF.SQLComm comm = new VF.SQLComm())
                                        {
                                            var uploadID = comm.GenerateNewUploadEntry(_Contribution.GetContributor(), DateTime.UtcNow);
                                            uploadIDs.Add(uploadID);
                                        }
                                    }
                                    return(uploadIDs[_Index]);
                                };
                                RealmDatabase realmDB = m_Realms[realm];
                                realmDB.UpdatePlayer(playerNode, _Contribution.GetContributor(), getUploadID);
                            }
                        }
                    }
                    catch (Npgsql.NpgsqlException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        if (loggedExceptions < 5)
                        {
                            Logger.LogException(ex);
                        }
                        ++loggedExceptions;
                    }
                }
                if (wowVersionWrongGuessCount > 0)
                {
                    Logger.ConsoleWriteLine("RealmPlayers WoWversion guess was wrong " + wowVersionWrongGuessCount + " times!!!", ConsoleColor.Red);
                }
                Logger.ConsoleWriteLine(_Contribution.GetContributor().GetFilename() + " just updated database successfully!");
                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(false);
        }
Ejemplo n.º 15
0
        private static void _LaunchWow(string _Config, string _RealmName, ProcessStartInfo _WowProcessStartInfo)
        {
            if (System.IO.File.Exists("VF_WowLauncherTools\\NotAdmin.exe") == false)
            {
                VF_Utility.AssertDirectory("VF_WowLauncherTools");
                System.IO.File.WriteAllBytes("VF_WowLauncherTools\\NotAdmin.exe", Properties.Resources.NotAdmin);
            }

            Logger.LogText("Started Launching");

            WowVersionEnum wowVersion    = WowVersionEnum.Vanilla;
            string         realmListFile = "";

            if (Settings.Instance.RealmLists.ContainsKey(_RealmName) == true)
            {
                var realmList = Settings.Instance.RealmLists[_RealmName];
                realmListFile = realmList.GetRealmListWTF();
                wowVersion    = realmList.WowVersion;
            }
            else
            {
                Logger.LogText("Unexpected Error: No such Realm exists!");
                return;
            }

            if (_Config != "Active Wow Config")
            {
                ConfigWTF config = ConfigProfiles.GetProfileConfigFile(_Config);
                config.SaveWTFConfigFile(wowVersion);
                Settings.Instance.AddLaunchShortcut(_Config, _RealmName);
            }

            DateTime startCheck = DateTime.UtcNow;

            if (System.IO.File.Exists(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") == false || System.IO.File.ReadAllText(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") != realmListFile)
            {
                System.IO.File.WriteAllText(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf", realmListFile);
                if (System.IO.File.Exists(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf") == false)
                {
                    Logger.LogText("Unexpected Error: There is no realmlist.wtf!");
                    return;
                }
                Logger.LogText("Waiting for realmlist.wtf to get saved correctly");
                startCheck = DateTime.UtcNow;
                while ((startCheck - System.IO.File.GetLastWriteTimeUtc(Settings.GetWowDirectory(wowVersion) + "realmlist.wtf")).Seconds > 10)
                {
                    Logger.LogText(".", false);
                    System.Threading.Thread.Sleep(20);
                    if ((DateTime.UtcNow - startCheck).Seconds > 10)
                    {
                        Logger.LogText("Unexpected Error: Took too long trying to create the new realmlist.wtf!");
                        return;
                    }
                }
            }
            Logger.LogText("realmlist.wtf is saved, Launching World of Warcraft!");
            Process[] processesBeforeStart = Process.GetProcessesByName("Wow");
            var       wowProcess           = Process.Start(_WowProcessStartInfo);

            if (_WowProcessStartInfo.FileName.ToLower().EndsWith("wow.exe") == false)
            {
                wowProcess = null;
                while (wowProcess == null && (DateTime.UtcNow - startCheck).TotalSeconds < 30)
                {
                    Utility.SoftThreadSleep(500);
                    Process[] currentProcesses = Process.GetProcessesByName("Wow");
                    foreach (var currProcess in currentProcesses)
                    {
                        if (processesBeforeStart.Length == 0 || processesBeforeStart.FirstOrDefault((_Value) => _Value.Id == currProcess.Id) == null)
                        {
                            //Logger.LogText("found new Wow.exe Process!");
                            wowProcess = currProcess;
                            break;
                        }
                    }
                }
            }
            if (wowProcess == null)
            {
                Utility.MessageBoxShow("There was an error, WoW could not be launched");
                return;
            }
            startCheck = DateTime.UtcNow;
            try
            {
                while (wowProcess.WaitForInputIdle(50) == false && (DateTime.UtcNow - startCheck).TotalSeconds < 20)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            //wait 1 extra second
            Utility.SoftThreadSleep(1000);

            Logger.LogText("Done Launching");
        }
Ejemplo n.º 16
0
 public static string GetSavedVariableFilePath(string _Account, string _AddonName, WowVersionEnum _WowVersion)
 {
     return(Settings.GetWowDirectory(_WowVersion) + "WTF\\Account\\" + _Account + "\\SavedVariables\\" + _AddonName + ".lua");
 }
Ejemplo n.º 17
0
        internal static AddonInfo GetAddonInfo(string _AddonName, WowVersionEnum _WowVersion)
        {
            string addonDirectory = Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + _AddonName + "\\";

            return(GetAddonInfo(_AddonName, addonDirectory));
        }
Ejemplo n.º 18
0
 public RealmDatabase(WowRealm _Realm)
 {
     Realm      = _Realm;
     WowVersion = StaticValues.GetWowVersion(_Realm);
     Updated    = false;
 }
Ejemplo n.º 19
0
        public static List <string> GetPerCharacterSavedVariableFilePaths(string _AddonName, WowVersionEnum _WowVersion)
        {
            List <string> returnPaths = new List <string>();
            var           accounts    = GetAccounts(_WowVersion);

            foreach (var account in accounts)
            {
                var realms = GetRealms(account, _WowVersion);
                foreach (var realm in realms)
                {
                    var characters = GetCharacters(account, realm, _WowVersion);
                    foreach (var character in characters)
                    {
                        string savedVariableFilePath = GetPerCharacterSavedVariableFilePath(account, realm, character, _AddonName, _WowVersion);
                        if (System.IO.File.Exists(savedVariableFilePath))
                        {
                            returnPaths.Add(savedVariableFilePath);
                        }
                    }
                }
            }
            return(returnPaths);
        }
Ejemplo n.º 20
0
 public HonorData(string _HonorDataString, WowVersionEnum _WowVersion)
 {
     InitData(_HonorDataString, _WowVersion);
 }
Ejemplo n.º 21
0
 public bool IsSame(HonorData _HonorData, WowVersionEnum _WowVersion = WowVersionEnum.Vanilla)
 {
     if (TodayHK != _HonorData.TodayHK)
     {
         return(false);
     }
     if (YesterdayHK != _HonorData.YesterdayHK)
     {
         return(false);
     }
     if (YesterdayHonor != _HonorData.YesterdayHonor)
     {
         return(false);
     }
     if (LifetimeHK != _HonorData.LifetimeHK)
     {
         return(false);
     }
     if (_WowVersion != WowVersionEnum.Vanilla)
     {
         if (TodayHonorTBC != _HonorData.TodayHonorTBC)
         {
             return(false);
         }
     }
     else
     {
         if (ThisWeekHK != _HonorData.ThisWeekHK)
         {
             return(false);
         }
         if (ThisWeekHonor != _HonorData.ThisWeekHonor)
         {
             return(false);
         }
         if (LastWeekHK != _HonorData.LastWeekHK)
         {
             return(false);
         }
         if (LastWeekHonor != _HonorData.LastWeekHonor)
         {
             return(false);
         }
         if (CurrentRank != _HonorData.CurrentRank)
         {
             return(false);
         }
         if (CurrentRankProgress != _HonorData.CurrentRankProgress)
         {
             return(false);
         }
         if (TodayDK != _HonorData.TodayDK)
         {
             return(false);
         }
         if (LastWeekStanding != _HonorData.LastWeekStanding)
         {
             return(false);
         }
         if (LifetimeDK != _HonorData.LifetimeDK)
         {
             return(false);
         }
         if (LifetimeHighestRank != _HonorData.LifetimeHighestRank)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 22
0
 public static bool IsAddonInstalled(string _AddonName, WowVersionEnum _WowVersion)
 {
     return(System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\Addons\\" + _AddonName));
 }
Ejemplo n.º 23
0
 public static List <string> GetCharacters(string _Account, string _Realm, WowVersionEnum _WowVersion)
 {
     return(Utility.GetDirectoriesInDirectory(Settings.GetWowDirectory(_WowVersion) + "WTF\\Account\\" + _Account + "\\" + _Realm + "\\"));
 }
Ejemplo n.º 24
0
 public static List <string> GetAccounts(WowVersionEnum _WowVersion)
 {
     return(Utility.GetDirectoriesInDirectory(Settings.GetWowDirectory(_WowVersion) + "WTF\\Account\\"));
 }
Ejemplo n.º 25
0
 public HonorData(System.Xml.XmlNode _PlayerNode, WowVersionEnum _WowVersion)
 {
     InitData(XMLUtility.GetChildValue(_PlayerNode, "HonorData", ""), _WowVersion);
 }
Ejemplo n.º 26
0
        public void AddContribution(RPPContribution _Contribution)
        {
            int loggedExceptions = 0;

            try
            {
                SavedVariablesParser.Document doc = new SavedVariablesParser.Document(_Contribution.GetFilename());
                var xmlDoc = doc.ConvertToXMLDocument();

                WowVersionEnum wowVersion = WowVersionEnum.Unknown;
                try
                {
                    string addonVersion = XMLUtility.GetChildValue(xmlDoc.DocumentElement, "VF_RealmPlayersVersion", "0.0");
                    if (addonVersion.Split('.').Length == 2) //VF_RealmPlayers
                    {
                        if (Utility.ParseDouble(addonVersion) <= 1.58)
                        {
                            return;
                        }
                        wowVersion = WowVersionEnum.Vanilla;
                    }
                    else //VF_RealmPlayersTBC
                    {
                        wowVersion = WowVersionEnum.TBC;
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
                var dataNode = XMLUtility.GetChild(xmlDoc.DocumentElement, "VF_RealmPlayersData");
                foreach (System.Xml.XmlNode playerNode in dataNode.ChildNodes)
                {
                    try
                    {
                        if (XMLUtility.GetChild(playerNode, "PlayerData") != null)
                        {
                            string   realmStr = PlayerData.DataParser.ParseRealm(playerNode);
                            WowRealm realm    = StaticValues.ConvertRealm(realmStr);
                            if (realm == WowRealm.Archangel || wowVersion == WowVersionEnum.TBC)
                            {
                                if (realm != WowRealm.Archangel || wowVersion != WowVersionEnum.TBC)
                                {
                                    Logger.ConsoleWriteLine("RealmPlayers WoWversion guess was wrong!!!", ConsoleColor.Red);
                                }
                            }

                            if (realm == WowRealm.Unknown || m_Realms.ContainsKey(realm) == false)
                            {
                                Logger.ConsoleWriteLine("RealmStr: \"" + realmStr + "\" was not recognized as a realm");
                            }
                            else
                            {
                                RealmDatabase realmDB = m_Realms[realm];
                                realmDB.UpdatePlayer(playerNode, _Contribution.GetContributor());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (loggedExceptions < 5)
                        {
                            Logger.LogException(ex);
                        }
                        ++loggedExceptions;
                    }
                }
                Logger.ConsoleWriteLine(_Contribution.GetContributor().GetFilename() + " just updated database successfully!");
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Ejemplo n.º 27
0
 internal static ConfigWTF LoadWTFConfigFile(WowVersionEnum _WowVersion)
 {
     return(LoadConfigFile(Settings.GetWowDirectory(_WowVersion) + "WTF\\Config.wtf"));
 }
Ejemplo n.º 28
0
 internal void SaveWTFConfigFile(WowVersionEnum _WowVersion)
 {
     SaveConfigFile(Settings.GetWowDirectory(_WowVersion) + "WTF\\Config.wtf");
 }
Ejemplo n.º 29
0
        internal static List <string> InstallAddonPackage(string _AddonZipFilePackage, WowVersionEnum _WowVersion, Action <float> _InstallProgress = null, bool _ClearWTFSettings = false)
        {
            List <string> addonsInPackage = GetAddonsInAddonPackage(_AddonZipFilePackage);

            _InstallProgress(0.2f);
            string backupFile = BackupAddons(addonsInPackage, _WowVersion);

            _InstallProgress(0.4f);
            for (int i = 0; i < addonsInPackage.Count; ++i)
            {
                string addon = addonsInPackage[i];
                if (_ClearWTFSettings == true)
                {
                    var savedVariableFiles = WowUtility.GetPerCharacterSavedVariableFilePaths(addon, _WowVersion);
                    savedVariableFiles.AddRange(WowUtility.GetSavedVariableFilePaths(addon, _WowVersion));
                    foreach (string savedVariableFile in savedVariableFiles)
                    {
                        Utility.DeleteFile(savedVariableFile);
                    }
                }
                if (System.IO.Directory.Exists(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addon))
                {
                    Utility.DeleteDirectory(Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\" + addon);
                }
                _InstallProgress(0.4f + ((float)(i + 1) / (float)addonsInPackage.Count) * 0.4f);
            }

            _InstallProgress(0.8f);
            try
            {
                FastZip fastZip = new FastZip();
                fastZip.ExtractZip(_AddonZipFilePackage, Settings.GetWowDirectory(_WowVersion) + "Interface\\AddOns\\", null);
                _InstallProgress(1.0f);
                return(addonsInPackage);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                Utility.MessageBoxShow("There was an error extracting the AddonPackage, Backup of anything deleted/replaced exists in the \"" + backupFile + "\" unfortunately automatic restoration is not implemented yet");
            }
            return(null);
        }
Ejemplo n.º 30
0
        public bool Update(System.Xml.XmlNode _PlayerNode, UploadID _Uploader /*Contains LastSeen*/, DateTime _LastSeen, PlayerHistory _PlayerHistory, WowVersionEnum _WowVersion, Func <int, VF.SQLUploadID> _GetSQLUploadIDFunc = null)
        {
            var newCharacter = new PlayerData.CharacterData(_PlayerNode);
            var newGuild     = new PlayerData.GuildData(_PlayerNode);
            var newGear      = new PlayerData.GearData(_PlayerNode, _WowVersion);
            var newHonor     = new PlayerData.HonorData(_PlayerNode, _WowVersion);

            if (newGear.Items.Count == 0 && newGuild.GuildName == "nil" && newGuild.GuildRank == "nil" && newHonor.CurrentRank == 0 && _WowVersion == WowVersionEnum.Vanilla)
            {
                return(true);
            }

            PlayerData.ArenaData newArena = null;
            string newTalentPointsData    = null;

            if (_WowVersion == WowVersionEnum.TBC)
            {
                newArena            = new PlayerData.ArenaData(_PlayerNode);
                newTalentPointsData = XMLUtility.GetChildValue(_PlayerNode, "TalentsData", "");
            }
            if (_GetSQLUploadIDFunc != null)
            {
                UpdateSQL(_GetSQLUploadIDFunc, Uploader, _LastSeen, _PlayerHistory, _WowVersion, newCharacter, newGuild, newGear, newHonor, newArena, newTalentPointsData);
            }
            return(Update(_Uploader, _LastSeen, _PlayerHistory, _WowVersion, newCharacter, newGuild, newGear, newHonor, newArena, newTalentPointsData));
        }