feat(Core/DB): Add Hooks On creature/game object save to db (#11246)
* implement OnCreatureSaveToDB and OnGameObjectSaveToDB Hooks * fix Whitespaces in ScriptMgr.h Co-authored-by: Timothée Moos <t1997.m@gmx.net>
This commit is contained in:
@@ -1416,6 +1416,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||||||
trans->Append(stmt);
|
trans->Append(stmt);
|
||||||
|
|
||||||
WorldDatabase.CommitTransaction(trans);
|
WorldDatabase.CommitTransaction(trans);
|
||||||
|
sScriptMgr->OnCreatureSaveToDB(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::SelectLevel(bool changelevel)
|
void Creature::SelectLevel(bool changelevel)
|
||||||
|
|||||||
@@ -1061,6 +1061,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
WorldDatabase.CommitTransaction(trans);
|
WorldDatabase.CommitTransaction(trans);
|
||||||
|
sScriptMgr->OnGameObjectSaveToDB(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap)
|
bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap)
|
||||||
|
|||||||
@@ -38,6 +38,16 @@ void ScriptMgr::OnCreatureRemoveWorld(Creature* creature)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnCreatureSaveToDB(Creature* creature)
|
||||||
|
{
|
||||||
|
ASSERT(creature);
|
||||||
|
|
||||||
|
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
||||||
|
{
|
||||||
|
script->OnCreatureSaveToDB(creature);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
|
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
|
||||||
{
|
{
|
||||||
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
|
||||||
|
|||||||
@@ -37,3 +37,13 @@ void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go)
|
|||||||
script->OnGameObjectRemoveWorld(go);
|
script->OnGameObjectRemoveWorld(go);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGameObjectSaveToDB(GameObject* go)
|
||||||
|
{
|
||||||
|
ASSERT(go);
|
||||||
|
|
||||||
|
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
|
||||||
|
{
|
||||||
|
script->OnGameObjectSaveToDB(go);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -561,6 +561,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void OnCreatureRemoveWorld(Creature* /*creature*/) { }
|
virtual void OnCreatureRemoveWorld(Creature* /*creature*/) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This hook runs after creature has been saved to DB
|
||||||
|
*
|
||||||
|
* @param creature Contains information about the Creature
|
||||||
|
*/
|
||||||
|
virtual void OnCreatureSaveToDB(Creature* /*creature*/) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This hook called when a player opens a gossip dialog with the creature.
|
* @brief This hook called when a player opens a gossip dialog with the creature.
|
||||||
*
|
*
|
||||||
@@ -643,7 +650,12 @@ public:
|
|||||||
* @param go Contains information about the GameObject
|
* @param go Contains information about the GameObject
|
||||||
*/
|
*/
|
||||||
virtual void OnGameObjectAddWorld(GameObject* /*go*/) { }
|
virtual void OnGameObjectAddWorld(GameObject* /*go*/) { }
|
||||||
|
/**
|
||||||
|
* @brief This hook runs after the game object iis saved to the database
|
||||||
|
*
|
||||||
|
* @param go Contains information about the GameObject
|
||||||
|
*/
|
||||||
|
virtual void OnGameObjectSaveToDB(GameObject* /*go*/) { }
|
||||||
/**
|
/**
|
||||||
* @brief This hook runs after remove game object in world
|
* @brief This hook runs after remove game object in world
|
||||||
*
|
*
|
||||||
@@ -2392,6 +2404,10 @@ public: /* AllCreatureScript */
|
|||||||
//listener function (OnAllCreatureUpdate) is called by OnCreatureUpdate
|
//listener function (OnAllCreatureUpdate) is called by OnCreatureUpdate
|
||||||
//void OnAllCreatureUpdate(Creature* creature, uint32 diff);
|
//void OnAllCreatureUpdate(Creature* creature, uint32 diff);
|
||||||
void Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature);
|
void Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature);
|
||||||
|
void OnCreatureSaveToDB(Creature* creature);
|
||||||
|
|
||||||
|
public: /* AllGameobjectScript */
|
||||||
|
void OnGameObjectSaveToDB(GameObject* go);
|
||||||
|
|
||||||
public: /* AllMapScript */
|
public: /* AllMapScript */
|
||||||
void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask);
|
void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask);
|
||||||
|
|||||||
Reference in New Issue
Block a user