mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +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:
|
case GAMEOBJECT_TYPE_GOOBER:
|
||||||
{
|
{
|
||||||
if(pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
|
if (pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
|
||||||
return true;
|
return true;
|
||||||
break;
|
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
|
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *updateMask, Player *target) const
|
||||||
{
|
{
|
||||||
if(!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool IsActivateToQuest = false;
|
bool IsActivateToQuest = false;
|
||||||
bool IsPerCasterAuraState = false;
|
bool IsPerCasterAuraState = false;
|
||||||
|
|
||||||
if (updatetype == UPDATETYPE_CREATE_OBJECT || updatetype == UPDATETYPE_CREATE_OBJECT2)
|
if (updatetype == UPDATETYPE_CREATE_OBJECT || updatetype == UPDATETYPE_CREATE_OBJECT2)
|
||||||
{
|
{
|
||||||
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
|
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
|
||||||
{
|
{
|
||||||
if ( ((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||||
IsActivateToQuest = true;
|
IsActivateToQuest = true;
|
||||||
|
|
||||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||||
}
|
}
|
||||||
else if (isType(TYPEMASK_UNIT))
|
else if (isType(TYPEMASK_UNIT))
|
||||||
{
|
{
|
||||||
if( ((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
if (((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||||
{
|
{
|
||||||
IsPerCasterAuraState = true;
|
IsPerCasterAuraState = true;
|
||||||
updateMask->SetBit(UNIT_FIELD_AURASTATE);
|
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 (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
|
||||||
{
|
{
|
||||||
if ( ((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
|
||||||
{
|
|
||||||
IsActivateToQuest = true;
|
IsActivateToQuest = true;
|
||||||
}
|
|
||||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||||
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
||||||
}
|
}
|
||||||
else if (isType(TYPEMASK_UNIT))
|
else if (isType(TYPEMASK_UNIT))
|
||||||
{
|
{
|
||||||
if( ((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
if (((Unit*)this)->HasAuraState(AURA_STATE_CONFLAGRATE))
|
||||||
{
|
{
|
||||||
IsPerCasterAuraState = true;
|
IsPerCasterAuraState = true;
|
||||||
updateMask->SetBit(UNIT_FIELD_AURASTATE);
|
updateMask->SetBit(UNIT_FIELD_AURASTATE);
|
||||||
|
|
@ -585,19 +585,19 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
||||||
MANGOS_ASSERT(updateMask && updateMask->GetCount() == m_valuesCount);
|
MANGOS_ASSERT(updateMask && updateMask->GetCount() == m_valuesCount);
|
||||||
|
|
||||||
*data << (uint8)updateMask->GetBlockCount();
|
*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
|
// 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
|
// 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)
|
if (GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
|
|
@ -621,65 +621,65 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
||||||
}
|
}
|
||||||
else if (index == UNIT_FIELD_AURASTATE)
|
else if (index == UNIT_FIELD_AURASTATE)
|
||||||
{
|
{
|
||||||
if(IsPerCasterAuraState)
|
if (IsPerCasterAuraState)
|
||||||
{
|
{
|
||||||
// IsPerCasterAuraState set if related pet caster aura state set already
|
// IsPerCasterAuraState set if related pet caster aura state set already
|
||||||
if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE,target->GetGUID()))
|
if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE,target->GetGUID()))
|
||||||
*data << m_uint32Values[ index ];
|
*data << m_uint32Values[index];
|
||||||
else
|
else
|
||||||
*data << (m_uint32Values[ index ] & ~(1 << (AURA_STATE_CONFLAGRATE-1)));
|
*data << (m_uint32Values[index] & ~(1 << (AURA_STATE_CONFLAGRATE-1)));
|
||||||
}
|
}
|
||||||
else
|
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
|
// 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
|
// 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
|
// there are some float values which may be negative or can't get negative due to other checks
|
||||||
else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) ||
|
else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) ||
|
||||||
(index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) ||
|
(index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) ||
|
||||||
(index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) ||
|
(index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) ||
|
||||||
(index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4))
|
(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
|
// 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
|
// hide lootable animation for unallowed players
|
||||||
else if (index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_UNIT)
|
else if (index == UNIT_DYNAMIC_FLAGS && GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
if (!target->isAllowedToLoot((Creature*)this))
|
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
|
else
|
||||||
{
|
{
|
||||||
// flag only for original loot recipent
|
// flag only for original loot recipent
|
||||||
if (target->GetObjectGuid() == ((Creature*)this)->GetLootRecipientGuid())
|
if (target->GetObjectGuid() == ((Creature*)this)->GetLootRecipientGuid())
|
||||||
*data << m_uint32Values[ index ];
|
*data << m_uint32Values[index];
|
||||||
else
|
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
|
else
|
||||||
{
|
{
|
||||||
// send in current format (float as float, uint32 as uint32)
|
// 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)
|
// send in current format (float as float, uint32 as uint32)
|
||||||
if (index == GAMEOBJECT_DYNAMIC)
|
if (index == GAMEOBJECT_DYNAMIC)
|
||||||
|
|
@ -701,8 +701,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
||||||
*data << uint16(-1);
|
*data << uint16(-1);
|
||||||
break;
|
break;
|
||||||
case GAMEOBJECT_TYPE_CHEST:
|
case GAMEOBJECT_TYPE_CHEST:
|
||||||
// enable quest object. Represent 9, but 1 for client before 2.3.0
|
*data << uint16(9); // 1 for client before 2.3.0
|
||||||
*data << uint16(9);
|
|
||||||
*data << uint16(-1);
|
*data << uint16(-1);
|
||||||
break;
|
break;
|
||||||
case GAMEOBJECT_TYPE_GENERIC:
|
case GAMEOBJECT_TYPE_GENERIC:
|
||||||
|
|
@ -732,18 +731,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*data << m_uint32Values[ index ]; // other cases
|
*data << m_uint32Values[index]; // other cases
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // other objects case (no special index checks)
|
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)
|
// 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
|
mGameObjectForQuestSet.clear(); // need for reload case
|
||||||
|
|
||||||
if( !sGOStorage.MaxEntry )
|
if (!sGOStorage.MaxEntry)
|
||||||
{
|
{
|
||||||
barGoLink bar( 1 );
|
barGoLink bar( 1 );
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
@ -7707,7 +7707,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
barGoLink bar( sGOStorage.MaxEntry - 1 );
|
barGoLink bar(sGOStorage.MaxEntry - 1);
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
// collect GO entries for GO that must activated
|
// collect GO entries for GO that must activated
|
||||||
|
|
@ -7715,7 +7715,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
||||||
{
|
{
|
||||||
bar.step();
|
bar.step();
|
||||||
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(go_entry);
|
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(go_entry);
|
||||||
if(!goInfo)
|
if (!goInfo)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch(goInfo->type)
|
switch(goInfo->type)
|
||||||
|
|
@ -7768,7 +7768,7 @@ void ObjectMgr::LoadGameObjectForQuests()
|
||||||
}
|
}
|
||||||
case GAMEOBJECT_TYPE_GOOBER:
|
case GAMEOBJECT_TYPE_GOOBER:
|
||||||
{
|
{
|
||||||
if(goInfo->goober.questId) //quests objects
|
if (goInfo->goober.questId) //quests objects
|
||||||
{
|
{
|
||||||
mGameObjectForQuestSet.insert(go_entry);
|
mGameObjectForQuestSet.insert(go_entry);
|
||||||
count++;
|
count++;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10592"
|
#define REVISION_NR "10593"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue