[8077] Resolve mixed store and use 2 different flags values types in single field.

* Create new monster move field in Creature class and use it in all cases when expected use MONSTER_MOVE_* flags.
* Store and use MOVEMENTFLAG_* values in field in MovementInfo structure of Player class.
* Cleanups and fix related code.

NOTE: DB in creature_addon store values similar MONSTER_MOVE_* flags, scritps also expected set only this flags.
This commit is contained in:
VladimirMangos 2009-06-25 11:03:51 +04:00
parent 00fc1d7593
commit 21a6a26386
24 changed files with 215 additions and 201 deletions

View file

@ -64,7 +64,6 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
}
unit.StopMoving();
unit.RemoveUnitMovementFlag(MONSTER_MOVE_WALK);
unit.addUnitState(UNIT_STAT_CONFUSED);
}
@ -72,6 +71,8 @@ template<>
void
ConfusedMovementGenerator<Creature>::_InitSpecific(Creature &creature, bool &is_water_ok, bool &is_land_ok)
{
creature.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
is_water_ok = creature.canSwim();
is_land_ok = creature.canWalk();
}
@ -138,17 +139,21 @@ ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
return true;
}
template<class T>
void
ConfusedMovementGenerator<T>::Finalize(T &unit)
template<>
void ConfusedMovementGenerator<Player>::Finalize(Player &unit)
{
unit.clearUnitState(UNIT_STAT_CONFUSED);
}
template<>
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
{
unit.clearUnitState(UNIT_STAT_CONFUSED);
unit.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
}
template void ConfusedMovementGenerator<Player>::Initialize(Player &player);
template void ConfusedMovementGenerator<Creature>::Initialize(Creature &creature);
template void ConfusedMovementGenerator<Player>::Finalize(Player &player);
template void ConfusedMovementGenerator<Creature>::Finalize(Creature &creature);
template void ConfusedMovementGenerator<Player>::Reset(Player &player);
template void ConfusedMovementGenerator<Creature>::Reset(Creature &creature);
template bool ConfusedMovementGenerator<Player>::Update(Player &player, const uint32 &diff);

View file

