Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -143,9 +140,6 @@ local function loadMapInundate()
end
creaturePosition:sendMagicEffect(CONST_ME_TELEPORT)
end
if player then
player:sendCreatureAppear()
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/server/network/connection/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -205,7 +206,12 @@ void Connection::parseHeader(const std::error_code &error) {
}

uint32_t timePassed = std::max<uint32_t>(1, (time(nullptr) - timeConnected) + 1);
if ((++packetsSent / timePassed) > static_cast<uint32_t>(g_configManager().getNumber(MAX_PACKETS_PER_SECOND))) {
uint32_t maxPps = static_cast<uint32_t>(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;
Expand Down
Loading