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..1a2b350 100644 --- a/src/Solocraft.cpp +++ b/src/Solocraft.cpp @@ -12,6 +12,11 @@ #include #include #include "ObjectGuid.h" +#include "utils/Utils.h" +#include +#include +#include +#include bool SoloCraftEnable = 1; bool SoloCraftAnnounceModule = 1; @@ -28,6 +33,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 +311,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 +370,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 +394,11 @@ class SolocraftPlayerInstanceHandler : public PlayerScript { if (map) { + if (IsInSolocraftInstanceExcludedList(map->GetId())) + { + return 0; + } + if (map->Is25ManRaid()) { if (map->IsHeroic() && map->GetId() == 649) @@ -536,8 +555,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 +732,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..9b65574 --- /dev/null +++ b/src/utils/Utils.h @@ -0,0 +1,21 @@ +#ifndef UTILS_H +#define UTILS_H + +#include +#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