Skip to content

Commit 5801a39

Browse files
committed
sonar issues
1 parent f16662f commit 5801a39

File tree

6 files changed

+53
-56
lines changed

6 files changed

+53
-56
lines changed

src/creatures/players/player.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
15841584
}
15851585

15861586
BidErrorMessage canBidHouse(uint32_t houseId);
1587-
void sendCyclopediaHouseList(HouseMap houses) {
1587+
void sendCyclopediaHouseList(HouseMap &houses) {
15881588
if (client) {
15891589
client->sendCyclopediaHouseList(houses);
15901590
}

src/game/game.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10241,7 +10241,7 @@ bool Game::removeFiendishMonster(uint32_t id, bool create /* = true*/) {
1024110241
}
1024210242

1024310243
void Game::updateForgeableMonsters() {
10244-
if (auto influencedLimit = g_configManager().getNumber(FORGE_INFLUENCED_CREATURES_LIMIT, __FUNCTION__);
10244+
if (auto influencedLimit = g_configManager().getNumber(FORGE_INFLUENCED_CREATURES_LIMIT);
1024510245
forgeableMonsters.size() < influencedLimit * 2) {
1024610246
forgeableMonsters.clear();
1024710247
for (const auto &[monsterId, monster] : monsters) {
@@ -10740,7 +10740,7 @@ const std::unordered_map<uint16_t, std::string> &Game::getHirelingOutfits() {
1074010740
return m_hirelingOutfits;
1074110741
}
1074210742

10743-
void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string townName) {
10743+
void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string &townName) {
1074410744
std::shared_ptr<Player> player = getPlayerByID(playerId);
1074510745
if (!player) {
1074610746
return;
@@ -10756,7 +10756,7 @@ void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string tow
1075610756
return;
1075710757
}
1075810758

10759-
const std::string houseTown = town->getName();
10759+
const std::string &houseTown = town->getName();
1076010760
if (houseTown == townName) {
1076110761
houses.emplace(house->getClientId(), house);
1076210762
}
@@ -10781,7 +10781,7 @@ void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string tow
1078110781
}
1078210782

1078310783
void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_t bidValue) {
10784-
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) {
10784+
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) {
1078510785
return;
1078610786
}
1078710787

@@ -10846,7 +10846,7 @@ void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_
1084610846
}
1084710847

1084810848
void Game::playerCyclopediaHouseLeave(uint32_t playerId, uint32_t houseId, uint32_t timestamp) {
10849-
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) {
10849+
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) {
1085010850
return;
1085110851
}
1085210852

src/game/game.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Game {
316316
static std::string getSkillNameById(uint8_t &skill);
317317

318318
// House Auction
319-
void playerCyclopediaHousesByTown(uint32_t playerId, const std::string townName);
319+
void playerCyclopediaHousesByTown(uint32_t playerId, const std::string &townName);
320320
void playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_t bidValue);
321321
void playerCyclopediaHouseLeave(uint32_t playerId, uint32_t houseId, uint32_t timestamp);
322322
bool processBankAuction(std::shared_ptr<Player> player, std::shared_ptr<House> house, uint64_t bid, bool replace = false);

src/map/house/house.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase /* = true*/, std::shared
105105
}
106106

107107
if (guid != 0) {
108-
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__));
108+
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD));
109109
time_t currentTime = time(nullptr);
110110
if (strRentPeriod == "yearly") {
111111
currentTime += 24 * 60 * 60 * 365;
@@ -140,7 +140,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase /* = true*/, std::shared
140140
owner = guid;
141141
ownerName = name;
142142
ownerAccountId = result->getNumber<uint32_t>("account_id");
143-
state = 2;
143+
m_state = 2;
144144
}
145145
}
146146

@@ -155,14 +155,14 @@ void House::updateDoorDescription() const {
155155
ss << "It belongs to house '" << houseName << "'. Nobody owns this house.";
156156
}
157157

