From 9aac12f517a8cd17086b963b2c3ff1392d74e268 Mon Sep 17 00:00:00 2001 From: Natedog2012 Date: Wed, 22 Sep 2021 18:21:53 -0500 Subject: [PATCH 1/2] Hide tradeskill recipes that require being learned before crafting them, as well as fix how learned recipes are checked. --- zone/tradeskills.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 7e0ce5857..950ddb06d 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -810,6 +810,14 @@ void Client::SendTradeskillSearchResults( continue; } } + + //Check if we need to learn it before sending them the recipe.. + DBTradeskillRecipe_Struct spec; + if (content_db.GetTradeRecipe(recipe_id, objtype, someid, this->CharacterID(), &spec)) { + if ((spec.must_learn & 0xf) && !spec.has_learnt) { + continue; + } + } auto outapp = new EQApplicationPacket(OP_RecipeReply, sizeof(RecipeReply_Struct)); RecipeReply_Struct *reply = (RecipeReply_Struct *) outapp->pBuffer; @@ -1489,7 +1497,7 @@ bool ZoneDatabase::GetTradeRecipe( recipe_id ); - if (character_learned_recipe.made_count > 0) { + if (character_learned_recipe.recipe_id) { //If this exists we learned it LogTradeskills("[GetTradeRecipe] made_count [{}]", character_learned_recipe.made_count); spec->has_learnt = true; From bf8d94eb35fdb1ba53065042299bdcf5cbc2466b Mon Sep 17 00:00:00 2001 From: Natedog2012 Date: Wed, 22 Sep 2021 21:43:47 -0500 Subject: [PATCH 2/2] Fix SendTradeskillSearchResults row count was incorrect format. Remove extra database hits from last commit. --- zone/client_packet.cpp | 6 ++++-- zone/tradeskills.cpp | 29 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 6d5dd2314..a74f65180 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12198,7 +12198,8 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) tr.name, tr.trivial, SUM(tre.componentcount), - tr.tradeskill + tr.tradeskill, + tr.must_learn FROM tradeskill_recipe AS tr LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id = tre.recipe_id @@ -12298,7 +12299,8 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) tr.name, tr.trivial, SUM(tre.componentcount), - tr.tradeskill + tr.tradeskill, + tr.must_learn FROM tradeskill_recipe AS tr LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id = tre.recipe_id diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 950ddb06d..ea46fae9a 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -782,7 +782,7 @@ void Client::SendTradeskillSearchResults( for (auto row = results.begin(); row != results.end(); ++row) { if (row == nullptr || row[0] == nullptr || row[1] == nullptr || row[2] == nullptr || row[3] == nullptr || - row[5] == nullptr) { + row[4] == nullptr || row[5] == nullptr) { continue; } @@ -790,35 +790,36 @@ void Client::SendTradeskillSearchResults( const char *name = row[1]; uint32 trivial = (uint32) atoi(row[2]); uint32 comp_count = (uint32) atoi(row[3]); - uint32 tradeskill = (uint16) atoi(row[5]); + uint32 tradeskill = (uint16) atoi(row[4]); + uint32 must_learn = (uint16) atoi(row[5]); + // Skip the recipes that exceed the threshold in skill difference // Recipes that have either been made before or were // explicitly learned are excempt from that limit + + auto character_learned_recipe = CharacterRecipeListRepository::GetRecipe( + character_learned_recipe_list, + recipe_id + ); + if (RuleB(Skills, UseLimitTradeskillSearchSkillDiff) && ((int32) trivial - (int32) GetSkill((EQ::skills::SkillType) tradeskill)) > RuleI(Skills, MaxTradeskillSearchSkillDiff)) { LogTradeskills("Checking limit recipe_id [{}] name [{}]", recipe_id, name); - auto character_learned_recipe = CharacterRecipeListRepository::GetRecipe( - character_learned_recipe_list, - recipe_id - ); - if (character_learned_recipe.made_count == 0) { continue; } } - - //Check if we need to learn it before sending them the recipe.. - DBTradeskillRecipe_Struct spec; - if (content_db.GetTradeRecipe(recipe_id, objtype, someid, this->CharacterID(), &spec)) { - if ((spec.must_learn & 0xf) && !spec.has_learnt) { - continue; - } + + //Skip recipes that must be learned + if ((must_learn & 0xf) && !character_learned_recipe.recipe_id) { + continue; } + auto outapp = new EQApplicationPacket(OP_RecipeReply, sizeof(RecipeReply_Struct)); RecipeReply_Struct *reply = (RecipeReply_Struct *) outapp->pBuffer;