Skip to content

Commit

Permalink
calc params are now only loaded if a preference is on
Browse files Browse the repository at this point in the history
normal users dont have to care about this and we can bypass some logic here as a result
this also allows us to be really careless with the load params function which basically means im going to tell it to open files endless amounts of times and it wont be slow ok good luck
  • Loading branch information
poco0317 committed Jul 13, 2021
1 parent a25ec25 commit 817c913
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Etterna/MinaCalc/MinaCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ Calc::InitializeHands(const std::vector<NoteInfo>& NoteInfo,
thread_local TheGreatBazoinkazoinkInTheSky ulbu_that_which_consumes_all(
*this);
// if debug, force params to load
if (debugmode)
if (debugmode || loadparams)
ulbu_that_which_consumes_all.load_calc_params_from_disk(true);
ulbu_that_which_consumes_all();

Expand Down
4 changes: 4 additions & 0 deletions src/Etterna/MinaCalc/MinaCalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class Calc
// set to true for scores, false for cache
bool ssr = true;

// set to true to load params
// alternative to telling load_params to force load
bool loadparams = false;

private:
/* Splits up the chart by each hand and processes them individually to
* produce hand specific base difficulty values, which are then passed to
Expand Down
14 changes: 5 additions & 9 deletions src/Etterna/MinaCalc/Ulbu.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ struct TheGreatBazoinkazoinkInTheSky

explicit TheGreatBazoinkazoinkInTheSky(Calc& calc)
: _calc(calc)
{
#if NDEBUG
load_calc_params_from_disk();
#endif

{
// setup our data pointers
_last_mri = std::make_unique<metaRowInfo>();
_mri = std::make_unique<metaRowInfo>();
Expand Down Expand Up @@ -505,8 +501,8 @@ struct TheGreatBazoinkazoinkInTheSky
int iError;

// Hold calc params program-global persistent info
static RageFileBasic* pFile;
static XNode params;
thread_local RageFileBasic* pFile;
thread_local XNode params;
// Only ever try to load params once per thread unless forcing
thread_local bool paramsLoaded = false;

Expand All @@ -515,11 +511,10 @@ struct TheGreatBazoinkazoinkInTheSky
if (paramsLoaded && !bForce)
return;

// Load if missing or allow a force reload
// Load if missing
if (pFile == nullptr || bForce) {
delete pFile;
pFile = FILEMAN->Open(fn, RageFile::READ, iError);
paramsLoaded = true;
// Failed to load
if (pFile == nullptr)
return;
Expand All @@ -539,6 +534,7 @@ struct TheGreatBazoinkazoinkInTheSky
if (vers.empty() || stoi(vers) != GetCalcVersion()) {
return;
}
paramsLoaded = true;

load_params_for_mod(&params, _s._params, _s.name);
load_params_for_mod(&params, _js._params, _js.name);
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Singletons/PrefsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ PrefsManager::PrefsManager()
, m_bShowLogOutput("ShowLogOutput", TRUE_IF_DEBUG)
, m_bLogSkips("LogSkips", false)
, m_show_theme_errors("ShowThemeErrors", false)
, m_bAlwaysLoadCalcParams("AlwaysLoadCalcParams", false)

{
Init();
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Singletons/PrefsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class PrefsManager
Preference<bool> m_bShowLoadingWindow;
Preference<bool> m_bPseudoLocalize;
Preference<bool> m_show_theme_errors;
Preference<bool> m_bAlwaysLoadCalcParams;

// levels 0, 1, and 2 where higher numbers
// means more logging
Expand Down
2 changes: 2 additions & 0 deletions src/Etterna/Singletons/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld)
std::pair<vectorIt<HighScore*>, vectorIt<HighScore*>> workload,
ThreadData* data) {
const auto per_thread_calc = std::make_unique<Calc>();
per_thread_calc->loadparams = PREFSMAN->m_bAlwaysLoadCalcParams;

auto* pair =
static_cast<std::pair<int, LoadingWindow*>*>(data->data);
Expand Down Expand Up @@ -699,6 +700,7 @@ ScoreManager::RecalculateSSRs(const string& profileID)
std::pair<vectorIt<HighScore*>, vectorIt<HighScore*>> workload,
ThreadData* data) {
const auto per_thread_calc = std::make_unique<Calc>();
per_thread_calc->loadparams = PREFSMAN->m_bAlwaysLoadCalcParams;

auto scoreIndex = 0;
for (auto it = workload.first; it != workload.second; ++it) {
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Singletons/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ SongManager::SongManager()

// calc for debug/session scores
calc = std::make_unique<Calc>();
calc->loadparams = PREFSMAN->m_bAlwaysLoadCalcParams;
}

SongManager::~SongManager()
Expand Down

0 comments on commit 817c913

Please sign in to comment.