@ -109,9 +109,10 @@ lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGrou
m_lootMoney(0), m_lootRecipient(0),
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
m_gossipOptionLoaded(false), m_isPet(false), m_isVehicle(false), m_isTotem(false),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0),
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(NULL), m_isActiveObject(false), m_AlreadySearchedAssistance(false)
m_creatureInfo(NULL), m_isActiveObject(false), m_monsterMoveFlags(MONSTER_MOVE_WALK)
{
m_regenTimer = 200;
m_valuesCount = UNIT_END;
@ -122,7 +123,8 @@ m_creatureInfo(NULL), m_isActiveObject(false), m_AlreadySearchedAssistance(false
m_CreatureSpellCooldowns.clear();
m_CreatureCategoryCooldowns.clear();
m_GlobalCooldown = 0;
m_unit_movement_flags = MONSTER_MOVE_WALK;
m_monsterMoveFlags = MONSTER_MOVE_WALK;
}
Creature::~Creature()
@ -1032,7 +1034,7 @@ void Creature::LoadGossipOptions()
m_gossipOptionLoaded = true;
}
void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type)
void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags flags, uint8 type)
{
/* uint32 timeElap = getMSTime();
if ((timeElap - m_startMove) < m_moveTime)
@ -1052,7 +1054,7 @@ void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint3
m_startMove = getMSTime();
m_moveTime = time;*/
SendMonsterMove(x, y, z, type, MovementFlags, time);
SendMonsterMove(x, y, z, type, flags, time);
}
Player *Creature::GetLootRecipient() const
@ -1533,7 +1535,7 @@ void Creature::setDeathState(DeathState s)
CreatureInfo const *cinfo = GetCreatureInfo();
SetUInt32Value(UNIT_DYNAMIC_FLAGS, 0);
RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
AddUnitMovementFlag(MONSTER_MOVE_WALK);
AddMonsterMoveFlag(MONSTER_MOVE_WALK);
SetUInt32Value(UNIT_NPC_FLAGS, cinfo->npcflag);
clearUnitState(UNIT_STAT_ALL_STATE);
i_motionMaster.Clear();
@ -1938,7 +1940,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
if (cainfo->move_flags != 0)
SetUnitMovementFlags(cainfo->move_flags);
SetMonsterMoveFlags(MonsterMovementFlags(cainfo->move_flags));
if(cainfo->auras)
{
@ -2279,3 +2281,29 @@ void Creature::SetActiveObjectState( bool on )
if(world)
map->Add(this);
}
void Creature::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
{
float x, y, z;
if(GetMotionMaster()->GetDestination(x, y, z))
SendMonsterMoveWithSpeed(x, y, z, 0, player);
}
void Creature::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player)
{
if (!transitTime)
{
if(GetTypeId()==TYPEID_PLAYER)
{
Traveller<Player> traveller(*(Player*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
}
else
{
Traveller<Creature> traveller(*(Creature*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
}
}
//float orientation = (float)atan2((double)dy, (double)dx);
SendMonsterMove(x, y, z, 0, GetMonsterMoveFlags(), transitTime, player);
}

View file

@ -517,9 +517,18 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool AIM_Initialize();
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags MovementFlags, uint8 type);
CreatureAI* AI() { return i_AI; }
void AddMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags | f); }
void RemoveMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags & ~f); }
bool HasMonsterMoveFlag(MonsterMovementFlags f) const { return m_monsterMoveFlags & f; }
MonsterMovementFlags GetMonsterMoveFlags() const { return m_monsterMoveFlags; }
void SetMonsterMoveFlags(MonsterMovementFlags f) { m_monsterMoveFlags = f; }
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
uint32 GetShieldBlockValue() const //dunno mob block value
{
return (getLevel()/2 + uint32(GetStat(STAT_STRENGTH)/20));
@ -725,6 +734,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
GridReference<Creature> m_gridRef;
CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry())
bool m_isActiveObject;
MonsterMovementFlags m_monsterMoveFlags;
};
class AssistDelayEvent : public BasicEvent

View file

@ -285,7 +285,6 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
return;
_Init(owner);
owner.RemoveUnitMovementFlag(MONSTER_MOVE_WALK);
if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
{
@ -313,6 +312,8 @@ FleeingMovementGenerator<Creature>::_Init(Creature &owner)
{
if(!&owner)
return;
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
is_water_ok = owner.canSwim();
is_land_ok = owner.canWalk();
@ -326,13 +327,19 @@ FleeingMovementGenerator<Player>::_Init(Player &)
is_land_ok = true;
}
template<class T>
void
FleeingMovementGenerator<T>::Finalize(T &owner)
template<>
void FleeingMovementGenerator<Player>::Finalize(Player &owner)
{
owner.clearUnitState(UNIT_STAT_FLEEING);
}
template<>
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner)
{
owner.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
owner.clearUnitState(UNIT_STAT_FLEEING);
}
template<class T>
void
FleeingMovementGenerator<T>::Reset(T &owner)
@ -379,8 +386,6 @@ template bool FleeingMovementGenerator<Player>::_getPoint(Player &, float &, flo
template bool FleeingMovementGenerator<Creature>::_getPoint(Creature &, float &, float &, float &);
template void FleeingMovementGenerator<Player>::_setTargetLocation(Player &);
template void FleeingMovementGenerator<Creature>::_setTargetLocation(Creature &);
template void FleeingMovementGenerator<Player>::Finalize(Player &);
template void FleeingMovementGenerator<Creature>::Finalize(Creature &);
template void FleeingMovementGenerator<Player>::Reset(Player &);
template void FleeingMovementGenerator<Creature>::Reset(Creature &);
template bool FleeingMovementGenerator<Player>::Update(Player &, const uint32 &);

View file

@ -27,7 +27,7 @@
void
HomeMovementGenerator<Creature>::Initialize(Creature & owner)
{
owner.RemoveUnitMovementFlag(MONSTER_MOVE_WALK);
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
_setTargetLocation(owner);
}
@ -63,7 +63,7 @@ HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff
if (time_diff > i_travel_timer)
{
owner.AddUnitMovementFlag(MONSTER_MOVE_WALK);
owner.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
// restore orientation of not moving creature at returning to home
if(owner.GetDefaultMovementType()==IDLE_MOTION_TYPE)

View file

@ -6057,7 +6057,7 @@ bool ChatHandler::HandleComeToMeCommand(const char *args)
uint32 newFlags = atoi(newFlagStr);
caster->SetUnitMovementFlags(newFlags);
caster->SetMonsterMoveFlags(MonsterMovementFlags(newFlags));
Player* pl = m_session->GetPlayer();

View file

@ -276,7 +276,7 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ )
if( GetPlayer()->isInCombat() || //...is in combat
GetPlayer()->duel || //...is in Duel
//...is jumping ...is falling
GetPlayer()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_JUMPING | MOVEMENTFLAG_FALLING))
GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEMENTFLAG_JUMPING | MOVEMENTFLAG_FALLING)))
{
WorldPacket data( SMSG_LOGOUT_RESPONSE, (2+4) ) ;
data << (uint8)0xC;
@ -1542,7 +1542,7 @@ void WorldSession::HandleMoveSetCanFlyAckOpcode( WorldPacket & recv_data )
recv_data >> guid >> unk >> flags;
_player->m_movementInfo.flags = flags;
_player->m_movementInfo.SetMovementFlags(MovementFlags(flags));
}
void WorldSession::HandleRequestPetInfoOpcode( WorldPacket & /*recv_data */)

