Skip to content

Commit

Permalink
[10145] Use better (but still hack) way for gameobject size calculation
Browse files Browse the repository at this point in the history
* This is also hack because some float with unknown exactly value used as 'size'
* Another not resolved problem: go size used in creature target autoselection, so for large 'virtual' go
  creature can seelct strange points near in attempt select 'free' place near target.
  • Loading branch information
VladimirMangos committed Jul 3, 2010
1 parent 9d4e7e9 commit 4351c20
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/game/DBCStructure.h
Expand Up @@ -867,7 +867,8 @@ struct GameObjectDisplayInfoEntry
uint32 Displayid; // 0 m_ID
// char* filename; // 1
// uint32 unknown2[10]; // 2-11 unknown data
// float unknown12[6]; // 12-17 unknown data
float unknown12; // 12-17 unknown size data, use first value as interact dist, mostly in hacks way
// float unknown13[5]; // 12-17 unknown size data
// uint32 unknown18; // 18 unknown data
};

Expand Down
2 changes: 1 addition & 1 deletion src/game/DBCfmt.h
Expand Up @@ -46,7 +46,7 @@ const char EmotesEntryfmt[]="nxxiiix";
const char EmotesTextEntryfmt[]="nxixxxxxxxxxxxxxxxx";
const char FactionEntryfmt[]="niiiiiiiiiiiiiiiiiixxxxssssssssssssssssxxxxxxxxxxxxxxxxxx";
const char FactionTemplateEntryfmt[]="niiiiiiiiiiiii";
const char GameObjectDisplayInfofmt[]="nxxxxxxxxxxxxxxxxxx";
const char GameObjectDisplayInfofmt[]="nxxxxxxxxxxxfxxxxxx";
const char GemPropertiesEntryfmt[]="nixxi";
const char GlyphPropertiesfmt[]="niii";
const char GlyphSlotfmt[]="nii";
Expand Down
11 changes: 11 additions & 0 deletions src/game/GameObject.cpp
Expand Up @@ -1515,3 +1515,14 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
// common faction based case (GvC,GvP)
return tester_faction->IsFriendlyTo(*target_faction);
}

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();

return DEFAULT_WORLD_OBJECT_SIZE;
}
2 changes: 2 additions & 0 deletions src/game/GameObject.h
Expand Up @@ -660,6 +660,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }

float GetObjectBoundingRadius() const; // overwrite WorldObject version

void Use(Unit* user);

LootState getLootState() const { return m_lootState; }
Expand Down
5 changes: 1 addition & 4 deletions src/game/Object.h
Expand Up @@ -371,10 +371,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
GetNearPoint(obj, x, y, z, obj->GetObjectBoundingRadius(), distance2d, GetAngle(obj));
}

float GetObjectBoundingRadius() const
{
return ( m_valuesCount > UNIT_FIELD_BOUNDINGRADIUS ) ? m_floatValues[UNIT_FIELD_BOUNDINGRADIUS] : DEFAULT_WORLD_OBJECT_SIZE;
}
virtual float GetObjectBoundingRadius() const { return DEFAULT_WORLD_OBJECT_SIZE; }

bool IsPositionValid() const;
void UpdateGroundPositionZ(float x, float y, float &z) const;
Expand Down
4 changes: 2 additions & 2 deletions src/game/Player.cpp
Expand Up @@ -2312,8 +2312,8 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo
if (go->IsWithinDistInMap(this, maxdist) && go->isSpawned())
return go;

sLog.outError("GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal 10 is allowed)", go->GetGOInfo()->name,
go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this));
sLog.outError("GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal %f is allowed)",
go->GetGOInfo()->name, go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this), maxdist);
}
}
return NULL;
Expand Down
5 changes: 5 additions & 0 deletions src/game/Unit.h
Expand Up @@ -1110,6 +1110,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject

void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)

float GetObjectBoundingRadius() const // overwrite WorldObject version
{
return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS];
}

DiminishingLevels GetDiminishing(DiminishingGroup group);
void IncrDiminishing(DiminishingGroup group);
void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level, int32 limitduration);
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 "10144"
#define REVISION_NR "10145"
#endif // __REVISION_NR_H__

0 comments on commit 4351c20

Please sign in to comment.