[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

@ -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);
}