[11138] Make sure GameEvent/Pool systems work with static instance object guids

* Pool System for correct full power work in instance need implement
  MapPersistentState local pool system state for instanceable maps.
  Unit this not implemented pool system must avoid creating/despawn/touch
  instance map objects. Currently this work because instance map object use
  dynamic generated guids and "invisible" for Pool System, with explcitly forbiden
  for it spawn directly new objects. Code changes add explicit checks for preserve
  this way work for time when instance object will use static guids. When local pool
  state storing in persistent state this protection checks will possible drop.
  Non-instanced working cases converted in local map object search calls.

* GameEvent Systems currently have code that work correctly only with objects at
  non-instanced maps by same reasons as Pool System. But in different Pool System
  case game event activate/deactivate expected applied to _all_ object copies in all
  existed instanceable map copies. Code modified for work in expected way.
  Direct spawn disabled for instanceable maps until swith to static guids.
  Despawn code will make affect only for non-instanceavble maps unit swithc to static guids as-is.
  This is preserve current code working result.

* Convert last case usage global creature search in aura code to map local case.
  Player case also possible not need now after including caster damage/heal mods
  part to aura base damage/heal. In any cases player case preserved in old way work.

NOTE: this last places dependent from global creature/gameobject guid search so look like this
      make possible start direct work to switch instances use static guids instead dynamic generated
This commit is contained in:
VladimirMangos 2011-02-11 23:17:39 +03:00
parent 47060fe4b1
commit 9a8a74c2ad
8 changed files with 231 additions and 65 deletions

View file

@ -2407,3 +2407,56 @@ void Creature::FillGuidsListFromThreatList( std::vector<ObjectGuid>& guids, uint
for (ThreatList::const_iterator itr = threats.begin(); maxamount && itr != threats.end(); ++itr, --maxamount)
guids.push_back((*itr)->getUnitGuid());
}
struct AddCaretureToRemoveListInMapsWorker
{
AddCaretureToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {}
void operator() (Map* map)
{
if (Creature* pCreature = map->GetCreature(i_guid))
pCreature->AddObjectToRemoveList();
}
ObjectGuid i_guid;
};
void Creature::AddToRemoveListInMaps(uint32 db_guid, CreatureData const* data)
{
AddCaretureToRemoveListInMapsWorker worker(ObjectGuid(HIGHGUID_UNIT, data->id, db_guid));
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
}
struct SpawnCreatureInMapsWorker
{
SpawnCreatureInMapsWorker(uint32 guid, CreatureData const* data)
: i_guid(guid), i_data(data) {}
void operator() (Map* map)
{
// We use spawn coords to spawn
if (map->IsLoaded(i_data->posX, i_data->posY))
{
Creature* pCreature = new Creature;
//DEBUG_LOG("Spawning creature %u",*itr);
if (!pCreature->LoadFromDB(i_guid, map))
{
delete pCreature;
}
else
{
map->Add(pCreature);
}
}
}
uint32 i_guid;
CreatureData const* i_data;
};
void Creature::SpawnInMaps(uint32 db_guid, CreatureData const* data)
{
SpawnCreatureInMapsWorker worker(db_guid, data);
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
}