Run clang-format

This commit is contained in:
Yunfan Li
2024-08-04 10:23:36 +08:00
parent 44da167492
commit 53611c9040
835 changed files with 35085 additions and 31861 deletions

View File

@@ -1,8 +1,10 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "Talentspec.h"
#include "Event.h"
#include "Playerbots.h"
@@ -11,7 +13,7 @@ uint32 TalentSpec::TalentListEntry::tabPage() const
return talentTabInfo->TalentTabID == 41 ? 1 : talentTabInfo->tabpage;
}
//Checks a talent link on basic validity.
// Checks a talent link on basic validity.
bool TalentSpec::CheckTalentLink(std::string const link, std::ostringstream* out)
{
std::string const validChar = "-";
@@ -50,10 +52,7 @@ uint32 TalentSpec::PointstoLevel(uint32 points) const
return uint32(ceil(points / sWorld->getRate(RATE_TALENT))) + 9;
}
TalentSpec::TalentSpec(uint32 classMask)
{
GetTalents(classMask);
}
TalentSpec::TalentSpec(uint32 classMask) { GetTalents(classMask); }
TalentSpec::TalentSpec(TalentSpec* base, std::string const link)
{
@@ -73,7 +72,7 @@ TalentSpec::TalentSpec(Player* bot, std::string const link)
ReadTalents(link);
}
//Check the talentspec for errors.
// Check the talentspec for errors.
bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out)
{
for (auto& entry : talents)
@@ -81,7 +80,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out)
if (entry.rank > entry.maxRank)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]);
*out << "spec is not for this class. " << spellInfo->SpellName[0] << " has " << (entry.rank - entry.maxRank) << " points above max rank.";
*out << "spec is not for this class. " << spellInfo->SpellName[0] << " has " << (entry.rank - entry.maxRank)
<< " points above max rank.";
return false;
}
@@ -103,7 +103,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out)
if (!found)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]);
*out << "spec is invalid. Talent:" << spellInfo->SpellName[0] << " needs: " << spellInfodep->SpellName[0] << " at rank: " << entry.talentInfo->DependsOnRank;
*out << "spec is invalid. Talent:" << spellInfo->SpellName[0]
<< " needs: " << spellInfodep->SpellName[0] << " at rank: " << entry.talentInfo->DependsOnRank;
return false;
}
}
@@ -120,7 +121,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out)
if (entry.rank > 0 && entry.talentInfo->Row * 5 > points)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]);
*out << "spec is is invalid. Talent " << spellInfo->SpellName[0] << " is selected with only " << points << " in row below it.";
*out << "spec is is invalid. Talent " << spellInfo->SpellName[0] << " is selected with only " << points
<< " in row below it.";
return false;
}
@@ -137,17 +139,18 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out)
return true;
}
//Set the talents for the bots to the current spec.
// Set the talents for the bots to the current spec.
void TalentSpec::ApplyTalents(Player* bot, std::ostringstream* out)
{
for (auto& entry : talents) {
for (auto& entry : talents)
{
if (entry.rank == 0)
continue;
bot->LearnTalent(entry.talentInfo->TalentID, entry.rank - 1);
}
}
//Returns a base talentlist for a class.
// Returns a base talentlist for a class.
void TalentSpec::GetTalents(uint32 classMask)
{
TalentListEntry entry;
@@ -185,7 +188,7 @@ void TalentSpec::GetTalents(uint32 classMask)
SortTalents(talents, SORT_BY_DEFAULT);
}
//Sorts a talent list by page, row, column.
// Sorts a talent list by page, row, column.
bool sortTalentMap(TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j, uint32* tabSort)
{
uint32 itab = i.tabPage();
@@ -208,38 +211,35 @@ bool sortTalentMap(TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j,
return false;
}
void TalentSpec::SortTalents(uint32 sortBy)
{
SortTalents(talents, sortBy);
}
void TalentSpec::SortTalents(uint32 sortBy) { SortTalents(talents, sortBy); }
//Sort the talents.
// Sort the talents.
void TalentSpec::SortTalents(std::vector<TalentListEntry>& talents, uint32 sortBy)
{
switch (sortBy)
{
case SORT_BY_DEFAULT:
{
uint32 tabSort[] = { 0, 1, 2 };
std::sort(talents.begin(), talents.end(), [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j)
{
return sortTalentMap(i, j, tabSort);
});
uint32 tabSort[] = {0, 1, 2};
std::sort(talents.begin(), talents.end(),
[&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j)
{ return sortTalentMap(i, j, tabSort); });
break;
}
case SORT_BY_POINTS_TREE:
{
uint32 tabSort[] = { GetTalentPoints(talents, 0) * 100 - urand(0, 99), GetTalentPoints(talents, 1) * 100 - urand(0, 99), GetTalentPoints(talents, 2) * 100 - urand(0, 99) };
std::sort(talents.begin(), talents.end(), [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j)
{
return sortTalentMap(i, j, tabSort);
});
uint32 tabSort[] = {GetTalentPoints(talents, 0) * 100 - urand(0, 99),
GetTalentPoints(talents, 1) * 100 - urand(0, 99),
GetTalentPoints(talents, 2) * 100 - urand(0, 99)};
std::sort(talents.begin(), talents.end(),
[&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j)
{ return sortTalentMap(i, j, tabSort); });
break;
}
}
}
//Set the talent ranks to the current rank of the player.
// Set the talent ranks to the current rank of the player.
void TalentSpec::ReadTalents(Player* bot)
{
for (auto& entry : talents)
@@ -257,7 +257,7 @@ void TalentSpec::ReadTalents(Player* bot)
}
}
//Set the talent ranks to the ranks of the link.
// Set the talent ranks to the ranks of the link.
void TalentSpec::ReadTalents(std::string const link)
{
uint32 rank = 0;
@@ -308,7 +308,7 @@ void TalentSpec::ReadTalents(std::string const link)
}
}
//Returns only a specific tree from a talent list.
// Returns only a specific tree from a talent list.
std::vector<TalentSpec::TalentListEntry> TalentSpec::GetTalentTree(uint32 tabpage)
{
std::vector<TalentListEntry> retList;
@@ -320,12 +320,9 @@ std::vector<TalentSpec::TalentListEntry> TalentSpec::GetTalentTree(uint32 tabpag
return std::move(retList);
}
uint32 TalentSpec::GetTalentPoints(int32 tabpage)
{
return GetTalentPoints(talents, tabpage);
};
uint32 TalentSpec::GetTalentPoints(int32 tabpage) { return GetTalentPoints(talents, tabpage); };
//Counts the point in a talent list.
// Counts the point in a talent list.
uint32 TalentSpec::GetTalentPoints(std::vector<TalentListEntry>& talents, int32 tabpage)
{
if (tabpage == -1)
@@ -339,7 +336,7 @@ uint32 TalentSpec::GetTalentPoints(std::vector<TalentListEntry>& talents, int32
return tPoints;
}
//Generates a wow-head link from a talent list.
// Generates a wow-head link from a talent list.
std::string const TalentSpec::GetTalentLink()
{
std::string link = "";
@@ -403,7 +400,7 @@ std::string const TalentSpec::FormatSpec(Player* bot)
uint8 cls = bot->getClass();
std::ostringstream out;
//out << chathelper:: specs[cls][highestTree()] << " (";
// out << chathelper:: specs[cls][highestTree()] << " (";
uint32 c0 = GetTalentPoints(0);
uint32 c1 = GetTalentPoints(1);
@@ -416,7 +413,7 @@ std::string const TalentSpec::FormatSpec(Player* bot)
return out.str();
}
//Removes talentpoints to match the level
// Removes talentpoints to match the level
void TalentSpec::CropTalents(uint32 level)
{
if (points <= LeveltoPoints(level))
@@ -436,8 +433,10 @@ void TalentSpec::CropTalents(uint32 level)
SortTalents(talents, SORT_BY_DEFAULT);
}
//Substracts ranks. Follows the sorting of the newList.
std::vector<TalentSpec::TalentListEntry> TalentSpec::SubTalentList(std::vector<TalentListEntry>& oldList, std::vector<TalentListEntry>& newList, uint32 reverse = SUBSTRACT_OLD_NEW)
// Substracts ranks. Follows the sorting of the newList.
std::vector<TalentSpec::TalentListEntry> TalentSpec::SubTalentList(std::vector<TalentListEntry>& oldList,
std::vector<TalentListEntry>& newList,
uint32 reverse = SUBSTRACT_OLD_NEW)
{
std::vector<TalentSpec::TalentListEntry> deltaList = newList;
@@ -466,35 +465,35 @@ bool TalentSpec::isEarlierVersionOf(TalentSpec& newSpec)
return true;
}
//Modifies current talents towards new talents up to a maxium of points.
// Modifies current talents towards new talents up to a maxium of points.
void TalentSpec::ShiftTalents(TalentSpec* currentSpec, uint32 level)
{
uint32 currentPoints = currentSpec->GetTalentPoints();
if (points >= LeveltoPoints(level)) //We have no more points to spend. Better reset and crop
if (points >= LeveltoPoints(level)) // We have no more points to spend. Better reset and crop
{
CropTalents(level);
return;
}
SortTalents(SORT_BY_POINTS_TREE); //Apply points first to the largest new tree.
SortTalents(SORT_BY_POINTS_TREE); // Apply points first to the largest new tree.
std::vector<TalentSpec::TalentListEntry> deltaList = SubTalentList(currentSpec->talents, talents);
for (auto& entry : deltaList)
{
if (entry.rank < 0) //We have to remove talents. Might as well reset and crop the new list.
if (entry.rank < 0) // We have to remove talents. Might as well reset and crop the new list.
{
CropTalents(level);
return;
}
}
//Start from the current spec.
// Start from the current spec.
talents = currentSpec->talents;
for (auto& entry : deltaList)
{
if (entry.rank + points > LeveltoPoints(level)) //Running out of points. Only apply what we have left.
if (entry.rank + points > LeveltoPoints(level)) // Running out of points. Only apply what we have left.
entry.rank = std::max(0, std::abs(int32(LeveltoPoints(level) - points)));
for (auto& subentry : talents)