Skip to content

Commit ec8e662

Browse files
committed
[O] 同头星星不用同头写法的情况的兼容
1 parent fa0ce6a commit ec8e662

8 files changed

Lines changed: 53 additions & 3 deletions

File tree

chart/Slide.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override Duration Duration
7575
}
7676
}
7777

78-
private string DebuggerDisplay()
78+
internal string DebuggerDisplay()
7979
{
8080
string result;
8181
if (SharedHeadWith != null) result = "*";

generator/MA2Generator.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ protected int T(Rational r, int offset = 0)
7171
if (offset != 0) result = Math.Max(result + offset, result > 0 ? 1 : 0);
7272
return result;
7373
}
74+
protected int T(int bar, int tick) => bar * RSL + tick;
75+
protected int T(MA2Line ma2Line) => T(ma2Line.Bar, ma2Line.Tick);
7476

7577
protected void Warn(string description, Note note, MA2Line? ma2Line = null)
7678
{
@@ -94,13 +96,33 @@ protected void Warn(string description, Note note, MA2Line? ma2Line = null)
9496
return new MA2Line(prefix + name, bar, tick, tap.Key - 1, extra);
9597
}
9698

99+
private HashSet<string> _broadTap = ["TAP", "HLD", "STR", "BRK", "XTP", "XHO", "BST", "XST"];
100+
protected bool hasSameTimeTap(MA2Line ma2Line)
101+
{
102+
var curT = T(ma2Line);
103+
for (int i = lines.Count - 1; i >=0 ; i--)
104+
{
105+
var l = lines[i];
106+
var lT = l.Bar * RSL + l.Tick;
107+
if (T(l) < curT) break;
108+
if (T(l) == curT && l.Key == ma2Line.Key && // 同一时间、同一键位、都是广义tap
109+
_broadTap.Contains(l.Name[^3..]) && _broadTap.Contains(ma2Line.Name[^3..])) return true;
110+
}
111+
return false;
112+
}
113+
97114
protected virtual List<MA2Line> AddSlide(Slide slide, int bar, int tick)
98115
{
99116
List<MA2Line> result = [];
100117
if (slide.OwnHead != null)
101118
{
102119
var headTap = AddTap(slide.OwnHead, bar, tick);
103-
if (headTap != null) result.Add(headTap);
120+
if (headTap != null)
121+
{
122+
if (hasSameTimeTap(headTap))
123+
alerts.Add(new Alert(Warning, Locale.SimultaneousSlideHead, (chart, slide.OwnHead.Time), null, slide.DebuggerDisplay()));
124+
else result.Add(headTap);
125+
}
104126
}
105127

106128
// 首先很重要的一点是,详见 https://github.com/Neskol/MaiLib/issues/46#issuecomment-3301893924 ,

generator/MA2_103Generator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using MuConvert.chart;
2+
using MuConvert.utils;
3+
using static MuConvert.utils.Alert.LEVEL;
24

35
namespace MuConvert.generator;
46

@@ -41,7 +43,12 @@ protected override List<MA2Line> AddSlide(Slide slide, int bar, int tick)
4143
if (slide.OwnHead != null)
4244
{
4345
var headTap = AddTap(slide.OwnHead, bar, tick);
44-
if (headTap != null) result.Add(headTap);
46+
if (headTap != null)
47+
{
48+
if (hasSameTimeTap(headTap))
49+
alerts.Add(new Alert(Warning, Locale.SimultaneousSlideHead, (chart, slide.OwnHead.Time), null, slide.DebuggerDisplay()));
50+
else result.Add(headTap);
51+
}
4552
}
4653

4754
var seg = slide.segments[0];

i18n/Locale.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

i18n/Locale.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,7 @@
211211
<data name="FixModifiersOnHead" xml:space="preserve">
212212
<value>For Slide's head, modifiers should appear after the key number and before the slide type notation.</value>
213213
</data>
214+
<data name="SimultaneousSlideHead" xml:space="preserve">
215+
<value>Detected another Slide head/Tap at the same time and position as this Slide head. This would cause judgement issues in-game. Fixed automatically (removed the redundant Slide head(s)). PS: If you intend same-head Slides, use syntax like "1-2*-3" rather than "1-2/1-3"; the latter triggers this issue.</value>
216+
</data>
214217
</root>

i18n/Locale.zh-hans.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,7 @@
211211
<data name="FixModifiersOnHead" xml:space="preserve">
212212
<value>对星星头的修饰符,应该出现在键位号后、星星类型标记之前</value>
213213
</data>
214+
<data name="SimultaneousSlideHead" xml:space="preserve">
215+
<value>检测到在星星头所在的时刻和位置,存在着其他星星头/Tap,这会造成游戏内的绝对无理。已自动为您修复(去除多余的星星头)。PS:如果您要编写同头星星,请使用类似"1-2*-3"而非"1-2/1-3"的写法,后者就会造成上面的情况。</value>
216+
</data>
214217
</root>

i18n/Locale.zh-hant.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,7 @@
211211
<data name="FixModifiersOnHead" xml:space="preserve">
212212
<value>對星星頭的修飾符,應該出現在鍵位號後、星星類型標記之前</value>
213213
</data>
214+
<data name="SimultaneousSlideHead" xml:space="preserve">
215+
<value>檢測到在星星頭所在的時刻與位置,存在其他星星頭/Tap,這會造成遊戲內的絕對無理。已自動為您修復(移除多餘的星星頭)。PS:若您要編寫同頭星星,請使用類似「1-2*-3」而非「1-2/1-3」的寫法;後者會造成上述情況。</value>
216+
</data>
214217
</root>

tests/Statistics测试.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ public static IEnumerable<object[]> OfficialLevel5()
2727

2828
foreach (var maidataPath in Directory.EnumerateFiles(testsetRoot, "maidata.txt", SearchOption.AllDirectories)
2929
.OrderBy(p => p, StringComparer.Ordinal))
30+
{
31+
if (!File.Exists(Path.Combine(Path.GetDirectoryName(maidataPath)!, "03.ma2"))) continue;
3032
yield return [new TestInput(maidataPath, levelId)];
33+
}
3134
}
3235

3336
private static List<string> T_JUDGE_HLD不准确所以不测 = ["系ぎて", "PANDORA PARADOXXX", "Xaleid◆scopiX", "Ref:rain (for 7th Heaven)", "Grievous Lady"];

0 commit comments

Comments
 (0)