fix build, codestyle and add enabled hooks list for performance improvement

This commit is contained in:
Ludwig
2025-02-27 08:38:11 +01:00
parent cfae767a8a
commit b57a36e667

View File

@@ -1,7 +1,7 @@
#include "Config.h"
#include "ScriptMgr.h"
#include "Chat.h" #include "Chat.h"
#include "Config.h"
#include "Player.h" #include "Player.h"
#include "ScriptMgr.h"
#include <set> // Required for std::set -- might be redundant #include <set> // Required for std::set -- might be redundant
#include <sstream> // Required for std::istringstream -- might be redundant #include <sstream> // Required for std::istringstream -- might be redundant
#include <string> // Required for std::string -- might be redundant #include <string> // Required for std::string -- might be redundant
@@ -12,7 +12,9 @@ class AccountMounts : public PlayerScript
std::set<uint32> excludedSpellIds; // Set to hold the Spell IDs to be excluded std::set<uint32> excludedSpellIds; // Set to hold the Spell IDs to be excluded
public: public:
AccountMounts() : PlayerScript("AccountMounts") AccountMounts() : PlayerScript("AccountMounts", {
PLAYERHOOK_ON_LOGIN
})
{ {
// Retrieve the string of excluded Spell IDs from the config file // Retrieve the string of excluded Spell IDs from the config file
std::string excludedSpellsStr = sConfigMgr->GetOption<std::string>("Account.Mounts.ExcludedSpellIDs", ""); std::string excludedSpellsStr = sConfigMgr->GetOption<std::string>("Account.Mounts.ExcludedSpellIDs", "");
@@ -21,23 +23,21 @@ public:
{ {
std::istringstream spellStream(excludedSpellsStr); std::istringstream spellStream(excludedSpellsStr);
std::string spellIdStr; std::string spellIdStr;
while (std::getline(spellStream, spellIdStr, ',')) { while (std::getline(spellStream, spellIdStr, ','))
{
uint32 spellId = static_cast<uint32>(std::stoul(spellIdStr)); uint32 spellId = static_cast<uint32>(std::stoul(spellIdStr));
if (spellId != 0) { // Ensure the spell ID is not 0, as 0 is used to indicate no exclusions if (spellId != 0) // Ensure the spell ID is not 0, as 0 is used to indicate no exclusions
excludedSpellIds.insert(spellId); // Add the Spell ID to the set of exclusions excludedSpellIds.insert(spellId); // Add the Spell ID to the set of exclusions
}
} }
} }
} }
void OnLogin(Player* pPlayer) void OnPlayerLogin(Player* pPlayer)
{ {
if (sConfigMgr->GetOption<bool>("Account.Mounts.Enable", true)) if (sConfigMgr->GetOption<bool>("Account.Mounts.Enable", true))
{ {
if (sConfigMgr->GetOption<bool>("Account.Mounts.Announce", false)) if (sConfigMgr->GetOption<bool>("Account.Mounts.Announce", false))
{
ChatHandler(pPlayer->GetSession()).SendSysMessage("This server is running the |cff4CFF00AccountMounts |rmodule."); ChatHandler(pPlayer->GetSession()).SendSysMessage("This server is running the |cff4CFF00AccountMounts |rmodule.");
}
std::vector<uint32> Guids; std::vector<uint32> Guids;
uint32 playerAccountID = pPlayer->GetSession()->GetAccountId(); uint32 playerAccountID = pPlayer->GetSession()->GetAccountId();