Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display which paths led to "Illegal BMS Songs" error #631

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions src/bms/player/beatoraja/BMSResource.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package bms.player.beatoraja;

import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.logging.Logger;

import bms.model.BMSModel;
import bms.player.beatoraja.audio.AudioDriver;
import bms.player.beatoraja.play.bga.BGAProcessor;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

import java.nio.file.Path;
import java.util.ArrayDeque;
import java.util.logging.Logger;

/**
* BMSの音源、BGAリソースを管理するクラス
*
Expand Down Expand Up @@ -99,17 +99,15 @@ public boolean setBMSFile(BMSModel model, final Path f, final Config config, BMS
while(!bgaloaders.isEmpty() && !bgaloaders.getFirst().isAlive()) {
bgaloaders.removeFirst();
}

if(MainLoader.getIllegalSongCount() == 0) {
// Audio, BGAともキャッシュがあるため、何があっても全リロードする
BGALoaderThread bgaloader = new BGALoaderThread(
config.getBga() == Config.BGA_ON || (config.getBga() == Config.BGA_AUTO && (mode.mode == BMSPlayerMode.Mode.AUTOPLAY || mode.mode == BMSPlayerMode.Mode.REPLAY)) ? model : null);
bgaloaders.addLast(bgaloader);
bgaloader.start();
AudioLoaderThread audioloader = new AudioLoaderThread(model);
audioloaders.addLast(audioloader);
audioloader.start();
}

// Audio, BGAともキャッシュがあるため、何があっても全リロードする
BGALoaderThread bgaloader = new BGALoaderThread(
config.getBga() == Config.BGA_ON || (config.getBga() == Config.BGA_AUTO && (mode.mode == BMSPlayerMode.Mode.AUTOPLAY || mode.mode == BMSPlayerMode.Mode.REPLAY)) ? model : null);
bgaloaders.addLast(bgaloader);
bgaloader.start();
AudioLoaderThread audioloader = new AudioLoaderThread(model);
audioloaders.addLast(audioloader);
audioloader.start();
return true;
}

Expand Down
44 changes: 21 additions & 23 deletions src/bms/player/beatoraja/MainLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.*;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.swing.JOptionPane;

Expand Down Expand Up @@ -102,9 +103,7 @@ public static void main(String[] args) {
}
}



if (Files.exists(MainController.configpath) && (bmsPath != null || auto != null)) {
if(Files.exists(MainController.configpath) && (bmsPath != null || auto != null)) {
IRConnectionManager.getAllAvailableIRConnectionName();
play(bmsPath, auto, true, null, null, bmsPath != null);
} else {
Expand All @@ -117,19 +116,13 @@ public static void play(Path f, BMSPlayerMode auto, boolean forceExit, Config co
config = Config.read();
}

verifyIllegalSongs();

if(config.isUseDiscordRPC()) {
discord = new Discord("", "");
discord.startup();
}

for(SongData song : getScoreDatabaseAccessor().getSongDatas(SongUtils.illegalsongs)) {
MainLoader.putIllegalSong(song.getSha256());
}
if(illegalSongs.size() > 0) {
JOptionPane.showMessageDialog(null, "This Application detects " + illegalSongs.size() + " illegal BMS songs. \n Remove them, update song database and restart.", "Error", JOptionPane.ERROR_MESSAGE);
System.exit(1);
}

try {
MainController main = new MainController(f, config, player, auto, songUpdated);

Expand Down Expand Up @@ -203,6 +196,23 @@ public static void play(Path f, BMSPlayerMode auto, boolean forceExit, Config co
}
}

private static void verifyIllegalSongs() {
SongData[] foundIllegalSongs = getScoreDatabaseAccessor().getSongDatas(SongUtils.illegalsongs);
if (foundIllegalSongs.length > 0) {
String paths = Arrays.stream(foundIllegalSongs)
.limit(30)
.map(song -> Paths.get(song.getPath()).getParent().toString())
.distinct()
.collect(Collectors.joining("\n"));
JOptionPane.showMessageDialog(null,
"This Application detects " + foundIllegalSongs.length + " illegal BMS songs.\nRemove them, update song database and restart.\n\n" +
"Do not use this application to play copyrighted content.\n\n" + paths,
"Error",
JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}

public static Graphics.DisplayMode[] getAvailableDisplayMode() {
return LwjglApplicationConfiguration.getDisplayModes();
}
Expand Down Expand Up @@ -241,18 +251,6 @@ public static Path getBMSPath() {
return bmsPath;
}

public static void putIllegalSong(String hash) {
illegalSongs.add(hash);
}

public static String[] getIllegalSongs() {
return illegalSongs.toArray(new String[illegalSongs.size()]);
}

public static int getIllegalSongCount() {
return illegalSongs.size();
}

@Override
public void start(javafx.stage.Stage primaryStage) throws Exception {
Config config = Config.read();
Expand Down
30 changes: 13 additions & 17 deletions src/bms/player/beatoraja/select/BarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public BarRenderer(MusicSelector select) {

TableData[] unsortedtables = tdaccessor.readAll();
Array<TableData> sortedtables = new Array<TableData>(unsortedtables.length);

for(String url : select.main.getConfig().getTableURL()) {
for(int i = 0;i < unsortedtables.length;i++) {
final TableData td = unsortedtables[i];
Expand All @@ -137,7 +137,7 @@ public BarRenderer(MusicSelector select) {
}
}
}

for(TableData td : unsortedtables) {
if(td != null) {
sortedtables.add(td);
Expand Down Expand Up @@ -184,7 +184,7 @@ public BarRenderer(MusicSelector select) {
song.setUrl(chart.url);
song.setAppendurl(chart.appendurl);
if(chart.mode != null) {
song.setMode(chart.mode.id);
song.setMode(chart.mode.id);
}
songs[j] = song;
}
Expand All @@ -208,7 +208,7 @@ public BarRenderer(MusicSelector select) {
song.setUrl(chart.url);
song.setAppendurl(chart.appendurl);
if(chart.mode != null) {
song.setMode(chart.mode.id);
song.setMode(chart.mode.id);
}
songs[j] = song;
}
Expand All @@ -229,7 +229,7 @@ public BarRenderer(MusicSelector select) {
}
td.setCourse(course);
if(td.validate()) {
table.add(new TableBar(select, td, new TableDataAccessor.DifficultyTableAccessor(main.getConfig().getTablepath(), td.getUrl())));
table.add(new TableBar(select, td, new TableDataAccessor.DifficultyTableAccessor(main.getConfig().getTablepath(), td.getUrl())));
}
}
} else {
Expand Down Expand Up @@ -464,17 +464,15 @@ public boolean mousePressed(SkinBar baro, int button, int x, int y) {
}

private long time;

public void prepare(MusicSelectSkin skin, SkinBar baro, long time) {
this.time = time;
final long timeMillis = System.currentTimeMillis();
this.time = time;final long timeMillis = System.currentTimeMillis();
boolean applyMovement = duration != 0 && duration > timeMillis;
float angleLerp = 0;
if (applyMovement) {
angleLerp = angle < 0 ? ((float) (timeMillis - duration)) / angle
: ((float) (duration - timeMillis)) / angle;
}

for (int i = 0; i < barlength; i++) {
// calcurate song bar position
final BarArea ba = bararea[i];
Expand Down Expand Up @@ -579,11 +577,11 @@ public void render(SkinObjectRenderer sprite, MusicSelectSkin skin, SkinBar baro
for (char c : charset) {
chars[i++] = c;
}

for(int index = 0;index < SkinBar.BARTEXT_COUNT;index++) {
if(baro.getText(index) != null) {
baro.getText(index).prepareFont(String.valueOf(chars));
}
baro.getText(index).prepareFont(String.valueOf(chars));
}
}
}

Expand Down Expand Up @@ -635,7 +633,7 @@ public void render(SkinObjectRenderer sprite, MusicSelectSkin skin, SkinBar baro
final SkinText text = baro.getText(ba.text);
if(text != null) {
text.setText(ba.sd.getTitle());
text.draw(sprite, ba.x, ba.y);
text.draw(sprite, ba.x, ba.y);
}
}

Expand All @@ -652,7 +650,7 @@ public void render(SkinObjectRenderer sprite, MusicSelectSkin skin, SkinBar baro
if (TROPHY[j].equals(trophy.getName())) {
final SkinImage trophyImage = baro.getTrophy(j);
if(trophyImage != null) {
trophyImage.draw(sprite, ba.x, ba.y);
trophyImage.draw(sprite, ba.x, ba.y);
}
break;
}
Expand Down Expand Up @@ -862,9 +860,7 @@ public boolean updateBar(Bar bar) {
boolean showInvisibleCharts = false;
boolean isSortable = true;

if (MainLoader.getIllegalSongCount() > 0) {
l.addAll(SongBar.toSongBarArray(select.getSongDatabase().getSongDatas(MainLoader.getIllegalSongs())));
} else if (bar == null) {
if (bar == null) {
if (dir.size > 0) {
prevbar = dir.first();
}
Expand Down