Skip to content

Commit

Permalink
Fixing some bugs here and there in the SNP/XNT parsers
Browse files Browse the repository at this point in the history
Basically, sorting the final chartlist and, if there isn't an audio file in the snp, just skip it.
  • Loading branch information
mrcdk committed Jan 31, 2012
1 parent cbf6fa1 commit af117e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions parsers/src/org/open2jam/parsers/SNPParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.logging.Level;
Expand Down Expand Up @@ -143,12 +144,14 @@ public static ChartList parseFile(File file)
chart.file_index = file_index;
chart.source = file;
}

try {
f.close();
} catch (IOException ex) {
Logger.global.log(Level.WARNING, "Error closing the file (lol?) {0}", ex);
}

Collections.sort(list);
return list;
}

Expand All @@ -157,7 +160,7 @@ public static ByteBuffer extract(SNPFileHeader fh, RandomAccessFile f) throws IO
ByteBuffer b =
f.getChannel().map(FileChannel.MapMode.READ_ONLY, fh.file_offset+FILE_HEADER, fh.size_packed);
b.order(ByteOrder.LITTLE_ENDIAN);

return Compressor.decompress(b);
}

Expand All @@ -177,8 +180,8 @@ public static HashMap<Integer, AudioData> getSamples(XNTChart chart)

if(!chart.file_index.containsKey(fname))
{
Logger.global.log(Level.WARNING, "I can't find the file {0} in the snp :/", fname);
return new HashMap<Integer, AudioData>(); //it will xplode if It's return null so... XD
Logger.global.log(Level.WARNING, "I can\'t find the file [{0}] in the snp :/", fname);
continue;
}
fh = chart.file_index.get(fname);
buffer = SNPParser.extract(fh, f);
Expand Down
2 changes: 1 addition & 1 deletion parsers/src/org/open2jam/parsers/XNTChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void setDuration(int duration) {
File image_file;
@Override
public BufferedImage getCover() {
return null;
return getNoImage();
}

@Override
Expand Down

0 comments on commit af117e1

Please sign in to comment.