Skip to content

Commit

Permalink
Fix def type name case sensitivity preprocess module
Browse files Browse the repository at this point in the history
  • Loading branch information
duduluu committed Nov 30, 2017
1 parent a2afbcc commit ddf6e9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
26 changes: 7 additions & 19 deletions RimTrans.Builder/DefinitionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public static DefinitionData Load(string path, DefinitionData definitionDataCore
if (definitionData._data.Count == 0)
return definitionData;

definitionData.Preprocess();

definitionData.Inherit(definitionDataCore);

definitionData.MarkIndex();
Expand Down Expand Up @@ -102,6 +100,13 @@ private void Load(string path) {
countInvalidFiles++;
}
if (doc != null) {
foreach (XElement def in doc.Root.Elements()) {
foreach (string defTypeName in DefTypeNameOf.AllNames) {
if (string.Compare(def.Name.ToString(), defTypeName, true) == 0 && def.Name.ToString() != defTypeName) {
def.Name = defTypeName;
}
}
}
this._data.Add(filePath.Substring(splitIndex), doc);
foreach (XElement abstr in from ele in doc.Root.Elements()
where ele.Attribute("Name") != null
Expand Down Expand Up @@ -145,23 +150,6 @@ where ele.Attribute("Name") != null

#endregion

#region Preprocess

private void Preprocess() {
var allDefTypeNames = DefTypeNameOf.AllNames.ToList();
foreach (XDocument doc in this.Data.Values) {
foreach (XElement def in doc.Root.Elements()) {
foreach (string defTypeName in allDefTypeNames) {
if (string.Compare(def.Name.ToString(), defTypeName, true) == 0 && def.Name.ToString() != defTypeName) {
def.Name = defTypeName;
}
}
}
}
}

#endregion

#region Inherit

/// <summary>
Expand Down
15 changes: 8 additions & 7 deletions RimTrans.Builder/Xml/DefTypeNameOf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

namespace RimTrans.Builder.Xml {
public static class DefTypeNameOf {
public static IEnumerable<string> AllNames {
get {
Type typeDef = typeof(Def);
yield return typeDef.Name;
foreach (Type subclass in typeDef.AllSubclasses()) {
yield return subclass.Name;
}
private static IEnumerable<string> getAllNames() {
Type typeDef = typeof(Def);
yield return typeDef.Name;
foreach (Type subclass in typeDef.AllSubclasses()) {
yield return subclass.Name;
}
}
private static readonly List<string> allNames = getAllNames().ToList();

public static IEnumerable<string> AllNames => allNames;

//public static readonly string Unknown = "Unknown";
public static readonly string Def = "Def";
Expand Down

0 comments on commit ddf6e9d

Please sign in to comment.