Skip to content

Commit

Permalink
refactor: optimize MoreGlobal
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Aug 4, 2024
1 parent 4d8c560 commit 23199eb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/legacy/api/MoreGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "mc/world/level/storage/DBStorage.h"
#include "mc/world/level/storage/DBStorageConfig.h"

DBStorage* MoreGlobal::dbStorage;
DefaultDataLoadHelper* MoreGlobal::defaultDataLoadHelper;
namespace MoreGlobal {
DBStorage* dbStorage;
DefaultDataLoadHelper* defaultDataLoadHelper;

LL_TYPE_INSTANCE_HOOK(
DBStorageHook,
Expand All @@ -21,13 +22,14 @@ LL_TYPE_INSTANCE_HOOK(
return ori;
};

void MoreGlobal::onLoad() { DBStorageHook::hook(); }
void onLoad() { DBStorageHook::hook(); }

bool MoreGlobal::onEnable() {
bool onEnable() {
defaultDataLoadHelper =
static_cast<DefaultDataLoadHelper*>(ll::memory::resolveSymbol("??_7DefaultDataLoadHelper@@6B@"));
if (defaultDataLoadHelper && DBStorageHook::unhook()) {
if (defaultDataLoadHelper && dbStorage && DBStorageHook::unhook()) {
return true;
}
return false;
}
} // namespace MoreGlobal

0 comments on commit 23199eb

Please sign in to comment.