Skip to content

Commit

Permalink
Core/MovementGenerators: Ensure correct virtual function overrides ar…
Browse files Browse the repository at this point in the history
…e called. May/should/will/could/might fix various different movement related issues. Please report back.
  • Loading branch information
Machiavell1 committed Feb 27, 2012
1 parent b8310cb commit f402bad
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/server/game/Movement/MovementGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MovementGenerator

virtual void Reset(Unit &) = 0;

virtual bool Update(Unit &, const uint32 time_diff) = 0;
virtual bool Update(Unit &, const uint32& time_diff) = 0;

virtual MovementGeneratorType GetMovementGeneratorType() = 0;

Expand All @@ -64,7 +64,7 @@ class MovementGeneratorMedium : public MovementGenerator
//u->AssertIsType<T>();
(static_cast<D*>(this))->Reset(*((T*)&u));
}
bool Update(Unit &u, const uint32 time_diff)
bool Update(Unit &u, const uint32& time_diff)
{
//u->AssertIsType<T>();
return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
Expand All @@ -74,7 +74,7 @@ class MovementGeneratorMedium : public MovementGenerator
void Initialize(T &u);
void Finalize(T &u);
void Reset(T &u);
bool Update(T &u, const uint32 time_diff);
bool Update(T &u, const uint32& time_diff);
};

struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void TimedFleeingMovementGenerator::Finalize(Unit &owner)
}
}

bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 time_diff)
bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32& time_diff)
{
if (!owner.isAlive())
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TimedFleeingMovementGenerator
i_totalFleeTime(time) {}

MovementGeneratorType GetMovementGeneratorType() { return TIMED_FLEEING_MOTION_TYPE; }
bool Update(Unit &, const uint32);
bool Update(Unit &, const uint32&);
void Finalize(Unit &);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void RotateMovementGenerator::Initialize(Unit& owner)
owner.AttackStop();
}

bool RotateMovementGenerator::Update(Unit& owner, const uint32 diff)
bool RotateMovementGenerator::Update(Unit& owner, const uint32& diff)
{
float angle = owner.GetOrientation();
if (m_direction == ROTATE_DIRECTION_LEFT)
Expand Down Expand Up @@ -93,7 +93,7 @@ DistractMovementGenerator::Finalize(Unit& owner)
}

bool
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32 time_diff)
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
{
if (time_diff > m_timer)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class IdleMovementGenerator : public MovementGenerator
void Initialize(Unit &);
void Finalize(Unit &) { }
void Reset(Unit &);
bool Update(Unit &, const uint32) { return true; }
bool Update(Unit &, const uint32&) { return true; }
MovementGeneratorType GetMovementGeneratorType() { return IDLE_MOTION_TYPE; }
};

Expand All @@ -42,7 +42,7 @@ class RotateMovementGenerator : public MovementGenerator
void Initialize(Unit& owner);
void Finalize(Unit& owner);
void Reset(Unit& owner) { Initialize(owner); }
bool Update(Unit& owner, const uint32 time_diff);
bool Update(Unit& owner, const uint32& time_diff);
MovementGeneratorType GetMovementGeneratorType() { return ROTATE_MOTION_TYPE; }

private:
Expand All @@ -58,7 +58,7 @@ class DistractMovementGenerator : public MovementGenerator
void Initialize(Unit& owner);
void Finalize(Unit& owner);
void Reset(Unit& owner) { Initialize(owner); }
bool Update(Unit& owner, const uint32 time_diff);
bool Update(Unit& owner, const uint32& time_diff);
MovementGeneratorType GetMovementGeneratorType() { return DISTRACT_MOTION_TYPE; }

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void AssistanceMovementGenerator::Finalize(Unit &unit)
unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY));
}

bool EffectMovementGenerator::Update(Unit &unit, const uint32)
bool EffectMovementGenerator::Update(Unit &unit, const uint32&)
{
return !unit.movespline->Finalized();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EffectMovementGenerator : public MovementGenerator
void Initialize(Unit &) {}
void Finalize(Unit &unit);
void Reset(Unit &) {}
bool Update(Unit &u, const uint32);
bool Update(Unit &u, const uint32&);
MovementGeneratorType GetMovementGeneratorType() { return EFFECT_MOTION_TYPE; }
private:
uint32 m_Id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void FlightPathMovementGenerator::Reset(Player & player)
init.Launch();
}

bool FlightPathMovementGenerator::Update(Player &player, const uint32 /*diff*/)
bool FlightPathMovementGenerator::Update(Player &player, const uint32& /*diff*/)
{
uint32 pointId = (uint32)player.movespline->currentPathIdx();
if (pointId > i_currentNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public PathMovementBase<Player, TaxiPathNodeList const*>
void Initialize(Player &);
void Reset(Player &);
void Finalize(Player &);
bool Update(Player &, const uint32);
bool Update(Player &, const uint32&);
MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; }

TaxiPathNodeList const& GetPath() { return *i_path; }
Expand Down

4 comments on commit f402bad

@teyrnon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm, why not use an 'override' keyword to be always sure that everything is ok and function really overriden?

@Subv
Copy link
Contributor

@Subv Subv commented on f402bad Feb 27, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teyrnon im not sure what you mean, but this is not C#, there is no override keyword

@azuritus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++11 specifies override keyword. See virt-specifiers in section 10.3 [1]. But unfortunately trinity doesn't use C++11 yet.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf

@DDuarte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"In MSVC, you can use the CLR override keyword even if you're not compiling for CLR."
"In gcc, -Woverloaded-virtual warns against hiding a base class virtual function with a function of the same name but a sufficiently different signature that it doesn't override it."

Please sign in to comment.