feat(Core/Scripts): Optimize PlayerScripts by calling only overridden/implemented functions. (#18672)

* feat(Core/Scripts): Optimize PlayerScripts by calling only overridden/implemented functions.

* Fix codestyle.

* Fix typo

* PLAYERHOOK_END is not a hook

* Address code review feedback.

Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com>

* Codestyle fixes

* Fix typo



Co-authored-by: PkllonG

---------

Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com>
This commit is contained in:
Anton Popovichenko
2024-04-11 22:08:30 +02:00
committed by GitHub
parent fd029f81aa
commit f792b0d708
11 changed files with 452 additions and 1054 deletions

View File

@@ -153,7 +153,7 @@ uint32 const GoBonfireCity[COUNT_GO_BONFIRE_CITY] = { 181332, 181333, 181334, 18
class MidsummerPlayerScript : public PlayerScript
{
public:
MidsummerPlayerScript() : PlayerScript("MidsummerPlayerScript")
MidsummerPlayerScript() : PlayerScript("MidsummerPlayerScript", {PLAYERHOOK_ON_UPDATE_ZONE})
{
}

View File

@@ -169,7 +169,15 @@ public:
class CharacterActionIpLogger : public PlayerScript
{
public:
CharacterActionIpLogger() : PlayerScript("CharacterActionIpLogger") { }
CharacterActionIpLogger() :
PlayerScript("CharacterActionIpLogger",
{
PLAYERHOOK_ON_CREATE,
PLAYERHOOK_ON_LOGIN,
PLAYERHOOK_ON_LOGOUT
})
{
}
// CHARACTER_CREATE = 7
void OnCreate(Player* player) override
@@ -256,7 +264,14 @@ public:
class CharacterDeleteActionIpLogger : public PlayerScript
{
public:
CharacterDeleteActionIpLogger() : PlayerScript("CharacterDeleteActionIpLogger") { }
CharacterDeleteActionIpLogger() :
PlayerScript("CharacterDeleteActionIpLogger",
{
PLAYERHOOK_ON_DELETE,
PLAYERHOOK_ON_FAILED_DELETE
})
{
}
// CHARACTER_DELETE = 10
void OnDelete(ObjectGuid guid, uint32 accountId) override

View File

@@ -25,7 +25,17 @@
class ChatLogScript : public PlayerScript
{
public:
ChatLogScript() : PlayerScript("ChatLogScript") { }
ChatLogScript() :
PlayerScript("ChatLogScript",
{
PLAYERHOOK_ON_CHAT,
PLAYERHOOK_ON_CHAT_WITH_GROUP,
PLAYERHOOK_ON_CHAT_WITH_GUILD,
PLAYERHOOK_ON_CHAT_WITH_CHANNEL,
PLAYERHOOK_ON_CHAT_WITH_RECEIVER
})
{
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg) override
{

View File

@@ -27,7 +27,7 @@ enum ApprenticeAnglerQuestEnum
class QuestApprenticeAnglerPlayerScript : public PlayerScript
{
public:
QuestApprenticeAnglerPlayerScript() : PlayerScript("QuestApprenticeAnglerPlayerScript")
QuestApprenticeAnglerPlayerScript() : PlayerScript("QuestApprenticeAnglerPlayerScript", {PLAYERHOOK_ON_PLAYER_COMPLETE_QUEST})
{
}

View File

@@ -24,7 +24,7 @@
class ServerMailReward : public PlayerScript
{
public:
ServerMailReward() : PlayerScript("ServerMailReward") { }
ServerMailReward() : PlayerScript("ServerMailReward", {PLAYERHOOK_ON_LOGIN}) { }
// CHARACTER_LOGIN = 8
void OnLogin(Player* player) override