View file

@ -230,7 +230,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
return;
/* handle special cases */
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
@ -272,7 +272,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
plMover->HandleFall(movementInfo);
if (plMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plMover->IsInWater())
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
@ -331,7 +331,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
if(Map *map = mover->GetMap())
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
mover->SetUnitMovementFlags(movementInfo.flags);
}
}

View file

@ -1511,43 +1511,6 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const*
*data << (uint8)0; // ChatTag
}
void WorldObject::BuildHeartBeatMsg(WorldPacket *data) const
{
//Heartbeat message cannot be used for non-units
if (!isType(TYPEMASK_UNIT))
return;
data->Initialize(MSG_MOVE_HEARTBEAT, 32);
data->append(GetPackGUID());
*data << uint32(((Unit*)this)->GetUnitMovementFlags()); // movement flags
*data << uint16(0); // 2.3.0
*data << uint32(getMSTime()); // time
*data << m_positionX;
*data << m_positionY;
*data << m_positionZ;
*data << m_orientation;
*data << uint32(0);
}
void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float z, float ang) const
{
//TeleportAck message cannot be used for non-units
if (!isType(TYPEMASK_UNIT))
return;
data->Initialize(MSG_MOVE_TELEPORT_ACK, 41);
data->append(GetPackGUID());
*data << uint32(0); // this value increments every time
*data << uint32(((Unit*)this)->GetUnitMovementFlags()); // movement flags
*data << uint16(0); // 2.3.0
*data << uint32(getMSTime()); // time
*data << x;
*data << y;
*data << z;
*data << ang;
*data << uint32(0);
}
void WorldObject::SendMessageToSet(WorldPacket *data, bool /*bToSelf*/)
{
//if object is in world, map for it already created!

View file

@ -449,8 +449,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object
virtual void SendMessageToSet(WorldPacket *data, bool self);
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self);
void BuildHeartBeatMsg( WorldPacket *data ) const;
void BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang) const;
void MonsterSay(const char* text, uint32 language, uint64 TargetGuid);
void MonsterYell(const char* text, uint32 language, uint64 TargetGuid);

View file

