From 5566b0d912e0143884c1a016e0cd51b0c7fba81b Mon Sep 17 00:00:00 2001 From: sruon Date: Tue, 5 May 2026 02:55:43 -0600 Subject: [PATCH] Stamp Scheduler on MapSession at creation --- src/map/ipc_client.cpp | 4 ++-- src/map/map_networking.cpp | 2 +- src/map/map_session_container.cpp | 8 ++++++++ src/map/map_session_container.h | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/map/ipc_client.cpp b/src/map/ipc_client.cpp index 777418eb37e..d793251001e 100644 --- a/src/map/ipc_client.cpp +++ b/src/map/ipc_client.cpp @@ -201,8 +201,8 @@ void IPCClient::handleMessage_CharZone(const IPP& ipp, const ipc::CharZone& mess } else { - auto* PSession = networking_.sessions().createPendingSession(message.charId); // Create a pending session that the character might use ahead of time - PSession->scheduler = &networking_.scheduler(); + // Create a pending session that the character might use ahead of time + networking_.sessions().createPendingSession(message.charId); } } diff --git a/src/map/map_networking.cpp b/src/map/map_networking.cpp index fcbe3797982..1c0256091ea 100644 --- a/src/map/map_networking.cpp +++ b/src/map/map_networking.cpp @@ -51,6 +51,7 @@ MapNetworking::MapNetworking(Scheduler& scheduler, MapStatistics& mapStatistics, : scheduler_(scheduler) , mapStatistics_(mapStatistics) , mapIPP_(config.ipp) // TODO: Refactor to not use this, since we have config_ in here +, mapSessions_(scheduler) , config_(config) , PBuff{} , PBuffCopy{} @@ -266,7 +267,6 @@ int32 MapNetworking::recv_parse(uint8* buff, size_t* buffsize, MapSession* PSess // TODO: err msg? return -1; } - PSession->scheduler = &scheduler_; } else { diff --git a/src/map/map_session_container.cpp b/src/map/map_session_container.cpp index c503c6a2143..93dafe45fe4 100644 --- a/src/map/map_session_container.cpp +++ b/src/map/map_session_container.cpp @@ -26,6 +26,7 @@ #include "status_effect_container.h" #include "common/database.h" +#include "common/scheduler.h" #include "common/xi.h" #include "entities/charentity.h" @@ -33,6 +34,11 @@ #include "utils/charutils.h" #include "utils/petutils.h" +MapSessionContainer::MapSessionContainer(Scheduler& scheduler) +: scheduler_(scheduler) +{ +} + auto MapSessionContainer::createSession(IPP ipp) -> MapSession* { TracyZoneScoped; @@ -55,6 +61,7 @@ auto MapSessionContainer::createSession(IPP ipp) -> MapSession* auto map_session_data = std::make_unique(); + map_session_data->scheduler = &scheduler_; map_session_data->last_update = timer::now(); map_session_data->client_ipp = ipp; @@ -78,6 +85,7 @@ auto MapSessionContainer::createPendingSession(uint32 charId) -> MapSession* auto map_session_data = std::make_unique(); + map_session_data->scheduler = &scheduler_; map_session_data->last_update = timer::now(); // This may need adjustment if sessions feel like they take too long to free map_session_data->charID = charId; diff --git a/src/map/map_session_container.h b/src/map/map_session_container.h index acc05d116a2..eb2db37252f 100644 --- a/src/map/map_session_container.h +++ b/src/map/map_session_container.h @@ -32,6 +32,8 @@ struct MapSession; class MapSessionContainer { public: + explicit MapSessionContainer(Scheduler& scheduler); + auto createSession(IPP ipp) -> MapSession*; auto createPendingSession(uint32 charId) -> MapSession*; @@ -51,6 +53,7 @@ class MapSessionContainer void destroyPendingSession(uint32 charId); private: + Scheduler& scheduler_; std::map> sessions_; // Confirmed sessions mapped by IP std::map> pending_sessions_; // Pending sessions notified via IPC that a character may be arriving };