internal async Task QueryHunt(ushort id) { if (FFXIVHunts.hubConnection.Connected && FFXIVHunts.Joined) { IOrderedEnumerable <Hunt> results = from x in await FFXIVHunts.hubConnection.Connection.InvokeAsync("QueryHunt", id, default(CancellationToken)).ConfigureAwait(false) orderby x.LastReported select x; foreach (Hunt result in results) { TimeSpan timeSinceLastReport = FFXIVHunts.ServerTimeUtc.Subtract(result.LastReported); if (timeSinceLastReport < TimeSpan.Zero) { timeSinceLastReport = TimeSpan.Zero; } ChatMessage cm = new ChatMessage(); double TotalHours = Math.Floor(timeSinceLastReport.TotalHours); if (!result.LastAlive) { cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIHuntKilled, result.Name); if (Resources.LKIHuntKilled.Contains("<time>")) { ChatMessage chatMessage = cm; chatMessage.MessageString += cm.MessageString.Replace("<time>", string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes)); } else if (timeSinceLastReport.TotalDays > 90.0) { cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIHuntNotReported, result.Name); } else if (timeSinceLastReport.TotalHours > 72.0) { ChatMessage chatMessage2 = cm; chatMessage2.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIHours, TotalHours); } else if (timeSinceLastReport.TotalHours < 1.0) { ChatMessage chatMessage3 = cm; chatMessage3.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIMinutes, Math.Floor(timeSinceLastReport.TotalMinutes)); } else { ChatMessage chatMessage4 = cm; chatMessage4.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes); } } else { ushort zid = FFXIVHunts.GetZoneId(result.Id); cm = ChatMessage.MakePosChatMessage(FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKILastSeenAt, result.Name), zid, result.LastX, result.LastY, string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes), 0); } if (result.Instance > 0) { cm.PostpendToMessage(string.Format(CultureInfo.CurrentCulture, " " + Resources.InstanceSpecifier, result.Instance)); } await Program.mem.WriteChatMessage(cm).ConfigureAwait(false); } IEnumerator <Hunt> enumerator = null; } }
public override int GetHashCode() { if (this.WorldId > 1000 && this.WorldId < 2000 && (this.IsSHB || FFXIVHunts.GetZoneId(this.Id) == 156 || FFXIVHunts.GetZoneId(this.Id) == 152)) { return(this.Id.GetHashCode() ^ this.WorldId.GetHashCode() ^ this.Instance.GetHashCode()); } return(this.Id.GetHashCode() ^ this.WorldId.GetHashCode()); }
public override bool Equals(object obj) { Hunt item = obj as Hunt; if (item == null) { return(false); } if (this.WorldId > 1000 && this.WorldId < 2000 && (this.IsSHB || FFXIVHunts.GetZoneId(this.Id) == 156 || FFXIVHunts.GetZoneId(this.Id) == 152)) { return(this.Id.Equals(item.Id) && this.WorldId.Equals(item.WorldId) && this.Instance.Equals(item.Instance)); } return(this.Id.Equals(item.Id) && this.WorldId.Equals(item.WorldId)); }
private static void CreateWorldsOnDC(IEnumerable <World> worldsOnCurrentDC) { foreach (World worldNotYetCreated in from x in worldsOnCurrentDC where !FFXIVHunts.Worlds.ContainsKey(x.ID) select x) { FFXIVHunts.Worlds.Add(worldNotYetCreated.ID, new World(worldNotYetCreated.ID)); foreach (KeyValuePair <ushort, HuntRank> kvp in Hunt.RankMap) { if (worldNotYetCreated.ID > 100 && worldNotYetCreated.ID < 2000 && (kvp.Key > 8000 || FFXIVHunts.GetZoneId(kvp.Key) == 156 || FFXIVHunts.GetZoneId(kvp.Key) == 152)) { for (byte i = 1; i <= 3; i += 1) { FFXIVHunts.Worlds[worldNotYetCreated.ID].Hunts.Add(new Hunt(kvp.Key, worldNotYetCreated.ID) { Instance = i }); } } else { FFXIVHunts.Worlds[worldNotYetCreated.ID].Hunts.Add(new Hunt(kvp.Key, worldNotYetCreated.ID)); } } } }
internal async void Check(FFXIVMemory mem) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals1 = new FFXIVHunts.< > c__DisplayClass44_0(); if (!FFXIVHunts.hubConnection.Connected) { await this.Connect(); } if (FFXIVHunts.hubConnection.Connected) { ushort currentWorldID = mem.GetCurrentWorldId(); if ((FFXIVHunts.LastJoinedWorldID != currentWorldID && FFXIVHunts.Joined && !FFXIVHunts.Joining) || !FFXIVHunts.Joined) { await this.LeaveGroup(); await this.JoinServerGroup(); } FFXIVHunts.ServerTimeUtc = mem.GetServerUtcTime(); CS$ < > 8__locals1.thisZone = mem.GetZoneId(); if (CS$ < > 8__locals1.thisZone != FFXIVHunts.lastZone && Settings.Default.OncePerHunt && Settings.Default.ForgetOnZoneChange) { FFXIVHunts.HuntsPutInChat.Clear(); } if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) > -1 && Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)FFXIVHunts.lastZone) == -1 && FFXIVHunts.Joined) { TaskAwaiter <DateTime> taskAwaiter = this.JoinDCZone(CS$ < > 8__locals1.thisZone).GetAwaiter(); if (!taskAwaiter.IsCompleted) { await taskAwaiter; TaskAwaiter <DateTime> taskAwaiter2; taskAwaiter = taskAwaiter2; taskAwaiter2 = default(TaskAwaiter <DateTime>); } FFXIVHunts.LastShoutChatSync = taskAwaiter.GetResult(); } else if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)FFXIVHunts.lastZone) > -1 && Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) == -1) { await this.LeaveDCZone(); } FFXIVHunts.lastZone = CS$ < > 8__locals1.thisZone; IEnumerable <Monster> source = mem.Combatants.OfType <Monster>(); Func <Monster, bool> predicate; if ((predicate = CS$ < > 8__locals1.< > 9__3) == null) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals2 = CS$ < > 8__locals1; Func <Monster, bool> func = (Monster c) => FFXIVHunts.CurrentWorld.Hunts.Exists((Hunt h) => h.Id == c.BNpcNameID && FFXIVHunts.GetZoneId(c.BNpcNameID) == CS$ < > 8__locals1.thisZone); CS$ < > 8__locals2.< > 9__3 = func; predicate = func; } foreach (Monster c2 in source.Where(predicate)) { this.ReportHunt(c2); } if (Array.IndexOf <uint>(FFXIVHunts.DCZones, (uint)CS$ < > 8__locals1.thisZone) > -1) { DateTime lastShoutChatSync = FFXIVHunts.LastShoutChatSync; await this.ReportDCShoutChat((from x in mem.ReadChatLogBackwards(1000, (ChatMessage x) => x.Channel == ChatChannel.Shout && !string.IsNullOrWhiteSpace(x.Sender.Name), (ChatMessage x) => x.Timestamp <= FFXIVHunts.LastShoutChatSync) orderby x.Timestamp descending select x).Take(10)); } IEnumerable <FATE> fateList = mem.GetFateList(); Func <FATE, bool> predicate2; if ((predicate2 = CS$ < > 8__locals1.< > 9__5) == null) { FFXIVHunts.< > c__DisplayClass44_0 CS$ < > 8__locals3 = CS$ < > 8__locals1; Func <FATE, bool> func2 = (FATE f) => f.ZoneID == CS$ < > 8__locals1.thisZone; CS$ < > 8__locals3.< > 9__5 = func2; predicate2 = func2; } foreach (FATE f2 in fateList.Where(predicate2)) { this.ReportFate(f2); if (f2.IsDataCenterShared() && this.PutInChat(new FATEReport(f2) { WorldId = mem.GetHomeWorldId() }) && Settings.Default.FlashTaskbarIconOnHuntAndFATEs) { NativeMethods.FlashTaskbarIcon(mem.Process); } } }