@ -449,9 +449,6 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_summon_y = 0.0f;
m_summon_z = 0.0f;
//Default movement to run mode
m_unit_movement_flags = 0;
m_mover = this;
m_miniPet = 0;
@ -1623,7 +1620,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
}
// reset movement flags at teleport, because player will continue move with these flags after teleport
m_movementInfo.flags = 0;
m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
if ((GetMapId() == mapid) && (!m_transport))
{
@ -17970,7 +17967,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
// set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment
if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight())
m_movementInfo.flags |= MOVEMENTFLAG_FLYING2;
m_movementInfo.AddMovementFlag(MOVEMENTFLAG_FLYING2);
m_mover = this;
}
@ -20321,3 +20318,18 @@ void Player::SendClearCooldown( uint32 spell_id, Unit* target )
data << uint64(target->GetGUID());
SendDirectMessage(&data);
}
void Player::BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang ) const
{
data->Initialize(MSG_MOVE_TELEPORT_ACK, 41);
data->append(GetPackGUID());
*data << uint32(0); // this value increments every time
*data << uint32(m_movementInfo.GetMovementFlags()); // movement flags
*data << uint16(0); // 2.3.0
*data << uint32(getMSTime()); // time
*data << x;
*data << y;
*data << z;
*data << ang;
*data << uint32(0);
}

View file

@ -687,10 +687,42 @@ enum InstanceResetWarningType
RAID_INSTANCE_EXPIRED = 5
};
// used in most movement packets (send and received)
enum MovementFlags
{
MOVEMENTFLAG_NONE = 0x00000000,
MOVEMENTFLAG_FORWARD = 0x00000001,
MOVEMENTFLAG_BACKWARD = 0x00000002,
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
MOVEMENTFLAG_LEFT = 0x00000010,
MOVEMENTFLAG_RIGHT = 0x00000020,
MOVEMENTFLAG_PITCH_UP = 0x00000040,
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking
MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
MOVEMENTFLAG_LEVITATING = 0x00000400,
MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
MOVEMENTFLAG_JUMPING = 0x00001000,
MOVEMENTFLAG_UNK4 = 0x00002000,
MOVEMENTFLAG_FALLING = 0x00004000,
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
MOVEMENTFLAG_FLY_UP = 0x00400000,
MOVEMENTFLAG_CAN_FLY = 0x00800000,
MOVEMENTFLAG_FLYING = 0x01000000,
MOVEMENTFLAG_FLYING2 = 0x02000000, // Actual flying mode
MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths
MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
MOVEMENTFLAG_UNK3 = 0x40000000
};
struct MovementInfo
{
// common
uint32 flags;
uint32 flags; // see enum MovementFlags
uint16 unk1;
uint32 time;
float x, y, z, o;
@ -710,16 +742,18 @@ struct MovementInfo
MovementInfo()
{
flags = 0;
flags = MOVEMENTFLAG_NONE;
time = t_time = fallTime = 0;
unk1 = 0;
x = y = z = o = t_x = t_y = t_z = t_o = s_pitch = j_unk = j_sinAngle = j_cosAngle = j_xyspeed = u_unk1 = 0.0f;
t_guid = 0;
}
uint32 GetMovementFlags() { return flags; }
void AddMovementFlag(uint32 flag) { flags |= flag; }
bool HasMovementFlag(uint32 flag) const { return flags & flag; }
void AddMovementFlag(MovementFlags f) { flags |= f; }
void RemoveMovementFlag(MovementFlags f) { flags &= ~f; }
bool HasMovementFlag(MovementFlags f) const { return flags & f; }
MovementFlags GetMovementFlags() const { return MovementFlags(flags); }
void SetMovementFlags(MovementFlags f) { flags = f; }
};
// flags that use in movement check for example at spell casting
@ -1945,6 +1979,8 @@ class MANGOS_DLL_SPEC Player : public Unit
}
void HandleFall(MovementInfo const& movementInfo);
void BuildTeleportAckMsg( WorldPacket *data, float x, float y, float z, float ang) const;
bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }

View file

