Skip to content

Commit

Permalink
Merge pull request #883 from utilForever/fix-code
Browse files Browse the repository at this point in the history
Fix SonarCloud issues
  • Loading branch information
utilForever authored Apr 18, 2023
2 parents 175da47 + 9560500 commit e2c125b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
14 changes: 12 additions & 2 deletions Includes/Rosetta/Common/PriorityQueue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PriorityQueue
}
}

//! Deleted move constructor.
//! Move constructor.
PriorityQueue(PriorityQueue&& rhs) noexcept : m_count(rhs.m_count)
{
const Node* rhsNode = rhs.m_head;
Expand All @@ -84,14 +84,24 @@ class PriorityQueue
//! Copy assignment operator.
PriorityQueue& operator=(const PriorityQueue& rhs)
{
if (this == &rhs)
{
return *this;
}

PriorityQueue<T> temp(rhs);
std::swap(temp.m_head, m_head);
return *this;
}

//! Deleted move assignment operator.
//! Move assignment operator.
PriorityQueue& operator=(PriorityQueue&& rhs) noexcept
{
if (*this == rhs)
{
return *this;
}

PriorityQueue<T> temp(rhs);
std::swap(temp.m_head, m_head);
return *this;
Expand Down
6 changes: 3 additions & 3 deletions Sources/Rosetta/PlayMode/Enchants/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ void Power::ClearData()

void Power::AddAura(std::shared_ptr<IAura> aura)
{
m_aura = std::move(aura);
m_aura = aura;
}

void Power::AddEnchant(std::shared_ptr<Enchant> enchant)
{
m_enchant = std::move(enchant);
m_enchant = enchant;
}

void Power::AddTrigger(std::shared_ptr<Trigger> trigger)
{
m_trigger = std::move(trigger);
m_trigger = trigger;
}

void Power::AddPowerTask(const std::shared_ptr<ITask>& task)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Rosetta/PlayMode/Tasks/SimpleTasks/ConditionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace RosettaStone::PlayMode::SimpleTasks
ConditionTask::ConditionTask(
EntityType entityType,
std::vector<std::shared_ptr<SelfCondition>> selfConditions)
: ITask(entityType), m_selfConditions(std::move(selfConditions))
: ITask(entityType), m_selfConditions(selfConditions)
{
// Do nothing
}

ConditionTask::ConditionTask(
EntityType entityType,
std::vector<std::shared_ptr<RelaCondition>> relaConditions)
: ITask(entityType), m_relaConditions(std::move(relaConditions))
: ITask(entityType), m_relaConditions(relaConditions)
{
// Do nothing
}
Expand All @@ -32,8 +32,8 @@ ConditionTask::ConditionTask(
std::vector<std::shared_ptr<SelfCondition>> selfConditions,
std::vector<std::shared_ptr<RelaCondition>> relaConditions)
: ITask(entityType),
m_selfConditions(std::move(selfConditions)),
m_relaConditions(std::move(relaConditions))
m_selfConditions(selfConditions),
m_relaConditions(relaConditions)
{
// Do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace RosettaStone::PlayMode::SimpleTasks
{
FilterStackTask::FilterStackTask(
std::vector<std::shared_ptr<SelfCondition>> selfConditions)
: m_selfConditions(std::move(selfConditions))
: m_selfConditions(selfConditions)
{
// Do nothing
}

FilterStackTask::FilterStackTask(
EntityType type, std::vector<std::shared_ptr<RelaCondition>> relaConditions)
: ITask(type), m_relaConditions(std::move(relaConditions))
: ITask(type), m_relaConditions(relaConditions)
{
// Do nothing
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/Rosetta/PlayMode/Triggers/Trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,18 @@ std::shared_ptr<Trigger> Trigger::Activate(Playable* source,

void Trigger::Remove()
{
if (m_isRemoved)
if (m_isRemoved || !m_owner)
{
return;
}

Game* game = m_owner->game;

if (!game)
{
return;
}

switch (m_triggerType)
{
case TriggerType::GAME_START:
Expand Down

0 comments on commit e2c125b

Please sign in to comment.