From 9cd4bca0600130714a8bca2fa965d1f931a37e5c Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Thu, 27 Sep 2018 21:39:25 +0300 Subject: [PATCH] Parsesong: Fix drumroll timing again --- public/src/js/parsesong.js | 27 +++++++++++++++------------ public/src/js/songselect.js | 10 +++++----- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/public/src/js/parsesong.js b/public/src/js/parsesong.js index 5f9ad12..668d064 100644 --- a/public/src/js/parsesong.js +++ b/public/src/js/parsesong.js @@ -1,6 +1,5 @@ class ParseSong{ constructor(fileContent){ - this.data = fileContent this.osu = { OFFSET: 0, MSPERBEAT: 1, @@ -35,8 +34,16 @@ class ParseSong{ EDGEHITSOUNDS: 3, EDGEADDITIONS: 4 } + this.data = [] + for(let line of fileContent){ + line = line.trim().replace(/\/\/.*/, "") + if(line !== ""){ + this.data.push(line) + } + } this.beatInfo = { beatInterval: 0, + lastBeatInterval: 0, bpm: 0 } this.generalInfo = this.parseGeneralInfo() @@ -53,7 +60,7 @@ class ParseSong{ end: 0 } while(indexes.start < this.data.length){ - if(this.data[indexes.start].match(type)){ + if(this.data[indexes.start] === "[" + type + "]"){ break } indexes.start++ @@ -61,7 +68,7 @@ class ParseSong{ indexes.start++ indexes.end = indexes.start while(indexes.end < this.data.length){ - if(this.data[indexes.end].match(/^\s*$/)){ + if(this.data[indexes.end].match(/^\[\w+\]$/)){ break } indexes.end++ @@ -122,8 +129,7 @@ class ParseSong{ start: start, sliderMultiplier: sliderMultiplier, measure: parseInt(values[this.osu.METER]), - gogoTime: parseInt(values[this.osu.KIAIMODE]), - beatLength: msOrPercent + gogoTime: parseInt(values[this.osu.KIAIMODE]) }) } return timingPoints @@ -235,13 +241,13 @@ class ParseSong{ var osuType = parseInt(values[this.osu.TYPE]) var hitSound = parseInt(values[this.osu.HITSOUND]) var beatLength = speed + var lastMultiplier = this.difficulty.lastMultiplier for(var j = 0; j < this.timingPoints.length; j++){ if(this.timingPoints[j].start > start){ break } speed = this.timingPoints[j].sliderMultiplier - beatLength = this.timingPoints[j].beatLength gogoTime = this.timingPoints[j].gogoTime } @@ -264,13 +270,10 @@ class ParseSong{ }else if(osuType & this.osu.SLIDER){ var extras = values.slice(this.osu.EXTRAS) - var distance = parseFloat(extras[this.osu.PIXELLENGTH]) - var speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1 - var speedAdjustedBeatLength = this.beatInfo.beatInterval / speedMultiplier - var taikoVelocity = 100 * this.difficulty.sliderMultiplier / speedAdjustedBeatLength - var taikoDuration = distance / taikoVelocity - var endTime = start + taikoDuration + var distance = parseFloat(extras[this.osu.PIXELLENGTH]) + var velocity = this.difficulty.sliderMultiplier * speed / 10 + var endTime = start + distance / velocity if(hitSound & this.osu.FINISH){ type = "daiDrumroll" diff --git a/public/src/js/songselect.js b/public/src/js/songselect.js index d2891b3..ce73015 100644 --- a/public/src/js/songselect.js +++ b/public/src/js/songselect.js @@ -83,19 +83,19 @@ class SongSelect{ this.songs.push({ id: song.id, title: song.title, - skin: this.songSkin[song.category || "default"], + skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default, stars: song.stars, category: song.category, preview: song.preview || 0 }) } this.songs.sort((a, b) => { - var sortA = this.songSkin[a.category || "default"].sort - var sortB = this.songSkin[b.category || "default"].sort - if(sortA === sortB){ + var catA = a.category in this.songSkin ? this.songSkin[a.category] : this.songSkin.default + var catB = b.category in this.songSkin ? this.songSkin[b.category] : this.songSkin.default + if(catA.sort === catB.sort){ return a.id > b.id ? 1 : -1 }else{ - return sortA > sortB ? 1 : -1 + return catA.sort > catB.sort ? 1 : -1 } }) this.songs.push({