Skip to content

Commit

Permalink
Merge branch 'YARC-Official:master' into fivefret-solo
Browse files Browse the repository at this point in the history
  • Loading branch information
wyrdough authored Dec 18, 2024
2 parents d1c3619 + 76b8fa7 commit c62317a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
23 changes: 21 additions & 2 deletions YARG.Core/IO/DTA/DTAEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System;
using System.Text;
using YARG.Core.Song;

namespace YARG.Core.IO
Expand Down Expand Up @@ -78,7 +79,25 @@ public void LoadData(string nodename, YARGTextContainer<byte> container)
case "name": Name = YARGDTAReader.ExtractText(ref container); break;
case "artist": Artist = YARGDTAReader.ExtractText(ref container); break;
case "master": IsMaster = YARGDTAReader.ExtractBoolean_FlippedDefault(ref container); break;
case "context": /*Context = YARGDTAReader.ExtractUInt32(ref container);*/ break;
case "context":
unsafe
{
int scopeLevel = 0;
while (container.Position < container.End && *container.Position != ')')
{
switch (*container.Position++)
{
case (byte)'{': ++scopeLevel; break;
case (byte)'}': --scopeLevel; break;
}
}

if (scopeLevel != 0)
{
throw new Exception("Invalid Context - Unbalanced brace count!");
}
break;
}
case "song":
while (YARGDTAReader.StartNode(ref container))
{
Expand Down
10 changes: 8 additions & 2 deletions YARG.Core/IO/DTA/YARGDTAReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public static bool StartNode(ref YARGTextContainer<byte> container)
public static void EndNode(ref YARGTextContainer<byte> container)
{
int scopeLevel = 0;
int squirlyCount = 0;
var textState = TextScopeState.None;
while (container.Position < container.End && scopeLevel >= 0)
{
Expand All @@ -256,19 +257,24 @@ public static void EndNode(ref YARGTextContainer<byte> container)
}
else if (curr == '{')
{
if (textState != TextScopeState.None)
if (textState != TextScopeState.None && textState != TextScopeState.Squirlies)
{
throw new Exception("Invalid open-squirly found!");
}
textState = TextScopeState.Squirlies;
++squirlyCount;
}
else if (curr == '}')
{
if (textState != TextScopeState.Squirlies)
{
throw new Exception("Invalid close-squirly found!");
}
textState = TextScopeState.None;
--squirlyCount;
if (squirlyCount == 0)
{
textState = TextScopeState.None;
}
}
else if (curr == '\"')
{
Expand Down
2 changes: 1 addition & 1 deletion YARG.Core/MoonscraperChartParser/IO/Chart/ChartReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int GetLineCount(ReadOnlySpan<char> chartText, int startIndex, int relati
++sectionEndIndex;
}

sectionBody = search[sectionStartIndex..sectionEndIndex].SplitTrimmedAscii('\n');
sectionBody = search[..sectionEndIndex].SplitTrimmedAscii('\n');
index += sectionEndIndex + 1;
return true;
}
Expand Down

0 comments on commit c62317a

Please sign in to comment.