From 737298d8461e1f8fabd71b587c647acd43b3fa4a Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Tue, 17 Oct 2023 18:35:14 -0300 Subject: [PATCH] fix smells --- src/creatures/creature.cpp | 2 +- src/creatures/creature.hpp | 6 +++--- src/game/game.cpp | 3 +-- src/map/house/house.cpp | 2 +- src/map/house/house.hpp | 2 +- src/server/network/protocol/protocolgame.cpp | 12 ++++++------ 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index d207172bf33..c75bcd5eb9e 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -1793,7 +1793,7 @@ void Creature::setIncreasePercent(CombatType_t combat, int32_t value) { } } -const std::vector> Creature::getZones() { +std::vector> Creature::getZones() { return Zone::getZones(getPosition()); } diff --git a/src/creatures/creature.hpp b/src/creatures/creature.hpp index 6241f9a0cb3..1acc0c820d0 100644 --- a/src/creatures/creature.hpp +++ b/src/creatures/creature.hpp @@ -263,7 +263,7 @@ class Creature : virtual public Thing, public SharedObject { return ZONE_NORMAL; } - const std::vector> getZones(); + std::vector> getZones(); // walk functions void startAutoWalk(const std::forward_list &listDir, bool ignoreConditions = false); @@ -331,7 +331,7 @@ class Creature : virtual public Thing, public SharedObject { return m_master.lock(); } - const auto &getSummons() { + const auto &getSummons() const { return m_summons; } @@ -459,7 +459,7 @@ class Creature : virtual public Thing, public SharedObject { return false; } - size_t getSummonCount() { + size_t getSummonCount() const { return m_summons.size(); } diff --git a/src/game/game.cpp b/src/game/game.cpp index e5d29ed8c02..7ac84acccd5 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7487,8 +7487,7 @@ void Game::updatePlayerHelpers(std::shared_ptr player) { return; } - uint16_t helpers = player->getHelpers(); - + const uint16_t helpers = player->getHelpers(); for (const auto &spectator : Spectators().find(player->getPosition(), true)) { spectator->getPlayer()->sendCreatureHelpers(player->getID(), helpers); } diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index 0e482927684..b7eec130216 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -588,7 +588,7 @@ void AccessList::addGuildRank(const std::string &name, const std::string &guildN } } -bool AccessList::isInList(std::shared_ptr player) { +bool AccessList::isInList(std::shared_ptr player) const { if (allowEveryone) { return true; } diff --git a/src/map/house/house.hpp b/src/map/house/house.hpp index 845693e303e..45ecd6a3583 100644 --- a/src/map/house/house.hpp +++ b/src/map/house/house.hpp @@ -25,7 +25,7 @@ class AccessList { void addGuild(const std::string &name); void addGuildRank(const std::string &name, const std::string &rankName); - bool isInList(std::shared_ptr player); + bool isInList(std::shared_ptr player) const; void getList(std::string &list) const; diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 71c5588e767..86a1005343b 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5822,7 +5822,7 @@ void ProtocolGame::sendPartyCreatureUpdate(std::shared_ptr target) { void ProtocolGame::sendPartyCreatureShield(std::shared_ptr target) { uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); return; } @@ -5840,7 +5840,7 @@ void ProtocolGame::sendPartyCreatureSkull(std::shared_ptr target) { } uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); return; } @@ -5854,7 +5854,7 @@ void ProtocolGame::sendPartyCreatureSkull(std::shared_ptr target) { void ProtocolGame::sendPartyCreatureHealth(std::shared_ptr target, uint8_t healthPercent) { uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); return; } @@ -5868,7 +5868,7 @@ void ProtocolGame::sendPartyCreatureHealth(std::shared_ptr target, uin void ProtocolGame::sendPartyPlayerMana(std::shared_ptr target, uint8_t manaPercent) { uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); } @@ -5886,7 +5886,7 @@ void ProtocolGame::sendPartyPlayerMana(std::shared_ptr target, uint8_t m void ProtocolGame::sendPartyCreatureShowStatus(std::shared_ptr target, bool showStatus) { uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); } @@ -5904,7 +5904,7 @@ void ProtocolGame::sendPartyCreatureShowStatus(std::shared_ptr target, void ProtocolGame::sendPartyPlayerVocation(std::shared_ptr target) { uint32_t cid = target->getID(); - if (knownCreatureSet.find(cid) == knownCreatureSet.end()) { + if (!knownCreatureSet.contains(cid)) { sendPartyCreatureUpdate(target); return; }