From df7b3b5ba22bd6295f55c451dd8d4600c447e239 Mon Sep 17 00:00:00 2001 From: Drewol Date: Tue, 18 May 2021 18:20:49 +0200 Subject: [PATCH] Add support for KSH 'Standard BPM' --- Beatmap/include/Beatmap/Beatmap.hpp | 4 +++ Beatmap/src/BeatmapFromKSH.cpp | 4 +++ Main/src/Game.cpp | 38 +++++++++++++++++------------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Beatmap/include/Beatmap/Beatmap.hpp b/Beatmap/include/Beatmap/Beatmap.hpp index 5ab041243..c63286886 100644 --- a/Beatmap/include/Beatmap/Beatmap.hpp +++ b/Beatmap/include/Beatmap/Beatmap.hpp @@ -44,6 +44,10 @@ struct BeatmapSettings float slamVolume = 1.0f; float laserEffectMix = 1.0f; float musicVolume = 1.0f; + + // BPM Override for mmod calculation + float speedBpm = -1.0f; + EffectType laserEffectType = EffectType::PeakingFilter; }; diff --git a/Beatmap/src/BeatmapFromKSH.cpp b/Beatmap/src/BeatmapFromKSH.cpp index 8e58dca83..35b306ae2 100755 --- a/Beatmap/src/BeatmapFromKSH.cpp +++ b/Beatmap/src/BeatmapFromKSH.cpp @@ -547,6 +547,10 @@ bool Beatmap::m_ProcessKShootMap(BinaryStream &input, bool metadataOnly) { m_settings.musicVolume = (float)atoi(*s.second) / 100.0f; } + else if (s.first == "to") + { + m_settings.speedBpm = atof(*s.second); + } } // Temporary map for timing points diff --git a/Main/src/Game.cpp b/Main/src/Game.cpp index fdb1e48d9..3259d9abe 100755 --- a/Main/src/Game.cpp +++ b/Main/src/Game.cpp @@ -316,28 +316,36 @@ class Game_Impl : public Game MapTime largestMT = -1; double useBPM = -1; double lastBPM = -1; - for (TimingPoint* tp : timingPoints) + + if (mapSettings.speedBpm > 0.0f) + { + useBPM = mapSettings.speedBpm; + } + else { - double thisBPM = tp->GetBPM(); - if (!bpmDurations.count(lastBPM)) + for (TimingPoint* tp : timingPoints) { - bpmDurations[lastBPM] = 0; + double thisBPM = tp->GetBPM(); + if (!bpmDurations.count(lastBPM)) + { + bpmDurations[lastBPM] = 0; + } + MapTime timeSinceLastTP = tp->time - lastMT; + bpmDurations[lastBPM] += timeSinceLastTP; + if (bpmDurations[lastBPM] > largestMT) + { + useBPM = lastBPM; + largestMT = bpmDurations[lastBPM]; + } + lastMT = tp->time; + lastBPM = thisBPM; } - MapTime timeSinceLastTP = tp->time - lastMT; - bpmDurations[lastBPM] += timeSinceLastTP; + bpmDurations[lastBPM] += m_endTime - lastMT; + if (bpmDurations[lastBPM] > largestMT) { useBPM = lastBPM; - largestMT = bpmDurations[lastBPM]; } - lastMT = tp->time; - lastBPM = thisBPM; - } - bpmDurations[lastBPM] += m_endTime - lastMT; - - if (bpmDurations[lastBPM] > largestMT) - { - useBPM = lastBPM; } m_hispeed = m_modSpeed / useBPM;