Beispiel #1
0
        /// <summary>
        /// Called by ThwargLauncher
        /// </summary>
        public static void RecordLaunchInfo(string serverName, string accountName, string characterName, DateTime timestampUtc)
        {
            string filepath = FileLocations.GetCurrentLaunchFilePath();

            using (var file = new StreamWriter(filepath, append: false))
            {
                file.WriteLine("FileVersion:{0}", LaunchInfo.MASTER_FILE_VERSION);
                file.WriteLine("Timestamp=TimeUtc:'{0}'", timestampUtc);
                file.WriteLine("ServerName:{0}", serverName);
                file.WriteLine("AccountName:{0}", accountName);
                file.WriteLine("CharacterName:{0}", characterName);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called by Mag-Filter
        /// </summary>
        internal static LaunchInfo GetLaunchInfo()
        {
            var info = new LaunchInfo();

            try
            {
                string filepath = FileLocations.GetCurrentLaunchFilePath();

                if (!File.Exists(filepath))
                {
                    log.WriteError("No launch file found: '{0}'", filepath);
                    return(info);
                }
                var settings = (new SettingsFileLoader()).ReadSettingsFile(filepath);

                info.FileVersion = SettingHelpers.GetSingleStringValue(settings, "FileVersion");
                if (!info.FileVersion.StartsWith(LaunchInfo.MASTER_FILE_VERSION_COMPAT))
                {
                    throw new Exception(string.Format(
                                            "Incompatible launch info file version: {0}",
                                            info.FileVersion));
                }

                info.LaunchTime = settings.GetValue("Timestamp").GetDateParam("TimeUtc");
                TimeSpan maxLatency = new TimeSpan(0, 0, 0, 45); // 30 seconds max latency from exe call to game launch
                if (DateTime.UtcNow - info.LaunchTime >= maxLatency)
                {
                    log.WriteInfo("DateTime.UtcNow-'{0}', info.LaunchTime='{1}', maxLatency='{2}'", DateTime.UtcNow, info.LaunchTime, maxLatency);
                    log.WriteInfo("Launch file TimeUtc too old");
                    return(info);
                }

                info.ServerName    = SettingHelpers.GetSingleStringValue(settings, "ServerName");
                info.AccountName   = SettingHelpers.GetSingleStringValue(settings, "AccountName");
                info.CharacterName = SettingHelpers.GetSingleStringValue(settings, "CharacterName");

                info.IsValid = true;
            }
            catch (Exception exc)
            {
                log.WriteError("GetLaunchInfo exception: {0}", exc);
            }
            return(info);
        }