Files
WoW-Hybrid-gateway/patches/client-world-loading-timestamp.patch
2026-11-23 03:28:32 +02:00

65 lines
3.0 KiB
Diff

--- /dev/null
+++ b/native/verify_anchor.h
@@ -0,0 +1,42 @@
+// Include in the Backend translation unit which records GW_T_VERIFY_WORLD.
+#pragma once
+#ifdef _WIN32
+#include <windows.h>
+#include <stdio.h>
+#include <stdint.h>
+static inline void gw_loading_verify_anchor(void) {
+ DWORD saved = GetLastError();
+ static bool initialized = false;
+ static HANDLE file = INVALID_HANDLE_VALUE;
+ static unsigned rows = 0;
+ // The world-message pump invokes this at the first VERIFY_WORLD of each trip.
+ // Serialize multiple worlds even if separate transports have separate pumps.
+ static SRWLOCK lock = SRWLOCK_INIT;
+ if (!TryAcquireSRWLockExclusive(&lock)) { SetLastError(saved); return; }
+ FILETIME now;
+ GetSystemTimePreciseAsFileTime(&now);
+ if (!initialized) {
+ initialized = true;
+ wchar_t path[1024];
+ DWORD n = GetEnvironmentVariableW(L"GW_LOADING_ANCHOR_FILE",path,1024);
+ if (n && n < 1024) file = CreateFileW(path, GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ }
+ if (file != INVALID_HANDLE_VALUE && rows < 64) {
+ const uint64_t ft = (uint64_t(now.dwHighDateTime) << 32) | now.dwLowDateTime;
+ if (ft >= 116444736000000000ULL) {
+ char line[112]; DWORD written = 0;
+ int n = snprintf(line, sizeof(line), "{\"event\":\"verify_world\",\"epoch_us\":%llu}\n",
+ (unsigned long long)((ft - 116444736000000000ULL)/10));
+ if (n <= 0 || n >= int(sizeof(line)) || !WriteFile(file,line,n,&written,NULL) ||
+ written != (DWORD)n || ++rows == 64) {
+ CloseHandle(file); file = INVALID_HANDLE_VALUE;
+ }
+ }
+ }
+ ReleaseSRWLockExclusive(&lock);
+ SetLastError(saved);
+}
+#else
+static inline void gw_loading_verify_anchor(void) {}
+#endif
--- a/native/session.cpp
+++ b/native/session.cpp
@@ -1,3 +1,4 @@
+#include "verify_anchor.h"
#include "diagnostics_journal.hpp"
#include "gateway/login_timing.h"
#include "query_failure_numeric.hpp"
@@ -470,9 +471,9 @@
gw_timing_event(GW_T_ENUM_RECEIVED,(uint32_t)t->roster.size());
}
if((packet.opcode==0x236 || packet.opcode==0xa9 || packet.opcode==0x1f6) &&
- t->world && !t->world->logout_complete && t->authentication->accepted() && gw_timing_enabled()){
+ t->world && !t->world->logout_complete && t->authentication->accepted() && (packet.opcode==0x236 || gw_timing_enabled())){
if(packet.opcode==0x236){
- if(!t->timing_in_world)gw_timing_event(GW_T_VERIFY_WORLD,0);
+ if(!t->timing_in_world){gw_loading_verify_anchor();gw_timing_event(GW_T_VERIFY_WORLD,0);}
t->timing_in_world=true;
}else if((packet.opcode==0xa9||packet.opcode==0x1f6) && t->timing_in_world && t->timed_updates<100){
gw_timing_event(GW_T_OBJECT_UPDATE,++t->timed_updates);