Skip to content

Commit

Permalink
fix stalling and rebase without ac pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
hatersgit committed Oct 19, 2023
1 parent 061b03e commit ac576a2
Show file tree
Hide file tree
Showing 37 changed files with 1,550 additions and 847 deletions.
83 changes: 74 additions & 9 deletions modules/mod-Forge/src/ForgeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ enum CharacterPointType
LEVEL_10_TAB = 7
};

enum NodeType
{
AURA = 0,
SPELL = 1,
CHOICE = 2
};

enum ForgeSettingIndex
{
FORGE_SETTING_SPEC_SLOTS = 0
Expand Down Expand Up @@ -92,6 +99,13 @@ struct ForgeCharacterSpec
std::unordered_map<uint32, std::unordered_map<uint32, ForgeCharacterTalent*>> Talents;
// tabId
std::unordered_map<uint32, uint8> PointsSpent;
std::unordered_map<uint32 /*node id*/, uint32/*spell picked*/> ChoiceNodesChosen;
};

struct ForgeTalentChoice
{
uint32 spellId;
bool active;
};

struct ForgeTalent
Expand All @@ -104,10 +118,11 @@ struct ForgeTalent
uint16 TabPointReq;
uint8 RequiredLevel;
CharacterPointType TalentType;
NodeType nodeType;
uint8 NumberOfRanks;
PereqReqirementType PreReqType;
std::list<ForgeTalentPrereq*> Prereqs;
std::list<uint32> ExclusiveWith;
std::list<ForgeTalentChoice*> Choices;
std::list<uint32> UnlearnSpells;
// rank number, spellId
std::unordered_map<uint32, uint32> Ranks;
Expand Down Expand Up @@ -853,6 +868,9 @@ class ForgeCache : public DatabaseScript

// tabId
std::unordered_map<uint32, ForgeTalentTab*> TalentTabs;

// choiceNodeId is the id of the node in forge_talents
std::unordered_map<uint32 /*nodeid*/, std::vector<uint32/*choice spell id*/>> _choiceNodes;
private:
std::unordered_map<ObjectGuid, uint32> CharacterActiveSpecs;
std::unordered_map<std::string, uint32> CONFIG;
Expand Down Expand Up @@ -919,16 +937,29 @@ class ForgeCache : public DatabaseScript
AddTalentTrees();
AddTalentsToTrees();
AddTalentPrereqs();
AddTalentExclusiveness();
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();
}

void GetCharacters()
Expand Down Expand Up @@ -1194,6 +1225,7 @@ class ForgeCache : public DatabaseScript
newTalent->NumberOfRanks = talentFields[7].Get<uint8>();
newTalent->PreReqType = (PereqReqirementType)talentFields[8].Get<uint8>();
newTalent->TabPointReq = talentFields[9].Get<uint16>();
newTalent->nodeType = NodeType(talentFields[10].Get<uint8>());

auto tabItt = TalentTabs.find(newTalent->TalentTabId);

Expand Down Expand Up @@ -1237,33 +1269,66 @@ class ForgeCache : public DatabaseScript
} while (preReqTalents->NextRow());
}

void AddTalentExclusiveness()
void AddTalentChoiceNodes()
{
QueryResult exclTalents = WorldDatabase.Query("SELECT * FROM forge_talent_exclusive");
QueryResult exclTalents = WorldDatabase.Query("SELECT * FROM forge_talent_choice_nodes");

_choiceNodes.clear();

if (!exclTalents)
return;

do
{
Field* talentFields = exclTalents->Fetch();
uint32 spellId = talentFields[0].Get<uint32>();
uint32 choiceNodeId = talentFields[0].Get<uint32>();
uint32 talentTabId = talentFields[1].Get<uint32>();
uint32 exclusiveSpellId = talentFields[2].Get<uint32>();
uint32 spellChoice = talentFields[2].Get<uint32>();

ForgeTalent* lt = TalentTabs[talentTabId]->Talents[spellId];
ForgeTalentChoice* choice = new ForgeTalentChoice();
choice->active = false;
choice->spellId = spellChoice;

_choiceNodes[choiceNodeId].push_back(spellChoice);

ForgeTalent* lt = TalentTabs[talentTabId]->Talents[choiceNodeId];
if (lt != nullptr)
{
lt->ExclusiveWith.push_back(exclusiveSpellId);
lt->Choices.push_back(choice);
}
else
{
LOG_ERROR("FORGE.ForgeCache", "Error loading AddTalentExclusiveness, invaild exclusiveSpellId id: " + std::to_string(exclusiveSpellId));
LOG_ERROR("FORGE.ForgeCache", "Error loading AddTalentChoiceNodes, invaild choiceNodeId id: " + std::to_string(choiceNodeId));
}

} while (exclTalents->NextRow());
}

void AddCharacterChoiceNodes() {
QueryResult choiceQuery = CharacterDatabase.Query("SELECT * FROM forge_character_node_choices");

if (!choiceQuery)
return;

do
{
Field* fields = choiceQuery->Fetch();
uint32 id = fields[0].Get<uint32>();
ObjectGuid characterGuid = ObjectGuid::Create<HighGuid::Player>(id);
uint32 specId = fields[1].Get<uint32>();
uint32 TabId = fields[2].Get<uint32>();
uint32 nodeId = fields[3].Get<uint8>();
uint32 chosenSpell = fields[4].Get<uint32>();

ForgeTalent* ft = TalentTabs[TabId]->Talents[nodeId];
if (ft->nodeType == NodeType::CHOICE) {
ForgeCharacterSpec* spec = CharacterSpecs[characterGuid][specId];
spec->ChoiceNodesChosen[nodeId] = chosenSpell;
}

} while (choiceQuery->NextRow());
}

