[9208] Big cleanup in UNIT_STAT_* use

* Re-number enums by function groups and use where possible new defined masks in code instead raw enum |-lists.
* Avoid use movement generator generic state markers like UNIT_STAT_CONFUSED for mark movement stoped.
  Add special shadow UNIT_STAT_CONFUSED_MOVE/etc states for like use.
  UNIT_STAT_CONFUSED in like case will be safe expect use for normal checks confused state presence
  And UNIT_STAT_CONFUSED_MOVE for check real move in this state
This commit is contained in:
VladimirMangos 2010-01-18 10:48:31 +03:00
parent 7d6b1b292e
commit 6a2e8064f1
25 changed files with 251 additions and 104 deletions

View file

@ -64,7 +64,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
}
unit.StopMoving();
unit.addUnitState(UNIT_STAT_CONFUSED);
unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
}
template<>
@ -88,6 +88,8 @@ ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bo
template<class T>
void ConfusedMovementGenerator<T>::Interrupt(T &unit)
{
// confused state still applied while movegen disabled
unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE);
}
template<class T>
@ -97,6 +99,7 @@ void ConfusedMovementGenerator<T>::Reset(T &unit)
i_nextMoveTime.Reset(0);
i_destinationHolder.ResetUpdate();
unit.StopMoving();
unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
}
template<class T>
@ -105,12 +108,14 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
if(!&unit)
return true;
if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
// ignore in case other no reaction state
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED))
return true;
if( i_nextMoveTime.Passed() )
if (i_nextMoveTime.Passed())
{
// currently moving, update location
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
Traveller<T> traveller(unit);
if( i_destinationHolder.UpdateTraveller(traveller, diff, false))
{
@ -131,6 +136,7 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
if( i_nextMoveTime.Passed() )
{
// start moving
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
assert( i_nextMove <= MAX_CONF_WAYPOINTS );
const float x = i_waypoints[i_nextMove][0];
const float y = i_waypoints[i_nextMove][1];
@ -145,13 +151,13 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
template<>
void ConfusedMovementGenerator<Player>::Finalize(Player &unit)
{
unit.clearUnitState(UNIT_STAT_CONFUSED);
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
}
template<>
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
{
unit.clearUnitState(UNIT_STAT_CONFUSED);
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
unit.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
}