Skip to content

Commit

Permalink
fix: sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Oct 30, 2024
1 parent 8aa0eef commit b6ab7ab
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 182 deletions.
2 changes: 1 addition & 1 deletion src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void Combat::setPlayerCombatValues(formulaType_t newFormulaType, double newMina,
}

void Combat::postCombatEffects(const std::shared_ptr<Creature> &caster, const Position &origin, const Position &pos) const {
postCombatEffects(std::move(caster), origin, pos, params);
postCombatEffects(caster, origin, pos, params);
}

void Combat::setOrigin(CombatOrigin origin) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/condition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ConditionAttributes final : public ConditionGeneric {

bool setParam(ConditionParam_t param, int32_t value) final;

std::shared_ptr<Condition> clone() const final;
std::shared_ptr<Condition> clone() const override;

// serialization
void serialize(PropWriteStream &propWriteStream) final;
Expand Down
6 changes: 4 additions & 2 deletions src/creatures/combat/spells.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ class Spell : public BaseSpell {
*/
void setWheelOfDestinyBoost(WheelSpellBoost_t boost, WheelSpellGrade_t grade, int32_t value);

SpellType_t spellType = SPELL_UNDEFINED;

[[nodiscard]] const std::string &getWords() const;

void setWords(std::string_view newWord);
Expand All @@ -232,6 +230,7 @@ class Spell : public BaseSpell {

SpellGroup_t group = SPELLGROUP_NONE;
SpellGroup_t secondaryGroup = SPELLGROUP_NONE;
SpellType_t spellType = SPELL_UNDEFINED;

uint32_t cooldown = 1000;
uint32_t groupCooldown = 1000;
Expand All @@ -250,6 +249,7 @@ class Spell : public BaseSpell {
bool whellOfDestinyUpgraded = false;

private:

uint32_t mana = 0;
uint32_t manaPercent = 0;
uint32_t soul = 0;
Expand All @@ -265,6 +265,8 @@ class Spell : public BaseSpell {
std::string name;
std::string m_words;
std::string m_separator;

friend class SpellFunctions;
};

class InstantSpell final : public Script, public Spell {
Expand Down
6 changes: 6 additions & 0 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,12 @@ void Creature::setParent(std::weak_ptr<Cylinder> cylinder) {
}
}


// creature script events
bool Creature::hasEventRegistered(CreatureEventType_t event) const {
return (0 != (scriptEventsBitField & (static_cast<uint32_t>(1) << event)));
}

CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type) const {
CreatureEventList tmpEventList;

Expand Down
9 changes: 3 additions & 6 deletions src/creatures/creature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Item;
class Tile;
class Zone;
class MonsterType;
class Tile;
class Cylinder;
class ItemType;

Expand Down Expand Up @@ -551,9 +550,9 @@ class Creature : virtual public Thing, public SharedObject {
bool registerCreatureEvent(const std::string &name);
bool unregisterCreatureEvent(const std::string &name);

std::shared_ptr<Cylinder> getParent() override final;
std::shared_ptr<Cylinder> getParent() final;

void setParent(std::weak_ptr<Cylinder> cylinder) override final;
void setParent(std::weak_ptr<Cylinder> cylinder) final;

const Position &getPosition() override final {
return position;
Expand Down Expand Up @@ -801,9 +800,7 @@ class Creature : virtual public Thing, public SharedObject {
std::map<std::string, CreatureIcon> creatureIcons = {};

// creature script events
bool hasEventRegistered(CreatureEventType_t event) const {
return (0 != (scriptEventsBitField & (static_cast<uint32_t>(1) << event)));
}
bool hasEventRegistered(CreatureEventType_t event) const;

Check failure on line 803 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘CreatureEventType_t’ has not been declared

Check failure on line 803 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

‘CreatureEventType_t’ has not been declared

Check failure on line 803 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘CreatureEventType_t’ has not been declared

Check failure on line 803 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-release

‘CreatureEventType_t’ has not been declared
CreatureEventList getCreatureEvents(CreatureEventType_t type) const;

Check failure on line 804 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘CreatureEventType_t’ has not been declared

Check failure on line 804 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-debug

‘CreatureEventType_t’ has not been declared

Check failure on line 804 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘CreatureEventType_t’ has not been declared

Check failure on line 804 in src/creatures/creature.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-linux-release

‘CreatureEventType_t’ has not been declared

void updateMapCache();
Expand Down
12 changes: 7 additions & 5 deletions src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ const std::string &Monster::getNameDescription() const {
return nameDescription;
}

void Monster::setNameDescription(const std::string &nameDescription) {
this->nameDescription = nameDescription;
void Monster::setNameDescription(std::string_view newNameDescription) {
this->nameDescription = newNameDescription;
}

std::string Monster::getDescription(int32_t) {
Expand Down Expand Up @@ -2471,12 +2471,14 @@ std::vector<CreatureIcon> Monster::getIcons() const {
if (!creatureIcons.empty()) {
return creatureIcons;
}

using enum CreatureIconModifications_t;
if (challengeMeleeDuration > 0 && mType->info.targetDistance > targetDistance) {
return { CreatureIcon(CreatureIconModifications_t::TurnedMelee) };
return { CreatureIcon(TurnedMelee) };
} else if (varBuffs[BUFF_DAMAGERECEIVED] > 100) {
return { CreatureIcon(CreatureIconModifications_t::HigherDamageReceived) };
return { CreatureIcon(HigherDamageReceived) };
} else if (varBuffs[BUFF_DAMAGEDEALT] < 100) {
return { CreatureIcon(CreatureIconModifications_t::LowerDamageDealt) };
return { CreatureIcon(LowerDamageDealt) };
}
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/monsters/monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Monster final : public Creature {
// Real monster name, set on monster creation "createMonsterType(typeName)"
const std::string &getTypeName() const override;
const std::string &getNameDescription() const override;
void setNameDescription(const std::string &nameDescription);
void setNameDescription(std::string_view nameDescription);
;

Check warning on line 50 in src/creatures/monsters/monster.hpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

extra ‘;’ [-Wpedantic]
std::string getDescription(int32_t) override;

Expand Down
2 changes: 1 addition & 1 deletion src/creatures/players/grouping/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ void Party::reloadPrices() const {
}

std::shared_ptr<PartyAnalyzer> Party::getPlayerPartyAnalyzerStruct(uint32_t playerId) const {
if (auto it = std::find_if(membersData.begin(), membersData.end(), [playerId](const std::shared_ptr<PartyAnalyzer> &preyIt) {
if (auto it = std::ranges::find_if(membersData, [playerId](const std::shared_ptr<PartyAnalyzer> &preyIt) {
return preyIt->id == playerId;
});
it != membersData.end()) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/players/imbuements/imbuements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,6 @@ const std::vector<std::pair<uint16_t, uint16_t>> &Imbuement::getItems() const {
return items;
}

uint16_t Imbuement::getIconID() {
uint16_t Imbuement::getIconID() const {
return icon + (baseid - 1);
}
10 changes: 6 additions & 4 deletions src/creatures/players/imbuements/imbuements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Imbuement {

const std::vector<std::pair<uint16_t, uint16_t>> &getItems() const;

uint16_t getIconID();
uint16_t getIconID() const;

uint16_t icon = 1;
int32_t stats[maxSkillOrStatId + 1] = {};
Expand All @@ -113,9 +113,11 @@ class Imbuement {
friend class Item;

private:
bool premium = false;
uint32_t storage = 0;
uint16_t id, baseid, category = 0;
bool premium {};
uint32_t storage {};
uint16_t id {};
uint16_t baseid {};
uint16_t category {};
std::string name;
std::string description;
std::string subgroup;
Expand Down
12 changes: 6 additions & 6 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6273,7 +6273,7 @@ uint32_t Player::getAttackSpeed() const {
attackSpeed = MAX_ATTACK_SPEED;
}

return static_cast<uint32_t>(attackSpeed);
return attackSpeed;
} else {
return vocation->getAttackSpeed();
}
Expand Down Expand Up @@ -7381,7 +7381,7 @@ bool Player::hasAsyncOngoingTask(uint64_t flags) const {
}

void Player::resetAsyncOngoingTask(uint64_t flags) {
asyncOngoingTasks &= ~(flags);
asyncOngoingTasks &= ~flags;
}

void Player::sendEnterWorld() const {
Expand Down Expand Up @@ -8170,8 +8170,8 @@ const std::unique_ptr<PreySlot> &Player::getPreyWithMonster(uint16_t raceId) con
return PreySlotNull;
}

if (auto it = std::ranges::find_if(preys, [raceId](const std::unique_ptr<PreySlot> &it) {
return it->selectedRaceId == raceId;
if (auto it = std::ranges::find_if(preys, [raceId](const std::unique_ptr<PreySlot> &preyPtr) {
return preyPtr->selectedRaceId == raceId;
});
it != preys.end()) {
return *it;
Expand Down Expand Up @@ -8667,7 +8667,7 @@ std::pair<std::vector<std::shared_ptr<Item>>, uint16_t> Player::getLockerItemsAn
return std::make_pair(lockerItems, totalCount);
}

bool Player::saySpell(SpeakClasses type, const std::string &text, bool ghostMode, const Spectators* spectatorsPtr, const Position* pos) {
bool Player::saySpell(SpeakClasses type, const std::string &text, bool isGhostMode, const Spectators* spectatorsPtr, const Position* pos) {
if (text.empty()) {
g_logger().debug("{} - Spell text is empty for player {}", __FUNCTION__, getName());
return false;
Expand Down Expand Up @@ -8700,7 +8700,7 @@ bool Player::saySpell(SpeakClasses type, const std::string &text, bool ghostMode
if (g_configManager().getBoolean(EMOTE_SPELLS)) {
valueEmote = tmpPlayer->getStorageValue(STORAGEVALUE_EMOTE);
}
if (!ghostMode || tmpPlayer->canSeeCreature(static_self_cast<Player>())) {
if (!isGhostMode || tmpPlayer->canSeeCreature(static_self_cast<Player>())) {
if (valueEmote == 1) {
tmpPlayer->sendCreatureSay(static_self_cast<Player>(), TALKTYPE_MONSTER_SAY, text, pos);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum PreySlot_t : uint8_t;
enum SpeakClasses : uint8_t;
enum ChannelEvent_t : uint8_t;
enum SquareColor_t : uint8_t;
enum ZoneType_t;

using GuildWarVector = std::vector<uint32_t>;
using StashContainerList = std::vector<std::pair<std::shared_ptr<Item>, uint32_t>>;
Expand Down
Loading

0 comments on commit b6ab7ab

Please sign in to comment.