updates for recipe components
updates for recipe components, ie mulitple rawpelt pelts that can be used
This commit is contained in:
parent
3c42c9a9f2
commit
c8e66f8daf
8 changed files with 46 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,3 +34,4 @@
|
|||
|
||||
server/logs/*.log
|
||||
server/*.log
|
||||
*.bak
|
||||
|
|
|
@ -2275,8 +2275,8 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
|
|||
LogWrite(COMMAND__ERROR, 0, "Command", "Unknown spell ID: %u and tier: %u", item->skill_info->spell_id, item->skill_info->spell_tier);
|
||||
}
|
||||
else if(item->generic_info.item_type == 7){
|
||||
LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->details.item_id, player->GetName());
|
||||
Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->details.item_id));
|
||||
LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Scribing recipe book %s (%u) for player %s.", item->name.c_str(), item->recipebook_info->recipe_id, player->GetName());
|
||||
Recipe* recipe_book = new Recipe(master_recipebook_list.GetRecipeBooks(item->recipebook_info->recipe_id));//(item->details.item_id));
|
||||
// if valid recipe book and the player doesn't have it
|
||||
if (recipe_book && recipe_book->GetLevel() > client->GetPlayer()->GetTSLevel()) {
|
||||
client->Message(CHANNEL_NARRATIVE, "Your tradeskill level is not high enough to scribe this book.");
|
||||
|
@ -2286,7 +2286,7 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
|
|||
client->Message(CHANNEL_NARRATIVE, "Your tradeskill class cannot use this recipe.");
|
||||
safe_delete(recipe_book);
|
||||
}
|
||||
else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->details.item_id))) {
|
||||
else if (recipe_book && !(client->GetPlayer()->GetRecipeBookList()->HasRecipeBook(item->recipebook_info->recipe_id))){// (item->details.item_id))) {
|
||||
LogWrite(TRADESKILL__DEBUG, 0, "Recipe", "Valid recipe book that the player doesn't have");
|
||||
// Add recipe book to the players list
|
||||
client->GetPlayer()->GetRecipeBookList()->AddRecipeBook(recipe_book);
|
||||
|
|
|
@ -1502,6 +1502,7 @@ void Item::SetItemType(int8 in_type){
|
|||
}
|
||||
else if(IsRecipeBook() && !recipebook_info){
|
||||
recipebook_info = new RecipeBook_Info;
|
||||
recipebook_info->recipe_id = 0;
|
||||
recipebook_info->uses = 0;
|
||||
}
|
||||
else if(IsBook() && !book_info){
|
||||
|
@ -2422,7 +2423,7 @@ void Item::serialize(PacketStruct* packet, bool show_name, Player* player, int16
|
|||
}
|
||||
}
|
||||
packet->setDataByName("uses", recipebook_info->uses);
|
||||
if(player->GetRecipeBookList()->HasRecipeBook(details.item_id))
|
||||
if(player->GetRecipeBookList()->HasRecipeBook(recipebook_info->recipe_id))
|
||||
packet->setDataByName("scribed", 1);
|
||||
else
|
||||
packet->setDataByName("scribed", 0);
|
||||
|
|
|
@ -869,6 +869,7 @@ public:
|
|||
};
|
||||
struct RecipeBook_Info{
|
||||
vector<string> recipes;
|
||||
int32 recipe_id;
|
||||
int8 uses;
|
||||
};
|
||||
struct ItemSet_Info{
|
||||
|
|
|
@ -488,8 +488,11 @@ int32 WorldDatabase::LoadRecipeBookItems(int32 item_id)
|
|||
Query query;
|
||||
MYSQL_ROW row;
|
||||
|
||||
std::string select_query_addition = std::string(" where item_id = ") + std::to_string(item_id);
|
||||
MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT item_id, name FROM item_details_recipe_items%s", (item_id == 0) ? "" : select_query_addition.c_str());
|
||||
//std::string select_query_addition = std::string(" where item_id = ") + std::to_string(item_id);
|
||||
//MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT item_id, name FROM item_details_recipe_items%s", (item_id == 0) ? "" : select_query_addition.c_str());
|
||||
std::string select_query_addition = std::string(" and r.item_id = ") + std::to_string(item_id);
|
||||
MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT r.item_id, ri.recipe_id ,ri.`name`FROM item_details_recipe r LEFT JOIN item_details_recipe_items ri ON ri.recipe_id = r.recipe_id where ri.recipe_id is not null%s", (item_id == 0) ? "" : select_query_addition.c_str());
|
||||
|
||||
int32 total = 0;
|
||||
int32 id = 0;
|
||||
|
||||
|
@ -503,9 +506,11 @@ int32 WorldDatabase::LoadRecipeBookItems(int32 item_id)
|
|||
if(item)
|
||||
{
|
||||
LogWrite(ITEM__DEBUG, 5, "Items", "\tRecipe Book for item_id %u", id);
|
||||
LogWrite(ITEM__DEBUG, 5, "Items", "\tType: %i, '%s'", ITEM_TYPE_RECIPE, row[1]);
|
||||
LogWrite(ITEM__DEBUG, 5, "Items", "\tType: %i, '%s'", ITEM_TYPE_RECIPE, row[2]);
|
||||
item->SetItemType(ITEM_TYPE_RECIPE);
|
||||
item->recipebook_info->recipes.push_back(string(row[1]));
|
||||
item->recipebook_info->recipe_id = (atoi(row[1]));
|
||||
item->recipebook_info->recipes.push_back(string(row[2]));
|
||||
//item->recipebook_info->recipe_id(row[1]);
|
||||
total++;
|
||||
}
|
||||
else
|
||||
|
@ -1286,6 +1291,9 @@ void WorldDatabase::LoadCharacterItemList(int32 account_id, int32 char_id, Playe
|
|||
if(master_item)
|
||||
{
|
||||
Item* item = new Item(master_item);
|
||||
int32 xxx = 0;
|
||||
if(master_item->recipebook_info)
|
||||
item->recipebook_info->recipe_id = master_item->recipebook_info->recipe_id;
|
||||
item->details.unique_id = strtoul(row[1], NULL, 0);
|
||||
item->details.slot_id = atoi(row[2]);
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ int32 MasterRecipeList::Size() {
|
|||
}
|
||||
|
||||
vector<Recipe*> MasterRecipeList::GetRecipes(const char* book_name) {
|
||||
vector<Recipe*> ret;;
|
||||
vector<Recipe*> ret;
|
||||
map<int32, Recipe *>::iterator itr;
|
||||
|
||||
m_recipes.writelock(__FUNCTION__, __LINE__);
|
||||
|
@ -303,6 +303,8 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
Item* item = 0;
|
||||
RecipeProducts* rp = 0;
|
||||
vector<int32>::iterator itr;
|
||||
vector<RecipeComp> comp_list;
|
||||
|
||||
int8 i = 0;
|
||||
int32 firstID = 0;
|
||||
int32 primary_comp_id = 0;
|
||||
|
@ -412,6 +414,7 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
if (item) {
|
||||
packet->setSubstructDataByName("recipe_info", "primary_qty_avail", item->details.count);
|
||||
packet->setSubstructDataByName("recipe_info", "primary_comp", recipe->primary_build_comp_title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// store the id of the primary comp
|
||||
|
@ -436,11 +439,11 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
int8 total_build_components = 0;
|
||||
if (recipe->components.count(1) > 0)
|
||||
total_build_components++;
|
||||
if (recipe->components.count(2))
|
||||
if (recipe->components.count(2) > 0)
|
||||
total_build_components++;
|
||||
if (recipe->components.count(3))
|
||||
if (recipe->components.count(3) > 0)
|
||||
total_build_components++;
|
||||
if (recipe->components.count(4))
|
||||
if (recipe->components.count(4) > 0)
|
||||
total_build_components++;
|
||||
|
||||
|
||||
|
@ -486,7 +489,7 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
item = client->GetPlayer()->item_list.GetItemFromID((*itr));
|
||||
if (item) {
|
||||
packet->setArrayDataByName("build_comp_qty_avail", item->details.count, index );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (index == 2) {
|
||||
|
@ -500,7 +503,7 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
item = client->GetPlayer()->item_list.GetItemFromID((*itr));
|
||||
if (item) {
|
||||
packet->setArrayDataByName("build_comp_qty_avail", item->details.count, index );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (index == 3) {
|
||||
|
@ -514,7 +517,7 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
item = client->GetPlayer()->item_list.GetItemFromID((*itr));
|
||||
if (item) {
|
||||
packet->setArrayDataByName("build_comp_qty_avail", item->details.count, index );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,6 +666,9 @@ EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display
|
|||
return app;
|
||||
}
|
||||
|
||||
void Recipe::AddBuildComp(int32 itemID, int8 slot) {
|
||||
void Recipe::AddBuildComp(int32 itemID, int8 slot, bool preffered) {
|
||||
if (preffered = 1)
|
||||
components[slot].insert(components[slot].begin(), itemID);
|
||||
else
|
||||
components[slot].push_back(itemID);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
class Item;
|
||||
using namespace std;
|
||||
|
||||
struct RecipeComp
|
||||
|
||||
{
|
||||
int32 RecipeComp;
|
||||
|
||||
};
|
||||
struct RecipeProducts {
|
||||
int32 product_id;
|
||||
int32 byproduct_id;
|
||||
|
@ -122,7 +128,7 @@ public:
|
|||
///<summary>Add a build component to this recipe</summary>
|
||||
///<param name="itemID">Item id of the component</param>
|
||||
///<param name="slot">Slot id for this component</param>
|
||||
void AddBuildComp(int32 itemID, int8 slot);
|
||||
void AddBuildComp(int32 itemID, int8 slot, bool preferred = 0);
|
||||
|
||||
// int8 = slot, vector = itemid
|
||||
map<int8, vector<int32> > components;
|
||||
|
|
|
@ -41,8 +41,8 @@ void WorldDatabase::LoadRecipes() {
|
|||
"r.stage0_id, r.stage1_id, r.stage2_id, r.stage3_id, r.stage4_id, r.stage0_qty, r.stage1_qty, r.stage2_qty, r.stage3_qty, r.stage4_qty,\n"
|
||||
"r.stage0_byp_id, r.stage1_byp_id, r.stage2_byp_id, r.stage3_byp_id, r.stage4_byp_id, r.stage0_byp_qty, r.stage1_byp_qty, r.stage2_byp_qty, r.stage3_byp_qty, r.stage4_byp_qty\n"
|
||||
"FROM `recipe` r\n"
|
||||
"LEFT JOIN ((SELECT item_id, soe_recipe_crc FROM item_details_recipe_items GROUP BY soe_recipe_crc) as idri) ON idri.soe_recipe_crc = r.soe_id\n"
|
||||
"LEFT JOIN items i ON idri.item_id = i.id\n"
|
||||
"LEFT JOIN ((SELECT recipe_id, soe_recipe_crc FROM item_details_recipe_items GROUP BY soe_recipe_crc) as idri) ON idri.soe_recipe_crc = r.soe_id\n"
|
||||
"LEFT JOIN items i ON idri.recipe_id = i.id\n"
|
||||
"INNER JOIN items ipc ON r.stage4_id = ipc.id\n"
|
||||
"INNER JOIN recipe_comp_list pcl ON r.primary_comp_list = pcl.id\n"
|
||||
"INNER JOIN recipe_comp_list fcl ON r.fuel_comp_list = fcl.id\n"
|
||||
|
@ -243,10 +243,10 @@ void WorldDatabase::LoadRecipeComponents() {
|
|||
bool status = database_new.Select(&res,
|
||||
"SELECT r.id, pc.item_id AS primary_comp, fc.item_id AS fuel_comp, sc.item_id as secondary_comp, rsc.`index` + 1 AS slot\n"
|
||||
"FROM recipe r\n"
|
||||
"INNER JOIN (select comp_list, item_id FROM recipe_comp_list_item GROUP BY comp_list) as pc ON r.primary_comp_list = pc.comp_list\n"
|
||||
"INNER JOIN (select comp_list, item_id FROM recipe_comp_list_item GROUP BY comp_list) as fc ON r.fuel_comp_list = fc.comp_list\n"
|
||||
"INNER JOIN (select comp_list, item_id FROM recipe_comp_list_item ) as pc ON r.primary_comp_list = pc.comp_list\n"
|
||||
"INNER JOIN (select comp_list, item_id FROM recipe_comp_list_item ) as fc ON r.fuel_comp_list = fc.comp_list\n"
|
||||
"LEFT JOIN recipe_secondary_comp rsc ON rsc.recipe_id = r.id\n"
|
||||
"LEFT JOIN (select comp_list, item_id FROM recipe_comp_list_item GROUP BY comp_list) as sc ON rsc.comp_list = sc.comp_list\n"
|
||||
"LEFT JOIN (select comp_list, item_id FROM recipe_comp_list_item) as sc ON rsc.comp_list = sc.comp_list\n"
|
||||
"WHERE r.bHaveAllProducts\n"
|
||||
"ORDER BY r.id, rsc.`index` ASC");
|
||||
|
||||
|
@ -265,7 +265,6 @@ void WorldDatabase::LoadRecipeComponents() {
|
|||
if (!recipe) {
|
||||
continue;
|
||||
}
|
||||
|
||||
recipe->AddBuildComp(res.GetInt32(1), 0);
|
||||
recipe->AddBuildComp(res.GetInt32(2), 5);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue