Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh committed Dec 8, 2024
1 parent cd2d197 commit 37cf961
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Spells &Spells::getInstance() {
return inject<Spells>();
}

std::shared_ptr<Spell> Spells::getSpellByName(const std::string &name) {
std::shared_ptr<Spell> Spells::getSpellByName(const std::string &name) const {
std::shared_ptr<Spell> spell = getRuneSpellByName(name);
if (!spell) {
spell = getInstantSpellByName(name);
Expand Down
97 changes: 2 additions & 95 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,99 +286,6 @@ void Creature::stopEventWalk() {
}
}

void Creature::updateMapCache() {
if (!useCacheMap()) {
return;
}

metrics::method_latency measure(__METHOD_NAME__);
std::shared_ptr<Tile> 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<Tile> &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<Tile> &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<Tile> &tileItem, const Position &pos) {
if (isMapLoaded && pos.z == getPosition().z) {
updateTileCache(tileItem, pos);
}
}

void Creature::onUpdateTileItem(const std::shared_ptr<Tile> &updateTile, const Position &pos, const std::shared_ptr<Item> &, const ItemType &oldType, const std::shared_ptr<Item> &, 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<Tile> &updateTile, const Position &pos, const ItemType &iType, const std::shared_ptr<Item> &) {
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> &creature, bool isLogin) {
metrics::method_latency measure(__METRICS_METHOD_NAME__);
if (creature.get() == this) {
Expand Down Expand Up @@ -1304,7 +1211,7 @@ bool Creature::addCombatCondition(const std::shared_ptr<Condition> &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) {
Expand Down Expand Up @@ -1404,7 +1311,7 @@ std::vector<std::shared_ptr<Condition>> 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) {
Expand Down
4 changes: 0 additions & 4 deletions src/creatures/players/vocations/vocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ bool Vocations::reload() {
return loadFromXml();
}

Vocations &Vocations::getInstance() {
return inject<Vocations>();
}

bool Vocations::loadFromXml() {
pugi::xml_document doc;
auto folder = g_configManager().getString(CORE_DIRECTORY) + "/XML/vocations.xml";
Expand Down
1 change: 1 addition & 0 deletions src/server/network/protocol/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Protocol : public std::enable_shared_from_this<Protocol> {
OutputMessage_ptr outputBuffer;

const ConnectionWeak_ptr connectionPtr;
std::array<uint32_t, 4> key = {};
uint32_t serverSequenceNumber = 0;
uint32_t clientSequenceNumber = 0;
std::underlying_type_t<ChecksumMethods_t> checksumMethod = CHECKSUM_METHOD_NONE;
Expand Down

0 comments on commit 37cf961

Please sign in to comment.