This commit is contained in:
altalk23 2024-04-12 22:56:10 +03:00
commit 2db4834fff
2 changed files with 25 additions and 12 deletions

View file

@ -24,20 +24,19 @@ namespace {
// Without these, the game will very likely crash when the mod tries to free memory allocated by the game (or another non-debug mod).
static inline void* relallocthrow(size_t size) {
// void* p;
// while ((p = HeapAlloc(GetProcessHeap(), 0, size)) == 0) {
// if (_callnewh(size) == 0) {
// static const std::bad_alloc exc;
// throw exc;
// }
// }
void* p;
while ((p = HeapAlloc(GetProcessHeap(), 0, size)) == 0) {
if (_callnewh(size) == 0) {
static const std::bad_alloc exc;
throw exc;
}
}
return geode::stl::operatorNew(size);
return p;
}
static inline void relfree(void* block) {
// HeapFree(GetProcessHeap(), 0, block);
geode::stl::operatorDelete(block);
HeapFree(GetProcessHeap(), 0, block);
}
void* operator new(size_t size) {

View file

@ -146,13 +146,27 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
LoaderImpl::get()->updateResources(true);
this->continueLoadAssets();
}
int getLoadedMods() {
auto allMods = Loader::get()->getAllMods();
return std::count_if(allMods.begin(), allMods.end(), [&](auto& item) {
return item->isEnabled();
});
}
int getEnabledMods() {
auto allMods = Loader::get()->getAllMods();
return std::count_if(allMods.begin(), allMods.end(), [&](auto& item) {
return item->shouldLoad();
});
}
int getCurrentStep() {
return m_fields->m_geodeLoadStep + m_loadStep + 1 + LoaderImpl::get()->m_refreshedModCount;
return m_fields->m_geodeLoadStep + m_loadStep + getLoadedMods();
}
int getTotalStep() {
return 18 + m_fields->m_totalMods;
return 3 + 14 + getEnabledMods();
}
void updateLoadingBar() {