public void Load(string listing, string field, List <BootFile> files) { XmlDbTable table = GetTable(listing); if (table != null) { if ((table.Rows == null) || (table.Rows.Count == 0)) { BooterLogger.AddError(mName + ": " + table + " table empty"); } else { BooterLogger.AddTrace(mName + ": Found " + listing + " = " + table.Rows.Count); foreach (XmlDbRow row in table.Rows) { BootFile file = new DataBootFile(mName, row.GetString(field), false); if (file.IsValid) { files.Add(file); } } } } else { BooterLogger.AddTrace(mName + ": No " + listing + " Table"); } }
protected static bool LoadSocialData(BooterHelper.DocumentBootFile socialData) { if (!socialData.IsValid) { BooterLogger.AddError(socialData + ": Unknown SocialData File"); return(false); } XmlElementLookup lookup = new XmlElementLookup(socialData.Document); List <XmlElement> actions = lookup["Action"]; if ((actions == null) || (actions.Count == 0)) { BooterLogger.AddError(socialData + ": No Action"); return(false); } bool isEp5Installed = GameUtils.IsInstalled(ProductVersion.EP5); foreach (XmlElement element in actions) { XmlElementLookup table = new XmlElementLookup(element); CommodityTypes types; ParserFunctions.TryParseEnum <CommodityTypes>(element.GetAttribute("com"), out types, CommodityTypes.Undefined); ProductVersion version; ParserFunctions.TryParseEnum <ProductVersion>(element.GetAttribute("ver"), out version, ProductVersion.BaseGame); ActionData data = new ActionData(element.GetAttribute("key"), types, version, table, isEp5Installed); List <XmlElement> list = table["LHS"]; if (list.Count > 0x0) { SocialRuleLHS.sDictionary.Remove(data.Key); foreach (XmlElement element3 in list) { SocialRuleLHS lhs = new SocialRuleLHS(data.Key, data.IntendedCommodityString, element3); lhs.ProceduralPrecondition = FindMethod(element3.GetAttribute("ProcTest")); } SocialRuleLHS.Get(data.Key).Sort(new Comparison <SocialRuleLHS>(SocialRuleLHS.SortSocialRules)); } ActionData.Add(data); BooterLogger.AddTrace(" " + data.Key + " Added"); } return(true); }
protected static bool LoadSocializingActionAvailability(BooterHelper.DataBootFile actionAvailability) { if (actionAvailability.GetTable("ActiveTopic") == null) { BooterLogger.AddError(actionAvailability + ": No ActiveTopic"); return(false); } SocialManager.ParseStcActionAvailability(actionAvailability.Data); SocialManager.ParseActiveTopic(actionAvailability.Data); return(true); }
public bool Load(LoadFunc func) { if (!IsValid) { return(false); } BooterLogger.AddTrace(mName + ": Rows = " + mTable.Rows.Count); for (int i = 0; i < mTable.Rows.Count; i++) { BooterLogger.AddTrace("Row: " + i); func(mFile, mTable.Rows[i]); } return(true); }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DocumentBootFile socialData = new BooterHelper.DocumentBootFile(file.ToString(), row.GetString("SocialData"), false); if (!socialData.IsValid) { BooterLogger.AddTrace(file + ": No SocialData"); return; } BooterHelper.DataBootFile availability = new BooterHelper.DataBootFile(file.ToString(), row.GetString("SocializingActionAvailability"), false); if (!availability.IsValid) { BooterLogger.AddTrace(file + ": No SocializingActionAvailability"); return; } Load(socialData, availability); }
public DocumentBootFile(string reference, string name, bool primary) : base(name, primary) { try { mDocument = Simulator.LoadXML(mName); if (IsValid) { BooterLogger.AddTrace("Found: " + mName); } } catch (Exception e) { Common.Exception(mName, e); BooterLogger.AddError(reference + Common.NewLine + mName + ": XML Format Error"); } }
protected sealed override void PerformFile(BootFile file) { DataBootTable table = new DataBootTable(file as DataBootFile, mTable); if (!table.IsValid) { if (file.mPrimary) { BooterLogger.AddTrace(file + ": No " + mTable + " Table"); } else { BooterLogger.AddError(file + ": No " + mTable + " Table"); } return; } table.Load(Perform); }
public void OnStartupApp() { if (sBooters != null) { foreach (IBooter booter in sBooters) { try { BooterLogger.AddTrace("Try: " + booter.ToString()); booter.Perform(true); } catch (Exception e) { Common.Exception(booter.ToString(), e); } } } Booter.ClearFiles(); }
public DataBootFile(string reference, string name, bool primary) : base(name, primary) { if (!string.IsNullOrEmpty(mName)) { try { mFile = XmlDbData.ReadData(mName); if (IsValid) { BooterLogger.AddTrace("Found: " + mName); } } catch (Exception e) { BooterLogger.AddError(mName + " Parse fail"); Common.Exception(reference + Common.NewLine + mName, e); } } }
protected override void PerformFile(BooterHelper.BootFile file) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } if ((dataFile.GetTable("BuffList") == null) && (dataFile.GetTable("Buffs") == null)) { return; } try { BuffManager.ParseBuffData(dataFile.Data, true); } catch (Exception e) { Common.Exception(file.ToString(), e); BooterLogger.AddError(file + ": ParseBuffData Error"); } }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } bool success = false; mIndex++; try { string methodName = row.GetString("Name"); if (string.IsNullOrEmpty(methodName)) { BooterLogger.AddError(file + " : Method " + mIndex + " Unnamed"); } else if (ScoringLookup.GetScoring(methodName, false) != null) { BooterLogger.AddError(methodName + " Name already in use"); return; } else { Type classType = row.GetClassType("FullClassName"); if (classType == null) { BooterLogger.AddError(methodName + " Unknown FullClassName: " + row.GetString("FullClassName")); } else { IListedScoringMethod scoring = null; try { scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IListedScoringMethod; } catch { } if (scoring == null) { BooterLogger.AddError(methodName + ": Constructor Fail " + row.GetString("FullClassName")); } else { XmlDbTable scoringTable = dataFile.GetTable(methodName); if (scoringTable == null) { BooterLogger.AddError(methodName + ": Table Missing"); } else { if (scoring.Parse(row, scoringTable)) { BooterLogger.AddTrace("Added Scoring : " + methodName); ScoringLookup.AddScoring(methodName, scoring); success = true; } else { BooterLogger.AddError(methodName + ": Parsing Fail"); } } } } } } finally { if (!success) { foreach (string column in row.ColumnNames) { BooterLogger.AddError(column + "= " + row[column]); } } } }
protected static void ParseParts <TYPE>(string suffix, Dictionary <ResourceKey, List <InvalidPartBase> > partsByKey, Dictionary <BodyTypes, List <InvalidPartBase> > partsByType) where TYPE : InvalidPartBase, new() { partsByKey.Clear(); partsByType.Clear(); BooterLogger.AddTrace(suffix + ":OnPreLoad"); string name = VersionStamp.sNamespace + "." + suffix; XmlDbData data = null; try { data = XmlDbData.ReadData(name); if ((data == null) || (data.Tables == null)) { BooterLogger.AddTrace(name + " Missing"); return; } } catch (Exception e) { BooterLogger.AddTrace(name + " Formatting Error"); Common.Exception(name, e); return; } XmlDbTable table = data.Tables[suffix]; if ((table != null) && (table.Rows != null)) { Dictionary <ResourceKey, bool> allParts = new Dictionary <ResourceKey, bool>(); BooterLogger.AddTrace(name + " PartSearch"); PartSearch search = new PartSearch(); foreach (CASPart part in search) { if (allParts.ContainsKey(part.Key)) { continue; } allParts.Add(part.Key, true); } search.Reset(); BooterLogger.AddTrace(name + " Rows"); foreach (XmlDbRow row in table.Rows) { try { OutfitCategories categories; if (!row.TryGetEnum <OutfitCategories>("Categories", out categories, OutfitCategories.All)) { BooterLogger.AddError(suffix + " Unknown Categories: " + row.GetString("Categories")); continue; } /* * ProductVersion productVersion = ProductVersion.Undefined; * if (row.Exists("ProductVersion")) * { * if (!row.TryGetEnum<ProductVersion>(row["ProductVersion"], out productVersion, ProductVersion.Undefined)) * { * BooterLogger.AddError(suffix + " Unknown WorldTypes: " + row.GetString("WorldTypes")); * continue; * } * } */ List <WorldType> worldTypes = new List <WorldType>(); if (row.Exists("WorldTypes")) { if (!ParserFunctions.TryParseCommaSeparatedList <WorldType>(row["WorldTypes"], out worldTypes, WorldType.Undefined)) { BooterLogger.AddError(suffix + " Unknown WorldTypes: " + row.GetString("WorldTypes")); continue; } } OutfitCategoriesExtended extended = OutfitCategoriesExtended.ValidForRandom; if (row.Exists("Extended")) { if (!row.TryGetEnum <OutfitCategoriesExtended>("Extended", out extended, OutfitCategoriesExtended.ValidForRandom)) { BooterLogger.AddError(suffix + " Unknown Extended: " + row.GetString("Extended")); continue; } } CASAgeGenderFlags age; if (!row.TryGetEnum <CASAgeGenderFlags>("Age", out age, CASAgeGenderFlags.AgeMask)) { BooterLogger.AddError(suffix + " Unknown Age: " + row.GetString("Age")); continue; } CASAgeGenderFlags gender; if (!row.TryGetEnum <CASAgeGenderFlags>("Gender", out gender, CASAgeGenderFlags.GenderMask)) { BooterLogger.AddError(suffix + " Unknown Gender: " + row.GetString("Gender")); continue; } CASAgeGenderFlags species = CASAgeGenderFlags.Human; if (row.Exists("Species")) { if (!row.TryGetEnum <CASAgeGenderFlags>("Species", out species, CASAgeGenderFlags.Human)) { BooterLogger.AddError(suffix + " Unknown Species: " + row.GetString("Species")); continue; } } BodyTypes type = BodyTypes.None; if (!string.IsNullOrEmpty(row.GetString("BodyType"))) { if (!row.TryGetEnum <BodyTypes>("BodyType", out type, BodyTypes.None)) { BooterLogger.AddError(suffix + " Unknown BodyTypes: " + row.GetString("BodyType")); continue; } } ResourceKey key = ResourceKey.kInvalidResourceKey; List <InvalidPartBase> tests = null; if (type == BodyTypes.None) { ulong instance = row.GetUlong("Instance"); if (instance == 0) { BooterLogger.AddError(suffix + " Invalid Instance " + row.GetString("Key")); continue; } uint group = row.GetUInt("Group"); key = new ResourceKey(instance, 0x034aeecb, group); if (!allParts.ContainsKey(key)) { BooterLogger.AddError(suffix + " Key not found: " + key); continue; } if (!partsByKey.TryGetValue(key, out tests)) { tests = new List <InvalidPartBase>(); partsByKey.Add(key, tests); } } else { if (!partsByType.TryGetValue(type, out tests)) { tests = new List <InvalidPartBase>(); partsByType.Add(type, tests); } } TYPE newPart = new TYPE(); newPart.Set(categories, worldTypes, extended, age, gender, species); tests.Add(newPart); } catch (Exception e) { string setDump = suffix; foreach (string column in row.ColumnNames) { setDump += Common.NewLine + column + " = " + row.GetString(column); } Common.Exception(setDump, e); } } BooterLogger.AddTrace(suffix + " Parts By Key Added: " + partsByKey.Count); BooterLogger.AddTrace(suffix + " Parts By Type Added: " + partsByType.Count); } }
private static void ParseSkillData(XmlDbData data, XmlDbRow row, bool bStore) { ProductVersion version; bool flag = false; SkillNames guid = SkillNames.None; string skillHex = row.GetString("Hex"); try { guid = (SkillNames)SkillManager.GetGuid(ref skillHex, bStore); } catch { } if (guid == SkillNames.None) { flag = true; BooterLogger.AddError("GUID Fail " + skillHex); } if (!row.TryGetEnum <ProductVersion>("CodeVersion", out version, ProductVersion.BaseGame)) { flag = true; BooterLogger.AddError("CodeVersion Fail " + version); } else if (!GameUtils.IsInstalled(version)) { flag = true; BooterLogger.AddError("Install Fail " + version); } if (!flag) { Skill skill = null; string typeName = row.GetString("CustomClassName"); bool flag2 = typeName.Length > 0x0; if (flag2) { Type type = null; /* * if (bStore) * { * string[] strArray = typeName.Split(new char[] { ',' }); * if (strArray.Length < 0x2) * { * flag = true; * } * else * { * type = Type.GetType(strArray[0x0] + ",Sims3StoreObjects"); * } * } */ if (type == null) { type = Type.GetType(typeName); } if (type == null) { flag = true; BooterLogger.AddError("CustomClassName Not Found " + typeName); } else { object[] args = new object[] { guid }; ConstructorInfo constructor = type.GetConstructor(Type.GetTypeArray(args)); if (constructor == null) { flag = true; BooterLogger.AddError("Constructor Missing " + typeName); } else { try { skill = constructor.Invoke(args) as Skill; } catch (Exception e) { Common.Exception(skillHex, e); } if (skill == null) { flag = true; BooterLogger.AddError("Constructor Fail " + typeName); } } } } else { skill = new Skill(guid); BooterLogger.AddTrace("Generic Skill Used " + skillHex); } if (!flag) { Skill.NonPersistableSkillData data2 = new Skill.NonPersistableSkillData(); skill.NonPersistableData = data2; uint group = ResourceUtils.ProductVersionToGroupId(version); data2.SkillProductVersion = version; data2.Name = "Gameplay/Excel/Skills/SkillList:" + row.GetString("SkillName"); if (!bStore || Localization.HasLocalizationString(data2.Name)) { data2.Description = "Gameplay/Excel/Skills/SkillList:" + row.GetString("SkillDescription"); data2.MaxSkillLevel = row.GetInt("MaxSkillLevel", 0x0); //skill.Guid = (SkillNames)(uint)guid; // Performed by the constructor, don't do it again here data2.ThoughtBalloonTopicString = row.GetString("ThoughtBalloonTopic"); data2.IconKey = ResourceKey.CreatePNGKey(row.GetString("IconKey"), group); data2.SkillUIIconKey = ResourceKey.CreatePNGKey(row.GetString("SkillUIIcon"), group); string str3 = row.GetString("Commodity"); CommodityKind commodity = CommodityKind.None; try { commodity = (CommodityKind)Enum.Parse(typeof(CommodityKind), str3); } catch { } if (commodity == CommodityKind.None) { commodity = unchecked ((CommodityKind)ResourceUtils.HashString64(str3)); } data2.Commodity = commodity; SkillManager.SkillCommodityMap.Add(commodity, guid); double num = 0; if (bStore) { string versionStr = row.GetString("Version"); if (!string.IsNullOrEmpty(versionStr)) { num = Convert.ToDouble(versionStr); } } data2.SkillVersion = num; if (row.GetBool("Physical")) { skill.AddCategoryToSkill(SkillCategory.Physical); } if (row.GetBool("Mental")) { skill.AddCategoryToSkill(SkillCategory.Mental); } if (row.GetBool("Musical")) { skill.AddCategoryToSkill(SkillCategory.Musical); } if (row.GetBool("Creative")) { skill.AddCategoryToSkill(SkillCategory.Creative); } if (row.GetBool("Artistic")) { skill.AddCategoryToSkill(SkillCategory.Artistic); } if (row.GetBool("Hidden")) { skill.AddCategoryToSkill(SkillCategory.Hidden); } if (row.GetBool("Certificate")) { skill.AddCategoryToSkill(SkillCategory.Certificate); } if ((row.Exists("HiddenWithSkillProgress") && row.GetBool("HiddenWithSkillProgress")) && skill.HasCategory(SkillCategory.Hidden)) { skill.AddCategoryToSkill(SkillCategory.HiddenWithSkillProgress); } int[] numArray = new int[skill.MaxSkillLevel]; int num3 = 0x0; for (int i = 0x1; i <= skill.MaxSkillLevel; i++) { string column = "Level_" + i.ToString(); num3 += row.GetInt(column, 0x0); numArray[i - 0x1] = num3; } data2.PointsForNextLevel = numArray; data2.AlwaysDisplayLevelUpTns = row.GetBool("AlwaysDisplayTNS"); string[] strArray2 = new string[skill.MaxSkillLevel + 0x1]; for (int j = 0x2; j <= skill.MaxSkillLevel; j++) { string str6 = "Level_" + j.ToString() + "_Text"; strArray2[j - 0x1] = row.GetString(str6); if (strArray2[j - 0x1] != string.Empty) { strArray2[j - 0x1] = "Gameplay/Excel/Skills/SkillList:" + strArray2[j - 0x1]; } } strArray2[skill.MaxSkillLevel] = row.GetString("Level_10_Text_Alternate"); if (strArray2[skill.MaxSkillLevel] != string.Empty) { strArray2[skill.MaxSkillLevel] = "Gameplay/Excel/Skills/SkillList:" + strArray2[skill.MaxSkillLevel]; } data2.LevelUpStrings = strArray2; if (flag2) { XmlDbTable table2 = null; string key = row.GetString("CustomDataSheet"); data.Tables.TryGetValue(key, out table2); if ((table2 == null) && (key.Length > 0x0)) { flag = true; skill = null; } else if (!skill.ParseSkillData(table2)) { flag = true; skill = null; } } data2.AvailableAgeSpecies = ParserFunctions.ParseAllowableAgeSpecies(row, "AvailableAgeSpecies"); data2.DreamsAndPromisesIcon = row.GetString("DreamsAndPromisesIcon"); data2.DreamsAndPromisesIconKey = ResourceKey.CreatePNGKey(data2.DreamsAndPromisesIcon, group); data2.LogicSkillBoost = row.GetBool("LogicSkillBoost"); if (!flag) { GenericManager <SkillNames, Skill, Skill> .sDictionary.Add((uint)guid, skill); SkillManager.sSkillEnumValues.AddNewEnumValue(skillHex, skill.Guid); BooterLogger.AddTrace("Loaded " + skill.Name + " (" + skill.Guid + ")"); } } } } }