diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index e77530f96..4d2f248b3 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -68,7 +68,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) Object::_Create( guidlow, 0, HIGHGUID_CONTAINER ); SetEntry(itemid); - SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); + SetObjectScale(DEFAULT_OBJECT_SCALE); SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0); diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 3beb2bda6..9e80e08df 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -90,7 +90,7 @@ bool Corpse::Create( uint32 guidlow, Player *owner) return false; } - SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); + SetObjectScale(DEFAULT_OBJECT_SCALE); SetUInt64Value( CORPSE_FIELD_OWNER, owner->GetGUID() ); m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY()); @@ -185,7 +185,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE)); SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(playerGuid, 0, HIGHGUID_PLAYER)); - SetFloatValue( OBJECT_FIELD_SCALE_X, 1.0f ); + SetObjectScale(DEFAULT_OBJECT_SCALE); PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class); if(!info) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 4305b3be7..759e20416 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -221,6 +221,8 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) SetEntry(Entry); // normal entry always m_creatureInfo = cinfo; // map mode related always + SetObjectScale(cinfo->scale); + // equal to player Race field, but creature does not have race SetByteValue(UNIT_FIELD_BYTES_0, 0, 0); @@ -272,8 +274,6 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) SetSpeedRate(MOVE_SWIM, 1.0f); // using 1.0 rate SetSpeedRate(MOVE_FLIGHT, 1.0f); // using 1.0 rate - SetFloatValue(OBJECT_FIELD_SCALE_X, cinfo->scale); - // checked at loading m_defaultMovementType = MovementGeneratorType(cinfo->MovementType); diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 9c55c6b17..ff10001fa 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -71,7 +71,8 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellE } SetEntry(spellId); - SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); + SetObjectScale(DEFAULT_OBJECT_SCALE); + SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() ); SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 ); SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId ); diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index a446784bb..9b2c7e0f6 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -126,13 +126,13 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa return false; } + SetObjectScale(goinfo->size); + SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0); SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1); UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3 - SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); - SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 146d735e0..191196818 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -251,7 +251,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner) Object::_Create( guidlow, 0, HIGHGUID_ITEM ); SetEntry(itemid); - SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); + SetObjectScale(DEFAULT_OBJECT_SCALE); SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0); SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0); diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 60150af00..fcb819b4b 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -1335,7 +1335,7 @@ bool ChatHandler::HandleModifyScaleCommand(const char* args) ChatHandler((Player*)target).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale); } - target->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); + target->SetObjectScale(Scale); return true; } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index fc7693df4..4d6e45e88 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -122,6 +122,14 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh ) m_PackGUID.Set(guid); } +void Object::SetObjectScale(float newScale) +{ + if (newScale <= 0.0f) + newScale = DEFAULT_OBJECT_SCALE; + + SetFloatValue(OBJECT_FIELD_SCALE_X, newScale); +} + void Object::BuildMovementUpdateBlock(UpdateData * data, uint16 flags ) const { ByteBuffer buf(500); diff --git a/src/game/Object.h b/src/game/Object.h index 5ae719791..a1be3d9bc 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -38,6 +38,8 @@ #define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards #define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects +#define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc + #define MAX_STEALTH_DETECT_RANGE 45.0f uint32 GuidHigh2TypeId(uint32 guid_hi); @@ -116,6 +118,13 @@ class MANGOS_DLL_SPEC Object uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); } + float GetObjectScale() const + { + return m_floatValues[OBJECT_FIELD_SCALE_X] ? m_floatValues[OBJECT_FIELD_SCALE_X] : DEFAULT_OBJECT_SCALE; + } + + void SetObjectScale(float newScale); + uint8 GetTypeId() const { return m_objectTypeId; } bool isType(uint16 mask) const { return (mask & m_objectType); } @@ -366,6 +375,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object { return ( m_valuesCount > UNIT_FIELD_BOUNDINGRADIUS ) ? m_floatValues[UNIT_FIELD_BOUNDINGRADIUS] : DEFAULT_WORLD_OBJECT_SIZE; } + bool IsPositionValid() const; void UpdateGroundPositionZ(float x, float y, float &z) const; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 2579242d4..0dd4cd59d 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -754,7 +754,7 @@ void ObjectMgr::LoadCreatureTemplates() if(displayScaleEntry) const_cast(cInfo)->scale = displayScaleEntry->scale; else - const_cast(cInfo)->scale = 1.0f; + const_cast(cInfo)->scale = DEFAULT_OBJECT_SCALE; } } } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 395ea51ed..5f947c39e 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -834,7 +834,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) else scale = cFamily->minScale + float(getLevel() - cFamily->minScaleLevel) / cFamily->maxScaleLevel * (cFamily->maxScale - cFamily->minScale); - SetFloatValue(OBJECT_FIELD_SCALE_X, scale); + SetObjectScale(scale); } m_bonusdamage = 0; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 91026bbe6..4de1a9e7b 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2704,8 +2704,8 @@ void Player::InitStatsForLevel(bool reapplyMods) // set default cast time multiplier SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); - // reset size before reapply auras - SetFloatValue(OBJECT_FIELD_SCALE_X,1.0f); + // reset scale before reapply auras + SetObjectScale(DEFAULT_OBJECT_SCALE); // save base values (bonuses already included in stored stats for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index b54152df5..2473a187b 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -161,7 +161,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, m_goInfo = goinfo; - SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); + SetObjectScale(goinfo->size); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); //SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a5e09251c..994a1e4c3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10109" + #define REVISION_NR "10110" #endif // __REVISION_NR_H__