void AddTalentRanks()
{
QueryResult talentRanks = WorldDatabase.Query("SELECT * FROM forge_talent_ranks");
Expand Down
36 changes: 13 additions & 23 deletions modules/mod-Forge/src/ForgeCommonMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ std::string ForgeCommonMessage::BuildTree(Player* player, CharacterPointType poi

j = 0;

for (auto& preReq : talentKvp.second->ExclusiveWith)
for (auto& preReq : talentKvp.second->Ranks)
{
std::string reqDel = "!";
std::string reqDel = "%";

if (j == 0)
reqDel = "";

msg = msg + reqDel + std::to_string(preReq);
msg = msg + reqDel + std::to_string(preReq.first) + "~" +
std::to_string(preReq.second);

j++;
}
Expand All @@ -110,32 +111,29 @@ std::string ForgeCommonMessage::BuildTree(Player* player, CharacterPointType poi

j = 0;

for (auto& preReq : talentKvp.second->Ranks)
for (auto& preReq : talentKvp.second->UnlearnSpells)
{
std::string reqDel = "%";
std::string reqDel = "`";

if (j == 0)
reqDel = "";

msg = msg + reqDel + std::to_string(preReq.first) + "~" +
std::to_string(preReq.second);
msg = msg + reqDel + std::to_string(preReq);

j++;
}

msg = msg + "&"; // delimit the field
msg = msg + "&" + std::to_string(talentKvp.second->nodeType) + "&";

j = 0;

for (auto& preReq : talentKvp.second->UnlearnSpells)
// TODO: SET THIS TO BE CHOICE NODE
for (auto& choice : talentKvp.second->Choices)
{
std::string reqDel = "`";
std::string choiceDel = "!";

if (j == 0)
reqDel = "";

msg = msg + reqDel + std::to_string(preReq);
choiceDel = "";

msg = msg + choiceDel + std::to_string(choice->spellId);
j++;
}

Expand Down Expand Up @@ -313,14 +311,6 @@ bool ForgeCommonMessage::CanLearnTalent(Player* player, uint32 tabId, uint32 spe
}
}

for (auto& exclu : ft->ExclusiveWith)
{
auto typeItt = skillTabs.find(exclu);

if (typeItt != skillTabs.end() && (typeItt->second->CurrentRank > 0))
return false;
}

return true;
}

Expand Down
4 changes: 4 additions & 0 deletions modules/mod-Forge/src/ForgePlayerMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <GetTransmogHandler.cpp>
#include <GetTransmogSetsHandler.cpp>
#include <SaveTransmogSetHandler.cpp>
#include <StartMythicHandler.cpp>
#include <GetAffixesHandler.cpp>
#include <unordered_map>

// Add player scripts
Expand Down Expand Up @@ -282,6 +284,8 @@ void AddForgePlayerMessageHandler()
sTopicRouter->AddHandler(new SaveTransmogSetHandler(cache, cm));
sTopicRouter->AddHandler(new GetTransmogSetsHandler(cache, cm));
sTopicRouter->AddHandler(new GetTransmogHandler(cache, cm));
sTopicRouter->AddHandler(new StartMythicHandler(cache, cm));
sTopicRouter->AddHandler(new GetAffixesHandler(cache, cm));

new UseSkillBook();
new ForgeCacheCommands();
Expand Down
49 changes: 49 additions & 0 deletions modules/mod-Forge/src/TopicHandlers/GetAffixesHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "ScriptMgr.h"
#include "Player.h"
#include "Config.h"
#include "Chat.h"
#include "WorldPacket.h"
#include "TopicRouter.h"
#include "ForgeCommonMessage.h"
#include <ForgeCache.cpp>

class GetAffixesHandler : public ForgeTopicHandler
{
public:
GetAffixesHandler(ForgeCache* cache, ForgeCommonMessage* messageCommon) : ForgeTopicHandler(ForgeTopic::MYTHIC_GET_AFFIXES_LIST)
{
fc = cache;
mc = messageCommon;
}

void HandleMessage(ForgeAddonMessage& iam) override
{
auto affixes = sObjectMgr->GetForgeAffixesByTierMap();

std::string out = "";
std::string delim = "";

for (auto tier : affixes) {
if (tier.first > 1)
delim = ";";

out += delim + std::to_string(tier.first) + "K";

std::string sep = "";
for (int i = 0; i < tier.second.size(); i++) {
if (i > 0)
sep = "*";

out += sep + std::to_string(tier.second[i]);
}
}

iam.player->SendForgeUIMsg(ForgeTopic::MYTHIC_GET_AFFIXES_LIST, out);
}


private:

ForgeCache* fc;
ForgeCommonMessage* mc;
};
21 changes: 11 additions & 10 deletions modules/mod-Forge/src/TopicHandlers/LearnTalentHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,17 @@ class LearnTalentHandler : public ForgeTopicHandler
}
}

for (auto& exclu : ft->ExclusiveWith)
{
auto typeItt = skillTabs.find(exclu);

if (typeItt != skillTabs.end() && typeItt->second->CurrentRank > 0)
{
RequirementsNotMet(iam);
return;
}
}
// TODO: FIX
//for (auto& exclu : ft->Choices)
//{
// auto typeItt = skillTabs.find(exclu);

// if (typeItt != skillTabs.end() && typeItt->second->CurrentRank > 0)
// {
// RequirementsNotMet(iam);
// return;
// }
//}

auto spellItter = skillTabs.find(ft->SpellId);
ForgeCharacterTalent* ct = new ForgeCharacterTalent();
Expand Down
Loading

0 comments on commit ac576a2

Please sign in to comment.