Skip to content

Commit

Permalink
Fix Trade Skill Limit (#192)
Browse files Browse the repository at this point in the history
* Fix trade skill max limit count
- Removed unused configuration
- Removed GM Ignore configurations

Notice: With GM Ignore configurations removed, trade skill count works as intended again. Accounts with higher permission can still learn additional trade skills for testing or debugging. As before there was no limit to how many you could learn before this commit.

Co-authored-by: Fyre <[email protected]>

* Update Configuration Version
2023031100 -> 2023053000

* Fix an incorrect check method

---------

Co-authored-by: Fyre <[email protected]>
  • Loading branch information
2 people authored and billy1arm committed Oct 22, 2023
1 parent 6f6608f commit 2e4111a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 44 deletions.
2 changes: 1 addition & 1 deletion cmake/MangosParams.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(MANGOS_EXP "CATA")
set(MANGOS_PKG "Mangos Three")
set(MANGOS_WORLD_VER 2023031800)
set(MANGOS_WORLD_VER 2023102200)
set(MANGOS_REALM_VER 2021010100)
set(MANGOS_AHBOT_VER 2021010100)
36 changes: 14 additions & 22 deletions src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3965,12 +3965,11 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
UpdateFreeTalentPoints(false);
}

// update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning)
// update free primary prof.points (if any, can be none in case GM .learn prof. learning)
if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id))
{
uint32 freeProfs = GetFreePrimaryProfessionPoints() + 1;
uint32 maxProfs = GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT)) ? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10;
if (freeProfs <= maxProfs)
if (freeProfs <= sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL))
{
SetFreePrimaryProfessions(freeProfs);
}
Expand Down Expand Up @@ -4732,17 +4731,6 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
return TRAINER_SPELL_RED;
}

bool prof = SpellMgr::IsProfessionSpell(trainer_spell->learnedSpell);

// check level requirement
if (!prof || GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_LEVEL)))
{
if (getLevel() < reqLevel)
{
return TRAINER_SPELL_RED;
}
}

if (SpellChainNode const* spell_chain = sSpellMgr.GetSpellChainNode(trainer_spell->learnedSpell))
{
// check prev.rank requirement
Expand All @@ -4758,12 +4746,18 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell
}
}

// check level requirement
bool prof = SpellMgr::IsProfessionSpell(trainer_spell->spell);
if (prof || trainer_spell->reqLevel && (trainer_spell->reqLevel) < reqLevel)
{
return TRAINER_SPELL_RED;
}

// check skill requirement
if (!prof || GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_SKILL)))
if (trainer_spell->reqSkill && GetBaseSkillValue(trainer_spell->reqSkill) < trainer_spell->reqSkillValue)
{
return TRAINER_SPELL_RED;
}
if (prof || trainer_spell->reqSkill && GetBaseSkillValue(trainer_spell->reqSkill) < trainer_spell->reqSkillValue)
{
return TRAINER_SPELL_RED;
}

// exist, already checked at loading
SpellEntry const* spell = sSpellStore.LookupEntry(trainer_spell->learnedSpell);
Expand Down Expand Up @@ -23430,9 +23424,7 @@ template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, DynamicOb

void Player::InitPrimaryProfessions()
{
uint32 maxProfs = GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT))
? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10;
SetFreePrimaryProfessions(maxProfs);
SetFreePrimaryProfessions(sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL));
}

void Player::SendComboPoints()
Expand Down
6 changes: 1 addition & 5 deletions src/game/WorldHandlers/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,7 @@ void World::LoadConfigSettings(bool reload)

setConfigMinMax(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL, "MaxPrimaryTradeSkill", 2, 0, 10);

setConfigMinMax(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT, "TradeSkill.GMIgnore.MaxPrimarySkillsCount", SEC_CONSOLE, SEC_PLAYER, SEC_CONSOLE);
setConfigMinMax(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_LEVEL, "TradeSkill.GMIgnore.Level", SEC_CONSOLE, SEC_PLAYER, SEC_CONSOLE);
setConfigMinMax(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_SKILL, "TradeSkill.GMIgnore.Skill", SEC_CONSOLE, SEC_PLAYER, SEC_CONSOLE);

setConfig(CONFIG_UINT32_MIN_PETITION_SIGNS, "Guild.PetitionSignatures", 4);
setConfigMinMax(CONFIG_UINT32_MIN_PETITION_SIGNS, "MinPetitionSigns", 9, 0, 9);

setConfig(CONFIG_UINT32_GM_LOGIN_STATE, "GM.LoginState", 2);
setConfig(CONFIG_UINT32_GM_VISIBLE_STATE, "GM.Visible", 2);
Expand Down
3 changes: 0 additions & 3 deletions src/game/WorldHandlers/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ enum eConfigUInt32Values
CONFIG_UINT32_BIRTHDAY_TIME,
CONFIG_UINT32_RABBIT_DAY,
CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_LEVEL,
CONFIG_UINT32_TRADE_SKILL_GMIGNORE_SKILL,
CONFIG_UINT32_MIN_PETITION_SIGNS,
CONFIG_UINT32_GM_LOGIN_STATE,
CONFIG_UINT32_GM_VISIBLE_STATE,
Expand Down
17 changes: 4 additions & 13 deletions src/mangosd/mangosd.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -724,19 +724,6 @@ SD3ErrorLogFile = "scriptdev3-errors.log"
# Default: 2
# Max : 10
#
# TradeSkill.GMIgnore.MaxPrimarySkillsCount
# GM level starting from max primary skill count requirement ignored.
# Default: 4 (Console as noneone)
#
# TradeSkill.GMIgnore.Level
# GM level starting from trade skill level requirement ignored.
# Default: 4 (Console as noneone)
#
# TradeSkill.GMIgnore.Skill
# GM level starting from trade skill skill requirement ignored.
# Default: 4 (Console as noneone)
#
#
# MaxGroupXPDistance
# Max distance to creature for group memeber to get XP at creature death.
# Default: 74
Expand Down Expand Up @@ -867,9 +854,13 @@ TimerBar.Breath.Max = 180
TimerBar.Fire.GMLevel = 4
TimerBar.Fire.Max = 1
MaxPrimaryTradeSkill = 2
<<<<<<< HEAD
TradeSkill.GMIgnore.MaxPrimarySkillsCount = 4
TradeSkill.GMIgnore.Level = 4
TradeSkill.GMIgnore.Skill = 4
=======
MinPetitionSigns = 9
>>>>>>> 2212e1ef1 (Fix Trade Skill Limit (#192))
MaxGroupXPDistance = 74
MailDeliveryDelay = 3600
MassMailer.SendPerTick = 10
Expand Down

0 comments on commit 2e4111a

Please sign in to comment.