Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/gwdevhub/GWToolboxpp into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Sep 22, 2024
2 parents 06e699b + 77806eb commit 6e453d7
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions GWToolboxdll/Windows/ObjectiveTimerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void ObjectiveTimerWindow::Initialize()

// NB: Server may not send packets in the order we want them
// e.g. InstanceLoadInfo comes in before ExamplePlugin which means the run start is whacked out
// keep track of the packets and only trigger relevent events when the needed packets are in.
// keep track of the packets and only trigger relevant events when the needed packets are in.
GW::StoC::RegisterPostPacketCallback<GW::Packet::StoC::InstanceLoadInfo>(
&InstanceLoadInfo_Entry,
[this](GW::HookStatus*, const GW::Packet::StoC::InstanceLoadInfo* packet) {
Expand Down Expand Up @@ -284,21 +284,23 @@ void ObjectiveTimerWindow::Initialize()
map_load_pending = true;
}, -5);
// packet hooks that trigger events:
GW::StoC::RegisterPacketCallback<GW::Packet::StoC::MessageServer>(&MessageServer_Entry,
[this](GW::HookStatus*, GW::Packet::StoC::MessageServer*) {
const GW::Array<wchar_t>* buff = &GW::GetGameContext()->world->message_buff;
if (!buff || !buff->valid() || !buff->size()) {
return; // Message buffer empty!?
}
const wchar_t* msg = buff->begin();
// NB: buff->size() includes null terminating char. All GW strings are null terminated, use wcslen instead
Event(EventType::ServerMessage, wcslen(msg), msg);
});
GW::StoC::RegisterPacketCallback<GW::Packet::StoC::DisplayDialogue>(&DisplayDialogue_Entry,
[this](GW::HookStatus*, const GW::Packet::StoC::DisplayDialogue* packet) {
// NB: All GW strings are null terminated, use wcslen to avoid having to check all 122 chars
Event(EventType::DisplayDialogue, wcslen(packet->message), packet->message);
});
GW::StoC::RegisterPacketCallback<GW::Packet::StoC::MessageServer>(
&MessageServer_Entry,
[this](GW::HookStatus*, GW::Packet::StoC::MessageServer*) {
const GW::Array<wchar_t>* buff = &GW::GetGameContext()->world->message_buff;
if (!buff || !buff->valid() || !buff->size()) {
return; // Message buffer empty!?
}
const wchar_t* msg = buff->begin();
// NB: buff->size() includes null terminating char. All GW strings are null terminated, use wcslen instead
Event(EventType::ServerMessage, wcslen(msg), msg);
});
GW::StoC::RegisterPacketCallback<GW::Packet::StoC::DisplayDialogue>(
&DisplayDialogue_Entry,
[this](GW::HookStatus*, const GW::Packet::StoC::DisplayDialogue* packet) {
// NB: All GW strings are null terminated, use wcslen to avoid having to check all 122 chars
Event(EventType::DisplayDialogue, wcslen(packet->message), packet->message);
});
GW::StoC::RegisterPacketCallback<GW::Packet::StoC::ManipulateMapObject>(
&ManipulateMapObject_Entry, [this](GW::HookStatus*, const GW::Packet::StoC::ManipulateMapObject* packet) {
if (GW::Map::GetInstanceType() == GW::Constants::InstanceType::Explorable) {
Expand Down

0 comments on commit 6e453d7

Please sign in to comment.