aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-18 20:46:21 -0600
committermegamage <none@none>2009-03-18 20:46:21 -0600
commit249d0d53c0ec073f3b1f3366940a57c8563c3455 (patch)
treeb818c01d87d418c13c49f88c346dd5cd0db838bb
parentef47783882e609406f879856d2d3ce5ee865ec80 (diff)
[7489] Update gameobject rotation fields if need. Author: VladimirMangos
* Fixed update absent in ".gobject turn" command * Propetly set rotation fields for summoned objects * Check rotation/coordinates fields values at server loading --HG-- branch : trunk
-rw-r--r--contrib/extractor/System.cpp1
-rw-r--r--src/game/GameObject.cpp42
-rw-r--r--src/game/GameObject.h2
-rw-r--r--src/game/Level2.cpp13
-rw-r--r--src/game/ObjectMgr.cpp18
-rw-r--r--src/game/SpellEffects.cpp19
6 files changed, 51 insertions, 44 deletions
diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp
index afa2301e487..b656a6ab535 100644
--- a/contrib/extractor/System.cpp
+++ b/contrib/extractor/System.cpp
@@ -33,7 +33,6 @@
#else
#define OPEN_FLAGS (O_RDONLY | O_BINARY)
#endif
-
extern ArchiveSet gOpenArchives;
typedef struct
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 95a83ce6819..00e60395ce4 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -125,28 +125,11 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetFloatValue(GAMEOBJECT_POS_X, x);
SetFloatValue(GAMEOBJECT_POS_Y, y);
SetFloatValue(GAMEOBJECT_POS_Z, z);
- SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle
-
- int64 rotation = 0;
-
- double f_rot1 = sin(ang / 2.0f);
- int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f)));
- rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
-
- //float f_rot2 = sin(0.0f / 2.0f);
- //int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f));
- //rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000;
-
- //float f_rot3 = sin(0.0f / 2.0f);
- //int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f));
- //rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000;
-
- SetUInt64Value(GAMEOBJECT_ROTATION, rotation);
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0);
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1);
- SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
- SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
+
+ UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size);
@@ -1421,3 +1404,24 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const
return GetName();
}
+void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.0f*/)
+{
+ SetFloatValue(GAMEOBJECT_FACING, GetOrientation());
+
+ int64 rotation = 0;
+
+ double f_rot1 = sin(GetOrientation() / 2.0f);
+ int64 i_rot1 = int64(f_rot1 / atan(pow(2.0f, -20.0f)));
+ rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
+
+ SetUInt64Value(GAMEOBJECT_ROTATION, rotation);
+
+ if(rotation2==0.0f && rotation3==0.0f)
+ {
+ rotation2 = sin(GetOrientation()/2);
+ rotation3 = cos(GetOrientation()/2);
+ }
+
+ SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
+ SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
+}
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 07f6c5a4362..89786d6b2d8 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -444,6 +444,8 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
+ void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
+
void Say(int32 textId, uint32 language, uint64 TargetGuid) { MonsterSay(textId,language,TargetGuid); }
void Yell(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYell(textId,language,TargetGuid); }
void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index eea2e237035..4c5a8f51ce0 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1793,17 +1793,11 @@ bool ChatHandler::HandleTurnObjectCommand(const char* args)
o = chr->GetOrientation();
}
- float rot2 = sin(o/2);
- float rot3 = cos(o/2);
-
Map* map = obj->GetMap();
map->Remove(obj,false);
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
-
- obj->SetFloatValue(GAMEOBJECT_FACING, o);
- obj->SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rot2);
- obj->SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rot3);
+ obj->UpdateRotationFields();
map->Add(obj);
@@ -3582,13 +3576,10 @@ bool ChatHandler::HandleGameObjectCommand(const char* args)
float o = float(chr->GetOrientation());
Map *map = chr->GetMap();
- float rot2 = sin(o/2);
- float rot3 = cos(o/2);
-
GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
- if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0, 0, rot2, rot3, 0, 1))
+ if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
{
delete pGameObj;
return false;
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 1045cf982d2..6326ac7ff7a 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -1163,6 +1163,24 @@ void ObjectMgr::LoadGameobjects()
int16 gameEvent = fields[16].GetInt16();
int16 PoolId = fields[17].GetInt16();
+ if(data.rotation2 < -1.0f || data.rotation2 > 1.0f)
+ {
+ sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation2 (%f) value, skip",guid,data.id,data.rotation2 );
+ continue;
+ }
+
+ if(data.rotation3 < -1.0f || data.rotation3 > 1.0f)
+ {
+ sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation3 (%f) value, skip",guid,data.id,data.rotation3 );
+ continue;
+ }
+
+ if(!MapManager::IsValidMapCoord(data.mapid,data.posX,data.posY,data.posZ,data.orientation))
+ {
+ sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid coordinates, skip",guid,data.id );
+ continue;
+ }
+
if(data.phaseMask==0)
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id );
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 30861c2f451..6479a006d8b 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -4625,7 +4625,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
Map *map = target->GetMap();
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
- m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1))
+ m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
{
delete pGameObj;
return;
@@ -4673,7 +4673,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
{
GameObject* linkedGO = new GameObject;
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map,
- m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0, 0, 0, 0, 100, 1))
+ m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
{
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
linkedGO->SetSpellId(m_spellInfo->Id);
@@ -5395,7 +5395,7 @@ void Spell::EffectDuel(uint32 i)
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 ,
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 ,
m_caster->GetPositionZ(),
- m_caster->GetOrientation(), 0, 0, 0, 0, 0, 1))
+ m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
{
delete pGameObj;
return;
@@ -5770,9 +5770,6 @@ void Spell::EffectSummonObject(uint32 i)
GameObject* pGameObj = new GameObject;
- float rot2 = sin(m_caster->GetOrientation()/2);
- float rot3 = cos(m_caster->GetOrientation()/2);
-
float x,y,z;
// If dest location if present
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
@@ -5787,7 +5784,7 @@ void Spell::EffectSummonObject(uint32 i)
Map *map = m_caster->GetMap();
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
- m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0, 0, rot2, rot3, 0, 1))
+ m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1))
{
delete pGameObj;
return;
@@ -6430,7 +6427,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
GameObject* pGameObj = new GameObject;
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
- m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1))
+ m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
{
delete pGameObj;
return;
@@ -6443,10 +6440,6 @@ void Spell::EffectTransmitted(uint32 effIndex)
case GAMEOBJECT_TYPE_FISHINGNODE:
{
m_caster->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT,pGameObj->GetGUID());
- // Orientation3
- pGameObj->SetFloatValue(GAMEOBJECT_PARENTROTATION + 2, 0.88431775569915771 );
- // Orientation4
- pGameObj->SetFloatValue(GAMEOBJECT_PARENTROTATION + 3, -0.4668855369091033 );
m_caster->AddGameObject(pGameObj); // will removed at spell cancel
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
@@ -6501,7 +6494,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
{
GameObject* linkedGO = new GameObject;
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap,
- m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0, 0, 0, 0, 100, 1))
+ m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1))
{
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
//linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );