From c4c96904d1c2b1133e4521ec76ae5487f28defb9 Mon Sep 17 00:00:00 2001 From: Emagi Date: Thu, 13 Mar 2025 06:48:12 -0400 Subject: [PATCH] Assure the db entry of the byproduct is valid to use --- source/WorldServer/Tradeskills/Tradeskills.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/WorldServer/Tradeskills/Tradeskills.cpp b/source/WorldServer/Tradeskills/Tradeskills.cpp index a5b6cfd..c875bdf 100644 --- a/source/WorldServer/Tradeskills/Tradeskills.cpp +++ b/source/WorldServer/Tradeskills/Tradeskills.cpp @@ -490,12 +490,15 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) { item->creator = std::string(client->GetPlayer()->GetName()); client->AddItem(item); if(byproduct_itemid) { - Item* byproductItem = new Item(master_item_list.GetItem(byproduct_itemid)); - byproductItem->creator = std::string(client->GetPlayer()->GetName()); - byproductItem->details.count = byproduct_qty; - client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You received %s as a byproduct.", byproductItem->CreateItemLink(client->GetVersion()).c_str()); - client->AddItem(byproductItem); - client->GetPlayer()->CheckQuestsCraftUpdate(byproductItem, byproduct_qty); + Item* byproduct = master_item_list.GetItem(byproduct_itemid); + if(byproduct) { + Item* byproductItem = new Item(byproduct); + byproductItem->creator = std::string(client->GetPlayer()->GetName()); + byproductItem->details.count = byproduct_qty; + client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You received %s as a byproduct.", byproductItem->CreateItemLink(client->GetVersion()).c_str()); + client->AddItem(byproductItem); + client->GetPlayer()->CheckQuestsCraftUpdate(byproductItem, byproduct_qty); + } } //Check for crafting quest updates int8 update_amt = 0;