Skip to content

Commit 796f874

Browse files
author
dudehacker
committed
fix 1ms fail copy
1 parent 235d1e1 commit 796f874

File tree

4 files changed

+830
-840
lines changed

4 files changed

+830
-840
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ repositories {
88
mavenCentral()
99
}
1010

11+
apply plugin: 'idea'
12+
apply plugin: 'java'
13+
1114
dependencies {
15+
implementation 'ch.qos.logback:logback-classic:1.2.3'
16+
implementation 'ch.qos.logback:logback-core:1.2.3'
17+
implementation 'org.slf4j:slf4j-api:1.7.25'
1218
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3'
1319
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
1420
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.30'

src/main/MagicCopyMania.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package main;
22

3+
import lombok.extern.slf4j.Slf4j;
34
import osu.HitObject;
45
import osu.Sample;
56
import osu.Timing;
@@ -8,9 +9,10 @@
89
import javax.swing.*;
910
import java.io.File;
1011
import java.util.ArrayList;
11-
import java.util.Collections;
1212
import java.util.List;
13+
import java.util.Set;
1314

15+
@Slf4j
1416
public class MagicCopyMania implements Runnable {
1517

1618
// Variables
@@ -85,14 +87,17 @@ public void run() {
8587
}
8688

8789
private String copyHS() {
88-
Collections.sort(List_Samples, Sample.StartTimeComparator);
90+
List_Samples.sort(Sample.StartTimeComparator);
8991
StringBuilder output = new StringBuilder();
90-
ArrayList<HitObject> outputHOs = new ArrayList<HitObject>();
91-
ArrayList<Long> list_time = OsuUtils.getDistinctStartTime(List_SourceHS, List_TargetHS);
92+
ArrayList<HitObject> outputHOs = new ArrayList<>();
93+
Set<Long> list_time = OsuUtils.getDistinctStartTime(List_SourceHS, List_TargetHS);
94+
log.debug("full target HitObjects {}", List_TargetHS);
9295
for (Long t : list_time) {
9396

9497
ArrayList<HitObject> sourceChord = OsuUtils.getChordByTime(List_SourceHS, t);
98+
log.debug("source chord: {}", sourceChord);
9599
ArrayList<HitObject> targetChord = OsuUtils.getChordByTime(List_TargetHS, t);
100+
log.debug("target chord: {}", targetChord);
96101
int sourceSize = sourceChord.size();
97102
int targetSize = targetChord.size();
98103
if (sourceSize == targetSize) {
@@ -106,7 +111,7 @@ private String copyHS() {
106111
}
107112
} else if (sourceSize > targetSize) {
108113
// CASE 2
109-
System.out.println("sourceSize> targetSize at " + t);
114+
log.debug("sourceSize > targetSize at {}", t);
110115
if (targetSize == 0) {
111116
if (isKeysound) {
112117
// keysound = true then copy to SB, else do nothing
@@ -119,10 +124,11 @@ private String copyHS() {
119124

120125
} else {
121126
int defaultHitSoundSize = OsuUtils.getDefaultHSChordSizeForTime(sourceChord, t);
127+
log.debug("default HS size at {} is {}", t, defaultHitSoundSize);
122128
switch (defaultHitSoundSize) {
123129
case 0:
124130
case 1:
125-
System.out.println("source WFC size 0|1 at " + t);
131+
log.debug("source WFC size 0|1 at {}", t);
126132
for (int i = 0; i < targetSize; i++) {
127133
HitObject source_ho = sourceChord.get(i);
128134
HitObject target_ho = targetChord.get(i);
@@ -136,13 +142,12 @@ private String copyHS() {
136142
break;
137143

138144
case 2: // Combine both default hitsounds into 1 HitObject
139-
System.out.println("source WFC size 2 at " + t);
145+
log.debug("source WFC size 2 at {}", t);
140146
outputHOs.addAll(combineDefaultHS(sourceChord, targetChord, 2));
141147
break;
142148

143149
case 3:
144-
System.out.println("source WFC size 3 at " + t);
145-
// System.out.println("target size " + targetSize);
150+
log.debug("source WFC size 3 at {}", t);
146151
if (targetSize >= 2) {
147152
if (sourceSize > defaultHitSoundSize) {
148153
outputHOs.addAll(combineDefaultHS(sourceChord, targetChord, 3));

src/osu/HitObject.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class HitObject {
1212
public final static int HITFINISH = 4;
1313
public final static int HITCLAP = 8;
1414
public final static int AdditionDefault = 0;
15+
public final static int TIMING_UNCERTAINTY_MS = 1;
16+
1517
public static Comparator<HitObject> StartTimeComparator = (ho1, ho2) -> {
1618
long t1 = ho1.startTime;
1719
long t2 = ho2.startTime;
@@ -146,6 +148,10 @@ public void addWhistleFinishClap(int value1, int value2) {
146148
setWhislteFinishClap(whistle_finish_clap + value1 + value2);
147149
}
148150

151+
public boolean isStartTimeAboutEquals(long time) {
152+
return startTime - TIMING_UNCERTAINTY_MS <= time && startTime + TIMING_UNCERTAINTY_MS >= time;
153+
}
154+
149155
public Sample toSample() {
150156
Sample s;
151157
String newHitsound = "";

0 commit comments

Comments
 (0)