mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[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:
parent
47060fe4b1
commit
9a8a74c2ad
8 changed files with 231 additions and 65 deletions
|
|
@ -710,24 +710,12 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
|||
|
||||
sObjectMgr.AddCreatureToGrid(*itr, data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
if (Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid)))
|
||||
{
|
||||
// We use spawn coords to spawn
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX,data->posY))
|
||||
{
|
||||
Creature* pCreature = new Creature;
|
||||
//DEBUG_LOG("Spawning creature %u",*itr);
|
||||
if (!pCreature->LoadFromDB(*itr, map))
|
||||
{
|
||||
delete pCreature;
|
||||
}
|
||||
else
|
||||
{
|
||||
map->Add(pCreature);
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME: gameevent system can't work correctly in instanceable maps while object sin instances use dynamic guids
|
||||
// Current code prevent wrong way work until switch to use static guids for instance objects
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
|
||||
|
||||
if (mapEntry && !mapEntry->Instanceable())
|
||||
Creature::SpawnInMaps(*itr, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -757,26 +745,12 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
|||
|
||||
sObjectMgr.AddGameobjectToGrid(*itr, data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
// this base map checked as non-instanced and then only existing
|
||||
if (Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid)))
|
||||
{
|
||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
|
||||
{
|
||||
GameObject* pGameobject = new GameObject;
|
||||
//DEBUG_LOG("Spawning gameobject %u", *itr);
|
||||
if (!pGameobject->LoadFromDB(*itr, map))
|
||||
{
|
||||
delete pGameobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pGameobject->isSpawnedByDefault())
|
||||
map->Add(pGameobject);
|
||||
}
|
||||
}
|
||||
}
|
||||
// FIXME: gameevent system can't work correctly in instanceable maps while object sin instances use dynamic guids
|
||||
// Current code prevent wrong way work until switch to use static guids for instance objects
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
|
||||
|
||||
if (mapEntry && !mapEntry->Instanceable())
|
||||
GameObject::SpawnInMaps(*itr, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -819,10 +793,11 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
|
|||
}
|
||||
}
|
||||
|
||||
// Remove spawn data
|
||||
sObjectMgr.RemoveCreatureFromGrid(*itr, data);
|
||||
|
||||
if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, *itr)))
|
||||
pCreature->AddObjectToRemoveList();
|
||||
// Remove spawned cases
|
||||
Creature::AddToRemoveListInMaps(*itr, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -848,10 +823,11 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
|
|||
}
|
||||
}
|
||||
|
||||
// Remove spawn data
|
||||
sObjectMgr.RemoveGameobjectFromGrid(*itr, data);
|
||||
|
||||
if( GameObject* pGameobject = ObjectAccessor::GetGameObjectInWorld(ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, *itr)) )
|
||||
pGameobject->AddObjectToRemoveList();
|
||||
// Remove spawned cases
|
||||
GameObject::AddToRemoveListInMaps(*itr, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -894,6 +870,29 @@ GameEventCreatureData const* GameEventMgr::GetCreatureUpdateDataForActiveEvent(u
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct GameEventUpdateCreatureDataInMapsWorker
|
||||
{
|
||||
GameEventUpdateCreatureDataInMapsWorker(ObjectGuid guid, CreatureData const* data, GameEventCreatureData* event_data, bool activate)
|
||||
: i_guid(guid), i_data(data), i_event_data(event_data), i_activate(activate) {}
|
||||
|
||||
void operator() (Map* map)
|
||||
{
|
||||
if (Creature* pCreature = map->GetCreature(i_guid))
|
||||
{
|
||||
pCreature->UpdateEntry(i_data->id, TEAM_NONE, i_data, i_activate ? i_event_data : NULL);
|
||||
|
||||
// spells not casted for event remove case (sent NULL into update), do it
|
||||
if (!i_activate)
|
||||
pCreature->ApplyGameEventSpells(i_event_data, false);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectGuid i_guid;
|
||||
CreatureData const* i_data;
|
||||
GameEventCreatureData* i_event_data;
|
||||
bool i_activate;
|
||||
};
|
||||
|
||||
void GameEventMgr::UpdateCreatureData(int16 event_id, bool activate)
|
||||
{
|
||||
for(GameEventCreatureDataList::iterator itr = mGameEventCreatureData[event_id].begin();itr != mGameEventCreatureData[event_id].end();++itr)
|
||||
|
|
@ -904,14 +903,8 @@ void GameEventMgr::UpdateCreatureData(int16 event_id, bool activate)
|
|||
continue;
|
||||
|
||||
// Update if spawned
|
||||
if (Creature* pCreature = ObjectAccessor::GetCreatureInWorld(ObjectGuid(HIGHGUID_UNIT, data->id, itr->first)))
|
||||
{
|
||||
pCreature->UpdateEntry(data->id, TEAM_NONE, data, activate ? &itr->second : NULL);
|
||||
|
||||
// spells not casted for event remove case (sent NULL into update), do it
|
||||
if (!activate)
|
||||
pCreature->ApplyGameEventSpells(&itr->second, false);
|
||||
}
|
||||
GameEventUpdateCreatureDataInMapsWorker worker(ObjectGuid(HIGHGUID_UNIT, data->id, itr->first), data, &itr->second, activate);
|
||||
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue