Core/Scripts: Split OnCreatureCreate() and OnGameObjectCreate() into two virtual functions each.
Note to scripters: be aware that you will need to hook into the Remove functions if you want to do stuff at GO/creature removal. Closes issue 5011. --HG-- branch : trunk
This commit is contained in:
@@ -182,7 +182,7 @@ void Creature::AddToWorld()
|
||||
if (!IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnCreatureCreate(this, true);
|
||||
m_zoneScript->OnCreatureCreate(this);
|
||||
sObjectAccessor.AddObject(this);
|
||||
Unit::AddToWorld();
|
||||
SearchFormation();
|
||||
@@ -197,7 +197,7 @@ void Creature::RemoveFromWorld()
|
||||
if (IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnCreatureCreate(this, false);
|
||||
m_zoneScript->OnCreatureRemove(this);
|
||||
if (m_formation)
|
||||
formation_mgr.RemoveCreatureFromGroup(m_formation, this);
|
||||
Unit::RemoveFromWorld();
|
||||
|
||||
@@ -125,7 +125,7 @@ void GameObject::AddToWorld()
|
||||
if (!IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnGameObjectCreate(this, true);
|
||||
m_zoneScript->OnGameObjectCreate(this);
|
||||
|
||||
sObjectAccessor.AddObject(this);
|
||||
WorldObject::AddToWorld();
|
||||
@@ -138,7 +138,7 @@ void GameObject::RemoveFromWorld()
|
||||
if (IsInWorld())
|
||||
{
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnGameObjectCreate(this, false);
|
||||
m_zoneScript->OnGameObjectRemove(this);
|
||||
|
||||
// Possible crash at access to deleted GO in Unit::m_gameobj
|
||||
if (uint64 owner_guid = GetOwnerGUID())
|
||||
|
||||
@@ -33,8 +33,10 @@ class ZoneScript
|
||||
virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, const CreatureData *data) { return data->id; }
|
||||
virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; }
|
||||
|
||||
virtual void OnCreatureCreate(Creature *, bool /*add*/) {}
|
||||
virtual void OnGameObjectCreate(GameObject * /*go*/, bool /*add*/) {}
|
||||
virtual void OnCreatureCreate(Creature *) {}
|
||||
virtual void OnCreatureRemove(Creature *) {}
|
||||
virtual void OnGameObjectCreate(GameObject *) {}
|
||||
virtual void OnGameObjectRemove(GameObject *) {}
|
||||
|
||||
//All-purpose data storage 64 bit
|
||||
virtual uint64 GetData64(uint32 /*DataId*/) { return 0; }
|
||||
|
||||
@@ -590,11 +590,11 @@ void OutdoorPvP::TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2)
|
||||
TeamCastSpell(OTHER_TEAM(team), spellId2 ? -(int32)spellId2 : -(int32)spellId);
|
||||
}
|
||||
|
||||
void OutdoorPvP::OnGameObjectCreate(GameObject *go, bool add)
|
||||
void OutdoorPvP::OnGameObjectCreate(GameObject *go)
|
||||
{
|
||||
if (go->GetGoType() != GAMEOBJECT_TYPE_CAPTURE_POINT)
|
||||
return;
|
||||
|
||||
if (OPvPCapturePoint *cp = GetCapturePoint(go->GetDBTableGUIDLow()))
|
||||
cp->m_capturePoint = add ? go : NULL;
|
||||
cp->m_capturePoint = go;
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ class OutdoorPvP : public ZoneScript
|
||||
// setup stuff
|
||||
virtual bool SetupOutdoorPvP() {return true;}
|
||||
|
||||
void OnGameObjectCreate(GameObject *go, bool add);
|
||||
void OnCreatureCreate(Creature *, bool /*add*/) {}
|
||||
void OnGameObjectCreate(GameObject *go);
|
||||
void OnCreatureCreate(Creature *) {}
|
||||
|
||||
// send world state update to all players present
|
||||
void SendUpdateWorldState(uint32 field, uint32 value);
|
||||
|
||||
Reference in New Issue
Block a user