@ -33,7 +33,7 @@ void PointMovementGenerator<T>::Initialize(T &unit)
i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z);
if (unit.GetTypeId() == TYPEID_UNIT && ((Creature*)&unit)->canFly())
unit.AddUnitMovementFlag(MONSTER_MOVE_FLY);
((Creature&)unit).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
}
template<class T>

View file

@ -90,13 +90,13 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
if (is_air_ok)
{
i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime());
creature.AddUnitMovementFlag(MONSTER_MOVE_FLY);
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
}
//else if (is_water_ok) // Swimming mode to be done with more than this check
else
{
i_nextMoveTime.Reset(urand(500+i_destinationHolder.GetTotalTravelTime(),5000+i_destinationHolder.GetTotalTravelTime()));
creature.SetUnitMovementFlags(MONSTER_MOVE_WALK);
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
}
}
@ -108,9 +108,13 @@ RandomMovementGenerator<Creature>::Initialize(Creature &creature)
return;
if (creature.canFly())
creature.AddUnitMovementFlag(MONSTER_MOVE_FLY);
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
else if(irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
else
creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MONSTER_MOVE_WALK : MONSTER_MOVE_NONE);
creature.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); // run with 1/RUNNING_CHANCE_RANDOMMV chance
_setRandomLocation(creature);
}
@ -147,14 +151,17 @@ RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff
if(i_nextMoveTime.Passed())
{
if (creature.canFly())
creature.AddUnitMovementFlag(MONSTER_MOVE_FLY);
else
creature.SetUnitMovementFlags(irand(0,RUNNING_CHANCE_RANDOMMV) > 0 ? MONSTER_MOVE_WALK : MONSTER_MOVE_NONE);
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
else if(irand(0,RUNNING_CHANCE_RANDOMMV) > 0)
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
else // run with 1/RUNNING_CHANCE_RANDOMMV chance
creature.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
_setRandomLocation(creature);
}
else if(creature.isPet() && creature.GetOwner() && !creature.IsWithinDist(creature.GetOwner(),PET_FOLLOW_DIST+2.5f))
{
creature.SetUnitMovementFlags(MONSTER_MOVE_WALK);
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
_setRandomLocation(creature);
}
}

View file

