Skip to content

Commit 1cde69b

Browse files
committed
fix: UgcParser 兼容大写类型前缀和 >c 跟随行
- typeChar 统一转小写,兼容 H/S 等大写前缀 - TryParseFollowerLine 支持 >c (SLC) 跟随行
1 parent 4041dc3 commit 1cde69b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

parser/chu/UgcParser.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private static int ParseNoteLine(string[] lines, int idx, UgcChart chart, List<A
226226
Offset = tick,
227227
};
228228

229-
var typeChar = code[0];
229+
var typeChar = char.ToLowerInvariant(code[0]);
230230

231231
switch (typeChar)
232232
{
@@ -329,13 +329,17 @@ private static bool TryParseFollowerLine(string line, out int duration, out int
329329

330330
if (!line.StartsWith('#')) return false;
331331

332-
var gtSIdx = line.IndexOf(">s");
333-
if (gtSIdx < 1) return false;
332+
// support both >s (SLD) and >c (SLC) follower lines
333+
int gtIdx = -1;
334+
int markerLen = 0;
335+
if (line.Contains(">s")) { gtIdx = line.IndexOf(">s"); markerLen = 2; }
336+
else if (line.Contains(">c")) { gtIdx = line.IndexOf(">c"); markerLen = 2; }
337+
if (gtIdx < 1) return false;
334338

335-
var durationStr = line[1..gtSIdx];
339+
var durationStr = line[1..gtIdx];
336340
if (!int.TryParse(durationStr, NumberStyles.Integer, CultureInfo.InvariantCulture, out duration)) return false;
337341

338-
var afterMarker = line[(gtSIdx + 2)..];
342+
var afterMarker = line[(gtIdx + markerLen)..];
339343
if (afterMarker.Length >= 2)
340344
{
341345
endCell = HexCharToInt(afterMarker[0]);

0 commit comments

Comments
 (0)