diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index dedf6b9d119..b3fb4ed79d9 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -1584,7 +1584,7 @@ class Player final : public Creature, public Cylinder, public Bankable { } BidErrorMessage canBidHouse(uint32_t houseId); - void sendCyclopediaHouseList(HouseMap houses) { + void sendCyclopediaHouseList(const HouseMap &houses) { if (client) { client->sendCyclopediaHouseList(houses); } diff --git a/src/game/game.cpp b/src/game/game.cpp index 612aae6c297..f1e58285a20 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -10241,7 +10241,7 @@ bool Game::removeFiendishMonster(uint32_t id, bool create /* = true*/) { } void Game::updateForgeableMonsters() { - if (auto influencedLimit = g_configManager().getNumber(FORGE_INFLUENCED_CREATURES_LIMIT, __FUNCTION__); + if (auto influencedLimit = g_configManager().getNumber(FORGE_INFLUENCED_CREATURES_LIMIT); forgeableMonsters.size() < influencedLimit * 2) { forgeableMonsters.clear(); for (const auto &[monsterId, monster] : monsters) { @@ -10740,7 +10740,7 @@ const std::unordered_map &Game::getHirelingOutfits() { return m_hirelingOutfits; } -void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string townName) { +void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string &townName) { std::shared_ptr player = getPlayerByID(playerId); if (!player) { return; @@ -10756,7 +10756,7 @@ void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string tow return; } - const std::string houseTown = town->getName(); + const std::string &houseTown = town->getName(); if (houseTown == townName) { houses.emplace(house->getClientId(), house); } @@ -10781,7 +10781,7 @@ void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string tow } void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_t bidValue) { - if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) { + if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) { return; } @@ -10846,7 +10846,7 @@ void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_ } void Game::playerCyclopediaHouseLeave(uint32_t playerId, uint32_t houseId, uint32_t timestamp) { - if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) { + if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) { return; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 1b0b9b369d3..5258d0f1fc6 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -316,7 +316,7 @@ class Game { static std::string getSkillNameById(uint8_t &skill); // House Auction - void playerCyclopediaHousesByTown(uint32_t playerId, const std::string townName); + void playerCyclopediaHousesByTown(uint32_t playerId, const std::string &townName); void playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_t bidValue); void playerCyclopediaHouseLeave(uint32_t playerId, uint32_t houseId, uint32_t timestamp); bool processBankAuction(std::shared_ptr player, std::shared_ptr house, uint64_t bid, bool replace = false); diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index f9cfe5f995c..9a140ee9b65 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -105,7 +105,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase /* = true*/, std::shared } if (guid != 0) { - std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__)); + std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD)); time_t currentTime = time(nullptr); if (strRentPeriod == "yearly") { currentTime += 24 * 60 * 60 * 365; @@ -140,7 +140,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase /* = true*/, std::shared owner = guid; ownerName = name; ownerAccountId = result->getNumber("account_id"); - state = 2; + m_state = 2; } } @@ -155,14 +155,14 @@ void House::updateDoorDescription() const { ss << "It belongs to house '" << houseName << "'. Nobody owns this house."; } - if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) { + if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) { ss << " It is " << getSize() << " square meters."; const int32_t housePrice = getPrice(); if (housePrice != -1) { - if (g_configManager().getBoolean(HOUSE_PURSHASED_SHOW_PRICE, __FUNCTION__) || owner == 0) { + if (g_configManager().getBoolean(HOUSE_PURSHASED_SHOW_PRICE) || owner == 0) { ss << " It costs " << formatNumber(getPrice()) << " gold coins."; } - std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__)); + std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD)); if (strRentPeriod != "never") { ss << " The rent cost is " << formatNumber(getRent()) << " gold coins and it is billed " << strRentPeriod << "."; } @@ -484,7 +484,7 @@ void House::resetTransferItem() { void House::calculateBidEndDate(uint8_t daysToEnd) { auto currentTimeMs = std::chrono::system_clock::now().time_since_epoch(); - std::chrono::system_clock::time_point now = std::chrono::system_clock::time_point( + auto now = std::chrono::system_clock::time_point( std::chrono::duration_cast(currentTimeMs) ); @@ -492,11 +492,11 @@ void House::calculateBidEndDate(uint8_t daysToEnd) { days daysSinceEpoch = std::chrono::duration_cast(now.time_since_epoch()); // Get today's date at 00:00:00 UTC - std::chrono::system_clock::time_point todayMidnight = std::chrono::system_clock::time_point(daysSinceEpoch); + auto todayMidnight = std::chrono::system_clock::time_point(daysSinceEpoch); std::chrono::system_clock::time_point targetDay = todayMidnight + days(daysToEnd); - const auto serverSaveTime = g_configManager().getString(GLOBAL_SERVER_SAVE_TIME, __FUNCTION__); + const auto serverSaveTime = g_configManager().getString(GLOBAL_SERVER_SAVE_TIME); std::vector params = vectorAtoi(explodeString(serverSaveTime, ":")); int32_t hour = params.front(); @@ -513,9 +513,9 @@ void House::calculateBidEndDate(uint8_t daysToEnd) { std::time_t resultTime = std::chrono::system_clock::to_time_t(targetTime); std::tm* localTime = std::localtime(&resultTime); - uint32_t bidEndDate = static_cast(std::mktime(localTime)); + auto bidEndDate = static_cast(std::mktime(localTime)); - this->bidEndDate = bidEndDate; + this->m_bidEndDate = bidEndDate; } std::shared_ptr HouseTransferItem::createHouseTransferItem(std::shared_ptr house) { @@ -766,18 +766,18 @@ std::shared_ptr Houses::getHouseByPlayerId(uint32_t playerId) { std::vector> Houses::getAllHousesByPlayerId(uint32_t playerId) { std::vector> playerHouses; - for (const auto &it : houseMap) { - if (it.second->getOwner() == playerId) { - playerHouses.emplace_back(it.second); + for (const auto &[id, house] : houseMap) { + if (house->getOwner() == playerId) { + playerHouses.emplace_back(house); } } return playerHouses; } -std::shared_ptr Houses::getHouseByBidderName(std::string bidderName) { - for (const auto &it : houseMap) { - if (it.second->getBidderName() == bidderName) { - return it.second; +std::shared_ptr Houses::getHouseByBidderName(const std::string &bidderName) { + for (const auto &[id, house] : houseMap) { + if (house->getBidderName() == bidderName) { + return house; } } return nullptr; @@ -785,8 +785,8 @@ std::shared_ptr Houses::getHouseByBidderName(std::string bidderName) { uint16_t Houses::getHouseCountByAccount(uint32_t accountId) { uint16_t count = 0; - for (const auto &it : houseMap) { - if (it.second->getOwnerAccountId() == accountId) { + for (const auto &[id, house] : houseMap) { + if (house->getOwnerAccountId() == accountId) { ++count; } } diff --git a/src/map/house/house.hpp b/src/map/house/house.hpp index c763e5de595..8aefbf7002b 100644 --- a/src/map/house/house.hpp +++ b/src/map/house/house.hpp @@ -236,60 +236,60 @@ class House : public SharedObject { void setNewOwnership(); void setClientId(uint32_t newClientId) { - this->clientId = newClientId; + this->m_clientId = newClientId; } uint32_t getClientId() const { - return clientId; + return m_clientId; } void setBidder(int32_t bidder) { - this->bidder = bidder; + this->m_bidder = bidder; } int32_t getBidder() const { - return bidder; + return m_bidder; } - void setBidderName(std::string bidderName) { - this->bidderName = bidderName; + void setBidderName(const std::string &bidderName) { + this->m_bidderName = bidderName; } std::string getBidderName() const { - return bidderName; + return m_bidderName; } void setHighestBid(uint64_t bidValue) { - this->highestBid = bidValue; + this->m_highestBid = bidValue; } uint64_t getHighestBid() const { - return highestBid; + return m_highestBid; } void setInternalBid(uint64_t bidValue) { - this->internalBid = bidValue; + this->m_internalBid = bidValue; } uint64_t getInternalBid() const { - return internalBid; + return m_internalBid; } void setBidHolderLimit(uint64_t bidValue) { - this->bidHolderLimit = bidValue; + this->m_bidHolderLimit = bidValue; } uint64_t getBidHolderLimit() const { - return bidHolderLimit; + return m_bidHolderLimit; } void calculateBidEndDate(uint8_t daysToEnd); void setBidEndDate(uint32_t bidEndDate) { - this->bidEndDate = bidEndDate; + this->m_bidEndDate = bidEndDate; }; uint32_t getBidEndDate() const { - return bidEndDate; + return m_bidEndDate; } void setState(uint8_t state) { - this->state = state; + this->m_state = state; } uint8_t getState() const { - return state; + return m_state; } void setOwnerAccountId(uint32_t accountId) { @@ -341,14 +341,14 @@ class House : public SharedObject { Position posEntry = {}; // House Auction - uint32_t clientId; - int32_t bidder = 0; - std::string bidderName = ""; - uint64_t highestBid = 0; - uint64_t internalBid = 0; - uint64_t bidHolderLimit = 0; - uint32_t bidEndDate = 0; - uint8_t state = 0; + uint32_t m_clientId; + int32_t m_bidder = 0; + std::string m_bidderName = ""; + uint64_t m_highestBid = 0; + uint64_t m_internalBid = 0; + uint64_t m_bidHolderLimit = 0; + uint32_t m_bidEndDate = 0; + uint8_t m_state = 0; bool isLoaded = false; @@ -401,7 +401,7 @@ class Houses { std::shared_ptr getHouseByPlayerId(uint32_t playerId); std::vector> getAllHousesByPlayerId(uint32_t playerId); - std::shared_ptr getHouseByBidderName(std::string bidderName); + std::shared_ptr getHouseByBidderName(const std::string &bidderName); uint16_t getHouseCountByAccount(uint32_t accountId); bool loadHousesXML(const std::string &filename); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 2fa8a4b3a4b..2be8e4148cf 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -9295,10 +9295,7 @@ void ProtocolGame::sendCyclopediaHouseList(HouseMap houses) { NetworkMessage msg; msg.addByte(0xC7); msg.add(houses.size()); - for (const auto &house : houses) { - const auto clientId = house.first; - const auto &houseData = house.second; - + for (const auto &[clientId, houseData] : houses) { msg.add(clientId); msg.addByte(0x01); // 0x00 = Renovation; 0x01 = Available