@ -2579,7 +2579,7 @@ void Spell::update(uint32 difftime)
// check if the player caster has moved before the spell finished
if ((m_caster->GetTypeId() == TYPEID_PLAYER && m_timer != 0) &&
(m_castPositionX != m_caster->GetPositionX() || m_castPositionY != m_caster->GetPositionY() || m_castPositionZ != m_caster->GetPositionZ()) &&
(m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING)))
(m_spellInfo->Effect[0] != SPELL_EFFECT_STUCK || !((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING)))
{
// always cancel for channeled spells
if( m_spellState == SPELL_STATE_CASTING )
@ -2611,7 +2611,7 @@ void Spell::update(uint32 difftime)
if( m_caster->GetTypeId() == TYPEID_PLAYER )
{
// check if player has jumped before the channeling finished
if(m_caster->HasUnitMovementFlag(MOVEMENTFLAG_JUMPING))
if(((Player*)m_caster)->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_JUMPING))
cancel();
// check for incapacitating player states

View file

@ -3174,7 +3174,7 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
{
pet->AttackStop();
pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
pet->SetUnitMovementFlags(MONSTER_MOVE_WALK);
pet->AddMonsterMoveFlag(MONSTER_MOVE_WALK);
}
}
@ -3415,10 +3415,10 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
// Creature specific
if(m_target->GetTypeId() != TYPEID_PLAYER)
((Creature*)m_target)->StopMoving();
m_target->StopMoving();
else
{
((Player*)m_target)->m_movementInfo.flags = 0; // Clear movement flags
((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client
}
@ -3702,10 +3702,10 @@ void Aura::HandleAuraModRoot(bool apply, bool Real)
m_target->SendMessageToSet(&data, true);
//Clear unit movement flags
((Player*)m_target)->m_movementInfo.flags = 0;
((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
}
else
((Creature *)m_target)->StopMoving();
m_target->StopMoving();
}
else
{

View file

@ -85,24 +85,29 @@ TargetedMovementGenerator<T>::_setTargetLocation(T &owner)
i_destinationHolder.SetDestination(traveller, x, y, z);
owner.addUnitState(UNIT_STAT_CHASE);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
owner.AddUnitMovementFlag(MONSTER_MOVE_FLY);
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
}
template<class T>
void
TargetedMovementGenerator<T>::Initialize(T &owner)
template<>
void TargetedMovementGenerator<Creature>::Initialize(Creature &owner)
{
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->HasSearchedAssistance())
owner.AddUnitMovementFlag(MONSTER_MOVE_WALK);
if (owner.HasSearchedAssistance())
owner.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
else
owner.RemoveUnitMovementFlag(MONSTER_MOVE_WALK);
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
owner.AddUnitMovementFlag(MONSTER_MOVE_FLY);
if (((Creature*)&owner)->canFly())
owner.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
_setTargetLocation(owner);
}
template<>
void TargetedMovementGenerator<Player>::Initialize(Player &owner)
{
_setTargetLocation(owner);
}
template<class T>
void
TargetedMovementGenerator<T>::Finalize(T &owner)
@ -150,7 +155,7 @@ TargetedMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
{
owner.addUnitState(UNIT_STAT_CHASE);
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
owner.AddUnitMovementFlag(MONSTER_MOVE_FLY);
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
i_destinationHolder.StartTravel(traveller);
return true;
@ -199,8 +204,6 @@ TargetedMovementGenerator<T>::GetTarget() const
template void TargetedMovementGenerator<Player>::_setTargetLocation(Player &);
template void TargetedMovementGenerator<Creature>::_setTargetLocation(Creature &);
template void TargetedMovementGenerator<Player>::Initialize(Player &);
template void TargetedMovementGenerator<Creature>::Initialize(Creature &);
template void TargetedMovementGenerator<Player>::Finalize(Player &);
template void TargetedMovementGenerator<Creature>::Finalize(Creature &);
template void TargetedMovementGenerator<Player>::Reset(Player &);

View file

@ -71,9 +71,9 @@ inline uint32 Traveller<T>::GetTotalTrevelTimeTo(float x, float y, float z)
template<>
inline float Traveller<Creature>::Speed()
{
if(i_traveller.HasUnitMovementFlag(MONSTER_MOVE_WALK))
if(i_traveller.HasMonsterMoveFlag(MONSTER_MOVE_WALK))
return i_traveller.GetSpeed(MOVE_WALK);
else if(i_traveller.HasUnitMovementFlag(MONSTER_MOVE_FLY))
else if(i_traveller.HasMonsterMoveFlag(MONSTER_MOVE_FLY))
return i_traveller.GetSpeed(MOVE_FLIGHT);
else
return i_traveller.GetSpeed(MOVE_RUN);
@ -102,7 +102,7 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
template<>
inline void Traveller<Creature>::MoveTo(float x, float y, float z, uint32 t)
{
i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetUnitMovementFlags(), 0);
i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetMonsterMoveFlags(), 0);
}
// specialization for players

View file

@ -150,7 +150,6 @@ Unit::Unit()
m_removedAuras = 0;
m_charmInfo = NULL;
m_unit_movement_flags = 0;
// remove aurastates allowing special moves
for(int i=0; i < MAX_REACTIVE; ++i)
@ -229,33 +228,7 @@ bool Unit::haveOffhandWeapon() const
return false;
}
void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player)
{
float x, y, z;
if(GetMotionMaster()->GetDestination(x, y, z))
SendMonsterMoveWithSpeed(x, y, z, 0, player);
}
void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime, Player* player)
{
if (!transitTime)
{
if(GetTypeId()==TYPEID_PLAYER)
{
Traveller<Player> traveller(*(Player*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
}
else
{
Traveller<Creature> traveller(*(Creature*)this);
transitTime = traveller.GetTotalTrevelTimeTo(x,y,z);
}
}
//float orientation = (float)atan2((double)dy, (double)dx);
SendMonsterMove(x, y, z, 0, GetUnitMovementFlags(), transitTime, player);
}
void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player)
void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, MonsterMovementFlags flags, uint32 Time, Player* player)
{
float moveTime = Time;
@ -286,9 +259,9 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 ty
break;
}
data << uint32(MovementFlags);
data << uint32(flags);
if(MovementFlags & MONSTER_MOVE_WALK)
if(flags & MONSTER_MOVE_WALK)
moveTime *= 1.05f;
data << uint32(moveTime); // Time in between points
@ -301,7 +274,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 ty
SendMessageToSet( &data, true );
}
void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags)
void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, MonsterMovementFlags flags)
{
uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32);
@ -314,14 +287,32 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uin
data << GetPositionY();
data << GetPositionZ();
data << uint32(getMSTime());
data << uint8( 0 );
data << uint32( MovementFlags );
data << uint32( traveltime );
data << uint32( pathSize );
data.append( (char*)path.GetNodes(start), pathSize * 4 * 3 );
data << uint8(0);
data << uint32(flags);
data << uint32(traveltime);
data << uint32(pathSize);
data.append((char*)path.GetNodes(start), pathSize * 4 * 3);
SendMessageToSet(&data, true);
}
void Unit::BuildHeartBeatMsg(WorldPacket *data) const
{
MovementFlags move_flags = GetTypeId()==TYPEID_PLAYER
? ((Player const*)this)->m_movementInfo.GetMovementFlags()
: MOVEMENTFLAG_NONE;
data->Initialize(MSG_MOVE_HEARTBEAT, 32);
data->append(GetPackGUID());
*data << uint32(move_flags); // movement flags
*data << uint16(0); // 2.3.0
*data << uint32(getMSTime()); // time
*data << float(GetPositionX());
*data << float(GetPositionY());
*data << float(GetPositionZ());
*data << float(GetOrientation());
*data << uint32(0);
}
void Unit::resetAttackTimer(WeaponAttackType type)
{
m_attackTimer[type] = uint32(GetAttackTime(type) * m_modAttackSpeedPct[type]);
@ -11726,8 +11717,6 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca
GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation);
WorldPacket data;
// Work strange for many spells: triggered active mover set for targeted player to creature
//BuildTeleportAckMsg(&data, x, y, z, orientation);
BuildHeartBeatMsg(&data);
SendMessageToSet(&data, false);
}

