From 98aea06a8e640f3e00083160f55e8218f642abc9 Mon Sep 17 00:00:00 2001 From: valsan-azerty-boi <52854501+valsan-azerty-boi@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:37:16 +0200 Subject: [PATCH 1/2] Exclude map/instance from Solocraft scaling with conf --- .gitignore | 5 +++++ conf/Solocraft.conf.dist | 12 ++++++++++++ src/Solocraft.cpp | 30 ++++++++++++++++++++++++------ src/utils/Utils.cpp | 16 ++++++++++++++++ src/utils/Utils.h | 20 ++++++++++++++++++++ 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 src/utils/Utils.cpp create mode 100644 src/utils/Utils.h diff --git a/.gitignore b/.gitignore index c6e1299..bd7065f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,8 @@ local.properties .loadpath .project .cproject + +# +# Visual Studio Code +# +.vscode/ diff --git a/conf/Solocraft.conf.dist b/conf/Solocraft.conf.dist index b37ae34..1e72470 100644 --- a/conf/Solocraft.conf.dist +++ b/conf/Solocraft.conf.dist @@ -439,3 +439,15 @@ Solocraft.QuarryOfTears.Level = 78 Solocraft.HallsOfReflection.Level = 78 # The Ruby Sanctum Solocraft.ChamberOfAspectsRed.Level = 80 + +################################################################################################### +# Misc +################################################################################################### + +# Map excluded +# This settings excludes some maps from the Solocraft instance scaling + +# Example: +# Solocraft.Instance.Excluded = "30,489,529,559,562,566,572,607,617,618,628" +# This example excludes scaling in PvP BG & Arena maps +Solocraft.Instance.Excluded = "" diff --git a/src/Solocraft.cpp b/src/Solocraft.cpp index 59410f5..46ad144 100644 --- a/src/Solocraft.cpp +++ b/src/Solocraft.cpp @@ -12,6 +12,10 @@ #include #include #include "ObjectGuid.h" +#include "utils/Utils.h" +#include +#include +#include bool SoloCraftEnable = 1; bool SoloCraftAnnounceModule = 1; @@ -28,6 +32,7 @@ std::unordered_map classes; std::unordered_map dungeons; std::unordered_map diff_Multiplier; std::unordered_map diff_Multiplier_Heroics; +std::vector SolocraftInstanceExcluded; float D5 = 1.0; float D10 = 1.0; @@ -305,6 +310,9 @@ class SolocraftConfig : public WorldScript //Unique Raids beyond the heroic and normal versions of themselves D649H10 = sConfigMgr->GetOption("Solocraft.ArgentTournamentRaidH10", 10.0); //Trial of the Crusader 10 Heroic D649H25 = sConfigMgr->GetOption("Solocraft.ArgentTournamentRaidH25", 25.0); //Trial of the Crusader 25 Heroic + + //Get from conf excluded map for Solocraft scaling + LoadList(sConfigMgr->GetOption("Solocraft.Instance.Excluded", ""), SolocraftInstanceExcluded); } }; @@ -361,6 +369,11 @@ class SolocraftPlayerInstanceHandler : public PlayerScript { public: SolocraftPlayerInstanceHandler() : PlayerScript("SolocraftPlayerInstanceHandler") {} + + bool IsInSolocraftInstanceExcludedList(uint32 id) + { + return find(SolocraftInstanceExcluded.begin(), SolocraftInstanceExcluded.end(), id) != SolocraftInstanceExcluded.end(); + } void OnMapChanged(Player* player) override { @@ -380,6 +393,11 @@ class SolocraftPlayerInstanceHandler : public PlayerScript { if (map) { + if (IsInSolocraftInstanceExcludedList(map->GetId())) + { + return 0; + } + if (map->Is25ManRaid()) { if (map->IsHeroic() && map->GetId() == 649) @@ -536,8 +554,12 @@ class SolocraftPlayerInstanceHandler : public PlayerScript // Apply the player buffs void ApplyBuffs(Player* player, Map* map, float difficulty, int dunLevel, int numInGroup, int classBalance) { - // Check whether to buff the player or check to debuff back to normal - if (difficulty != 0) + // Check whether to debuff back to normal or check to buff the player + if (difficulty == 0 || IsInSolocraftInstanceExcludedList(map->GetId())) + { + ClearBuffs(player); // Check to revert player back to normal - Moving this here fixed logout and login while in instance buff and debuff issues + } + else { std::ostringstream ss; @@ -709,10 +731,6 @@ class SolocraftPlayerInstanceHandler : public PlayerScript ClearBuffs(player); // Check to revert player back to normal } } - else - { - ClearBuffs(player); // Check to revert player back to normal - Moving this here fixed logout and login while in instance buff and debuff issues - } } private: diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp new file mode 100644 index 0000000..c3b705e --- /dev/null +++ b/src/utils/Utils.cpp @@ -0,0 +1,16 @@ +#include "Utils.h" +#include +#include +#include +#include + +std::vector split(const std::string& str, char delimiter) { + std::vector res; + if (str.empty()) return res; + std::string token; + std::istringstream tokenStream(str); + while (std::getline(tokenStream, token, delimiter)) { + res.push_back(token); + } + return res; +} diff --git a/src/utils/Utils.h b/src/utils/Utils.h new file mode 100644 index 0000000..20d2183 --- /dev/null +++ b/src/utils/Utils.h @@ -0,0 +1,20 @@ +#ifndef UTILS_H +#define UTILS_H + +#include +#include +#include +#include + +std::vector split(const std::string& str, char delimiter); + +template +void LoadList(const std::string& value, T& list) { + std::vector ids = split(value, ','); + for (const std::string& id_str : ids) { + uint32_t id = static_cast(std::atoi(id_str.c_str())); + list.push_back(id); + } +} + +#endif From 57cabae93db8bb2a26415086b59734e7c59f525a Mon Sep 17 00:00:00 2001 From: valsan-azerty-boi <52854501+valsan-azerty-boi@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:00:09 +0200 Subject: [PATCH 2/2] include cstdint --- src/Solocraft.cpp | 1 + src/utils/Utils.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Solocraft.cpp b/src/Solocraft.cpp index 46ad144..1a2b350 100644 --- a/src/Solocraft.cpp +++ b/src/Solocraft.cpp @@ -16,6 +16,7 @@ #include #include #include +#include bool SoloCraftEnable = 1; bool SoloCraftAnnounceModule = 1; diff --git a/src/utils/Utils.h b/src/utils/Utils.h index 20d2183..9b65574 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -1,6 +1,7 @@ #ifndef UTILS_H #define UTILS_H +#include #include #include #include