diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2016-07-30 18:50:44 -0300 |
|---|---|---|
| committer | joschiwald <joschiwald.trinity@gmail.com> | 2017-02-11 20:50:29 +0100 |
| commit | c429e7d4899b51bba5df9bf0be0acee4ecc38cb7 (patch) | |
| tree | f0ebcb546932cc092ef92841c0d53a0649a0829a /src/server/game/Entities | |
| parent | 02cef6f034804eb7291f7539936226c0552cad7f (diff) | |
Core/Entities: debloat SummonGameObject parameter list using proper wrappers and enable GO rotation in scripts
- There's still an overload allowing for x, y, z, o to be passed directly
- Fixed default animstate for GameObject creation in many places, it should be 255, not 100 (checked in sniffs)
(cherry picked from commit 62bfee37cb21584cef631dda428feaf5eb829cda)
# Conflicts:
# src/server/game/Battlefield/Battlefield.cpp
# src/server/game/Battlegrounds/Battleground.cpp
# src/server/game/Entities/GameObject/GameObject.cpp
# src/server/game/Entities/GameObject/GameObject.h
# src/server/game/Entities/Object/Object.cpp
# src/server/game/Entities/Object/Object.h
# src/server/game/Spells/SpellEffects.cpp
# src/server/scripts/Commands/cs_gobject.cpp
# src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp
# src/server/scripts/EasternKingdoms/ZulAman/zulaman.cpp
# src/server/scripts/Kalimdor/zone_feralas.cpp
# src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
# src/server/scripts/Northrend/Nexus/EyeOfEternity/instance_eye_of_eternity.cpp
# src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 19 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 27 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 5 |
4 files changed, 32 insertions, 21 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 2e5f8b43280..760e1f23d7e 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -178,16 +178,16 @@ void GameObject::RemoveFromWorld() } } -bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) +bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, Position const& pos, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit /*= 0*/) { ASSERT(map); SetMap(map); - Relocate(x, y, z, ang); - m_stationaryPosition.Relocate(x, y, z, ang); + Relocate(pos); + m_stationaryPosition.Relocate(pos); if (!IsPositionValid()) { - TC_LOG_ERROR("misc", "Gameobject (Spawn id: " UI64FMTD " Entry: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", GetSpawnId(), name_id, x, y); + TC_LOG_ERROR("misc", "Gameobject (Spawn id: " UI64FMTD " Entry: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", GetSpawnId(), name_id, pos.GetPositionX(), pos.GetPositionY()); return false; } @@ -202,7 +202,7 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x, GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id); if (!goinfo) { - TC_LOG_ERROR("sql.sql", "Gameobject (Spawn id: " UI64FMTD " Entry: %u) not created: non-existing entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f)", GetSpawnId(), name_id, map->GetId(), x, y, z); + TC_LOG_ERROR("sql.sql", "Gameobject (Spawn id: " UI64FMTD " Entry: %u) not created: non-existing entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f)", GetSpawnId(), name_id, map->GetId(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); return false; } @@ -895,17 +895,14 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo uint32 entry = data->id; //uint32 map_id = data->mapid; // already used before call uint32 phaseMask = data->phaseMask; - float x = data->posX; - float y = data->posY; - float z = data->posZ; - float ang = data->orientation; + Position pos(data->posX, data->posY, data->posZ, data->orientation); uint32 animprogress = data->animprogress; GOState go_state = data->go_state; uint32 artKit = data->artKit; m_spawnId = spawnId; - if (!Create(entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit)) + if (!Create(entry, map, phaseMask, pos, data->rotation, animprogress, go_state, artKit)) return false; if (data->phaseid) @@ -934,7 +931,7 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId); // ready to respawn - if (m_respawnTime && m_respawnTime <= time(NULL)) + if (m_respawnTime && m_respawnTime <= time(nullptr)) { m_respawnTime = 0; GetMap()->RemoveGORespawnTime(m_spawnId); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 55c5c473e95..1cd3ff88552 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -943,7 +943,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> void RemoveFromWorld() override; void CleanupsBeforeDelete(bool finalCleanup = true) override; - bool Create(uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0); + bool Create(uint32 name_id, Map* map, uint32 phaseMask, Position const& pos, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0); void Update(uint32 p_time) override; GameObjectTemplate const* GetGOInfo() const { return m_goInfo; } GameObjectTemplateAddon const* GetTemplateAddon() const { return m_goTemplateAddon; } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 67cde258ed9..3d6f7498d9b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2449,7 +2449,7 @@ Scenario* WorldObject::GetScenario() const return nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const +TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 duration /*= 0*/, uint32 /*vehId = 0*/) const { if (Map* map = FindMap()) { @@ -2460,7 +2460,7 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempS } } - return NULL; + return nullptr; } TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang /*= 0*/, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despwtime /*= 0*/) const @@ -2470,29 +2470,30 @@ TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, fl GetClosePoint(x, y, z, GetObjectSize()); ang = GetOrientation(); } + Position pos; pos.Relocate(x, y, z, ang); return SummonCreature(id, pos, spwtype, despwtime, 0); } -GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime) +GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, G3D::Quat const& rot, uint32 respawnTime) { if (!IsInWorld()) - return NULL; + return nullptr; GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); if (!goinfo) { TC_LOG_ERROR("sql.sql", "Gameobject template %u not found in database!", entry); - return NULL; + return nullptr; } Map* map = GetMap(); GameObject* go = new GameObject(); - if (!go->Create(entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY)) + if (!go->Create(entry, map, GetPhaseMask(), pos, rot, 255, GO_STATE_READY)) { delete go; - return NULL; + return nullptr; } go->CopyPhaseFrom(this); @@ -2507,6 +2508,18 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float return go; } +GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, G3D::Quat const& rot, uint32 respawnTime) +{ + if (!x && !y && !z) + { + GetClosePoint(x, y, z, GetObjectSize()); + ang = GetOrientation(); + } + + Position pos(x, y, z, ang); + return SummonGameObject(entry, pos, rot, respawnTime); +} + Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint32 duration, CreatureAI* (*GetAI)(Creature*)) { TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 4e8b37a086d..5b7b324a70e 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -646,9 +646,10 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation Scenario* GetScenario() const; - TempSummon* SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const; + TempSummon* SummonCreature(uint32 id, Position const& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const; TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0) const; - GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime /* s */); + GameObject* SummonGameObject(uint32 entry, Position const& pos, G3D::Quat const& rot, uint32 respawnTime /* s */); + GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, G3D::Quat const& rot, uint32 respawnTime /* s */); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = NULL); |
