*Fix usage of grid removal state, thanks Sisif
--HG-- branch : trunk
This commit is contained in:
@@ -1221,29 +1221,24 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
|
||||
{
|
||||
// Add to correct cell
|
||||
CreatureData const* data = objmgr.GetCreatureData(*itr);
|
||||
if (data)
|
||||
if (CreatureData const* data = objmgr.GetCreatureData(*itr))
|
||||
{
|
||||
objmgr.AddCreatureToGrid(*itr, data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||
// We use spawn coords to spawn
|
||||
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX,data->posY))
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
|
||||
{
|
||||
Creature* pCreature = new Creature;
|
||||
//sLog.outDebug("Spawning creature %u",*itr);
|
||||
if (!pCreature->LoadFromDB(*itr, map))
|
||||
{
|
||||
delete pCreature;
|
||||
}
|
||||
else
|
||||
{
|
||||
map->Add(pCreature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
|
||||
{
|
||||
@@ -1254,22 +1249,19 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
|
||||
{
|
||||
// Add to correct cell
|
||||
GameObjectData const* data = objmgr.GetGOData(*itr);
|
||||
if (data)
|
||||
if (GameObjectData const* data = objmgr.GetGOData(*itr))
|
||||
{
|
||||
objmgr.AddGameobjectToGrid(*itr, data);
|
||||
// Spawn if necessary (loaded grids only)
|
||||
// this base map checked as non-instanced and then only existed
|
||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
|
||||
{
|
||||
GameObject* pGameobject = new GameObject;
|
||||
//sLog.outDebug("Spawning gameobject %u", *itr);
|
||||
if (!pGameobject->LoadFromDB(*itr, map))
|
||||
{
|
||||
delete pGameobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGameobject->isSpawnedByDefault())
|
||||
|
||||
@@ -304,6 +304,12 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
||||
return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL;
|
||||
}
|
||||
|
||||
bool IsLoaded(float x, float y) const
|
||||
{
|
||||
GridPair p = Trinity::ComputeGridPair(x, y);
|
||||
return loaded(p);
|
||||
}
|
||||
|
||||
bool GetUnloadLock(const GridPair &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
|
||||
void SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
|
||||
void LoadGrid(float x, float y);
|
||||
|
||||
@@ -1447,7 +1447,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
// We use spawn coords to spawn
|
||||
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
|
||||
if(!map->Instanceable() && map->IsLoaded(x, y))
|
||||
{
|
||||
GameObject *go = new GameObject;
|
||||
if (!go->LoadFromDB(guid, map))
|
||||
|
||||
@@ -229,27 +229,22 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
|
||||
template <>
|
||||
bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
||||
{
|
||||
CreatureData const* data = objmgr.GetCreatureData(guid);
|
||||
if (data)
|
||||
if (CreatureData const* data = objmgr.GetCreatureData(guid))
|
||||
{
|
||||
objmgr.AddCreatureToGrid(guid, data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||
// We use spawn coords to spawn
|
||||
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
|
||||
{
|
||||
Creature* pCreature = new Creature;
|
||||
//sLog.outDebug("Spawning creature %u",guid);
|
||||
if (!pCreature->LoadFromDB(guid, map))
|
||||
{
|
||||
delete pCreature;
|
||||
}
|
||||
else
|
||||
{
|
||||
map->Add(pCreature);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -259,22 +254,19 @@ bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
||||
template <>
|
||||
bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
||||
{
|
||||
GameObjectData const* data = objmgr.GetGOData(guid);
|
||||
if (data)
|
||||
if (GameObjectData const* data = objmgr.GetGOData(guid))
|
||||
{
|
||||
objmgr.AddGameobjectToGrid(guid, data);
|
||||
// Spawn if necessary (loaded grids only)
|
||||
// this base map checked as non-instanced and then only existed
|
||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
|
||||
{
|
||||
GameObject* pGameobject = new GameObject;
|
||||
//sLog.outDebug("Spawning gameobject %u", guid);
|
||||
if (!pGameobject->LoadFromDB(guid, map))
|
||||
{
|
||||
delete pGameobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGameobject->isSpawnedByDefault())
|
||||
|
||||
@@ -93,7 +93,7 @@ class DBCFileLoader
|
||||
uint32 GetRowSize() const { return recordSize; }
|
||||
uint32 GetCols() const { return fieldCount; }
|
||||
uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; }
|
||||
bool IsLoaded() {return (data!=NULL);}
|
||||
bool IsLoaded() { return data != NULL; }
|
||||
char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable, uint32 sqlRecordCount, uint32 sqlHighestIndex, char *& sqlDataTable);
|
||||
char* AutoProduceStrings(const char* fmt, char* dataTable);
|
||||
static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL);
|
||||
|
||||
Reference in New Issue
Block a user