From 7066062136dae87cf48ea9c1816e692691f77bbb Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 25 Mar 2026 15:19:03 -0700 Subject: [PATCH] refactor: extract updateNetworking() from GameHandler::update() Move socket update, packet processing, Warden async drain, RX silence detection, disconnect handling, and Warden gate logging into a separate updateNetworking() method. Reduces update() from ~704 to ~591 lines. --- include/game/game_handler.hpp | 1 + src/game/game_handler.cpp | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 9cee5301..c6cc8536 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -2314,6 +2314,7 @@ public: * @param deltaTime Time since last update in seconds */ void update(float deltaTime); + void updateNetworking(float deltaTime); /** * Reset DBC-backed caches so they reload from new expansion data. diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 4807cea9..74e313d9 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -844,19 +844,7 @@ bool GameHandler::isConnected() const { return socket && socket->isConnected(); } -void GameHandler::update(float deltaTime) { - // Fire deferred char-create callback (outside ImGui render) - if (pendingCharCreateResult_) { - pendingCharCreateResult_ = false; - if (charCreateCallback_) { - charCreateCallback_(pendingCharCreateSuccess_, pendingCharCreateMsg_); - } - } - - if (!socket) { - return; - } - +void GameHandler::updateNetworking(float deltaTime) { // Reset per-tick monster-move budget tracking (Classic/Turtle flood protection). monsterMovePacketsThisTick_ = 0; monsterMovePacketsDroppedThisTick_ = 0; @@ -938,6 +926,23 @@ void GameHandler::update(float deltaTime) { wardenGateNextStatusLog_ += 30.0f; } } +} + +void GameHandler::update(float deltaTime) { + // Fire deferred char-create callback (outside ImGui render) + if (pendingCharCreateResult_) { + pendingCharCreateResult_ = false; + if (charCreateCallback_) { + charCreateCallback_(pendingCharCreateSuccess_, pendingCharCreateMsg_); + } + } + + if (!socket) { + return; + } + + updateNetworking(deltaTime); + if (!socket) return; // disconnect() may have been called // Validate target still exists if (targetGuid != 0 && !entityManager.hasEntity(targetGuid)) {