/// <summary> /// Loads the events time table and initializes all cached event information /// </summary> public void LoadTable(bool isAdjustedTable) { logger.Info("Loading Event Time Table"); try { this.EventTimeTable = MegaserverEventTimeTable.LoadTable(isAdjustedTable); } catch (Exception ex) { logger.Error(ex); logger.Info("Error loading Event Time Table, re-creating table"); MegaserverEventTimeTable.CreateTable(isAdjustedTable); this.EventTimeTable = MegaserverEventTimeTable.LoadTable(isAdjustedTable); } try { logger.Info("Loading world event locations"); foreach (var worldEvent in this.EventTimeTable.WorldEvents) { if (!this.eventInformationCache.ContainsKey(worldEvent.ID)) { // Get event details for the current event var dynamicEvent = this.service.GetDynamicEventDetails(worldEvent.ID); // Ensure that the service returned event data for the current event if (dynamicEvent == null) { logger.Warn("Failed to load event data for event with ID '{0}'", worldEvent.ID); continue; } // Get map details for the current event // TODO: consider specifying a language (default: English) dynamicEvent.Map = this.service.GetMap(dynamicEvent.MapId); // Ensure that the service returned map data for the current event if (dynamicEvent.Map == null) { logger.Warn("Failed to load map data for event with ID '{0}'", worldEvent.ID); continue; } this.eventInformationCache.Add(worldEvent.ID, dynamicEvent); } // Set the event location name worldEvent.Location = this.eventInformationCache[worldEvent.ID].Map.MapName; } } catch (Exception ex) { // If something goes wrong with the API, don't crash, but log the error logger.Error(ex); } }
/// <summary> /// Loads the events time table and initializes all cached event information /// </summary> public void LoadTable(bool isAdjustedTable) { logger.Info("Loading Event Time Table"); try { this.EventTimeTable = MegaserverEventTimeTable.LoadTable(isAdjustedTable); } catch (Exception ex) { logger.Error(ex); logger.Info("Error loading Event Time Table, re-creating table"); MegaserverEventTimeTable.CreateTable(isAdjustedTable); this.EventTimeTable = MegaserverEventTimeTable.LoadTable(isAdjustedTable); } }