mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
feat(Core/Scripts): new OnBeforeFinalizePlayerWorldSession() hook (#7136)
Co-authored-by: Yehonal <yehonal.azeroth@gmail.com>
This commit is contained in:
3
doc/changelog/pendings/changes_1629216324271376300.md
Normal file
3
doc/changelog/pendings/changes_1629216324271376300.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `OnBeforeFinalizePlayerWorldSession ` that can be used to modify the cache version that is sent to the client via modules.
|
||||||
@@ -408,6 +408,11 @@ void ScriptMgr::OnAfterConfigLoad(bool reload)
|
|||||||
FOREACH_SCRIPT(WorldScript)->OnAfterConfigLoad(reload);
|
FOREACH_SCRIPT(WorldScript)->OnAfterConfigLoad(reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion)
|
||||||
|
{
|
||||||
|
FOREACH_SCRIPT(WorldScript)->OnBeforeFinalizePlayerWorldSession(cacheVersion);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::OnMotdChange(std::string& newMotd)
|
void ScriptMgr::OnMotdChange(std::string& newMotd)
|
||||||
{
|
{
|
||||||
FOREACH_SCRIPT(WorldScript)->OnMotdChange(newMotd);
|
FOREACH_SCRIPT(WorldScript)->OnMotdChange(newMotd);
|
||||||
|
|||||||
@@ -194,6 +194,13 @@ public:
|
|||||||
|
|
||||||
// Called when the world is actually shut down.
|
// Called when the world is actually shut down.
|
||||||
virtual void OnShutdown() { }
|
virtual void OnShutdown() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This hook runs before finalizing the player world session. Can be also used to mutate the cache version of the Client.
|
||||||
|
*
|
||||||
|
* @param version The cache version that we will be sending to the Client.
|
||||||
|
*/
|
||||||
|
virtual void OnBeforeFinalizePlayerWorldSession(uint32& /*cacheVersion*/) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FormulaScript : public ScriptObject
|
class FormulaScript : public ScriptObject
|
||||||
@@ -1466,6 +1473,7 @@ public: /* WorldScript */
|
|||||||
void OnOpenStateChange(bool open);
|
void OnOpenStateChange(bool open);
|
||||||
void OnBeforeConfigLoad(bool reload);
|
void OnBeforeConfigLoad(bool reload);
|
||||||
void OnAfterConfigLoad(bool reload);
|
void OnAfterConfigLoad(bool reload);
|
||||||
|
void OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion);
|
||||||
void OnMotdChange(std::string& newMotd);
|
void OnMotdChange(std::string& newMotd);
|
||||||
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
|
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
|
||||||
void OnShutdownCancel();
|
void OnShutdownCancel();
|
||||||
|
|||||||
@@ -312,9 +312,8 @@ void World::AddSession_(WorldSession* s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s->SendAuthResponse(AUTH_OK, true);
|
s->SendAuthResponse(AUTH_OK, true);
|
||||||
s->SendAddonsInfo();
|
|
||||||
s->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
|
FinalizePlayerWorldSession(s);
|
||||||
s->SendTutorialsData();
|
|
||||||
|
|
||||||
UpdateMaxSessionCounters();
|
UpdateMaxSessionCounters();
|
||||||
}
|
}
|
||||||
@@ -397,11 +396,9 @@ bool World::RemoveQueuedPlayer(WorldSession* sess)
|
|||||||
pop_sess->SetInQueue(false);
|
pop_sess->SetInQueue(false);
|
||||||
pop_sess->ResetTimeOutTime(false);
|
pop_sess->ResetTimeOutTime(false);
|
||||||
pop_sess->SendAuthWaitQue(0);
|
pop_sess->SendAuthWaitQue(0);
|
||||||
pop_sess->SendAddonsInfo();
|
|
||||||
|
|
||||||
pop_sess->SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
|
|
||||||
pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
|
pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
|
||||||
pop_sess->SendTutorialsData();
|
|
||||||
|
FinalizePlayerWorldSession(pop_sess);
|
||||||
|
|
||||||
m_QueuedPlayer.pop_front();
|
m_QueuedPlayer.pop_front();
|
||||||
|
|
||||||
@@ -3480,3 +3477,13 @@ uint32 World::GetNextWhoListUpdateDelaySecs()
|
|||||||
|
|
||||||
return uint32(ceil(t / 1000.0f));
|
return uint32(ceil(t / 1000.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::FinalizePlayerWorldSession(WorldSession* session)
|
||||||
|
{
|
||||||
|
uint32 cacheVersion = sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION);
|
||||||
|
sScriptMgr->OnBeforeFinalizePlayerWorldSession(cacheVersion);
|
||||||
|
|
||||||
|
session->SendAddonsInfo();
|
||||||
|
session->SendClientCacheVersion(cacheVersion);
|
||||||
|
session->SendTutorialsData();
|
||||||
|
}
|
||||||
|
|||||||
@@ -486,6 +486,13 @@ private:
|
|||||||
|
|
||||||
void ProcessQueryCallbacks();
|
void ProcessQueryCallbacks();
|
||||||
QueryCallbackProcessor _queryProcessor;
|
QueryCallbackProcessor _queryProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Executed when a World Session is being finalized. Be it from a normal login or via queue popping.
|
||||||
|
*
|
||||||
|
* @param session The World Session that we are finalizing.
|
||||||
|
*/
|
||||||
|
inline void FinalizePlayerWorldSession(WorldSession* session);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IWorld>& getWorldInstance();
|
std::unique_ptr<IWorld>& getWorldInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user