diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 62a3c650d..6d5f42dc9 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1353,7 +1353,17 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) } m_DBTableGuid = guid; - if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); + if (map->GetInstanceId() == 0) + { + // Creature can be loaded already in map if grid has been unloaded while creature walk to another grid + // FIXME: until creature guids is global and for instances used dynamic generated guids + // in instance possible load creature duplicates with same DB guid but different in game guids + // This will be until implementing per-map creature guids + if (map->GetCreature(MAKE_NEW_GUID(guid,data->id,HIGHGUID_UNIT))) + return false; + } + else + guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); uint16 team = 0; if(!Create(guid,map,data->phaseMask,data->id,team,data)) diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index 1282a7b2d..b2096c074 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -104,17 +104,6 @@ template<> void addUnitState(Creature *obj, CellPair const& cell_pair) obj->SetCurrentCell(cell); } -template bool alreadyLoaded(Map* /*map*/, uint32 /*guid*/) -{ - // Non creature objects not walk by grids - return false; -} - -template<> bool alreadyLoaded(Map* map, uint32 guid) -{ - return map->GetObjectsStore().find(guid,(Creature*)NULL); -} - template void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager &m, uint32 &count, Map* map) { @@ -124,13 +113,6 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager & { uint32 guid = *i_guid; - // Note: this will fully correct work only at non-instanced maps, - // at instanced maps will use dynamic selected guid - // and then duplicate just will not detected and will be 2 creature with identical DB guid - // with some chance - if (alreadyLoaded(map,guid)) - continue; // still loaded in another grid (move from respawn [this] grid early), we not need second copy - T* obj = new T; //sLog.outString("DEBUG: LoadHelper from table: %s for (guid: %u) Loading",table,guid); if(!obj->LoadFromDB(guid, map)) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e11f574e1..adcb65644 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8752" + #define REVISION_NR "8753" #endif // __REVISION_NR_H__