Browse Source

- DoF now properly shows recipe books (struct fix in ItemStructs.xml)
- AoM and DoF both properly display recipes inside recipe book examine
- Adding recipes from a book to a player will now add correctly (via CRC ID) if we cannot identify recipe book by its book name.

Emagi 11 months ago
parent
commit
355d89124d

+ 1 - 2
EQ2/source/WorldServer/Items/Items.cpp

@@ -2417,7 +2417,7 @@ void Item::serialize(PacketStruct* packet, bool show_name, Player* player, int16
 				if(recipebook_info){
 					packet->setArrayLengthByName("num_recipes", recipebook_info->recipes.size());
 					for (int32 i = 0; i < recipebook_info->recipes.size(); i++) {
-						Recipe* recipe = master_recipe_list.GetRecipe(recipebook_info->recipes.at(i));
+						Recipe* recipe = master_recipe_list.GetRecipeByCRC(recipebook_info->recipes.at(i));
 						if (recipe) {
 							packet->setArrayDataByName("recipe_name", recipe->GetName(), i);
 							packet->setArrayDataByName("recipe_id", recipe->GetID(), i);
@@ -2544,7 +2544,6 @@ void Item::serialize(PacketStruct* packet, bool show_name, Player* player, int16
 	packet->setSubstructDataByName("footer", "description", description.c_str());
 
 	LogWrite(ITEM__PACKET, 0, "Items", "Dump/Print Packet in func: %s, line: %i", __FUNCTION__, __LINE__);
-	//packet->PrintPacket();
 
 #if EQDEBUG >= 9
 	packet->PrintPacket();

+ 14 - 1
EQ2/source/WorldServer/Recipes/Recipe.cpp

@@ -99,6 +99,7 @@ bool MasterRecipeList::AddRecipe(Recipe *recipe) {
 	m_recipes.writelock(__FUNCTION__, __LINE__);
 	if (recipes.count(id) == 0) {
 		recipes[id] = recipe;
+		recipes_crc[recipe->GetSoeID()] = recipe;
 		ret = true;
 	}
 	m_recipes.releasewritelock(__FUNCTION__, __LINE__);
@@ -106,7 +107,7 @@ bool MasterRecipeList::AddRecipe(Recipe *recipe) {
 	return ret;
 }
 
-Recipe * MasterRecipeList::GetRecipe(int32 recipe_id) {
+Recipe* MasterRecipeList::GetRecipe(int32 recipe_id) {
 	Recipe *ret = 0;
 
 	m_recipes.readlock(__FUNCTION__, __LINE__);
@@ -117,6 +118,17 @@ Recipe * MasterRecipeList::GetRecipe(int32 recipe_id) {
 	return ret;
 }
 
+Recipe* MasterRecipeList::GetRecipeByCRC(int32 recipe_crc) {
+	Recipe *ret = 0;
+
+	m_recipes.readlock(__FUNCTION__, __LINE__);
+	if (recipes_crc.count(recipe_crc) > 0)
+		ret = recipes_crc[recipe_crc];
+	m_recipes.releasereadlock(__FUNCTION__, __LINE__);
+
+	return ret;
+}
+
 Recipe* MasterRecipeList::GetRecipeByName(const char* name) {
 	Recipe* ret = 0;
 	map<int32, Recipe*>::iterator itr;
@@ -140,6 +152,7 @@ void MasterRecipeList::ClearRecipes() {
 	for (itr = recipes.begin(); itr != recipes.end(); itr++)
 		safe_delete(itr->second);
 	recipes.clear();
+	recipes_crc.clear();
 	m_recipes.releasewritelock(__FUNCTION__, __LINE__);
 }
 

+ 3 - 1
EQ2/source/WorldServer/Recipes/Recipe.h

@@ -194,7 +194,8 @@ public:
 	virtual ~MasterRecipeList();
 
 	bool AddRecipe(Recipe *recipe);
-	Recipe * GetRecipe(int32 recipe_id);
+	Recipe* GetRecipe(int32 recipe_id);
+	Recipe* GetRecipeByCRC(int32 recipe_crc);
 	void ClearRecipes();
 	int32 Size();
 	EQ2Packet* GetRecipePacket(int32 recipe_id, Client *client = 0, bool display = false, int8 packet_type = 0);
@@ -212,6 +213,7 @@ public:
 private:
 	Mutex m_recipes;
 	map<int32, Recipe *> recipes;
+	map<int32, Recipe *> recipes_crc;
 };
 
 class MasterRecipeBookList {

+ 1 - 1
EQ2/source/WorldServer/client.cpp

@@ -11992,7 +11992,7 @@ bool Client::AddRecipeBookToPlayer(int32 recipe_book_id, Item* item) {
 			if (recipes.empty() && item && item->recipebook_info) {
 				//Backup I guess if the recipe book is empty for whatever reason?
 				for (auto& itr : item->recipebook_info->recipes) {
-					Recipe* r = master_recipe_list.GetRecipe(itr);   //GetRecipeByName(itr.c_str());
+					Recipe* r = master_recipe_list.GetRecipeByCRC(itr);   //GetRecipeByName(itr.c_str());
 					if (r) {
 						recipes.push_back(r);
 					}

+ 10 - 0
server/ItemStructs.xml

@@ -4502,6 +4502,16 @@
 <Data ElementName="fence_commission" Type="int16" Size="1" />
 <Data ElementName="footer" Substruct="Substruct_ItemFooter" Size="1" />
 </Struct>
+<Struct Name="WS_ItemRecipeBook" ClientVersion="546" OpcodeName="OP_ClientCmdMsg" OpcodeType="OP_EqExamineInfoCmd">
+<Data ElementName="header" Substruct="Substruct_ItemDescription" Size="1" />
+<Data ElementName="num_recipes" Type="int16" Size="1" OversizedValue="127" />
+<Data ElementName="recipe_array" Type="Array" ArraySizeVariable="num_recipes">
+	<Data ElementName="recipe_name" Type="EQ2_8Bit_String" Size="1" />
+</Data>
+<Data ElementName="uses" Type="int16" Size="1" />
+<Data ElementName="scribed" Type="int8" Size="1" />
+<Data ElementName="footer" Substruct="Substruct_ItemFooter" Size="1" />
+</Struct>
 <Struct Name="WS_ItemRecipeBook" ClientVersion="547" OpcodeName="OP_ClientCmdMsg" OpcodeType="OP_EqExamineInfoCmd">
 <Data ElementName="header" Substruct="Substruct_ItemDescription" Size="1" />
 <Data ElementName="num_recipes" Type="int16" Size="1" OversizedValue="127" />