mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[10593] Cleaning up code a bit, in related functions for recent commits
Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
795c3e1f2f
commit
0caa0e32dd
4 changed files with 42 additions and 43 deletions
|
|
@ -784,7 +784,7 @@ bool GameObject::ActivateToQuest(Player *pTarget)const
|
|||
}
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
{
|
||||
if(pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
|
||||
if (pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,23 +538,24 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
|
|||
|
||||
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *updateMask, Player *target) const
|
||||
{
|
||||
if(!target)
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
bool IsActivateToQuest = false;
|
||||
bool IsPerCasterAuraState = false;
|
||||
|
||||
if (updatetype == UPDATETYPE_CREATE_OBJECT || updatetype == UPDATETYPE_CREATE_OBJECT2)
|
||||
{
|
||||
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
|
||||
{
|
||||
if ( ((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||
IsActivateToQuest = true;
|
||||
|
||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||
}
|
||||
else if (isType(TYPEMASK_UNIT))
|
||||
{
|
||||
if( ((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||
if (((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||
{
|
||||
IsPerCasterAuraState = true;
|
||||
updateMask->SetBit(UNIT_FIELD_AURASTATE);
|
||||
|
|
@ -565,16 +566,15 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
{
|
||||
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
|
||||
{
|
||||
if ( ((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||
{
|
||||
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||
IsActivateToQuest = true;
|
||||
}
|
||||
|
||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
||||
}
|
||||
else if (isType(TYPEMASK_UNIT))
|
||||
{
|
||||
if( ((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||
if (((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||
{
|
||||
IsPerCasterAuraState = true;
|
||||
updateMask->SetBit(UNIT_FIELD_AURASTATE);
|
||||
|
|
@ -585,19 +585,19 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
MANGOS_ASSERT(updateMask && updateMask->GetCount() == m_valuesCount);
|
||||
|
||||
*data << (uint8)updateMask->GetBlockCount();
|
||||
data->append( updateMask->GetMask(), updateMask->GetLength() );
|
||||
data->append(updateMask->GetMask(), updateMask->GetLength());
|
||||
|
||||
// 2 specialized loops for speed optimization in non-unit case
|
||||
if(isType(TYPEMASK_UNIT)) // unit (creature/player) case
|
||||
if (isType(TYPEMASK_UNIT)) // unit (creature/player) case
|
||||
{
|
||||
for( uint16 index = 0; index < m_valuesCount; ++index )
|
||||
for(uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if( updateMask->GetBit( index ) )
|
||||
if (updateMask->GetBit(index))
|
||||
{
|
||||
if( index == UNIT_NPC_FLAGS )
|
||||
if (index == UNIT_NPC_FLAGS)
|
||||
{
|
||||
// remove custom flag before sending
|
||||
uint32 appendValue = m_uint32Values[ index ] & ~UNIT_NPC_FLAG_GUARD;
|
||||
uint32 appendValue = m_uint32Values[index] & ~UNIT_NPC_FLAG_GUARD;
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
|
|
@ -621,22 +621,22 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
}
|
||||
else if (index == UNIT_FIELD_AURASTATE)
|
||||
{
|
||||
if(IsPerCasterAuraState)
|
||||
if (IsPerCasterAuraState)
|
||||
{
|
||||
// IsPerCasterAuraState set if related pet caster aura state set already
|
||||
if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE,target->GetGUID()))
|
||||
*data << m_uint32Values[ index ];
|
||||
*data << m_uint32Values[index];
|
||||
else
|
||||
*data << (m_uint32Values[ index ] & ~(1 << (AURA_STATE_CONFLAGRATE-1)));
|
||||
*data << (m_uint32Values[index] & ~(1 << (AURA_STATE_CONFLAGRATE-1)));
|
||||
}
|
||||
else
|
||||
*data << m_uint32Values[ index ];
|
||||
*data << m_uint32Values[index];
|
||||
}
|
||||
// FIXME: Some values at server stored in float format but must be sent to client in uint32 format
|
||||
else if(index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME)
|
||||
else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME)
|
||||
{
|
||||
// convert from float to uint32 and send
|
||||
*data << uint32(m_floatValues[ index ] < 0 ? 0 : m_floatValues[ index ]);
|
||||
*data << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]);
|
||||
}
|
||||
|
||||
// there are some float values which may be negative or can't get negative due to other checks
|
||||
|
|
@ -645,41 +645,41 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
(index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) ||
|
||||
(index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4))
|
||||
{
|
||||
*data << uint32(m_floatValues[ index ]);
|
||||
*data << uint32(m_floatValues[index]);
|
||||
}
|
||||
|
||||
// Gamemasters should be always able to select units - remove not selectable flag
|
||||
else if(index == UNIT_FIELD_FLAGS && target->isGameMaster())
|
||||
else if (index == UNIT_FIELD_FLAGS && target->isGameMaster())
|
||||
{
|
||||
*data << (m_uint32Values[ index ] & ~UNIT_FLAG_NOT_SELECTABLE);
|
||||
*data << (m_uint32Values[index] & ~UNIT_FLAG_NOT_SELECTABLE);
|
||||
}
|
||||
// hide lootable animation for unallowed players
|
||||
else if (index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if (!target->isAllowedToLoot((Creature*)this))
|
||||
*data << (m_uint32Values[ index ] & ~(UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED_BY_PLAYER));
|
||||
*data << (m_uint32Values[index] & ~(UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED_BY_PLAYER));
|
||||
else
|
||||
{
|
||||
// flag only for original loot recipent
|
||||
if (target->GetObjectGuid() == ((Creature*)this)->GetLootRecipientGuid())
|
||||
*data << m_uint32Values[ index ];
|
||||
*data << m_uint32Values[index];
|
||||
else
|
||||
*data << (m_uint32Values[ index ] & ~(UNIT_DYNFLAG_TAPPED | UNIT_DYNFLAG_TAPPED_BY_PLAYER));
|
||||
*data << (m_uint32Values[index] & ~(UNIT_DYNFLAG_TAPPED | UNIT_DYNFLAG_TAPPED_BY_PLAYER));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// send in current format (float as float, uint32 as uint32)
|
||||
*data << m_uint32Values[ index ];
|
||||
*data << m_uint32Values[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(isType(TYPEMASK_GAMEOBJECT)) // gameobject case
|
||||
else if (isType(TYPEMASK_GAMEOBJECT)) // gameobject case
|
||||
{
|
||||
for( uint16 index = 0; index < m_valuesCount; ++index )
|
||||
for(uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if( updateMask->GetBit( index ) )
|
||||
if (updateMask->GetBit(index))
|
||||
{
|
||||
// send in current format (float as float, uint32 as uint32)
|
||||
if (index == GAMEOBJECT_DYNAMIC)
|
||||
|
|
@ -701,8 +701,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
*data << uint16(-1);
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
// enable quest object. Represent 9, but 1 for client before 2.3.0
|
||||
*data << uint16(9);
|
||||
*data << uint16(9); // 1 for client before 2.3.0
|
||||
*data << uint16(-1);
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_GENERIC:
|
||||
|
|
@ -732,18 +731,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
|||
}
|
||||
}
|
||||
else
|
||||
*data << m_uint32Values[ index ]; // other cases
|
||||
*data << m_uint32Values[index]; // other cases
|
||||
}
|
||||
}
|
||||
}
|
||||
else // other objects case (no special index checks)
|
||||
{
|
||||
for( uint16 index = 0; index < m_valuesCount; ++index )
|
||||
for(uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if( updateMask->GetBit( index ) )
|
||||
if (updateMask->GetBit(index))
|
||||
{
|
||||
// send in current format (float as float, uint32 as uint32)
|
||||
*data << m_uint32Values[ index ];
|
||||
*data << m_uint32Values[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7698,7 +7698,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
|||
{
|
||||
mGameObjectForQuestSet.clear(); // need for reload case
|
||||
|
||||
if( !sGOStorage.MaxEntry )
|
||||
if (!sGOStorage.MaxEntry)
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
bar.step();
|
||||
|
|
@ -7707,7 +7707,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
|||
return;
|
||||
}
|
||||
|
||||
barGoLink bar( sGOStorage.MaxEntry - 1 );
|
||||
barGoLink bar(sGOStorage.MaxEntry - 1);
|
||||
uint32 count = 0;
|
||||
|
||||
// collect GO entries for GO that must activated
|
||||
|
|
@ -7715,7 +7715,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
|||
{
|
||||
bar.step();
|
||||
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(go_entry);
|
||||
if(!goInfo)
|
||||
if (!goInfo)
|
||||
continue;
|
||||
|
||||
switch(goInfo->type)
|
||||
|
|
@ -7768,7 +7768,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
|||
}
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
{
|
||||
if(goInfo->goober.questId) //quests objects
|
||||
if (goInfo->goober.questId) //quests objects
|
||||
{
|
||||
mGameObjectForQuestSet.insert(go_entry);
|
||||
count++;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10592"
|
||||
#define REVISION_NR "10593"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue