aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Grids/ObjectGridLoader.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2017-07-31 21:23:26 +0200
committerTreeston <treeston.mmoc@gmail.com>2017-07-31 21:23:26 +0200
commit232db9777a3425891f55b5b94a02fa619adafcb5 (patch)
tree558af5bb20ba40d7dcdbbf06a5b4e9eddf0b2664 /src/server/game/Grids/ObjectGridLoader.cpp
parentd24ce1739a799042d5a164794c09674227c8572c (diff)
parent59db2eeea0a35028779fd76372ae06cc98c8086f (diff)
Merge remote-tracking branch 'base/dynamic_spawning' into 3.3.5 (PR #19056).
IT'S HAPPENING.
Diffstat (limited to 'src/server/game/Grids/ObjectGridLoader.cpp')
-rw-r--r--src/server/game/Grids/ObjectGridLoader.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/server/game/Grids/ObjectGridLoader.cpp b/src/server/game/Grids/ObjectGridLoader.cpp
index 653c9d51d11..6400e1532a6 100644
--- a/src/server/game/Grids/ObjectGridLoader.cpp
+++ b/src/server/game/Grids/ObjectGridLoader.cpp
@@ -27,6 +27,7 @@
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "World.h"
+#include "ScriptMgr.h"
void ObjectGridEvacuator::Visit(CreatureMapType &m)
{
@@ -119,15 +120,47 @@ void LoadHelper(CellGuidSet const& guid_set, CellCoord &cell, GridRefManager<T>
for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{
T* obj = new T;
- ObjectGuid::LowType guid = *i_guid;
- //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid);
- if (!obj->LoadFromDB(guid, map))
+
+ // Don't spawn at all if there's a respawn time
+ if ((obj->GetTypeId() == TYPEID_UNIT && !map->GetCreatureRespawnTime(*i_guid)) || (obj->GetTypeId() == TYPEID_GAMEOBJECT && !map->GetGORespawnTime(*i_guid)))
{
- delete obj;
- continue;
- }
+ ObjectGuid::LowType guid = *i_guid;
+ //TC_LOG_INFO("misc", "DEBUG: LoadHelper from table: %s for (guid: %u) Loading", table, guid);
- AddObjectHelper(cell, m, count, map, obj);
+ if (obj->GetTypeId() == TYPEID_UNIT)
+ {
+ CreatureData const* cdata = sObjectMgr->GetCreatureData(guid);
+ ASSERT(cdata, "Tried to load creature with spawnId %u, but no such creature exists.", guid);
+ SpawnGroupTemplateData const* const group = cdata->spawnGroupData;
+ // If creature in manual spawn group, don't spawn here, unless group is already active.
+ if ((group->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN) && !group->isActive)
+ continue;
+
+ // If script is blocking spawn, don't spawn but queue for a re-check in a little bit
+ if (!(group->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE) && !sScriptMgr->CanSpawn(guid, cdata->id, cdata, map))
+ {
+ map->SaveRespawnTime(SPAWN_TYPE_CREATURE, guid, cdata->id, time(NULL) + urand(4,7), map->GetZoneId(cdata->spawnPoint), Trinity::ComputeGridCoord(cdata->spawnPoint.GetPositionX(), cdata->spawnPoint.GetPositionY()).GetId(), false);
+ continue;
+ }
+ }
+ else if (obj->GetTypeId() == TYPEID_GAMEOBJECT)
+ {
+ // If gameobject in manual spawn group, don't spawn here, unless group is already active.
+ GameObjectData const* godata = sObjectMgr->GetGameObjectData(guid);
+ ASSERT(godata, "Tried to load gameobject with spawnId %u, but no such object exists.", guid);
+ if ((godata->spawnGroupData->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN) && !godata->spawnGroupData->isActive)
+ continue;
+ }
+
+ if (!obj->LoadFromDB(guid, map, false, false))
+ {
+ delete obj;
+ continue;
+ }
+ AddObjectHelper(cell, m, count, map, obj);
+ }
+ else
+ delete obj;
}
}