Skip to content

Commit

Permalink
Fix for func_door_rotating angles
Browse files Browse the repository at this point in the history
  • Loading branch information
Metapyziks committed Oct 8, 2017
1 parent 83c71e3 commit 9487796
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions VMFInstanceInserter/VMFStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private static string TrimFGDLine(String line)
}

private static readonly Regex _sIncludeRegex = new Regex("^@include \"[^\"]+\"");
private static readonly Regex _sClassTypeRegex = new Regex("^@[A-Z]([A-Za-z])*Class( |=)");
private static readonly Regex _sClassTypeRegex = new Regex("^@(?<classType>[A-Z]([A-Za-z])*Class)( |=)");
private static readonly Regex _sBaseDefRegex = new Regex("base\\(\\s*[A-Za-z0-9_]+(\\s*,\\s*[A-Za-z0-9_]+)*\\s*\\)");
private static readonly Regex _sParamDefRegex = new Regex("^[a-zA-Z0-9_]+\\s*\\(\\s*[A-Za-z0-9_]+\\s*\\)(\\s*readonly\\s*|\\s*):.*$");
public static void ParseFGD(String path)
Expand All @@ -156,11 +156,13 @@ public static void ParseFGD(String path)
line = line.TrimEnd('+', ' ', '\t') + TrimFGDLine(reader.ReadLine());
}

Match match;

if (_sIncludeRegex.IsMatch(line)) {
int start = line.IndexOf('"') + 1;
int end = line.IndexOf('"', start);
ParseFGD(Path.Combine(Path.GetDirectoryName(path), line.Substring(start, end - start)));
} else if (_sClassTypeRegex.IsMatch(line)) {
} else if ((match = _sClassTypeRegex.Match(line)).Success) {
int start = line.IndexOf('=') + 1;
int end = Math.Max(line.IndexOf(':', start), line.IndexOf('[', start));
if (end == -1) end = line.Length;
Expand All @@ -172,6 +174,11 @@ public static void ParseFGD(String path)

curDict = stEntitiesDict[curName];

// Don't rotate angles for brush entities
if (match.Groups["classType"].Value.Equals("SolidClass", StringComparison.InvariantCultureIgnoreCase)) {
curDict.Add("angles", TransformType.None);
}

var basesMatch = _sBaseDefRegex.Match(line);
while (basesMatch.Success && basesMatch.Index < start) {
int baseStart = basesMatch.Value.IndexOf('(') + 1;
Expand Down

0 comments on commit 9487796

Please # to comment.