aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Utilities/EventProcessor.cpp21
-rw-r--r--src/common/Utilities/EventProcessor.h8
-rw-r--r--src/server/game/Entities/Object/Object.cpp18
-rw-r--r--src/server/game/Entities/Object/Object.h6
4 files changed, 24 insertions, 29 deletions
diff --git a/src/common/Utilities/EventProcessor.cpp b/src/common/Utilities/EventProcessor.cpp
index 2cba5476c7d..3895b767aec 100644
--- a/src/common/Utilities/EventProcessor.cpp
+++ b/src/common/Utilities/EventProcessor.cpp
@@ -110,29 +110,24 @@ void EventProcessor::KillAllEvents(bool force)
m_events.clear();
}
-void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
+void EventProcessor::AddEvent(BasicEvent* event, uint64 e_time, bool set_addtime)
{
if (set_addtime)
- Event->m_addTime = m_time;
- Event->m_execTime = e_time;
- m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
+ event->m_addTime = m_time;
+ event->m_execTime = e_time;
+ m_events.insert(std::pair<uint64, BasicEvent*>(e_time, event));
}
-void EventProcessor::ModifyEventTime(BasicEvent* Event, uint64 newTime)
+void EventProcessor::ModifyEventTime(BasicEvent* event, uint64 newTime)
{
for (auto itr = m_events.begin(); itr != m_events.end(); ++itr)
{
- if (itr->second != Event)
+ if (itr->second != event)
continue;
- Event->m_execTime = newTime;
+ event->m_execTime = newTime;
m_events.erase(itr);
- m_events.insert(std::pair<uint64, BasicEvent*>(newTime, Event));
+ m_events.insert(std::pair<uint64, BasicEvent*>(newTime, event));
break;
}
}
-
-uint64 EventProcessor::CalculateTime(uint64 t_offset) const
-{
- return(m_time + t_offset);
-}
diff --git a/src/common/Utilities/EventProcessor.h b/src/common/Utilities/EventProcessor.h
index 5195158b608..591db59b935 100644
--- a/src/common/Utilities/EventProcessor.h
+++ b/src/common/Utilities/EventProcessor.h
@@ -19,6 +19,7 @@
#define __EVENTPROCESSOR_H
#include "Define.h"
+#include "Duration.h"
#include <map>
class EventProcessor;
@@ -75,9 +76,10 @@ class TC_COMMON_API EventProcessor
void Update(uint32 p_time);
void KillAllEvents(bool force);
- void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
- void ModifyEventTime(BasicEvent* Event, uint64 newTime);
- uint64 CalculateTime(uint64 t_offset) const;
+ void AddEvent(BasicEvent* event, uint64 e_time, bool set_addtime = true);
+ void AddEventAtOffset(BasicEvent* event, Milliseconds const& offset) { AddEvent(event, CalculateTime(offset.count())); }
+ void ModifyEventTime(BasicEvent* event, uint64 newTime);
+ uint64 CalculateTime(uint64 t_offset) const { return m_time + t_offset; }
std::multimap<uint64, BasicEvent*> const& GetEvents() const { return m_events; }
protected:
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 9b3a730d8b4..22970a8950e 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1822,13 +1822,13 @@ Scenario* WorldObject::GetScenario() const
return nullptr;
}
-TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 duration /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
+TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
{
if (Map* map = FindMap())
{
- if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, duration, ToUnit(), 0, vehId, visibleBySummonerOnly))
+ if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime, ToUnit(), 0, vehId, visibleBySummonerOnly))
{
- summon->SetTempSummonType(spwtype);
+ summon->SetTempSummonType(despawnType);
return summon;
}
}
@@ -1836,17 +1836,13 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS
return nullptr;
}
-TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang /*= 0*/, TempSummonType spwtype /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despwtime /*= 0*/, bool visibleBySummonerOnly /*= false*/)
+TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, uint32 despawnTime /*= 0*/, bool visibleBySummonerOnly /*= false*/)
{
if (!x && !y && !z)
- {
GetClosePoint(x, y, z, GetCombatReach());
- ang = GetOrientation();
- }
-
- Position pos;
- pos.Relocate(x, y, z, ang);
- return SummonCreature(id, pos, spwtype, despwtime, 0, visibleBySummonerOnly);
+ if (!o)
+ o = GetOrientation();
+ return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, visibleBySummonerOnly);
}
GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime)
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 5efc9825bc7..781c1a4b9dc 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -19,6 +19,7 @@
#define _OBJECT_H
#include "Common.h"
+#include "Duration.h"
#include "GridReference.h"
#include "GridRefManager.h"
#include "ModelIgnoreFlags.h"
@@ -503,8 +504,9 @@ 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, bool visibleBySummonerOnly = false);
- TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, bool visibleBySummonerOnly = false);
+ TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, bool visibleBySummonerOnly = false);
+ TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds const& despawnTime, uint32 vehId = 0, bool visibleBySummonerOnly = false) { SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, visibleBySummonerOnly); }
+ TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, bool visibleBySummonerOnly = false);
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime /* s */);
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, uint32 respawnTime /* s */);
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = nullptr);