mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +00:00
[Tradeskills] Implement learning recipes from books (#4170)
This uses the book scribe button to learn recipes in SoF+ clients. For Titanium clients the button is not available so a workaround will need to be added later. Note live gives no feedback when scribing books (at least those tested).
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "zonedb.h"
|
||||
#include "worldserver.h"
|
||||
#include "../common/repositories/char_recipe_list_repository.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "../common/repositories/tradeskill_recipe_repository.h"
|
||||
#include "../common/repositories/tradeskill_recipe_entries_repository.h"
|
||||
|
||||
@@ -1892,4 +1893,31 @@ bool Client::CheckTradeskillLoreConflict(int32 recipe_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Client::ScribeRecipes(uint32_t item_id) const
|
||||
{
|
||||
if (item_id == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto recipes = TradeskillRecipeRepository::GetWhere(content_db, fmt::format(
|
||||
"learned_by_item_id = {} {}", item_id, ContentFilterCriteria::apply()));
|
||||
|
||||
std::vector<CharRecipeListRepository::CharRecipeList> learned;
|
||||
learned.reserve(recipes.size());
|
||||
|
||||
for (const auto& recipe : recipes)
|
||||
{
|
||||
auto entry = CharRecipeListRepository::NewEntity();
|
||||
entry.char_id = static_cast<int32_t>(CharacterID());
|
||||
entry.recipe_id = recipe.id;
|
||||
learned.push_back(entry);
|
||||
}
|
||||
|
||||
if (!learned.empty())
|
||||
{
|
||||
// avoid replacing madecount for recipes the client already has
|
||||
int rows = CharRecipeListRepository::InsertUpdateMany(database, learned);
|
||||
LogTradeskills("Client [{}] scribed [{}] recipes from [{}]", CharacterID(), rows, item_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user