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_
|
#define SCRIPT_OBJECT_ACCOUNT_SCRIPT_H_
|
||||||
|
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum AccountHook
|
enum AccountHook
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum ArenaHook
|
enum ArenaHook
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Battleground.h"
|
#include "Battleground.h"
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum ArenaTeamHook
|
enum ArenaTeamHook
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define SCRIPT_OBJECT_AUCTION_HOUSE_SCRIPT_H_
|
#define SCRIPT_OBJECT_AUCTION_HOUSE_SCRIPT_H_
|
||||||
|
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum AuctionHouseHook
|
enum AuctionHouseHook
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum MovementHook
|
enum MovementHook
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ void ScriptMgr::Initialize()
|
|||||||
|
|
||||||
_script_loader_callback();
|
_script_loader_callback();
|
||||||
_modules_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()
|
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.
|
// With this approach, we wouldn't call all available hooks in case if we override just one hook.
|
||||||
static EnabledHooksVector EnabledHooks;
|
static EnabledHooksVector EnabledHooks;
|
||||||
|
|
||||||
|
static void InitEnabledHooksIfNeeded(uint16 totalAvailableHooks)
|
||||||
|
{
|
||||||
|
EnabledHooks.resize(totalAvailableHooks);
|
||||||
|
}
|
||||||
|
|
||||||
static void AddScript(TScript* const script, std::vector<uint16> enabledHooks = {})
|
static void AddScript(TScript* const script, std::vector<uint16> enabledHooks = {})
|
||||||
{
|
{
|
||||||
ASSERT(script);
|
ASSERT(script);
|
||||||
@@ -733,7 +738,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (EnabledHooks.empty())
|
if (EnabledHooks.empty())
|
||||||
EnabledHooks.resize(script->GetTotalAvailableHooks());
|
InitEnabledHooksIfNeeded(script->GetTotalAvailableHooks());
|
||||||
|
|
||||||
if (script->isAfterLoadScript())
|
if (script->isAfterLoadScript())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user