*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)
|
for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
|
||||||
{
|
{
|
||||||
// Add to correct cell
|
// Add to correct cell
|
||||||
CreatureData const* data = objmgr.GetCreatureData(*itr);
|
if (CreatureData const* data = objmgr.GetCreatureData(*itr))
|
||||||
if (data)
|
|
||||||
{
|
{
|
||||||
objmgr.AddCreatureToGrid(*itr, data);
|
objmgr.AddCreatureToGrid(*itr, data);
|
||||||
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||||
// We use spawn coords to spawn
|
// 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;
|
Creature* pCreature = new Creature;
|
||||||
//sLog.outDebug("Spawning creature %u",*itr);
|
//sLog.outDebug("Spawning creature %u",*itr);
|
||||||
if (!pCreature->LoadFromDB(*itr, map))
|
if (!pCreature->LoadFromDB(*itr, map))
|
||||||
{
|
|
||||||
delete pCreature;
|
delete pCreature;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
map->Add(pCreature);
|
map->Add(pCreature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
|
if(internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
|
||||||
{
|
{
|
||||||
@@ -1254,25 +1249,22 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
|||||||
for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
|
for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
|
||||||
{
|
{
|
||||||
// Add to correct cell
|
// Add to correct cell
|
||||||
GameObjectData const* data = objmgr.GetGOData(*itr);
|
if (GameObjectData const* data = objmgr.GetGOData(*itr))
|
||||||
if (data)
|
|
||||||
{
|
{
|
||||||
objmgr.AddGameobjectToGrid(*itr, data);
|
objmgr.AddGameobjectToGrid(*itr, data);
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
// this base map checked as non-instanced and then only existed
|
// this base map checked as non-instanced and then only existed
|
||||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
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
|
// 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;
|
GameObject* pGameobject = new GameObject;
|
||||||
//sLog.outDebug("Spawning gameobject %u", *itr);
|
//sLog.outDebug("Spawning gameobject %u", *itr);
|
||||||
if (!pGameobject->LoadFromDB(*itr, map))
|
if (!pGameobject->LoadFromDB(*itr, map))
|
||||||
{
|
|
||||||
delete pGameobject;
|
delete pGameobject;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pGameobject->isSpawnedByDefault())
|
if (pGameobject->isSpawnedByDefault())
|
||||||
map->Add(pGameobject);
|
map->Add(pGameobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
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(); }
|
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 SetUnloadLock(const GridPair &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
|
||||||
void LoadGrid(float x, float y);
|
void LoadGrid(float x, float y);
|
||||||
|
|||||||
@@ -1447,10 +1447,10 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
|
|||||||
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
|
if(!map->Instanceable() && map->IsLoaded(x, y))
|
||||||
{
|
{
|
||||||
GameObject *go = new GameObject;
|
GameObject *go = new GameObject;
|
||||||
if(!go->LoadFromDB(guid, map))
|
if (!go->LoadFromDB(guid, map))
|
||||||
{
|
{
|
||||||
sLog.outError("AddGOData: cannot add gameobject entry %u to map", entry);
|
sLog.outError("AddGOData: cannot add gameobject entry %u to map", entry);
|
||||||
delete go;
|
delete go;
|
||||||
|
|||||||
@@ -229,27 +229,22 @@ void PoolGroup<T>::SpawnObject(uint32 limit, bool cache)
|
|||||||
template <>
|
template <>
|
||||||
bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
||||||
{
|
{
|
||||||
CreatureData const* data = objmgr.GetCreatureData(guid);
|
if (CreatureData const* data = objmgr.GetCreatureData(guid))
|
||||||
if (data)
|
|
||||||
{
|
{
|
||||||
objmgr.AddCreatureToGrid(guid, data);
|
objmgr.AddCreatureToGrid(guid, data);
|
||||||
|
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
||||||
// We use spawn coords to spawn
|
// 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;
|
Creature* pCreature = new Creature;
|
||||||
//sLog.outDebug("Spawning creature %u",guid);
|
//sLog.outDebug("Spawning creature %u",guid);
|
||||||
if (!pCreature->LoadFromDB(guid, map))
|
if (!pCreature->LoadFromDB(guid, map))
|
||||||
{
|
|
||||||
delete pCreature;
|
delete pCreature;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
map->Add(pCreature);
|
map->Add(pCreature);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -259,22 +254,19 @@ bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
|
|||||||
template <>
|
template <>
|
||||||
bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
|
||||||
{
|
{
|
||||||
GameObjectData const* data = objmgr.GetGOData(guid);
|
if (GameObjectData const* data = objmgr.GetGOData(guid))
|
||||||
if (data)
|
|
||||||
{
|
{
|
||||||
objmgr.AddGameobjectToGrid(guid, data);
|
objmgr.AddGameobjectToGrid(guid, data);
|
||||||
// Spawn if necessary (loaded grids only)
|
// Spawn if necessary (loaded grids only)
|
||||||
// this base map checked as non-instanced and then only existed
|
// this base map checked as non-instanced and then only existed
|
||||||
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
|
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
|
// 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;
|
GameObject* pGameobject = new GameObject;
|
||||||
//sLog.outDebug("Spawning gameobject %u", guid);
|
//sLog.outDebug("Spawning gameobject %u", guid);
|
||||||
if (!pGameobject->LoadFromDB(guid, map))
|
if (!pGameobject->LoadFromDB(guid, map))
|
||||||
{
|
|
||||||
delete pGameobject;
|
delete pGameobject;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pGameobject->isSpawnedByDefault())
|
if (pGameobject->isSpawnedByDefault())
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ class DBCFileLoader
|
|||||||
Record getRecord(size_t id);
|
Record getRecord(size_t id);
|
||||||
/// Get begin iterator over records
|
/// Get begin iterator over records
|
||||||
|
|
||||||
uint32 GetNumRows() const { return recordCount;}
|
uint32 GetNumRows() const { return recordCount; }
|
||||||
uint32 GetRowSize() const { return recordSize;}
|
uint32 GetRowSize() const { return recordSize; }
|
||||||
uint32 GetCols() const { return fieldCount; }
|
uint32 GetCols() const { return fieldCount; }
|
||||||
uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; }
|
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* AutoProduceData(const char* fmt, uint32& count, char**& indexTable, uint32 sqlRecordCount, uint32 sqlHighestIndex, char *& sqlDataTable);
|
||||||
char* AutoProduceStrings(const char* fmt, char* dataTable);
|
char* AutoProduceStrings(const char* fmt, char* dataTable);
|
||||||
static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL);
|
static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user