From 0341c872441389dfa0386c1bd22cdd20351b714a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Thu, 13 Nov 2025 18:22:54 -0300 Subject: [PATCH 1/2] fix: Ebb and Flow player desconneciton This PR fixes player disconnection caused by exceeding the packet limit. --- .../soul_war/globalevent-ebb_and_flow_change_maps.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/data-global/scripts/quests/soul_war/globalevent-ebb_and_flow_change_maps.lua b/data-global/scripts/quests/soul_war/globalevent-ebb_and_flow_change_maps.lua index 69eb146b4..3d33c27b8 100644 --- a/data-global/scripts/quests/soul_war/globalevent-ebb_and_flow_change_maps.lua +++ b/data-global/scripts/quests/soul_war/globalevent-ebb_and_flow_change_maps.lua @@ -67,9 +67,6 @@ local function loadMapEmpty() creature:teleportTo(teleportPosition) logger.trace("Teleporting player to down.") end - if player then - player:sendCreatureAppear() - end end end end @@ -143,9 +140,6 @@ local function loadMapInundate() end creaturePosition:sendMagicEffect(CONST_ME_TELEPORT) end - if player then - player:sendCreatureAppear() - end end end end From caaa7b8ede5649fd4636c248a900c7661fd35aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Mon, 17 Nov 2025 11:38:18 -0300 Subject: [PATCH 2/2] fix: ebb and flow kick Adjusted the dynamic limit of received packets per connection during the map switching period. --- src/game/game.cpp | 1 + src/game/game.hpp | 6 ++++++ src/server/network/connection/connection.cpp | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 2733ccec4..337cb797e 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -780,6 +780,7 @@ void Game::loadCustomMaps(const std::filesystem::path &customMapPath) { } void Game::loadMap(const std::string &path, const Position &pos) { + lastMapLoadTime = OTSYS_TIME(); map.loadMap(path, false, false, false, false, false, pos); } diff --git a/src/game/game.hpp b/src/game/game.hpp index 357da8bc1..054c08143 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -134,6 +134,10 @@ class Game { void loadCustomMaps(const std::filesystem::path &customMapPath); void loadMap(const std::string &path, const Position &pos = Position()); + uint64_t getLastMapLoadTime() const { + return lastMapLoadTime; + } + void getMapDimensions(uint32_t &width, uint32_t &height) const { width = map.width; height = map.height; @@ -923,6 +927,8 @@ class Game { // (1440 total light of tibian day)/(3600 real seconds each tibian day) * 10 seconds event interval int32_t lightHourDelta = (LIGHT_DAY_LENGTH * (EVENT_LIGHTINTERVAL_MS / 1000)) / DAY_LENGTH_SECONDS; + uint64_t lastMapLoadTime = 0; + ServiceManager* serviceManager = nullptr; void updatePlayersRecord() const; diff --git a/src/server/network/connection/connection.cpp b/src/server/network/connection/connection.cpp index 6843d9934..f176e6973 100644 --- a/src/server/network/connection/connection.cpp +++ b/src/server/network/connection/connection.cpp @@ -21,6 +21,7 @@ #include "lib/di/container.hpp" #include "server/network/message/outputmessage.hpp" #include "server/network/protocol/protocol.hpp" +#include "game/game.hpp" #include "game/scheduling/dispatcher.hpp" #include "server/network/message/networkmessage.hpp" #include "server/server.hpp" @@ -205,7 +206,12 @@ void Connection::parseHeader(const std::error_code &error) { } uint32_t timePassed = std::max(1, (time(nullptr) - timeConnected) + 1); - if ((++packetsSent / timePassed) > static_cast(g_configManager().getNumber(MAX_PACKETS_PER_SECOND))) { + uint32_t maxPps = static_cast(g_configManager().getNumber(MAX_PACKETS_PER_SECOND)); + if ((OTSYS_TIME() - g_game().getLastMapLoadTime()) < 10000) { // next 10 seconds + maxPps *= 10; + } + + if ((++packetsSent / timePassed) > maxPps) { g_logger().warn("[Connection::parseHeader] - {} disconnected for exceeding packet per second limit.", convertIPToString(getIP())); close(); return;