Skip to content

Commit

Permalink
fix issue with extra HS not being detected
Browse files Browse the repository at this point in the history
  • Loading branch information
dudehacker committed Sep 27, 2020
1 parent d00a4cb commit 769e250
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/detective/ResultsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ResultsWindow extends JFrame {

private JPanel contentPane;
private JTabbedPane tabbedPane;
private static final String VERSION = "v20200427";
private static final String VERSION = "v20200927";
private static final String A_HREF = "<a href=\"";
private static final String HREF_CLOSED = "\">";
private static final String HREF_END = "</a>";
Expand Down
10 changes: 7 additions & 3 deletions src/detective/hitsound/HitsoundDetectiveThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public void run() {
}

Map<Long, Chord> targetChords = BeatmapUtils.convertToChordMapWithHitsound(targetHO, targetSB);
Map<Long, Chord> sourceChords = BeatmapUtils.convertToChordMapWithHitsound(sourceHO, sourceSB);

for (Map.Entry<Long, Chord> entry : targetChords.entrySet()) {
Chord chord = entry.getValue();
if (chord.SbHasSoundWhenHoIsEmpty()) {
Expand All @@ -115,15 +117,17 @@ public void run() {
mistakes.add(new TimedMistake(chord.getStartTime(), MistakeType.DuplicateHitsound));
}

if (!sourceDifficulty.equals(targetDifficulty)) {
Map<Long, Chord> sourceChords = BeatmapUtils.convertToChordMapWithHitsound(sourceHO, sourceSB);
String sourceDiffName = (String) sourceDifficulty.getMetadataSection().getProperty(MetadataSection.versionKey);
String targetDiffName = (String) targetDifficulty.getMetadataSection().getProperty(MetadataSection.versionKey);
if (!sourceDiffName.equals(targetDiffName)) {

int i = -1;
Chord sourceChord = null;
while (i < 2 && sourceChord == null) {
sourceChord = sourceChords.get(chord.getStartTime()+i);
i++;
}

if (!chord.containsHitsounds(sourceChord)) {
mistakes.add(new TimedMistake(chord.getStartTime(), MistakeType.Inconsistency));
}
Expand Down
310 changes: 157 additions & 153 deletions src/osu/beatmap/Chord.java
Original file line number Diff line number Diff line change
@@ -1,153 +1,157 @@
package osu.beatmap;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import osu.beatmap.event.Sample;
import osu.beatmap.hitobject.HitObject;

public class Chord {
private ArrayList<HitObject> list_HO;
private ArrayList<Sample> list_SB;

private long startTime;

public Chord() {
list_HO = new ArrayList<HitObject>();
list_SB = new ArrayList<Sample>();
startTime = -1;
}

public long getStartTime() {
if (list_HO.size() > 0)
return list_HO.get(0).getStartTime();
else if (list_SB.size() > 0)
return list_SB.get(0).getStartTime();
else
return -1;
}

public boolean containsDuplicateHitsound() {
Set<String> set = new HashSet<>();
for (Sample sample : list_SB) {
if (!set.add(sample.gethitSound())){
return true;
}
}
for (HitObject hitObject : list_HO) {

if (hitObject.hasHitsound()) {
for (String hs : hitObject.toHitsoundString()) {
if (!set.add(hs)){
return true;
}
}
}
}

return false;
}

/**
*
* @return Set of unique hitsounds
*/
public Set<String> getHitsounds() {
Set<String> output = new HashSet<>();

for (Sample sample : list_SB) {
output.add(sample.gethitSound());
}

for (HitObject hitObject : list_HO) {
if (hitObject.hasHitsound()) {
output.addAll(hitObject.toHitsoundString());
}
}

return output;
}

public boolean SbHasSoundWhenHoIsEmpty() {
if (list_HO.isEmpty()) {
if (!list_SB.isEmpty()) {
return true;
}
}
return false;
}

@Override
public int hashCode() {
return getHitsounds().hashCode();
}

public boolean containsHitsounds(Chord chord) {
if (chord == null)
return true;
return this.getHitsounds().containsAll(chord.getHitsounds());
}

@Override
public boolean equals(Object other) {
if (other instanceof Chord) {
return getHitsounds().equals(((Chord) other).getHitsounds());
}

return false;
}

public void addALLSB(ArrayList<Sample> SB) {
for (Sample s : SB) {
list_SB.add(s.clone());
}
}

public void add(HitObject ho) {
if (startTime != -1 && ho.getStartTime()!=startTime ) {
throw new IllegalArgumentException(ho.toString());
}
list_HO.add(ho);
}

public void add(Sample s) {
list_SB.add(s);
}

public HitObject getHitObjectByIndex(int i) {
return list_HO.get(i);
}

public Chord Clone() {
Chord newChord = new Chord();
for (HitObject ho : list_HO) {
newChord.add(ho.clone());
}
newChord.startTime = startTime;
return newChord;
}

@Override
public String toString() {
String output = "Hit Objects\n";
for (HitObject ho : list_HO) {
try {
output += ho.toSample().toString() + "\n";
} catch (Exception e) {
e.printStackTrace();
}
}
output += "\nSamples\n";
for (Sample s : list_SB) {
output += s.toString() + "\n";
}

return output;
}

public int getSize() {
return getHitsounds().size();
}

}
package osu.beatmap;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import osu.beatmap.event.Sample;
import osu.beatmap.hitobject.HitObject;

public class Chord {
private ArrayList<HitObject> list_HO;
private ArrayList<Sample> list_SB;

private long startTime;

public Chord() {
list_HO = new ArrayList<HitObject>();
list_SB = new ArrayList<Sample>();
startTime = -1;
}

public long getStartTime() {
if (list_HO.size() > 0)
return list_HO.get(0).getStartTime();
else if (list_SB.size() > 0)
return list_SB.get(0).getStartTime();
else
return -1;
}

public boolean containsDuplicateHitsound() {
Set<String> set = new HashSet<>();
for (Sample sample : list_SB) {
if (!set.add(sample.gethitSound())){
return true;
}
}
for (HitObject hitObject : list_HO) {

if (hitObject.hasHitsound()) {
for (String hs : hitObject.toHitsoundString()) {
if (!set.add(hs)){
return true;
}
}
}
}

return false;
}

/**
*
* @return Set of unique hitsounds
*/
public Set<String> getHitsounds() {
Set<String> output = new HashSet<>();

for (Sample sample : list_SB) {
output.add(sample.gethitSound());
}

for (HitObject hitObject : list_HO) {
if (hitObject.hasHitsound()) {
output.addAll(hitObject.toHitsoundString());
}
}

return output;
}

public boolean SbHasSoundWhenHoIsEmpty() {
if (list_HO.isEmpty()) {
if (!list_SB.isEmpty()) {
return true;
}
}
return false;
}

@Override
public int hashCode() {
return getHitsounds().hashCode();
}

public boolean containsHitsounds(Chord chord) {
if (chord == null || chord.getHitsounds().size() == 0) {
if (getHitsounds().size()>0) {
return false;
}
return true;
}
return this.getHitsounds().containsAll(chord.getHitsounds());
}

@Override
public boolean equals(Object other) {
if (other instanceof Chord) {
return getHitsounds().equals(((Chord) other).getHitsounds());
}

return false;
}

public void addALLSB(ArrayList<Sample> SB) {
for (Sample s : SB) {
list_SB.add(s.clone());
}
}

public void add(HitObject ho) {
if (startTime != -1 && ho.getStartTime()!=startTime ) {
throw new IllegalArgumentException(ho.toString());
}
list_HO.add(ho);
}

public void add(Sample s) {
list_SB.add(s);
}

public HitObject getHitObjectByIndex(int i) {
return list_HO.get(i);
}

public Chord Clone() {
Chord newChord = new Chord();
for (HitObject ho : list_HO) {
newChord.add(ho.clone());
}
newChord.startTime = startTime;
return newChord;
}

@Override
public String toString() {
String output = "Hit Objects\n";
for (HitObject ho : list_HO) {
try {
output += ho.toSample().toString() + "\n";
} catch (Exception e) {
e.printStackTrace();
}
}
output += "\nSamples\n";
for (Sample s : list_SB) {
output += s.toString() + "\n";
}

return output;
}

public int getSize() {
return getHitsounds().size();
}

}

0 comments on commit 769e250

Please sign in to comment.