Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2015, 02:34 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default Patch: Augmenting Fixes

This fix adds the ability to Remove, Delete, and Swap augmentations in an item via RoF's new birdbath-less easy way.

It also removes the hard-coded item IDs for augmentation solvents in older clients' augmentation removal methods in favor of checking the ItemType to see whether they're combining with a solvent or distiller.

diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp
Code:
index f1ec8e8..75a0658 100644
--- a/zone/client_packet.cpp
+++ b/zone/client_packet.cpp
@@ -2933,137 +2933,196 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
 
 		//Message(15, "%i %i %i %i %i %i", in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id);
 
-		// Adding augment
-		if (in_augment->augment_action == 0)
+		ItemInst *tobe_auged = nullptr, *auged_with = nullptr, *old_aug = nullptr, *aug = nullptr;
+		Inventory& user_inv = GetInv();
+
+		uint16 slot_id = in_augment->container_slot;
+		uint16 aug_slot_id = in_augment->augment_slot; //it's actually solvent slot
+		uint8 mat = Inventory::CalcMaterialFromSlot(slot_id);
+
+		if (slot_id == INVALID_INDEX || aug_slot_id == INVALID_INDEX)
 		{
-			ItemInst *tobe_auged = nullptr, *auged_with = nullptr;
-			int8 slot = -1;
-			Inventory& user_inv = GetInv();
+			Message(13, "Error: Invalid Aug Index.");
+			return;
+		}
 
-			uint16 slot_id = in_augment->container_slot;
-			uint16 aug_slot_id = in_augment->augment_slot;
-			if (slot_id == INVALID_INDEX || aug_slot_id == INVALID_INDEX)
-			{
-				Message(13, "Error: Invalid Aug Index.");
-				return;
-			}
+		tobe_auged = user_inv.GetItem(slot_id);
+		auged_with = user_inv.GetItem(aug_slot_id);
 
