Skip to content

Commit

Permalink
Fix: Removed scuffed code for getting network id
Browse files Browse the repository at this point in the history
  • Loading branch information
zzz-mimimi committed Jan 2, 2025
1 parent 07b9c8d commit e5e0434
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/client/Latite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,18 +1202,12 @@ void Latite::writeServerIP() {
lastServer = server;
}

void* Latite::networkIdentifier = nullptr;
void* Latite::netEventCallback = nullptr;

void Latite::setNetwork(void* netId, void* netEv) {
networkIdentifier = netId;
void Latite::setNetEv(void* netEv) {
netEventCallback = netEv;
}

void* Latite::getNetId() {
return networkIdentifier;
}

void* Latite::getNetEv() {
return netEventCallback;
}
4 changes: 1 addition & 3 deletions src/client/Latite.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ class Latite final : public Listener {
void queueForClientThread(std::function<void()> callback);
void queueForDXRender(std::function<void(ID2D1DeviceContext* ctx)> callback);

static void* networkIdentifier;
static void* netEventCallback;

static void setNetwork(void* netId, void* netEv);
static void* getNetId();
static void setNetEv(void* netEv);
static void* getNetEv();

Latite() = default;
Expand Down
2 changes: 1 addition & 1 deletion src/client/hook/impl/PacketHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::shared_ptr<SDK::Packet> PacketHooks::MinecraftPackets_createPacket(SDK::Pac
}

void PacketHooks::PacketHandlerDispatcherInstance_handle(void* instance, void* networkIdentifier, void* netEventCallback, std::shared_ptr<SDK::Packet>& packet) {
Latite::setNetwork(networkIdentifier, netEventCallback);
Latite::setNetEv(netEventCallback);

auto& hook = PacketHookArray[(size_t)packet->getID()];

Expand Down
8 changes: 7 additions & 1 deletion src/client/script/objects/GameScriptingObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ JsValueRef GameScriptingObject::openModalForm(JsValueRef callee, bool isConstruc
packet->Id = packetId;
packet->Json = json;

memory::callVirtual<void>(packet->handler, 1, (void*)Latite::getNetId(), (void*)Latite::getNetEv(), (std::shared_ptr<MFRP>&)packet);
SDK::RakNetConnector* raknetConnector = SDK::RakNetConnector::get();
void* networkIdentifier = raknetConnector->getNetworkIdentifier();

// TODO: Replace this with proper retrieving for netevent
void* networkEventCallback = Latite::getNetEv();

memory::callVirtual<void>(packet->handler, 1, networkIdentifier, networkEventCallback, (std::shared_ptr<MFRP>&)packet);

return Chakra::GetUndefined();
}
Expand Down
5 changes: 5 additions & 0 deletions src/sdk/common/network/RakNetConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ namespace SDK {
}
return util::directAccess<RakPeer*>(this, 0x230);
}

void* getNetworkIdentifier() {
return memory::callVirtual<void*>(this, 0xE);
}

};
}

0 comments on commit e5e0434

Please sign in to comment.