Переглянути джерело

More TS fixes

Fixed where new scribed books would send updated device info
Robert Allen 2 роки тому
батько
коміт
4b07fbdadd

+ 2 - 34
EQ2/source/WorldServer/Recipes/RecipeDB.cpp

@@ -72,40 +72,8 @@ void WorldDatabase::LoadRecipes() {
 		string device = res.GetString(i++);
 		int32 deviceID = 0;
 		int8 deviceSubType = 0;
-		if (device == "chemistry_table") {
-			device = "Chemistry Table";
-			deviceID = 3;
-		}
-		else if (device == "work_desk") {
-			device = "Engraved Desk";
-			deviceID = 4;
-		}
-		else if (device == "forge") {
-			device = "Forge";
-			deviceID = 2;
-		}
-		else if (device == "stove and keg") {
-			device = "Stove & Keg";
-			deviceID = 7;
-		}
-		else if (device == "sewing_table") {
-			device = "Sewing Table & Mannequin";
-			deviceID = 1;
-		}
-		else if (device == "woodworking_table") {
-			device = "Woodworking Table";
-			deviceID = 6;
-		}
-		else if (device == "work_bench") {
-			device = "Work Bench";
-			deviceID = 4;
-			}
-		else if (device == "crafting_intro_anvil") {
-			device = "Mender's Anvil";
-			deviceID = 0;
-			deviceSubType = 1;
-			}
-		recipe->SetDevice(device.c_str());
+		
+		recipe->SetDevice(GetDeviceName(device).c_str());
 		recipe->SetUnknown2(deviceID);
 		recipe->SetDevice_Sub_Type(deviceSubType);
 		recipe->SetClasses(res.GetInt64(i++));	

+ 18 - 2
EQ2/source/WorldServer/client.cpp

@@ -11263,6 +11263,9 @@ void Client::UpdateCharacterRewardData(QuestRewardData* data) {
 }
 
 void Client::AddRecipeToPlayer(Recipe* recipe, PacketStruct* packet, int16* i) {
+	
+	
+	int  index = 0;
 	if(recipe == nullptr)
 		return;
 	
@@ -11271,6 +11274,13 @@ void Client::AddRecipeToPlayer(Recipe* recipe, PacketStruct* packet, int16* i) {
 		delete recipe;
 		return;
 	}
+	auto res = std::find(devices.begin(), devices.end(), recipe->GetDevice());
+
+	if (res != devices.end())
+		index = res - devices.begin();
+	else
+		devices.push_back(recipe->GetDevice());
+
 
 	prl->AddRecipe(recipe);
 	database.SavePlayerRecipe(GetPlayer(), recipe->GetID());
@@ -11282,10 +11292,16 @@ void Client::AddRecipeToPlayer(Recipe* recipe, PacketStruct* packet, int16* i) {
 		packet->setArrayDataByName("level", recipe->GetLevel(), *i);
 		packet->setArrayDataByName("icon", recipe->GetIcon(), *i);
 		packet->setArrayDataByName("classes", recipe->GetClasses(), *i);
-		packet->setArrayDataByName("skill", recipe->GetSkill(), *i);
+		//packet->setArrayDataByName("skill", recipe->GetSkill(), *i);
 		packet->setArrayDataByName("technique", recipe->GetTechnique(), *i);
 		packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), *i);
-		packet->setArrayDataByName("unknown2", recipe->GetUnknown2(), *i);
+		auto recipe_device = std::find(devices.begin(), devices.end(), recipe->GetDevice());
+		if (recipe_device != devices.end())
+			packet->setArrayDataByName("device_type", recipe_device - devices.begin(), *i);
+		else
+		{//TODO error should never get here
+		}
+		packet->setArrayDataByName("device_sub_type", recipe->GetDevice_Sub_Type(), *i);
 		packet->setArrayDataByName("recipe_name", recipe->GetName(), *i);
 		packet->setArrayDataByName("recipe_book", recipe->GetBook(), *i);
 		packet->setArrayDataByName("unknown3", recipe->GetUnknown3(), *i);

+ 19 - 1
EQ2/source/common/MiscFunctions.cpp

@@ -801,7 +801,25 @@ bool INIReadBool(FILE *f, const char *section, const char *property, bool *out)
 	return true;
 
 }
-
+string GetDeviceName(string device) {
+	if (device == "chemistry_table") 
+		device = "Chemistry Table";
+	else if (device == "work_desk")
+		device = "Engraved Desk";
+	else if (device == "forge") 
+		device = "Forge";
+	else if (device == "stove and keg")
+		device = "Stove & Keg";
+	else if (device == "sewing_table") 
+		device = "Sewing Table & Mannequin";
+	else if (device == "woodworking_table") 
+		device = "Woodworking Table";
+	else if (device == "work_bench") 
+		device = "Work Bench";
+	else if (device == "crafting_intro_anvil")
+		device = "Mender's Anvil";
+	return device;
+}
 int16 GetItemPacketType(int32 version) {
 	int16 item_version;
 	if (version >= 64707)

+ 1 - 0
EQ2/source/common/MiscFunctions.h

@@ -76,6 +76,7 @@ int8 CheckOverLoadSize(int32 val);
 int32	CountWordsInString(const char* text);
 bool IsNumber(const char *num);
 void PrintSep(Seperator *sep, const char *name = 0);
+string GetDeviceName(string device);
 ///<summary>Gets the packet type for the given version</summary>
 ///<param name='version'>The client version</param>
 int16 GetItemPacketType(int32 version);