View file

@ -566,37 +566,7 @@ enum NPCFlags
UNIT_NPC_FLAG_GUARD = 0x10000000, // custom flag for guards
};
enum MovementFlags
{
MOVEMENTFLAG_NONE = 0x00000000,
MOVEMENTFLAG_FORWARD = 0x00000001,
MOVEMENTFLAG_BACKWARD = 0x00000002,
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
MOVEMENTFLAG_LEFT = 0x00000010,
MOVEMENTFLAG_RIGHT = 0x00000020,
MOVEMENTFLAG_PITCH_UP = 0x00000040,
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
MOVEMENTFLAG_WALK_MODE = 0x00000100, // Walking
MOVEMENTFLAG_ONTRANSPORT = 0x00000200, // Used for flying on some creatures
MOVEMENTFLAG_LEVITATING = 0x00000400,
MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
MOVEMENTFLAG_JUMPING = 0x00001000,
MOVEMENTFLAG_UNK4 = 0x00002000,
MOVEMENTFLAG_FALLING = 0x00004000,
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
MOVEMENTFLAG_FLY_UP = 0x00400000,
MOVEMENTFLAG_CAN_FLY = 0x00800000,
MOVEMENTFLAG_FLYING = 0x01000000,
MOVEMENTFLAG_FLYING2 = 0x02000000, // Actual flying mode
MOVEMENTFLAG_SPLINE = 0x04000000, // used for flight paths
MOVEMENTFLAG_SPLINE2 = 0x08000000, // used for flight paths
MOVEMENTFLAG_WATERWALKING = 0x10000000, // prevent unit from falling through water
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
MOVEMENTFLAG_UNK3 = 0x40000000
};
// used in SMSG_MONSTER_MOVE
enum MonsterMovementFlags
{
MONSTER_MOVE_NONE = 0x00000000,
@ -1143,10 +1113,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, uint32 MovementFlags);
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, MonsterMovementFlags flags, uint32 Time, Player* player = NULL);
void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end, MonsterMovementFlags flags);
void BuildHeartBeatMsg( WorldPacket *data ) const;
virtual void MoveOutOfRange(Player &) { };
@ -1474,16 +1444,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); }
void StopMoving();
void AddUnitMovementFlag(uint32 f) { m_unit_movement_flags |= f; }
void RemoveUnitMovementFlag(uint32 f)
{
uint32 oldval = m_unit_movement_flags;
m_unit_movement_flags = oldval & ~f;
}
uint32 HasUnitMovementFlag(uint32 f) const { return m_unit_movement_flags & f; }
uint32 GetUnitMovementFlags() const { return m_unit_movement_flags; }
void SetUnitMovementFlags(uint32 f) { m_unit_movement_flags = f; }
void SetFeared(bool apply, uint64 casterGUID = 0, uint32 spellID = 0, uint32 time = 0);
void SetConfused(bool apply, uint64 casterGUID = 0, uint32 spellID = 0);
@ -1558,7 +1518,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
virtual SpellSchoolMask GetMeleeDamageSchoolMask() const;
MotionMaster i_motionMaster;
uint32 m_unit_movement_flags;
uint32 m_reactiveTimer[MAX_REACTIVE];
uint32 m_regenTimer;

