mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 11:25:42 +00:00
fix(Core/Scripts): Fix build and crash when calling uninitialized scripts (#18718)
fix(Core/Scripts): Fix build and crash when calling uninitialized scripts.
This commit is contained in:
committed by
GitHub
parent
f05200fcca
commit
3a6231cb65
@@ -19,6 +19,7 @@
|
||||
#define SCRIPT_OBJECT_ACCOUNT_SCRIPT_H_
|
||||
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum AccountHook
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "ObjectGuid.h"
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum ArenaHook
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Battleground.h"
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum ArenaTeamHook
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define SCRIPT_OBJECT_AUCTION_HOUSE_SCRIPT_H_
|
||||
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum AuctionHouseHook
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Object.h"
|
||||
#include "ScriptObject.h"
|
||||
#include <vector>
|
||||
|
||||
enum MovementHook
|
||||
{
|
||||
|
||||
@@ -77,6 +77,12 @@ void ScriptMgr::Initialize()
|
||||
|
||||
_script_loader_callback();
|
||||
_modules_loader_callback();
|
||||
|
||||
ScriptRegistry<PlayerScript>::InitEnabledHooksIfNeeded(PLAYERHOOK_END);
|
||||
ScriptRegistry<AuctionHouseScript>::InitEnabledHooksIfNeeded(AUCTIONHOUSEHOOK_END);
|
||||
ScriptRegistry<ArenaTeamScript>::InitEnabledHooksIfNeeded(ARENATEAMHOOK_END);
|
||||
ScriptRegistry<ArenaScript>::InitEnabledHooksIfNeeded(ARENAHOOK_END);
|
||||
ScriptRegistry<MovementHandlerScript>::InitEnabledHooksIfNeeded(MOVEMENTHOOK_END);
|
||||
}
|
||||
|
||||
void ScriptMgr::Unload()
|
||||
|
||||
@@ -725,6 +725,11 @@ public:
|
||||
// With this approach, we wouldn't call all available hooks in case if we override just one hook.
|
||||
static EnabledHooksVector EnabledHooks;
|
||||
|
||||
static void InitEnabledHooksIfNeeded(uint16 totalAvailableHooks)
|
||||
{
|
||||
EnabledHooks.resize(totalAvailableHooks);
|
||||
}
|
||||
|
||||
static void AddScript(TScript* const script, std::vector<uint16> enabledHooks = {})
|
||||
{
|
||||
ASSERT(script);
|
||||
@@ -733,7 +738,7 @@ public:
|
||||
return;
|
||||
|
||||
if (EnabledHooks.empty())
|
||||
EnabledHooks.resize(script->GetTotalAvailableHooks());
|
||||
InitEnabledHooksIfNeeded(script->GetTotalAvailableHooks());
|
||||
|
||||
if (script->isAfterLoadScript())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user