Skip to content

Commit

Permalink
fix: fix client chunk load
Browse files Browse the repository at this point in the history
  • Loading branch information
KobeBryant114514 committed May 25, 2024
1 parent 24bf980 commit daccb05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool Entry::load() {
);
return false;
}
freecameraHook(true);
FreeCamera::freecameraHook(true);
return true;
}

Expand All @@ -49,7 +49,7 @@ bool Entry::disable() {
bool Entry::unload() {
mConfig.reset();
mI18n.reset();
freecameraHook(false);
FreeCamera::freecameraHook(false);
getInstance().reset();
return true;
}
Expand Down
25 changes: 4 additions & 21 deletions src/FreeCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,6 @@ void DisableFreeCamera(Player* pl) {
//}
}

LL_TYPE_INSTANCE_HOOK(
SubChunkRequestEvent,
ll::memory::HookPriority::Normal,
ServerNetworkHandler,
"?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVSubChunkRequestPacket@@@Z",
void,
NetworkIdentifier const& id,
SubChunkRequestPacket const& pkt
) {
if (FreeCamList.count(id.mGuid.g)) {
return;
} else {
return origin(id, pkt);
}
}

LL_TYPE_INSTANCE_HOOK(
ServerPlayerMoveHandleEvent,
ll::memory::HookPriority::Normal,
Expand All @@ -105,7 +89,7 @@ LL_TYPE_INSTANCE_HOOK(
NetworkIdentifier const& id,
PlayerAuthInputPacket const& pkt
) {
if (FreeCamList.count(id.mGuid.g)) {
if (FreeCamList.contains(id.mGuid.g)) {
return;
} else {
return origin(id, pkt);
Expand All @@ -121,7 +105,7 @@ LL_TYPE_INSTANCE_HOOK(
::GameType gamemode
) {
origin(gamemode);
if (FreeCamList.count(getNetworkIdentifier().mGuid.g)) {
if (FreeCamList.contains(getNetworkIdentifier().mGuid.g)) {
FreeCamera::DisableFreeCamera(this);
}
}
Expand All @@ -138,7 +122,7 @@ LL_TYPE_INSTANCE_HOOK(
auto res = origin(a1, a2);
if (this->isType(ActorType::Player) && res != 0) {
auto pl = (Player*)this;
if ((pl->isSurvival() || pl->isAdventure()) && FreeCamList.count(pl->getNetworkIdentifier().mGuid.g)) {
if ((pl->isSurvival() || pl->isAdventure()) && FreeCamList.contains(pl->getNetworkIdentifier().mGuid.g)) {
FreeCamera::DisableFreeCamera(pl);
}
}
Expand All @@ -153,7 +137,7 @@ LL_TYPE_INSTANCE_HOOK(
void,
class ActorDamageSource const& a1
) {
if (FreeCamList.count(getNetworkIdentifier().mGuid.g)) {
if (FreeCamList.contains(getNetworkIdentifier().mGuid.g)) {
FreeCamera::DisableFreeCamera(this);
}
return origin(a1);
Expand All @@ -172,7 +156,6 @@ LL_TYPE_INSTANCE_HOOK(

struct Impl {
ll::memory::HookRegistrar<
SubChunkRequestEvent,
ServerPlayerMoveHandleEvent,
PlayerGamemodeChangeEvent,
PlayerHurtEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ extern ll::Logger logger;
extern std::unordered_set<uint64> FreeCamList;

extern void RegisterCommand();
extern void freecameraHook(bool enable);

extern std::string tr(std::string const& key, std::vector<std::string> const& data = {});

namespace FreeCamera {
extern void DisableFreeCamera(Player* pl);
extern void EnableFreeCamera(Player* pl);
extern void freecameraHook(bool enable);
} // namespace FreeCamera

0 comments on commit daccb05

Please sign in to comment.