From 1b58782c9c76cf819c4a24d17c12fc8ecd68d034 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sun, 12 Jan 2025 06:13:28 -0300 Subject: [PATCH] fix: gha warnings (#3244) --- src/game/game.cpp | 9 +++++---- src/map/spectators.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index de3d0babc0e..9e01760b975 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -9120,12 +9120,13 @@ void Game::playerCreateMarketOffer(uint32_t playerId, uint8_t type, uint16_t ite } uint64_t totalPrice = price * amount; - uint64_t totalFee = totalPrice * 0.02; - uint64_t maxFee = std::min(1000000, totalFee); - uint64_t fee = std::max(20, totalFee); + uint64_t totalFee = totalPrice * 0.02; // 2% fee + uint64_t maxFee = std::min(1000000, totalFee); // Max fee is 1kk + uint64_t fee = std::clamp(totalFee, uint64_t(20), maxFee); // Limit between 20 and maxFee if (type == MARKETACTION_SELL) { - if (fee > (player->getBankBalance() + player->getMoney())) { + uint64_t totalPriceWithFee = totalPrice + fee; + if (totalPriceWithFee > (player->getMoney() + player->getBankBalance())) { offerStatus << "Fee is greater than player money"; return; } diff --git a/src/map/spectators.cpp b/src/map/spectators.cpp index 6a3ca09c513..3dbdf28fc79 100644 --- a/src/map/spectators.cpp +++ b/src/map/spectators.cpp @@ -59,14 +59,14 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl for (const auto &creature : *list) { const auto &specPos = creature->getPosition(); if ((centerPos.x - specPos.x >= minRangeX - && centerPos.y - specPos.y >= minRangeY - && centerPos.x - specPos.x <= maxRangeX - && centerPos.y - specPos.y <= maxRangeY - && (multifloor || specPos.z == centerPos.z) - && ((onlyPlayers && creature->getPlayer()) - || (onlyMonsters && creature->getMonster()) - || (onlyNpcs && creature->getNpc())) - || (!onlyPlayers && !onlyMonsters && !onlyNpcs))) { + && centerPos.y - specPos.y >= minRangeY + && centerPos.x - specPos.x <= maxRangeX + && centerPos.y - specPos.y <= maxRangeY + && (multifloor || specPos.z == centerPos.z) + && ((onlyPlayers && creature->getPlayer()) + || (onlyMonsters && creature->getMonster()) + || (onlyNpcs && creature->getNpc()))) + || (!onlyPlayers && !onlyMonsters && !onlyNpcs)) { spectators.emplace_back(creature); } } @@ -257,7 +257,7 @@ Spectators Spectators::excludePlayerMaster() const { specs.creatures.reserve(creatures.size()); for (const auto &c : creatures) { - if ((c->getMonster() != nullptr && !c->getMaster() || !c->getMaster()->getPlayer())) { + if ((c->getMonster() != nullptr && !c->getMaster()) || (!c->getMaster() || !c->getMaster()->getPlayer())) { specs.insert(c); } }