Exemplo n.º 1
0
        public static DateTime GetNextResetTime(MapDifficultyEntry difficulty)
        {
            GlobalInstanceTimer globalResetTimer = GlobalResetTimers[(int)difficulty.Map.Id];

            if (globalResetTimer != null)
            {
                return(globalResetTimer.LastResets.Get(difficulty.Index)
                       .AddSeconds(difficulty.ResetTime));
            }
            return(new DateTime());
        }
Exemplo n.º 2
0
		/// <summary>
		/// Load and verify timers
		/// </summary>
		public static GlobalInstanceTimer[] LoadTimers()
		{
            var arr = RealmWorldDBMgr.DatabaseProvider.FindAll<GlobalInstanceTimer>();
			var timers = new GlobalInstanceTimer[(int)MapId.End + 1000];
			foreach (var timer in arr)
			{
				timers[(int)timer.MapId] = timer;
			}

			var rgns = World.MapTemplates;
			for (var i = 0; i < rgns.Length; i++)
			{
				var rgn = rgns[i];
				var timer = timers[i];
				if (rgn != null && rgn.IsInstance)
				{
					if (timer != null && timer.LastResets.Length != InstanceMgr.MaxInstanceDifficulties)
					{
						// Invalid amount of reset times
						var resetTimes = timer.LastResets;
						Array.Resize(ref resetTimes, InstanceMgr.MaxInstanceDifficulties);
						timer.LastResets = resetTimes;
						for (var t = 0; t < timer.LastResets.Length; t++)
						{
							timer.LastResets[t] = DateTime.Now;
						}
						continue;
					}

					for (var d = 0; d < rgn.Difficulties.Length; d++)
					{
						var diff = rgn.Difficulties[d];
						if (diff != null)
						{
							if (timer == null && diff.ResetTime > 0)
							{
								// missing Timer
								timers[i] = timer = new GlobalInstanceTimer(rgn.Id);

								timer.LastResets[d] = DateTime.Now;
                                RealmWorldDBMgr.DatabaseProvider.SaveOrUpdate(timer);
							}
						}
					}
				}
				else if (timer != null)
				{
					// is not an instance (anymore)
                    RealmWorldDBMgr.DatabaseProvider.Delete(timer);
					timers[i] = null;
				}
			}
			return timers;
		}
Exemplo n.º 3
0
 public static void Initialize()
 {
     InstanceInfos.Sort();
     InstanceConfig.LoadSettings();
     try
     {
         GlobalResetTimers = GlobalInstanceTimer.LoadTimers();
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         GlobalResetTimers = GlobalInstanceTimer.LoadTimers();
     }
 }