internal ModMeta ImportFrom(ModMeta overrider) { lock (this) if (overrider == null) { return(this); } lock ( overrider ) { CopyNonNull(overrider.Id, ref Id); CopyNonNull(overrider.Version, ref Version); CopyNonNull(overrider.Flags, ref Flags); CopyNonNull(overrider.Name, ref Name); CopyNonNull(overrider.Lang, ref Lang); CopyNonNull(overrider.Duration, ref Duration); CopyNonNull(overrider.Description, ref Description); CopyNonNull(overrider.Author, ref Author); CopyNonNull(overrider.Url, ref Url); CopyNonNull(overrider.Contact, ref Contact); CopyNonNull(overrider.Copyright, ref Copyright); CopyNonNull(overrider.Avoids, ref Avoids); CopyNonNull(overrider.Requires, ref Requires); CopyNonNull(overrider.Disables, ref Disables); CopyNonNull(overrider.LoadIndex, ref LoadIndex); CopyNonNull(overrider.Mods, ref Mods); CopyNonNull(overrider.Dlls, ref Dlls); CopyNonNull(overrider.Actions, ref Actions); CopyNonNull(overrider.ConfigType, ref ConfigType); } lock (this) return(this); }
private static ActionDef[] LoadInclude(ModEntry mod, string path, ref ActionDef defValues, int level) { if (!IsSafePath(path)) { mod.Log().Error("Invalid or unsafe path: {0}", path); return(new ActionDef[0]); } if (level > 9) { throw new ApplicationException("Action includes too deep: " + path); } // todo: refactor mod path var actions = Json.Parse <ActionDef[]>(ReadText(Path.Combine(Path.GetDirectoryName(mod.Path), path))); ModMeta.NormDictArray(ref actions); try { return(PreprocessActions(mod, actions, ref defValues, level)); } catch (ApplicationException ex) { throw new ApplicationException("Error when including " + path, ex); } }
private static bool ValidateMod(ModMeta meta) { if (meta == null) { return(false); } var key = NormaliseModId(meta.Id); if (string.IsNullOrWhiteSpace(key)) { Log.Warn("Id must not be empty"); return(false); } switch (key) { case "modnix": case "loader": case "phoenixpoint": case "phoenix point": case "game": case "ppml": case "ppml+": case "phoenixpointmodloader": case "phoenix point mod loader": case "non-modnix": case "nonmodnix": Log.Warn("{0} is a reserved mod id.", meta.Id); return(false); } if (meta.Mods != null && (meta.Dlls != null || meta.Actions != null)) { Log.Warn("Mod Set cannot directly specify dlls and actions."); return(false); } return(true); }
private static void ScanDLLs(ModMeta meta, string dir, string container) { if (!meta.HasContent) { meta.Dlls = Directory.EnumerateFiles(dir, "*.dll") .Where(e => { var name = Path.GetFileNameWithoutExtension(e).ToLowerInvariant(); return(NameMatch(container, name) && !IGNORE_FILE_NAMES.Contains(name)); }) .Select(e => new DllMeta { Path = e }).ToArray(); } if (meta.Dlls != null) { foreach (var dll in meta.Dlls) { if (dll.Methods == null || dll.Methods.Count == 0) { dll.Methods = ParseEntryPoints(dll.Path, true); } } } }
public ModEntry(string path, ModMeta meta) { Path = path; Metadata = meta ?? throw new ArgumentNullException(nameof(meta)); }
public ModEntry(ModMeta meta) : this(null, meta) { }