Skip to content

Commit

Permalink
Code format - (Clang-format)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and murilo09 committed Oct 27, 2024
1 parent fef5579 commit f16662f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8256,7 +8256,7 @@ BidErrorMessage Player::canBidHouse(uint32_t houseId) {
}

if (house->isGuildhall()) {
if (getGuildRank() && getGuildRank()->level != 3) {
if (getGuildRank() && getGuildRank()->level != 3) {
return BidErrorMessage::Guildhall;
}

Expand All @@ -8266,4 +8266,4 @@ BidErrorMessage Player::canBidHouse(uint32_t houseId) {
}

return BidErrorMessage::NoError;
}
}
2 changes: 1 addition & 1 deletion src/enums/player_cyclopedia.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ enum class BidErrorMessage : uint8_t {
NotEnoughMoney = 17,
NotEnoughGuildMoney = 21,
Internal = 24,
};
};
14 changes: 7 additions & 7 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10242,7 +10242,7 @@ bool Game::removeFiendishMonster(uint32_t id, bool create /* = true*/) {

void Game::updateForgeableMonsters() {
if (auto influencedLimit = g_configManager().getNumber(FORGE_INFLUENCED_CREATURES_LIMIT, __FUNCTION__);
forgeableMonsters.size() < influencedLimit * 2) {
forgeableMonsters.size() < influencedLimit * 2) {
forgeableMonsters.clear();
for (const auto &[monsterId, monster] : monsters) {
auto monsterTile = monster->getTile();
Expand Down Expand Up @@ -10748,10 +10748,10 @@ void Game::playerCyclopediaHousesByTown(uint32_t playerId, const std::string tow

HouseMap houses;
if (!townName.empty()) {
const auto& housesList = g_game().map.houses.getHouses();
for (const auto& it : housesList) {
const auto& house = it.second;
const auto& town = g_game().map.towns.getTown(house->getTownId());
const auto &housesList = g_game().map.houses.getHouses();
for (const auto &it : housesList) {
const auto &house = it.second;
const auto &town = g_game().map.towns.getTown(house->getTownId());
if (!town) {
return;
}
Expand Down Expand Up @@ -10802,7 +10802,7 @@ void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_
ret = BidErrorMessage::NotEnoughMoney;
auto retSuccess = BidSuccessMessage::BidSuccess;

if(house->getBidderName().empty()) {
if (house->getBidderName().empty()) {
if (!processBankAuction(player, house, bidValue)) {
player->sendHouseAuctionMessage(houseId, HouseAuctionType::Bid, enumToValue(ret));
return;
Expand Down Expand Up @@ -10835,7 +10835,7 @@ void Game::playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_
house->setBidder(player->getGUID());
}

const auto& town = g_game().map.towns.getTown(house->getTownId());
const auto &town = g_game().map.towns.getTown(house->getTownId());
if (!town) {
return;
}
Expand Down
17 changes: 1 addition & 16 deletions src/io/iomapserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,7 @@ bool IOMapSerialize::SaveHouseInfoGuard() {
houseUpdate.upsert({ "owner", "paid", "warnings", "name", "town_id", "rent", "size", "beds", "bidder", "bidder_name", "highest_bid", "internal_bid", "bid_end_date", "state" });

for (const auto &[key, house] : g_game().map.houses.getHouses()) {
std::string values = fmt::format("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}",
house->getId(),
house->getOwner(),
house->getPaidUntil(),
house->getPayRentWarnings(),
db.escapeString(house->getName()),
house->getTownId(), house->getRent(),
house->getSize(),
house->getBedCount(),
house->getBidder(),
db.escapeString(house->getBidderName()),
house->getHighestBid(),
house->getInternalBid(),
house->getBidEndDate(),
house->getState()
);
std::string values = fmt::format("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}", house->getId(), house->getOwner(), house->getPaidUntil(), house->getPayRentWarnings(), db.escapeString(house->getName()), house->getTownId(), house->getRent(), house->getSize(), house->getBedCount(), house->getBidder(), db.escapeString(house->getBidderName()), house->getHighestBid(), house->getInternalBid(), house->getBidEndDate(), house->getState());

if (!houseUpdate.addRow(values)) {
return false;
Expand Down
24 changes: 12 additions & 12 deletions src/map/house/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,11 @@ 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(
std::chrono::duration_cast<std::chrono::milliseconds>(currentTimeMs)
);
auto currentTimeMs = std::chrono::system_clock::now().time_since_epoch();

std::chrono::system_clock::time_point now = std::chrono::system_clock::time_point(
std::chrono::duration_cast<std::chrono::milliseconds>(currentTimeMs)
);

// Truncate to whole days since epoch
days daysSinceEpoch = std::chrono::duration_cast<days>(now.time_since_epoch());
Expand Down Expand Up @@ -784,13 +784,13 @@ std::shared_ptr<House> 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) {
++count;
}
}
return count;
uint16_t count = 0;
for (const auto &it : houseMap) {
if (it.second->getOwnerAccountId() == accountId) {
++count;

Check warning on line 790 in src/map/house/house.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

[cppcheck] src/map/house/house.cpp#L790

Consider using std::count_if algorithm instead of a raw loop.
Raw output
src/map/house/house.cpp:790:Consider using std::count_if algorithm instead of a raw loop.
}
}
return count;
}

bool Houses::loadHousesXML(const std::string &filename) {
Expand Down
12 changes: 6 additions & 6 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9261,7 +9261,7 @@ void ProtocolGame::sendTakeScreenshot(Screenshot_t screenshotType) {
writeToOutputBuffer(msg);
}

void ProtocolGame::parseCyclopediaHouseAuction(NetworkMessage& msg) {
void ProtocolGame::parseCyclopediaHouseAuction(NetworkMessage &msg) {
if (oldProtocol) {
return;
}
Expand Down Expand Up @@ -9295,9 +9295,9 @@ void ProtocolGame::sendCyclopediaHouseList(HouseMap houses) {
NetworkMessage msg;
msg.addByte(0xC7);
msg.add<uint16_t>(houses.size());
for (const auto& house : houses) {
for (const auto &house : houses) {
const auto clientId = house.first;
const auto& houseData = house.second;
const auto &houseData = house.second;

msg.add<uint32_t>(clientId);
msg.addByte(0x01); // 0x00 = Renovation; 0x01 = Available
Expand Down Expand Up @@ -9375,11 +9375,11 @@ void ProtocolGame::sendHousesInfo() {
msg.addByte(0x01);
msg.add<uint32_t>(houseClientId);

const auto& housesList = g_game().map.houses.getHouses();
const auto &housesList = g_game().map.houses.getHouses();
msg.add<uint16_t>(housesList.size());
for (const auto& it : housesList) {
for (const auto &it : housesList) {
msg.add<uint32_t>(it.second->getClientId());
}

writeToOutputBuffer(msg);
}
}
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolgame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class ProtocolGame final : public Protocol {
void sendCyclopediaCharacterTitles();

void sendHousesInfo();
void parseCyclopediaHouseAuction(NetworkMessage& msg);
void parseCyclopediaHouseAuction(NetworkMessage &msg);
void sendCyclopediaHouseList(HouseMap houses);
void sendHouseAuctionMessage(uint32_t houseId, HouseAuctionType type, uint8_t index, bool bidSuccess);

Expand Down

0 comments on commit f16662f

Please sign in to comment.