Compare commits

..

No commits in common. "7a5bc41ce89191bb2d4c105a881e946d28ebb232" and "07a7ee97b761873474ec728ffb624f4dd91a1f0d" have entirely different histories.

3 changed files with 5 additions and 12 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reskit" name = "reskit"
version = "0.0.3" version = "0.0.2"
authors = ["ne0ndrag0n <ne0ndrag0n@users.noreply.github.com>"] authors = ["ne0ndrag0n <ne0ndrag0n@users.noreply.github.com>"]
edition = "2018" edition = "2018"

View File

@ -1,7 +1,7 @@
use std::{error::Error, fs::File, io::Read, convert::TryInto, collections::HashMap}; use std::{error::Error, fs::File, io::Read, convert::TryInto, collections::HashMap};
use flate2::read::ZlibDecoder; use flate2::read::ZlibDecoder;
use linked_hash_set::LinkedHashSet; use linked_hash_set::LinkedHashSet;
use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, print_info, sanitize_string, print_warning}, soundtrack::types::{SampleFormat, PsgEnvelope, Note, Sample, PsgSettings, PatternRow, Effect, DcsgChannelMode, NoiseType, Instrument, InstrumentType, Fm2612Operator, Fm2612Settings, Channel, CombinedAssets}}; use crate::reskit::{utility::{get_string, get_u8, skip, get_u32, get_i8, get_i32, get_u16, get_i16, print_info, sanitize_string}, soundtrack::types::{SampleFormat, PsgEnvelope, Note, Sample, PsgSettings, PatternRow, Effect, DcsgChannelMode, NoiseType, Instrument, InstrumentType, Fm2612Operator, Fm2612Settings, Channel, CombinedAssets}};
const DMF_MAGIC_NUMBER: &'static str = ".DelekDefleMask."; const DMF_MAGIC_NUMBER: &'static str = ".DelekDefleMask.";
const DMF_SUPPORTED_VERSION: u8 = 27; const DMF_SUPPORTED_VERSION: u8 = 27;
@ -669,10 +669,7 @@ impl DmfModule {
let bitrate = match get_u8( bytes.by_ref() )? { let bitrate = match get_u8( bytes.by_ref() )? {
8 => SampleFormat::Bits8, 8 => SampleFormat::Bits8,
16 => SampleFormat::Bits16, 16 => SampleFormat::Bits16,
invalid => { invalid => return Err( format!( "invalid file: invalid bitrate {}", invalid ) )?
print_warning( &format!( "sample with invalid bitrate: {}", invalid ) );
SampleFormat::Invalid
}
}; };
@ -688,10 +685,7 @@ impl DmfModule {
sample.data.push( get_i16( bytes.by_ref() )? ); sample.data.push( get_i16( bytes.by_ref() )? );
} }
// Don't push no-names or invalid bitrates samples.push( sample );
if sample.name != "" && !matches!( sample.bitrate, SampleFormat::Invalid ) {
samples.push( sample );
}
} }
Ok( Ok(

View File

@ -63,8 +63,7 @@ pub struct CombinedAssets {
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]
pub enum SampleFormat { pub enum SampleFormat {
Bits8, Bits8,
Bits16, Bits16
Invalid
} }
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]