/// <summary> /// Get all the [Base] sections here so we can load the base info. /// </summary> /// <param name="secs">List of [Base] sections.</param> /// <param name="flDataPath">Path to FL's DATA folder.</param> public static void LoadBases(IEnumerable <Section> secs, string flDataPath) { Parallel.ForEach(secs, sec => { var path = Path.Combine(flDataPath, sec.GetFirstOf("file")[0]); var bdata = new Base.Base(new DataFile(path), flDataPath); Bases[FLUtility.CreateID(bdata.Nickname)] = bdata; }); }
public static void LoadMBase(DataFile file) { Base.Base bd = null; //That's lame but the mbases retarded file format gives us no chance foreach (var sec in file.Sections) { switch (sec.Name.ToLowerInvariant()) { case "mbase": bd = GetBase(sec.GetFirstOf("nickname")[0]); if (bd == null) { Logger.Warn("LOAD Unknown base in MBases: {0}", sec.GetFirstOf("nickname")[0]); } break; case "mvendor": break; case "basefaction": break; case "gf_npc": if (bd == null) { continue; } var bc = new Character { Nickname = sec.GetFirstOf("nickname")[0] }; Setting set; if (sec.TryGetFirstOf("base_appr", out set)) { //TODO: get from base_appr } else { bc.Body = FLUtility.CreateID(sec.GetFirstOf("body")[0]); bc.Head = FLUtility.CreateID(sec.GetFirstOf("head")[0]); bc.Lefthand = FLUtility.CreateID(sec.GetFirstOf("lefthand")[0]); bc.Righthand = FLUtility.CreateID(sec.GetFirstOf("righthand")[0]); } bc.Voice = FLUtility.CreateID(sec.GetFirstOf("voice")[0]); bc.IndividualName = FLUtility.CreateID(sec.GetFirstOf("individual_name")[0]); bc.Faction = sec.GetFirstOf("affiliation")[0]; if (sec.TryGetFirstOf("room", out set)) { bc.Room = String.Format("{0:x}_{1}", bd.BaseID, set[0].ToLowerInvariant()); //bc.RoomID = Utilities.CreateID(bc.Room); } foreach (var bb in sec.GetSettings("bribe").Select(bset => new CharBribe { Faction = bset[0], Cost = uint.Parse(bset[1]), Text = uint.Parse(bset[2]) })) { bc.Bribes.Add(bb); } //TODO: unused fields in rumor foreach (var br in sec.GetSettings("rumor"). Select(rset => new BaseRumor { Text = uint.Parse(rset[3]) })) { bc.Rumors.Add(br); } bd.Chars[bc.Nickname] = bc; break; case "mroom": if (bd == null) { continue; } var rnick = sec.GetFirstOf("nickname")[0].ToLowerInvariant(); Setting tSetting; if (sec.TryGetFirstOf("character_density", out tSetting)) { if (!bd.Rooms.ContainsKey(rnick)) { Logger.Warn("LOAD MRoom definition for nonexistent room {0} in {1}", rnick, bd.Nickname); continue; } bd.Rooms[rnick].CharacterDensity = uint.Parse(tSetting[0]); } if (sec.TryGetFirstOf("fixture", out tSetting)) { //TODO: all tolower? string name = tSetting[0]; string roomLocation = tSetting[1]; string fidget_script = tSetting[2]; string type = tSetting[3]; if (!bd.Chars.ContainsKey(name)) { //log.AddLog(LogType.ERROR, "character not found at {0}", set.Desc); Logger.Warn("LOAD Fixture for unknown character in MBases: {0} {1}", name, bd.Nickname); continue; } bd.Chars[name].Room = String.Format("{0:x}_{1}", bd.BaseID, rnick); //bd.Chars[name].RoomID = Utilities.CreateID(bd.Chars[name].Room); bd.Chars[name].RoomLocation = roomLocation; bd.Chars[name].FidgetScript = fidget_script; bd.Chars[name].Type = type; } break; } } }