-			tobe_auged = user_inv.GetItem(slot_id);
-			auged_with = user_inv.GetItem(MainCursor);
+		switch (in_augment->augment_action)
+		{
+			case 0: // Adding augment
+			case 2: // Swapping augment
+				auged_with = user_inv.GetItem(MainCursor);
 
-			if (tobe_auged && auged_with)
-			{
-				if (((tobe_auged->IsAugmentSlotAvailable(auged_with->GetAugmentType(), in_augment->augment_index)) != -1) &&
-					(tobe_auged->AvailableWearSlot(auged_with->GetItem()->Slots)))
+				if (tobe_auged && auged_with)
 				{
-					tobe_auged->PutAugment(in_augment->augment_index, *auged_with);
-					tobe_auged->UpdateOrnamentationInfo();
-
-					ItemInst *aug = tobe_auged->GetAugment(in_augment->augment_index);
-					if (aug) {
-						std::vector<EQEmu::Any> args;
-						args.push_back(aug);
-						parse->EventItem(EVENT_AUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
-
-						args.assign(1, tobe_auged);
-						parse->EventItem(EVENT_AUGMENT_INSERT, this, aug, nullptr, "", in_augment->augment_index, &args);
-					}
-					else
+					if (((tobe_auged->IsAugmentSlotAvailable(auged_with->GetAugmentType(), in_augment->augment_index)) != -1) &&
+						(tobe_auged->AvailableWearSlot(auged_with->GetItem()->Slots)))
 					{
-						Message(13, "Error: Could not find augmentation at index %i. Aborting.", in_augment->augment_index);
-						return;
-					}
-
-					itemOneToPush = tobe_auged->Clone();
-					// Must push items after the items in inventory are deleted - necessary due to lore items...
-					if (itemOneToPush)
-					{
-						DeleteItemInInventory(slot_id, 0, true);
-						DeleteItemInInventory(MainCursor, 0, true);
-
-						if (PutItemInInventory(slot_id, *itemOneToPush, true))
+						old_aug = aug = tobe_auged->RemoveAugment(in_augment->augment_index);
+						if (aug)
 						{
-							CalcBonuses();
-							// Successfully added an augment to the item
+							std::vector<EQEmu::Any> args;
+							args.push_back(aug);
+							parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
+
+							args.assign(1, tobe_auged);
+
+							args.push_back(false);
+
+							parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
+						}
+
+						tobe_auged->PutAugment(in_augment->augment_index, *auged_with);
+						tobe_auged->UpdateOrnamentationInfo();
+
+						aug = tobe_auged->GetAugment(in_augment->augment_index);
+						if (aug)
+						{
+							std::vector<EQEmu::Any> args;
+							args.push_back(aug);
+							parse->EventItem(EVENT_AUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
+
+							args.assign(1, tobe_auged);
+							parse->EventItem(EVENT_AUGMENT_INSERT, this, aug, nullptr, "", in_augment->augment_index, &args);
+						}
+						else
+						{
+							Message(13, "Error: Could not find inserted augmentation at index %i. Aborting.", in_augment->augment_index);
+							return;
+						}
+
+						itemOneToPush = tobe_auged->Clone();
+						if (old_aug)
+							itemTwoToPush = old_aug->Clone();
+						// Must push items after the items in inventory are deleted - necessary due to lore items...
+						if (itemOneToPush)
+						{
+							DeleteItemInInventory(slot_id, 0, true);
+							DeleteItemInInventory(MainCursor, auged_with->IsStackable() ? 1 : 0, true);
+
+							if (itemTwoToPush)
+							{
+								PutItemInInventory(MainCursor, *itemTwoToPush, true);
+							}
+
+							if (PutItemInInventory(slot_id, *itemOneToPush, true))
+							{
+								CalcBonuses();
+								// Successfully added an augment to the item
+								if (mat != _MaterialInvalid)
+									SendWearChange(mat);
+							}
+							else
+							{
+								Message(13, "Error: No available slot for end result. Please free up the augment slot.");
+							}
+
 							return;
 						}
 						else
 						{
-							Message(13, "Error: No available slot for end result. Please free up the augment slot.");
+							Message(13, "Error in cloning item for augment. Aborted.");
 						}
+
 					}
 					else
 					{
-						Message(13, "Error in cloning item for augment. Aborted.");
+						Message(13, "Error: No available slot for augment in that item.");
 					}
+				}
+				break;
+			case 1: // Removing augment
+				if (!auged_with)
+					return;
 
+				aug = tobe_auged->GetAugment(in_augment->augment_index);
+				if (aug)
+				{
+					std::vector<EQEmu::Any> args;
+					args.push_back(aug);
+					parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
+
+					args.assign(1, tobe_auged);
+
+					args.push_back(false);
+
+					parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
 				}
 				else
 				{
-					Message(13, "Error: No available slot for augment in that item.");
+					Message(13, "Error: Could not find augmentation to remove at index %i. Aborting.");
+					return;
 				}
-			}
-		}
-		else if (in_augment->augment_action == 1)
-		{
-			ItemInst *tobe_auged = nullptr, *auged_with = nullptr;
-			int8 slot = -1;
-			Inventory& user_inv = GetInv();
 
-			uint16 slot_id = in_augment->container_slot;
-			uint16 aug_slot_id = in_augment->augment_slot; //it's actually solvent slot
-			if (slot_id == INVALID_INDEX || aug_slot_id == INVALID_INDEX)
-			{
-				Message(13, "Error: Invalid Aug Index.");
-				return;
-			}
+				old_aug = tobe_auged->RemoveAugment(in_augment->augment_index);
+				tobe_auged->UpdateOrnamentationInfo();
 
-			tobe_auged = user_inv.GetItem(slot_id);
-			auged_with = user_inv.GetItem(aug_slot_id);
-
-			ItemInst *old_aug = nullptr;
-			if (!auged_with)
-				return;
-			const uint32 id = auged_with->GetID();
-			ItemInst *aug = tobe_auged->GetAugment(in_augment->augment_index);
-			if (aug) {
-				std::vector<EQEmu::Any> args;
-				args.push_back(aug);
-				parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
-
-				args.assign(1, tobe_auged);
-
-				args.push_back(false);
-
-				parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
-			}
-			else
-			{
-				Message(13, "Error: Could not find augmentation at index %i. Aborting.");
-				return;
-			}
-			old_aug = tobe_auged->RemoveAugment(in_augment->augment_index);
-			tobe_auged->UpdateOrnamentationInfo();
-
-			itemOneToPush = tobe_auged->Clone();
-			if (old_aug)
-				itemTwoToPush = old_aug->Clone();
-			if (itemOneToPush && itemTwoToPush && auged_with)
-			{
-				DeleteItemInInventory(slot_id, 0, true);
-				DeleteItemInInventory(aug_slot_id, auged_with->IsStackable() ? 1 : 0, true);
-
-				if (!PutItemInInventory(slot_id, *itemOneToPush, true))
+				itemOneToPush = tobe_auged->Clone();
+				if (old_aug)
+					itemTwoToPush = old_aug->Clone();
+				if (itemOneToPush && itemTwoToPush && auged_with)
 				{
-					Message(15, "Failed to remove augment properly!");
+					DeleteItemInInventory(slot_id, 0, true);
+					DeleteItemInInventory(aug_slot_id, auged_with->IsStackable() ? 1 : 0, true);
+
+					if (!PutItemInInventory(slot_id, *itemOneToPush, true))
+					{
+						Message(15, "Failed to remove augment properly!");
+					}
+
+					if (PutItemInInventory(MainCursor, *itemTwoToPush, true))
+					{
+						CalcBonuses();
+						//Message(15, "Successfully removed an augmentation!");
+						if (mat != _MaterialInvalid)
+							SendWearChange(mat);
+					}
+				}
+				break;
+			case 3: // Destroying augment
+				aug = tobe_auged->GetAugment(in_augment->augment_index);
+				if (aug)
+				{
+					std::vector<EQEmu::Any> args;
+					args.push_back(aug);
+					parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
+
+					args.assign(1, tobe_auged);
+
+					args.push_back(true);
+
+					parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
+				}
+				else
+				{
+					Message(13, "Error: Could not find augmentation at index %i. Aborting.");
+					return;
 				}
 
-				if (PutItemInInventory(MainCursor, *itemTwoToPush, true))
+				tobe_auged->DeleteAugment(in_augment->augment_index);
+				tobe_auged->UpdateOrnamentationInfo();
+
+				itemOneToPush = tobe_auged->Clone();
+				if (itemOneToPush)
 				{
-					CalcBonuses();
-					//Message(15, "Successfully removed an augmentation!");
+					DeleteItemInInventory(slot_id, 0, true);
+
+					if (!PutItemInInventory(slot_id, *itemOneToPush, true))
+					{
+						Message(15, "Failed to delete augment properly!");
+					}
 				}
-			}
+
+				CalcBonuses();
+				//Message(15, "Successfully removed an augmentation!");
+				if (mat != _MaterialInvalid)
+					SendWearChange(mat);
+				break;
+			default: // Unknown
+				Log.Out(Logs::General, Logs::Inventory, "cslot: %i aslot: %i cidx: %i aidx: %i act: %i dest: %i", in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id);
+				break;
 		}
 	}
 	else
diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp
Code:
index 6ed516d..9037de6 100644
--- a/zone/tradeskills.cpp
+++ b/zone/tradeskills.cpp
@@ -166,7 +166,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
 	else
 	{
 		ItemInst *old_aug = nullptr;
-		const uint32 id = auged_with->GetID();
+		bool isSolvent = auged_with->GetItem()->ItemType == ItemUseTypes::ItemTypeAugmentationSolvent;
 		ItemInst *aug = tobe_auged->GetAugment(in_augment->augment_slot);
 		if(aug) {
 			std::vector<EQEmu::Any> args;
@@ -174,17 +174,13 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
 			parse->EventItem(EVENT_UNAUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
 
 			args.assign(1, tobe_auged);
-			bool destroyed = false;
-			if(id == 40408 || id == 40409 || id == 40410) {
-				destroyed = true;
-			}
 
-			args.push_back(&destroyed);
+			args.push_back(&isSolvent);
 
 			parse->EventItem(EVENT_AUGMENT_REMOVE, user, aug, nullptr, "", slot, &args);
 		}
 
-		if(id == 40408 || id == 40409 || id == 40410)
+		if (isSolvent)
 			tobe_auged->DeleteAugment(in_augment->augment_slot);
 		else
 			old_aug = tobe_auged->RemoveAugment(in_augment->augment_slot);
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:17 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3