/// <summary> /// Initializes/loads all known player titles. /// </summary> /// <returns>true if successful</returns> public static bool Init() { m_titles.Clear(); foreach (Type t in ScriptMgr.GetDerivedClasses(typeof(IPlayerTitle))) { if (t.IsAbstract) { continue; } if (t == ClearTitle.GetType()) { continue; } IPlayerTitle title; try { title = (IPlayerTitle)Activator.CreateInstance(t); } catch (Exception e) { log.Error("Error loading player title '" + t.FullName + "': ", e); continue; } m_titles.Add(title); log.DebugFormat(" loaded player title: {0}", title.GetType().FullName); } log.InfoFormat("Loaded {0} player titles", m_titles.Count); return(true); }
/// <summary> /// Finds and creates packetlib for specified raw version. /// </summary> /// <param name="rawVersion">The version number sent by the client.</param> /// <param name="client">The client for which to create packet lib.</param> /// <param name="version">The client version of packetlib.</param> /// <returns>null if not found or new packetlib instance.</returns> public static IPacketLib CreatePacketLibForVersion(int rawVersion, GameClient client, out GameClient.eClientVersion version) { foreach (Type t in ScriptMgr.GetDerivedClasses(typeof(IPacketLib))) { foreach (PacketLibAttribute attr in t.GetCustomAttributes(typeof(PacketLibAttribute), false)) { if (attr.RawVersion == rawVersion) { try { IPacketLib lib = (IPacketLib)Activator.CreateInstance(t, new object[] { client }); version = attr.ClientVersion; return(lib); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("error creating packetlib (" + t.FullName + ") for raw version " + rawVersion, e); } } } } } version = GameClient.eClientVersion.VersionUnknown; return(null); }
/// <summary> /// Initializes/loads all known player titles. /// </summary> /// <returns>true if successful</returns> public static bool Init() { Titles.Clear(); foreach (Type t in ScriptMgr.GetDerivedClasses(typeof(IPlayerTitle))) { if (t == ClearTitle.GetType()) { continue; } IPlayerTitle title; try { title = (IPlayerTitle)Activator.CreateInstance(t); } catch (Exception e) { Log.Error($"Error loading player title '{t.FullName}': {e}"); continue; } Titles.Add(title); Log.Debug($"Loaded player title: {title.GetType().FullName}"); } Log.Info($"Loaded {Titles.Count} player titles"); return(true); }