From 427866fbaa8c04b3d0e968bb20cf22e4d10b30b9 Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Mon, 23 Oct 2023 17:53:56 -0300 Subject: [PATCH] improve --- src/creatures/combat/combat.cpp | 2 +- src/creatures/players/player.cpp | 8 ++++---- src/items/tile.hpp | 2 +- src/lua/creature/events.cpp | 2 +- src/map/house/house.cpp | 6 +----- src/map/house/house.hpp | 6 ++++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 75cec14c30f..9944969c083 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -1311,7 +1311,7 @@ std::vector>> Combat::pickChainTargets std::vector>> resultMap; std::vector> targets; - std::set visited; + phmap::flat_hash_set visited; if (initialTarget && initialTarget != caster) { targets.push_back(initialTarget); diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index daca39172b8..ec74a5d012a 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -5928,18 +5928,18 @@ uint16_t Player::getHelpers() const { helperSet.emplace(party->getLeader()); - return helperSet.size(); + return static_cast(helperSet.size()); } if (guild) { - return guild->getMemberCountOnline(); + return static_cast(guild->getMemberCountOnline()); } if (party) { - return party->getMemberCount() + party->getInvitationCount() + 1; + return static_cast(party->getMemberCount() + party->getInvitationCount() + 1); } - return 0; + return 0u; } void Player::sendClosePrivate(uint16_t channelId) { diff --git a/src/items/tile.hpp b/src/items/tile.hpp index 0240cd92e35..7acf77f0e62 100644 --- a/src/items/tile.hpp +++ b/src/items/tile.hpp @@ -175,7 +175,7 @@ class Tile : public Cylinder, public SharedObject { void addZone(std::shared_ptr zone); void clearZones(); - auto getZones() { + auto getZones() const { return zones; } diff --git a/src/lua/creature/events.cpp b/src/lua/creature/events.cpp index 9fc8e2c8d5e..055394214b1 100644 --- a/src/lua/creature/events.cpp +++ b/src/lua/creature/events.cpp @@ -37,7 +37,7 @@ bool Events::loadFromXml() { } const std::string &className = eventNode.attribute("class").as_string(); - auto res = classes.insert(className); + auto res = classes.emplace(className); if (res.second) { const std::string &lowercase = asLowerCaseString(className); const std::string &scriptName = lowercase + ".lua"; diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index ecccce375b7..41d38570634 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -369,10 +369,6 @@ bool House::getAccessList(uint32_t listId, std::string &list) const { return door->getAccessList(list); } -bool House::isInvited(std::shared_ptr player) { - return getHouseAccessLevel(player) != HOUSE_NOT_INVITED; -} - void House::addDoor(std::shared_ptr door) { doorList.push_back(door); door->setHouse(static_self_cast()); @@ -414,7 +410,7 @@ std::shared_ptr House::getDoorByPosition(const Position &pos) { return nullptr; } -bool House::canEditAccessList(uint32_t listId, std::shared_ptr player) { +bool House::canEditAccessList(uint32_t listId, const std::shared_ptr &player) const { switch (getHouseAccessLevel(player)) { case HOUSE_OWNER: return true; diff --git a/src/map/house/house.hpp b/src/map/house/house.hpp index 2fac8e5b11d..2e8427a57a0 100644 --- a/src/map/house/house.hpp +++ b/src/map/house/house.hpp @@ -104,14 +104,16 @@ class House : public SharedObject { void addTile(std::shared_ptr tile); void updateDoorDescription() const; - bool canEditAccessList(uint32_t listId, std::shared_ptr player); + bool canEditAccessList(uint32_t listId, const std::shared_ptr &player) const; // listId special = values: // GUEST_LIST = guest list // SUBOWNER_LIST = subowner list void setAccessList(uint32_t listId, const std::string &textlist); bool getAccessList(uint32_t listId, std::string &list) const; - bool isInvited(std::shared_ptr player); + bool isInvited(const std::shared_ptr &player) const { + return getHouseAccessLevel(player) != HOUSE_NOT_INVITED; + } AccessHouseLevel_t getHouseAccessLevel(std::shared_ptr player) const; bool kickPlayer(std::shared_ptr player, std::shared_ptr target);