View file

@ -110,7 +110,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
// Now we re-set destination to same node and start travel
creature.addUnitState(UNIT_STAT_ROAMING);
if (creature.canFly())
creature.AddUnitMovementFlag(MONSTER_MOVE_FLY);
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
const WaypointNode &node = i_path->at(i_currentNode);
i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z);
i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime());
@ -173,7 +173,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
{
creature.addUnitState(UNIT_STAT_ROAMING);
if (creature.canFly())
creature.AddUnitMovementFlag(MONSTER_MOVE_FLY);
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
const WaypointNode &node = i_path->at(i_currentNode);
i_destinationHolder.SetDestination(traveller, node.x, node.y, node.z);
i_nextMoveTime.Reset(i_destinationHolder.GetTotalTravelTime());

View file

@ -1821,8 +1821,8 @@ void World::ScriptsProcess()
sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId());
break;
}
((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
((Creature*)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
((Creature*)source)->GetMap()->CreatureRelocation(((Creature*)source), step.script->x, step.script->y, step.script->z, 0);
break;
case SCRIPT_COMMAND_FLAG_SET:
if(!source)

View file

@ -635,7 +635,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
data >> mi->z;
data >> mi->o;
if(mi->flags & MOVEMENTFLAG_ONTRANSPORT)
if(mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
if(!data.readPackGUID(mi->t_guid))
return;
@ -649,7 +649,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
data >> mi->t_seat;
}
if((mi->flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) || (mi->unk1 & 0x20))
if((mi->HasMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2))) || (mi->unk1 & 0x20))
{
CHECK_PACKET_SIZE(data, data.rpos()+4);
data >> mi->s_pitch;
@ -658,7 +658,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
CHECK_PACKET_SIZE(data, data.rpos()+4);
data >> mi->fallTime;
if(mi->flags & MOVEMENTFLAG_JUMPING)
if(mi->HasMovementFlag(MOVEMENTFLAG_JUMPING))
{
CHECK_PACKET_SIZE(data, data.rpos()+4+4+4+4);
data >> mi->j_unk;
@ -667,7 +667,7 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
data >> mi->j_xyspeed;
}
if(mi->flags & MOVEMENTFLAG_SPLINE)
if(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE))
{
CHECK_PACKET_SIZE(data, data.rpos()+4);
data >> mi->u_unk1;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8076"
#define REVISION_NR "8077"
#endif // __REVISION_NR_H__