Skip to content

Commit

Permalink
fix: qodana linter and others
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Sep 14, 2024
1 parent cad47d8 commit fb734f5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 2 additions & 0 deletions qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: "1.0"
profile:
name: qodana.recommended

linter: "jetbrains/qodana-clang"

bootstrap: |
set -e
sudo apt-get update && sudo apt-get -y dist-upgrade
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7853,7 +7853,7 @@ bool Player::canBuyStoreOffer(const Offer* offer) {

case OfferTypes_t::ALLBLESSINGS: {
for (auto bless : magic_enum::enum_values<Blessings>()) {
auto blessingAmount = getBlessingCount(bless);
auto blessingAmount = getBlessingCount(enumToValue(bless));
if (blessingAmount >= STORE_BLESSING_MAX_AMOUNT) {
canBuy = false;
break;
Expand Down Expand Up @@ -7893,7 +7893,7 @@ bool Player::canBuyStoreOffer(const Offer* offer) {

case OfferTypes_t::HUNTINGSLOT: {
const auto &thirdSlot = getTaskHuntingSlotById(PreySlot_Three);
if (thirdSlot->state != PreyDataState_Locked) {
if (thirdSlot->state != PreyTaskDataState_Locked) {
canBuy = false;
}

Expand Down
27 changes: 13 additions & 14 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10257,7 +10257,7 @@ bool Game::addInfluencedMonster(std::shared_ptr<Monster> monster) {
return false;
}

bool Game::processHouseOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t charges /* = 0*/) {
bool Game::processHouseOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t charges /* = 0*/) {
std::shared_ptr<Item> decoKit = Item::CreateItem(ITEM_DECORATION_KIT, 1);
if (!decoKit) {
return false;
Expand Down Expand Up @@ -10307,7 +10307,7 @@ void Game::addPlayerUniqueLogin(std::shared_ptr<Player> player) {
m_uniqueLoginPlayerNames[lowercase_name] = player;
}

bool Game::processChargesOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t charges /* = 0*/, bool movable /* = false*/) {
bool Game::processChargesOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t charges /* = 0*/, bool movable /* = false*/) {
std::shared_ptr<Item> newItem = Item::CreateItem(itemId, 1);
if (!newItem) {
return false;
Expand Down Expand Up @@ -10346,7 +10346,7 @@ bool Game::processChargesOffer(std::shared_ptr<Player> player, uint32_t itemId,
return true;
}

bool Game::processStackableOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t amount /* = 1*/, bool movable /* = false*/) {
bool Game::processStackableOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t amount /* = 1*/, bool movable /* = false*/) {
std::shared_ptr<Item> newItem = Item::CreateItem(itemId, amount);
if (!newItem) {
return false;
Expand Down Expand Up @@ -10381,37 +10381,36 @@ bool Game::processStackableOffer(std::shared_ptr<Player> player, uint32_t itemId
return true;
}

bool Game::processNameChangeOffer(std::shared_ptr<Player> player, std::string &name) {
std::string newName = name;
trimString(newName);
bool Game::processNameChangeOffer(const std::shared_ptr<Player> &player, std::string name) {
trimString(name);

auto isValidName = validateName(newName);
auto isValidName = validateName(name);
if (isValidName != VALID) {
return false;
}

capitalizeWords(newName);
capitalizeWords(name);

if (g_monsters().getMonsterType(newName, true)) {
if (g_monsters().getMonsterType(name, true)) {
return false;
} else if (getNpcByName(newName)) {
} else if (getNpcByName(name)) {
return false;
}

DBResult_ptr result = g_database().storeQuery(fmt::format("SELECT `id` FROM `players` WHERE `name` = {}", g_database().escapeString(newName)));
DBResult_ptr result = g_database().storeQuery(fmt::format("SELECT `id` FROM `players` WHERE `name` = {}", g_database().escapeString(name)));
if (result) {
return false;
}

std::string query = fmt::format("UPDATE `players` SET `name` = {} WHERE `id` = {}", g_database().escapeString(newName), player->getGUID());
std::string query = fmt::format("UPDATE `players` SET `name` = {} WHERE `id` = {}", g_database().escapeString(name), player->getGUID());
if (!g_database().executeQuery(query)) {
return false;
}

return true;
}

bool Game::processTempleOffer(std::shared_ptr<Player> player) {
bool Game::processTempleOffer(const std::shared_ptr<Player> &player) {
if (player->isPzLocked() || player->hasCondition(CONDITION_INFIGHT)) {
return false;
}
Expand Down Expand Up @@ -10858,7 +10857,7 @@ void Game::playerBuyStoreOffer(uint32_t playerId, const Offer* offer, std::strin
case OfferTypes_t::HUNTINGSLOT: {
const auto &thirdSlot = player->getTaskHuntingSlotById(PreySlot_Three);

if (thirdSlot->state != PreyDataState_Locked) {
if (thirdSlot->state != PreyTaskDataState_Locked) {
break;
}

Expand Down
10 changes: 5 additions & 5 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ class Game {
void playerOpenStoreHistory(uint32_t playerId, uint32_t page);
void playerBuyStoreOffer(uint32_t playerId, const Offer* offer, std::string newName, uint8_t sexId);
// Process Offers
bool processChargesOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t charges = 0, bool movable = false);
bool processStackableOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t amount = 1, bool movable = false);
bool processHouseOffer(std::shared_ptr<Player> player, uint32_t itemId, uint16_t charges = 0);
bool processNameChangeOffer(std::shared_ptr<Player> player, std::string &name);
bool processTempleOffer(std::shared_ptr<Player> player);
bool processChargesOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t charges = 0, bool movable = false);
bool processStackableOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t amount = 1, bool movable = false);
bool processHouseOffer(const std::shared_ptr<Player> &player, uint32_t itemId, uint16_t charges = 0);
bool processNameChangeOffer(const std::shared_ptr<Player> &player, std::string name);
bool processTempleOffer(const std::shared_ptr<Player> &player);

void playerRewardChestCollect(uint32_t playerId, const Position &pos, uint16_t itemId, uint8_t stackPos, uint32_t maxMoveItems = 0);

Expand Down

0 comments on commit fb734f5

Please sign in to comment.