Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.74.2 merge #1340

Merged
merged 7 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/Release_0-74-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Release Changelog


## [0.74.2] - 2024-12-27 - Hotfix

### Fixed
- Crashing due to heap corruption while starting a song - [2408479](../../../commit/240847925c39a76077a8f039aed8fecaea477548) [f07029b](../../../commit/f07029b808a572c44e5d1cf6bcc009e490da6087) [209b88a](../../../commit/209b88a273e192bbe217f80219188e6cf82ff16b)
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# PROJECT WIDE SETUP
project(Etterna
VERSION 0.74.1
VERSION 0.74.2
HOMEPAGE_URL https://github.com/etternagame/etterna/
LANGUAGES C CXX ASM)

Expand Down
Binary file modified Data/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Themes/_fallback/Graphics/Common splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 41 additions & 13 deletions src/Etterna/Models/Misc/TimingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,30 +1451,58 @@ TimingData::BuildAndGetEtar(int lastrow)
return ElapsedTimesAtAllRows;
}

ElapsedTimesAtAllRows.reserve(lastrow);
std::iota(ElapsedTimesAtAllRows.begin(), ElapsedTimesAtAllRows.end(), 0);
const auto maxIndex = lastrow + 1;

// there is 1 extra because this would
// mean that etar[lastrow] = the time at the last row
ElapsedTimesAtAllRows.resize(maxIndex);

// just dont parallelize at all if it probably wont help anyways
if (lastrow < 100000) {
for (auto r = 0; r <= lastrow; ++r) {
if (maxIndex < 50000) {
for (auto r = 0; r < maxIndex; ++r) {
ElapsedTimesAtAllRows[r] =
GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(r));
}
return ElapsedTimesAtAllRows;
}

// stupid optimization
auto exec = [this](vectorRange<float> workload, ThreadData* d) {
// so now the iterator also provides indices
for (auto it = workload.first; it != workload.second; it++) {
const auto index = std::lround(*it);
ElapsedTimesAtAllRows[index] =
GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(index));
const int THREADS =
PREFSMAN->ThreadsToUse <= 0 ? std::thread::hardware_concurrency()
: PREFSMAN->ThreadsToUse <
static_cast<int>(std::thread::hardware_concurrency())
? PREFSMAN->ThreadsToUse
: static_cast<int>(std::thread::hardware_concurrency());
// [start, end)
std::vector<std::pair<int, int>> threadRanges{};
auto rindex = 0;
auto rsize = ElapsedTimesAtAllRows.size() / THREADS;
for (auto i = 0; i < THREADS; i++) {
rindex = i * rsize;
if (i == THREADS) {
threadRanges.emplace_back(rindex, ElapsedTimesAtAllRows.size());
} else {
threadRanges.emplace_back(rindex, rindex + rsize);
}
}

auto exec = [this, &threadRanges](int threadIndex) {
auto& range = threadRanges[threadIndex];
// the exclusive upper bound
// means that the final index etar.size() is skipped
// (because if it wasnt, that is out of bounds)
for (auto i = range.first; i < range.second; i++) {
ElapsedTimesAtAllRows[i] =
GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(i));
}
};
parallelExecution<float>(ElapsedTimesAtAllRows, exec);
ElapsedTimesAtAllRows[lastrow] =
GetElapsedTimeFromBeatNoOffset(NoteRowToBeat(lastrow));
std::vector<std::thread> threadpool;
for (int i = 0; i < THREADS; i++) {
threadpool.emplace_back(std::thread(exec, i));
}
for (auto& thread : threadpool) {
thread.join();
}

return ElapsedTimesAtAllRows;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Singletons/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class GameState
bool m_bLoadingNextSong;
[[nodiscard]] auto GetLoadingCourseSongIndex() const -> int;

static auto GetEtternaVersion() -> std::string { return "0.74.1"; }
static auto GetEtternaVersion() -> std::string { return "0.74.2"; }

/* is this the best place for this? it's not exactly a pref, and we
* shouldn't be copying and pasting these values everywhere as needed j1-j4
Expand Down
Loading