158-
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION, __FUNCTION__)) {
158+
if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) {
159159
ss << " It is " << getSize() << " square meters.";
160160
const int32_t housePrice = getPrice();
161161
if (housePrice != -1) {
162-
if (g_configManager().getBoolean(HOUSE_PURSHASED_SHOW_PRICE, __FUNCTION__) || owner == 0) {
162+
if (g_configManager().getBoolean(HOUSE_PURSHASED_SHOW_PRICE) || owner == 0) {
163163
ss << " It costs " << formatNumber(getPrice()) << " gold coins.";
164164
}
165-
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__));
165+
std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD));
166166
if (strRentPeriod != "never") {
167167
ss << " The rent cost is " << formatNumber(getRent()) << " gold coins and it is billed " << strRentPeriod << ".";
168168
}
@@ -484,19 +484,19 @@ void House::resetTransferItem() {
484484
void House::calculateBidEndDate(uint8_t daysToEnd) {
485485
auto currentTimeMs = std::chrono::system_clock::now().time_since_epoch();
486486

487-
std::chrono::system_clock::time_point now = std::chrono::system_clock::time_point(
487+
auto now = std::chrono::system_clock::time_point(
488488
std::chrono::duration_cast<std::chrono::milliseconds>(currentTimeMs)
489489
);
490490

491491
// Truncate to whole days since epoch
492492
days daysSinceEpoch = std::chrono::duration_cast<days>(now.time_since_epoch());
493493

494494
// Get today's date at 00:00:00 UTC
495-
std::chrono::system_clock::time_point todayMidnight = std::chrono::system_clock::time_point(daysSinceEpoch);
495+
auto todayMidnight = std::chrono::system_clock::time_point(daysSinceEpoch);
496496

497497
std::chrono::system_clock::time_point targetDay = todayMidnight + days(daysToEnd);
498498

499-
const auto serverSaveTime = g_configManager().getString(GLOBAL_SERVER_SAVE_TIME, __FUNCTION__);
499+
const auto serverSaveTime = g_configManager().getString(GLOBAL_SERVER_SAVE_TIME);
500500

501501
std::vector<int32_t> params = vectorAtoi(explodeString(serverSaveTime, ":"));
502502
int32_t hour = params.front();
@@ -513,9 +513,9 @@ void House::calculateBidEndDate(uint8_t daysToEnd) {
513513

514514
std::time_t resultTime = std::chrono::system_clock::to_time_t(targetTime);
515515
std::tm* localTime = std::localtime(&resultTime);
516-
uint32_t bidEndDate = static_cast<uint32_t>(std::mktime(localTime));
516+
auto bidEndDate = static_cast<uint32_t>(std::mktime(localTime));
517517

518-
this->bidEndDate = bidEndDate;
518+
this->m_bidEndDate = bidEndDate;
519519
}
520520

521521
std::shared_ptr<HouseTransferItem> HouseTransferItem::createHouseTransferItem(std::shared_ptr<House> house) {
@@ -766,27 +766,27 @@ std::shared_ptr<House> Houses::getHouseByPlayerId(uint32_t playerId) {
766766

767767
std::vector<std::shared_ptr<House>> Houses::getAllHousesByPlayerId(uint32_t playerId) {
768768
std::vector<std::shared_ptr<House>> playerHouses;
769-
for (const auto &it : houseMap) {
770-
if (it.second->getOwner() == playerId) {
771-
playerHouses.emplace_back(it.second);
769+
for (const auto &[id, house] : houseMap) {
770+
if (house->getOwner() == playerId) {
771+
playerHouses.emplace_back(house);
772772
}
773773
}
774774
return playerHouses;
775775
}
776776

777-
std::shared_ptr<House> Houses::getHouseByBidderName(std::string bidderName) {
778-
for (const auto &it : houseMap) {
779-
if (it.second->getBidderName() == bidderName) {
780-
return it.second;
777+
std::shared_ptr<House> Houses::getHouseByBidderName(const std::string &bidderName) {
778+
for (const auto &[id, house] : houseMap) {
779+
if (house->getBidderName() == bidderName) {
780+
return house;
781781
}
782782
}
783783
return nullptr;
784784
}
785785

786786
uint16_t Houses::getHouseCountByAccount(uint32_t accountId) {
787787
uint16_t count = 0;
788-
for (const auto &it : houseMap) {
789-
if (it.second->getOwnerAccountId() == accountId) {
788+
for (const auto &[id, house] : houseMap) {
789+
if (house->getOwnerAccountId() == accountId) {
790790
++count;
791791
}
792792
}

src/map/house/house.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -236,60 +236,60 @@ class House : public SharedObject {
236236
void setNewOwnership();
237237

238238
void setClientId(uint32_t newClientId) {
239-
this->clientId = newClientId;
239+
this->m_clientId = newClientId;
240240
}
241241
uint32_t getClientId() const {
242-
return clientId;
242+
return m_clientId;
243243
}
244244

245245
void setBidder(int32_t bidder) {
246-
this->bidder = bidder;
246+
this->m_bidder = bidder;
247247
}
248248
int32_t getBidder() const {
249-
return bidder;
249+
return m_bidder;
250250
}
251251

252-
void setBidderName(std::string bidderName) {
253-
this->bidderName = bidderName;
252+
void setBidderName(const std::string &bidderName) {
253+
this->m_bidderName = bidderName;
254254
}
255255
std::string getBidderName() const {
256-
return bidderName;
256+
return m_bidderName;
257257
}
258258

259259
void setHighestBid(uint64_t bidValue) {
260-
this->highestBid = bidValue;
260+
this->m_highestBid = bidValue;
261261
}
262262
uint64_t getHighestBid() const {
263-
return highestBid;
263+
return m_highestBid;
264264
}
265265

266266
void setInternalBid(uint64_t bidValue) {
267-
this->internalBid = bidValue;
267+
this->m_internalBid = bidValue;
268268
}
269269
uint64_t getInternalBid() const {
270-
return internalBid;
270+
return m_internalBid;
271271
}
272272

273273
void setBidHolderLimit(uint64_t bidValue) {
274-
this->bidHolderLimit = bidValue;
274+
this->m_bidHolderLimit = bidValue;
275275
}
276276
uint64_t getBidHolderLimit() const {
277-
return bidHolderLimit;
277+
return m_bidHolderLimit;
278278
}
279279

280280
void calculateBidEndDate(uint8_t daysToEnd);
281281
void setBidEndDate(uint32_t bidEndDate) {
282-
this->bidEndDate = bidEndDate;
282+
this->m_bidEndDate = bidEndDate;
283283
};
284284
uint32_t getBidEndDate() const {
285-
return bidEndDate;
285+
return m_bidEndDate;
286286
}
287287

288288
void setState(uint8_t state) {
289-
this->state = state;
289+
this->m_state = state;
290290
}
291291
uint8_t getState() const {
292-
return state;
292+
return m_state;
293293
}
294294

295295
void setOwnerAccountId(uint32_t accountId) {
@@ -341,14 +341,14 @@ class House : public SharedObject {
341341
Position posEntry = {};
342342

343343
// House Auction
344-
uint32_t clientId;
345-
int32_t bidder = 0;
346-
std::string bidderName = "";
347-
uint64_t highestBid = 0;
348-
uint64_t internalBid = 0;
349-
uint64_t bidHolderLimit = 0;
350-
uint32_t bidEndDate = 0;
351-
uint8_t state = 0;
344+
uint32_t m_clientId;
345+
int32_t m_bidder = 0;
346+
std::string m_bidderName = "";
347+
uint64_t m_highestBid = 0;
348+
uint64_t m_internalBid = 0;
349+
uint64_t m_bidHolderLimit = 0;
350+
uint32_t m_bidEndDate = 0;
351+
uint8_t m_state = 0;
352352

353353
bool isLoaded = false;
354354

@@ -401,7 +401,7 @@ class Houses {
401401

402402
std::shared_ptr<House> getHouseByPlayerId(uint32_t playerId);
403403
std::vector<std::shared_ptr<House>> getAllHousesByPlayerId(uint32_t playerId);
404-
std::shared_ptr<House> getHouseByBidderName(std::string bidderName);
404+
std::shared_ptr<House> getHouseByBidderName(const std::string &bidderName);
405405
uint16_t getHouseCountByAccount(uint32_t accountId);
406406

407407
bool loadHousesXML(const std::string &filename);

src/server/network/protocol/protocolgame.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9295,10 +9295,7 @@ void ProtocolGame::sendCyclopediaHouseList(HouseMap houses) {
92959295
NetworkMessage msg;
92969296
msg.addByte(0xC7);
92979297
msg.add<uint16_t>(houses.size());
9298-
for (const auto &house : houses) {
9299-
const auto clientId = house.first;
9300-
const auto &houseData = house.second;
9301-
9298+
for (const auto &[clientId, houseData] : houses) {
93029299
msg.add<uint32_t>(clientId);
93039300
msg.addByte(0x01); // 0x00 = Renovation; 0x01 = Available
93049301

0 commit comments

Comments
 (0)