From f444ef80ab94be381a0cd5da2237edbb25f472df Mon Sep 17 00:00:00 2001 From: Ludwig Date: Wed, 26 Feb 2025 08:39:57 +0100 Subject: [PATCH 1/4] fix build and add enabled hook lists for performance improvement --- src/mod_congratsonlevel.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/mod_congratsonlevel.cpp b/src/mod_congratsonlevel.cpp index 1fc52c1..eb4b9de 100644 --- a/src/mod_congratsonlevel.cpp +++ b/src/mod_congratsonlevel.cpp @@ -117,25 +117,27 @@ class CongratsAnnounce : public PlayerScript public: - CongratsAnnounce() : PlayerScript("CongratsAnnounce") {} + CongratsAnnounce() : PlayerScript("CongratsAnnounce", { + PLAYERHOOK_ON_LOGIN + }) {} - void OnLogin(Player* player) + void OnPlayerLogin(Player* player) { // Announce Module if (col.congratsAnnounce) - { ChatHandler(player->GetSession()).SendSysMessage(col.acoreMessageId); - } } }; class CongratsOnLevel : public PlayerScript { public: - CongratsOnLevel() : PlayerScript("CongratsOnLevel") { } + CongratsOnLevel() : PlayerScript("CongratsOnLevel", { + PLAYERHOOK_ON_LEVEL_CHANGED + }) { } // Level Up Rewards - void OnLevelChanged(Player* player, uint8 oldLevel) override + void OnPlayerLevelChanged(Player* player, uint8 oldLevel) override { // If enabled... if (col.congratsEnable) @@ -148,72 +150,56 @@ public: case 10: { if (oldLevel < 10) - { money = giveAward(player); - } } break; case 20: { if (oldLevel < 20) - { money = giveAward(player); - } } break; case 30: { if (oldLevel < 30) - { money = giveAward(player); - } } break; case 40: { if (oldLevel < 40) - { money = giveAward(player); - } } break; case 50: { if (oldLevel < 50) - { money = giveAward(player); - } } break; case 60: { if (oldLevel < 60) - { money = giveAward(player); - } } break; case 70: { if (oldLevel < 70) - { money = giveAward(player); - } } break; case 80: { if (oldLevel < 80) - { money = giveAward(player); - } } break; @@ -311,7 +297,9 @@ public: class ModCongratsLevelWorldScript : public WorldScript { public: - ModCongratsLevelWorldScript() : WorldScript("ModCongratsLevelWorldScript") { } + ModCongratsLevelWorldScript() : WorldScript("ModCongratsLevelWorldScript", { + WORLDHOOK_ON_BEFORE_CONFIG_LOAD + }) { } void OnBeforeConfigLoad(bool reload) override { From 793fc6ade3fa846d803ae76ecba399d0997f2c48 Mon Sep 17 00:00:00 2001 From: Ludwig Date: Wed, 26 Feb 2025 08:49:55 +0100 Subject: [PATCH 2/4] restore braces --- src/mod_congratsonlevel.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mod_congratsonlevel.cpp b/src/mod_congratsonlevel.cpp index eb4b9de..0385ef9 100644 --- a/src/mod_congratsonlevel.cpp +++ b/src/mod_congratsonlevel.cpp @@ -150,56 +150,72 @@ public: case 10: { if (oldLevel < 10) + { money = giveAward(player); + } } break; case 20: { if (oldLevel < 20) + { money = giveAward(player); + } } break; case 30: { if (oldLevel < 30) + { money = giveAward(player); + } } break; case 40: { if (oldLevel < 40) + { money = giveAward(player); + } } break; case 50: { if (oldLevel < 50) + { money = giveAward(player); + } } break; case 60: { if (oldLevel < 60) + { money = giveAward(player); + } } break; case 70: { if (oldLevel < 70) + { money = giveAward(player); + } } break; case 80: { if (oldLevel < 80) + { money = giveAward(player); + } } break; @@ -237,7 +253,7 @@ public: } // If level is defined, they hit a reward level. - if (!level && col.CongratsPerLevelEnable) + if (!level) { // Issue a server notification for the player on level up. std::ostringstream ss; From 0f8ee189b1bf20239507d4cd7cd2f7a7e8286c00 Mon Sep 17 00:00:00 2001 From: Ludwig Date: Wed, 26 Feb 2025 08:50:31 +0100 Subject: [PATCH 3/4] fix unintended changes --- src/mod_congratsonlevel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod_congratsonlevel.cpp b/src/mod_congratsonlevel.cpp index 0385ef9..54b1148 100644 --- a/src/mod_congratsonlevel.cpp +++ b/src/mod_congratsonlevel.cpp @@ -253,7 +253,7 @@ public: } // If level is defined, they hit a reward level. - if (!level) + if (!level && col.CongratsPerLevelEnable) { // Issue a server notification for the player on level up. std::ostringstream ss; From d1336842062b68ffca23b91c3650e51a3e68bc45 Mon Sep 17 00:00:00 2001 From: Ludwig Date: Wed, 26 Feb 2025 10:12:16 +0100 Subject: [PATCH 4/4] fix for WorldSessionMgr --- src/mod_congratsonlevel.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mod_congratsonlevel.cpp b/src/mod_congratsonlevel.cpp index 54b1148..9861aaf 100644 --- a/src/mod_congratsonlevel.cpp +++ b/src/mod_congratsonlevel.cpp @@ -64,9 +64,10 @@ config file for quick modifications. */ #include "Configuration/Config.h" -#include "ScriptMgr.h" -#include "Player.h" #include "Chat.h" +#include "Player.h" +#include "ScriptMgr.h" +#include "WorldSessionMgr.h" struct COL { @@ -249,7 +250,7 @@ public: default: break; } - sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str()); + sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str()); } // If level is defined, they hit a reward level. @@ -278,7 +279,7 @@ public: default: break; } - sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str()); + sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str()); // Issue a raid warning to the player std::ostringstream ss2;