Skip to content

Commit

Permalink
[11381] Add methods GetDisplayId/SetDisplayId for gameobjects
Browse files Browse the repository at this point in the history
Useful for GO type 33
  • Loading branch information
zergtmn committed Apr 19, 2011
1 parent f8dffb8 commit 53a222b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
18 changes: 12 additions & 6 deletions src/game/GameObject.cpp
Expand Up @@ -39,7 +39,9 @@
#include "Util.h"
#include "ScriptMgr.h"

GameObject::GameObject() : WorldObject()
GameObject::GameObject() : WorldObject(),
m_goInfo(NULL),
m_displayInfo(NULL)
{
m_objectType |= TYPEMASK_GAMEOBJECT;
m_objectTypeId = TYPEID_GAMEOBJECT;
Expand All @@ -54,7 +56,6 @@ GameObject::GameObject() : WorldObject()
m_useTimes = 0;
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = NULL;

m_rotation = 0;
}
Expand Down Expand Up @@ -140,8 +141,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetFlag(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN));

SetEntry(goinfo->id);

SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId);
SetDisplayId(goinfo->displayId);

// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
SetGoState(go_state);
Expand Down Expand Up @@ -1749,13 +1749,19 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
return tester_faction->IsFriendlyTo(*target_faction);
}

void GameObject::SetDisplayId(uint32 modelId)
{
SetUInt32Value(GAMEOBJECT_DISPLAYID, modelId);
m_displayInfo = sGameObjectDisplayInfoStore.LookupEntry(modelId);
}

float GameObject::GetObjectBoundingRadius() const
{
//FIXME:
// 1. This is clearly hack way because GameObjectDisplayInfoEntry have 6 floats related to GO sizes, but better that use DEFAULT_WORLD_OBJECT_SIZE
// 2. In some cases this must be only interactive size, not GO size, current way can affect creature target point auto-selection in strange ways for big underground/virtual GOs
if (GameObjectDisplayInfoEntry const* dispEntry = sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId))
return fabs(dispEntry->unknown12) * GetObjectScale();
if (m_displayInfo)
return fabs(m_displayInfo->unknown12) * GetObjectScale();

return DEFAULT_WORLD_OBJECT_SIZE;
}
Expand Down
3 changes: 3 additions & 0 deletions src/game/GameObject.h
Expand Up @@ -670,6 +670,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); }
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
void SetDisplayId(uint32 modelId);

float GetObjectBoundingRadius() const; // overwrite WorldObject version

Expand Down Expand Up @@ -739,6 +741,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
GuidsSet m_UniqueUsers; // all players who use item, some items activated after specific amount unique uses

GameObjectInfo const* m_goInfo;
GameObjectDisplayInfoEntry const* m_displayInfo;

This comment has been minimized.

Copy link
@rsa

rsa Apr 19, 2011

Contributor

need add
struct GameObjectDisplayInfoEntry
in top of header.

This comment has been minimized.

Copy link
@technoir42

technoir42 Apr 19, 2011

Contributor

Thanks. Fixed in 11382

uint64 m_rotation;
private:
void SwitchDoorOrButton(bool activate, bool alternative = false);
Expand Down
2 changes: 1 addition & 1 deletion src/game/Transports.cpp
Expand Up @@ -178,7 +178,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
SetUInt32Value(GAMEOBJECT_LEVEL, m_period);
SetEntry(goinfo->id);

SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId);
SetDisplayId(goinfo->displayId);

SetGoState(GO_STATE_READY);
SetGoType(GameobjectTypes(goinfo->type));
Expand Down
4 changes: 2 additions & 2 deletions src/game/Unit.h
Expand Up @@ -1781,9 +1781,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject

uint32 m_AuraFlags;

uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
void SetDisplayId(uint32 modelId);
uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11380"
#define REVISION_NR "11381"
#endif // __REVISION_NR_H__

0 comments on commit 53a222b

Please sign in to comment.