diff --git a/core/shared/core/note.h b/core/shared/core/note.h index 9f48b61..19bf997 100644 --- a/core/shared/core/note.h +++ b/core/shared/core/note.h @@ -23,6 +23,29 @@ public: return _perfect_offset; } + bool operator<(const Note& note) const + { + return (_perfect_offset < note._perfect_offset); + } + + bool operator==(const Note& note) const + { + return (_perfect_offset == note._perfect_offset); + } + + bool operator>(const Note& note) const + { + return (_perfect_offset > note._perfect_offset); + } + protected: microsec _perfect_offset; }; + +struct NotePtrCompt +{ + bool operator()(const Note* lhs, const Note* rhs) const + { + return lhs->offset() < rhs->offset(); + } +}; diff --git a/core/shared/core/timeline.h b/core/shared/core/timeline.h index ef65960..eec87d1 100644 --- a/core/shared/core/timeline.h +++ b/core/shared/core/timeline.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -12,12 +12,13 @@ class Timeline { public: explicit Timeline() : + _visibility_offset(0), _current_offset(0) {} - typedef typename std::vector::const_iterator Iterator; + typedef typename std::set::const_iterator Iterator; - void setNotes(const std::vector& notes, const microsec& visibility) + void setNotes(const std::set& notes, const microsec& visibility) { _visibility_offset = visibility; _timeline = std::move(notes); @@ -30,6 +31,18 @@ public: fetchVisibleNotes(); } + void insertNote(TNote* note) + { + _timeline.insert(_top_note, note); + update(_current_offset); + } + + void insertNotes(const std::set& notes) + { + _timeline.insert(notes.begin(), notes.end()); + update(_current_offset); + } + inline void clear() { for (auto& note : _timeline) @@ -116,8 +129,7 @@ public: } private: - std::vector _input_intervals; - std::vector _timeline; + std::set _timeline; microsec _visibility_offset; microsec _current_offset; diff --git a/modes/classicmode/game/classicarrownote.cpp b/modes/classicmode/game/classicarrownote.cpp index c1a6f85..ad43eb2 100644 --- a/modes/classicmode/game/classicarrownote.cpp +++ b/modes/classicmode/game/classicarrownote.cpp @@ -94,8 +94,10 @@ void ClassicArrowNote::update(const microsec& music_offset) break; case State::FLYING: - if (_evaluator.isActive(music_offset)) + if (_evaluator.isActive(music_offset)) { _state = State::ACTIVE; + + } break; case State::DYING: diff --git a/modes/classicmode/game/classicmapcreator.cpp b/modes/classicmode/game/classicmapcreator.cpp index c916ffc..65d1c3e 100644 --- a/modes/classicmode/game/classicmapcreator.cpp +++ b/modes/classicmode/game/classicmapcreator.cpp @@ -17,14 +17,14 @@ Beatmap ClassicMapCreator::createBeatmap(const std::string& filepath) const microsec starting_beat_offset = 362162; int amount_of_beats = 209; microsec interval = 1412162; - microsec tempo_interval = interval / 2; + microsec tempo_interval = interval / 4; microsec note_input_offset = 412162 / 2; //microsec note_input_offset_fast = 412162 / 6; microsec bpm_iterator = starting_beat_offset; microsec bpm_end = starting_beat_offset + (interval * amount_of_beats); std::vector input_intervals = {note_input_offset / 3, note_input_offset / 3 * 2, note_input_offset}; - std::vector notes; + std::set notes; input_intervals.shrink_to_fit(); bpm_iterator += tempo_interval; @@ -60,7 +60,7 @@ Beatmap ClassicMapCreator::createBeatmap(const std::string& filepath) const init.elements = {element}; - notes.emplace_back(new ClassicArrowNote(std::move(init))); + notes.insert(new ClassicArrowNote(std::move(init))); bpm_iterator += tempo_interval; x += 70; @@ -69,6 +69,6 @@ Beatmap ClassicMapCreator::createBeatmap(const std::string& filepath) const x = 90.; } - return {std::move(notes), note_input_offset * 12}; + return {std::move(notes), note_input_offset * 8}; } diff --git a/modes/classicmode/game/classicmapcreator.h b/modes/classicmode/game/classicmapcreator.h index 8a92ce8..d96f591 100644 --- a/modes/classicmode/game/classicmapcreator.h +++ b/modes/classicmode/game/classicmapcreator.h @@ -1,7 +1,7 @@ #ifndef CLASSICMAPCREATOR_H #define CLASSICMAPCREATOR_H -#include +#include #include "tools/mathutils.h" #include "core/note.h" @@ -10,7 +10,7 @@ struct Beatmap { - std::vector notes; + std::set notes; microsec visibility_offset; };