From ccc9ee6a8977305de8285d08df0c3662e2285d6e Mon Sep 17 00:00:00 2001 From: hater Date: Wed, 1 Nov 2023 16:45:58 -0400 Subject: [PATCH] add small infrastructure for spec spells at lvl 10; add error catch and log; update message for level 10 spec --- .../updates/20231101 talent spec select.sql | 8 +++ modules/mod-Forge/src/ForgeCache.cpp | 69 ++++++++++--------- modules/mod-Forge/src/ForgeCommonMessage.cpp | 28 ++++++++ modules/mod-Forge/src/ForgeCommonMessage.h | 1 + .../src/ForgePlayerMessageHandler.cpp | 11 +-- 5 files changed, 82 insertions(+), 35 deletions(-) create mode 100644 modules/mod-Forge/sql/world/updates/20231101 talent spec select.sql diff --git a/modules/mod-Forge/sql/world/updates/20231101 talent spec select.sql b/modules/mod-Forge/sql/world/updates/20231101 talent spec select.sql new file mode 100644 index 00000000000000..ebb721e927e13e --- /dev/null +++ b/modules/mod-Forge/sql/world/updates/20231101 talent spec select.sql @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS `acore_world`.`forge_character_spec_spells`; +CREATE TABLE `acore_world`.`forge_character_spec_spells` ( + `classId` INT(10) UNSIGNED NOT NULL, + `tabId` INT(10) UNSIGNED NOT NULL, + `level` INT(10) UNSIGNED NOT NULL, + `spell` INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (`tabId`, `level`) +) COLLATE='utf8_general_ci' ENGINE=InnoDB; \ No newline at end of file diff --git a/modules/mod-Forge/src/ForgeCache.cpp b/modules/mod-Forge/src/ForgeCache.cpp index 427d5c1e9cc02c..e6d1a50d4e9057 100644 --- a/modules/mod-Forge/src/ForgeCache.cpp +++ b/modules/mod-Forge/src/ForgeCache.cpp @@ -947,37 +947,44 @@ class ForgeCache : public DatabaseScript } } - GetCharacters(); - GetConfig(); - AddTalentTrees(); - AddTalentsToTrees(); - AddTalentPrereqs(); - AddTalentChoiceNodes(); - AddTalentRanks(); - AddTalentUnlearn(); - AddCharacterSpecs(); - AddTalentSpent(); - AddCharacterTalents(); - AddCharacterChoiceNodes(); - - LOG_INFO("server.load", "Loading characters points..."); - AddCharacterPointsFromDB(); - AddCharacterClassSpecs(); - AddCharacterXmogSets(); - - LOG_INFO("server.load", "Loading m+ difficulty multipliers..."); - sObjectMgr->LoadInstanceDifficultyMultiplier(); - LOG_INFO("server.load", "Loading m+ difficulty level scales..."); - sObjectMgr->LoadMythicLevelScale(); - LOG_INFO("server.load", "Loading m+ minion values..."); - sObjectMgr->LoadMythicMinionValue(); - LOG_INFO("server.load", "Loading m+ keys..."); - sObjectMgr->LoadMythicDungeonKeyMap(); - LOG_INFO("server.load", "Loading m+ affixes..."); - sObjectMgr->LoadMythicAffixes(); - - LOG_INFO("server.load", "Loading npc sounds..."); - sObjectMgr->LoadNpcSounds(); + try { + GetCharacters(); + GetConfig(); + AddTalentTrees(); + AddTalentsToTrees(); + AddTalentPrereqs(); + AddTalentChoiceNodes(); + AddTalentRanks(); + AddTalentUnlearn(); + AddCharacterSpecs(); + AddTalentSpent(); + AddCharacterTalents(); + AddCharacterChoiceNodes(); + + LOG_INFO("server.load", "Loading characters points..."); + AddCharacterPointsFromDB(); + AddCharacterClassSpecs(); + AddCharacterXmogSets(); + + LOG_INFO("server.load", "Loading m+ difficulty multipliers..."); + sObjectMgr->LoadInstanceDifficultyMultiplier(); + LOG_INFO("server.load", "Loading m+ difficulty level scales..."); + sObjectMgr->LoadMythicLevelScale(); + LOG_INFO("server.load", "Loading m+ minion values..."); + sObjectMgr->LoadMythicMinionValue(); + LOG_INFO("server.load", "Loading m+ keys..."); + sObjectMgr->LoadMythicDungeonKeyMap(); + LOG_INFO("server.load", "Loading m+ affixes..."); + sObjectMgr->LoadMythicAffixes(); + + LOG_INFO("server.load", "Loading npc sounds..."); + sObjectMgr->LoadNpcSounds(); + } + catch (std::exception & ex) { + std::string error = ex.what(); + LOG_ERROR("server.load", "ERROR IN FORGE CACHE BUILD: " + error); + throw ex; + } } void GetCharacters() diff --git a/modules/mod-Forge/src/ForgeCommonMessage.cpp b/modules/mod-Forge/src/ForgeCommonMessage.cpp index 88766400efc3b4..dd308f1b65e7bb 100644 --- a/modules/mod-Forge/src/ForgeCommonMessage.cpp +++ b/modules/mod-Forge/src/ForgeCommonMessage.cpp @@ -189,6 +189,9 @@ bool ForgeCommonMessage::CanLearnTalent(Player* player, uint32 tabId, uint32 spe fc->TryGetTalentTab(player, tabId, tab) && fc->TryGetCharacterActiveSpec(player, spec)) { + if (sConfigMgr->GetBoolDefault("Forge.StrictSpecs", false) && (!spec->CharacterSpecTabId || spec->CharacterSpecTabId != tabId /*|| not the class generic tree*/)) + return false; + ForgeCharacterPoint* curPoints = fc->GetSpecPoints(player, tabType, spec->Id); if (curPoints->Sum == 0) @@ -546,3 +549,28 @@ void ForgeCommonMessage::SendActiveSpecInfo(Player* player) player->SendForgeUIMsg(ForgeTopic::GET_CHARACTER_SPECS, msg); } } + +void ForgeCommonMessage::SendSpecSelectInfo(Player* player) +{ + + std::list tabs; + if (fc->TryGetForgeTalentTabs(player, CharacterPointType::TALENT_TREE, tabs)) + { + int i = 0; + std::string out = ""; // tabId;iconId;name;description?;spell~spell~spell~mastery?* + for (auto tab : tabs) + { + std::string sep = ";"; + std::string delim = "*"; + if (!i) + delim = ""; + + out += delim + std::to_string(tab->Id) + sep + std::to_string(tab->SpellIconId) + sep + + tab->Name + sep + "TODO: hater add descriptions" + sep; + + // get spells from forge_character_spec_spells where level = 10 + } + + + } +} diff --git a/modules/mod-Forge/src/ForgeCommonMessage.h b/modules/mod-Forge/src/ForgeCommonMessage.h index 140ed23fe83265..d05afbfea7bb0b 100644 --- a/modules/mod-Forge/src/ForgeCommonMessage.h +++ b/modules/mod-Forge/src/ForgeCommonMessage.h @@ -28,6 +28,7 @@ class ForgeCommonMessage void SendTalentTreeLayout(Player*, uint32); void SendSpecInfo(Player*); void SendActiveSpecInfo(Player* player); + void SendSpecSelectInfo(Player* player); std::string BuildTree(Player*, CharacterPointType pointType, std::list tabs); void ApplyKnownForgeSpells(Player*); bool CanLearnTalent(Player*, uint32, uint32); diff --git a/modules/mod-Forge/src/ForgePlayerMessageHandler.cpp b/modules/mod-Forge/src/ForgePlayerMessageHandler.cpp index 870998564050d5..3b9f768eb77900 100644 --- a/modules/mod-Forge/src/ForgePlayerMessageHandler.cpp +++ b/modules/mod-Forge/src/ForgePlayerMessageHandler.cpp @@ -69,10 +69,10 @@ class ForgePlayerMessageHandler : public PlayerScript } // If Remote Address matches, remove the player from the world - if (player->GetSession()->GetRemoteAddress() == _player->GetSession()->GetRemoteAddress() && ++count > 1) - { - player->GetSession()->KickPlayer(); - } + //if (player->GetSession()->GetRemoteAddress() == _player->GetSession()->GetRemoteAddress() && ++count > 1) + //{ + // player->GetSession()->KickPlayer(); + //} } fc->ApplyAccountBoundTalents(player); @@ -155,6 +155,9 @@ class ForgePlayerMessageHandler : public PlayerScript cm->SendActiveSpecInfo(player); cm->SendTalentTreeLayout(player); cm->SendTalents(player); + + if (!spec->CharacterSpecTabId) // Main spec not selected yet, prompt user + cm->SendSpecSelectInfo(player); } if (currentLevel == 80)