From 37cf9610415246141e3ee63d786ee587c162d7a5 Mon Sep 17 00:00:00 2001 From: Beats Date: Sat, 7 Dec 2024 21:38:20 -0400 Subject: [PATCH] fix merge --- src/creatures/combat/spells.cpp | 2 +- src/creatures/creature.cpp | 97 +------------------- src/creatures/players/vocations/vocation.cpp | 4 - src/server/network/protocol/protocol.hpp | 1 + 4 files changed, 4 insertions(+), 100 deletions(-) diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index bb27f1cade4..3798ea34267 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -187,7 +187,7 @@ Spells &Spells::getInstance() { return inject(); } -std::shared_ptr Spells::getSpellByName(const std::string &name) { +std::shared_ptr Spells::getSpellByName(const std::string &name) const { std::shared_ptr spell = getRuneSpellByName(name); if (!spell) { spell = getInstantSpellByName(name); diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index db40200696f..5ba4a8f2f07 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -286,99 +286,6 @@ void Creature::stopEventWalk() { } } -void Creature::updateMapCache() { - if (!useCacheMap()) { - return; - } - - metrics::method_latency measure(__METHOD_NAME__); - std::shared_ptr newTile; - const Position &myPos = getPosition(); - Position pos(0, 0, myPos.z); - - for (int32_t y = -maxWalkCacheHeight; y <= maxWalkCacheHeight; ++y) { - for (int32_t x = -maxWalkCacheWidth; x <= maxWalkCacheWidth; ++x) { - pos.x = myPos.getX() + x; - pos.y = myPos.getY() + y; - newTile = g_game().map.getTile(pos); - updateTileCache(newTile, pos); - } - } -} - -void Creature::updateTileCache(const std::shared_ptr &newTile, int32_t dx, int32_t dy) { - metrics::method_latency measure(__METHOD_NAME__); - if (std::abs(dx) <= maxWalkCacheWidth && std::abs(dy) <= maxWalkCacheHeight) { - localMapCache[maxWalkCacheHeight + dy][maxWalkCacheWidth + dx] = newTile && newTile->queryAdd(0, getCreature(), 1, FLAG_PATHFINDING | FLAG_IGNOREFIELDDAMAGE) == RETURNVALUE_NOERROR; - } -} - -void Creature::updateTileCache(const std::shared_ptr &upTile, const Position &pos) { - const Position &myPos = getPosition(); - if (pos.z == myPos.z) { - int32_t dx = Position::getOffsetX(pos, myPos); - int32_t dy = Position::getOffsetY(pos, myPos); - updateTileCache(upTile, dx, dy); - } -} - -int32_t Creature::getWalkCache(const Position &pos) { - metrics::method_latency measure(__METHOD_NAME__); - if (!useCacheMap()) { - return 2; - } - - const Position &myPos = getPosition(); - if (myPos.z != pos.z) { - return 0; - } - - if (pos == myPos) { - return 1; - } - - const int32_t dx = Position::getOffsetX(pos, myPos); - if (std::abs(dx) <= maxWalkCacheWidth) { - const int32_t dy = Position::getOffsetY(pos, myPos); - if (std::abs(dy) <= maxWalkCacheHeight) { - return localMapCache[maxWalkCacheHeight + dy][maxWalkCacheWidth + dx]; - } - } - - // out of range - return 2; -} - -void Creature::onAddTileItem(const std::shared_ptr &tileItem, const Position &pos) { - if (isMapLoaded && pos.z == getPosition().z) { - updateTileCache(tileItem, pos); - } -} - -void Creature::onUpdateTileItem(const std::shared_ptr &updateTile, const Position &pos, const std::shared_ptr &, const ItemType &oldType, const std::shared_ptr &, const ItemType &newType) { - if (!isMapLoaded) { - return; - } - - if (oldType.blockSolid || oldType.blockPathFind || newType.blockPathFind || newType.blockSolid) { - if (pos.z == getPosition().z) { - updateTileCache(updateTile, pos); - } - } -} - -void Creature::onRemoveTileItem(const std::shared_ptr &updateTile, const Position &pos, const ItemType &iType, const std::shared_ptr &) { - if (!isMapLoaded) { - return; - } - - if (iType.blockSolid || iType.blockPathFind || iType.isGroundTile()) { - if (pos.z == getPosition().z) { - updateTileCache(updateTile, pos); - } - } -} - void Creature::onCreatureAppear(const std::shared_ptr &creature, bool isLogin) { metrics::method_latency measure(__METRICS_METHOD_NAME__); if (creature.get() == this) { @@ -1304,7 +1211,7 @@ bool Creature::addCombatCondition(const std::shared_ptr &condition, b } void Creature::removeCondition(ConditionType_t type) { - metrics::method_latency measure(__METHOD_NAME__); + metrics::method_latency measure(__METRICS_METHOD_NAME__); auto it = conditions.begin(); const auto end = conditions.end(); while (it != end) { @@ -1404,7 +1311,7 @@ std::vector> Creature::getConditionsByType(ConditionT } void Creature::executeConditions(uint32_t interval) { - metrics::method_latency measure(__METHOD_NAME__); + metrics::method_latency measure(__METRICS_METHOD_NAME__); auto it = conditions.begin(); const auto end = conditions.end(); while (it != end) { diff --git a/src/creatures/players/vocations/vocation.cpp b/src/creatures/players/vocations/vocation.cpp index 26cea474a4b..47a97002fcd 100644 --- a/src/creatures/players/vocations/vocation.cpp +++ b/src/creatures/players/vocations/vocation.cpp @@ -27,10 +27,6 @@ bool Vocations::reload() { return loadFromXml(); } -Vocations &Vocations::getInstance() { - return inject(); -} - bool Vocations::loadFromXml() { pugi::xml_document doc; auto folder = g_configManager().getString(CORE_DIRECTORY) + "/XML/vocations.xml"; diff --git a/src/server/network/protocol/protocol.hpp b/src/server/network/protocol/protocol.hpp index de25da6dabb..172c9afba32 100644 --- a/src/server/network/protocol/protocol.hpp +++ b/src/server/network/protocol/protocol.hpp @@ -94,6 +94,7 @@ class Protocol : public std::enable_shared_from_this { OutputMessage_ptr outputBuffer; const ConnectionWeak_ptr connectionPtr; + std::array key = {}; uint32_t serverSequenceNumber = 0; uint32_t clientSequenceNumber = 0; std::underlying_type_t checksumMethod = CHECKSUM_METHOD_NONE;