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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2015, 02:53 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default New Feature: Dye items via an Augmentation

This is something of a feature request with all the code already written.

It adds the ability to dye visible armor pieces with any augmentation in any slot desired, simply by setting the item tint of the augmentation to the desired color.

It works with every client, and doesn't break anything already in effect, because augments don't have a tint color by default. They're all 0xFF000000.

It also plays nicely with items that already have a built-in tint, and with prismatic dye applied to the slot. The priority it gives as to which tint to apply to the slot in question is (highest to lowest): prismatic dye, then augmentation tint, then built-in item tint (if any).

The tint application is immediate when both inserting and removing the augmentation, even if the character is wearing the armor when (un-)augmenting (in RoF+).

It also includes a typo fix in client.cpp's Client::SetTint() methods, where they were saving the tint to the character_material table by the slot_id instead of the material_id, so it would break when re-loaded from the database and tried to be applied to a material slot.

diff --git a/common/item.h b/common/item.h
Code:
index a5dd01f..55cd861 100644
--- a/common/item.h
+++ b/common/item.h
@@ -350,7 +350,7 @@ public:
 	void SetPrice(uint32 price)				{ m_price = price; }
 
 	void SetColor(uint32 color)				{ m_color = color; }
-	uint32 GetColor() const					{ return m_color; }
+	uint32 GetColor() const;
 
 	uint32 GetMerchantSlot() const			{ return m_merchantslot; }
 	void SetMerchantSlot(uint32 slot)		{ m_merchantslot = slot; }
diff --git a/common/item.cpp b/common/item.cpp
Code:
index 8e8ec6f..ab08ec5 100644
--- a/common/item.cpp
+++ b/common/item.cpp
@@ -2318,6 +2318,22 @@ void ItemInst::StopTimer(std::string name) {
 	}
 }
 
+uint32 ItemInst::GetColor() const {
+	ItemInst* aug;
+
+	for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++)
+	{
+		if ((aug = GetAugment(i)) && (aug->GetColor() & 0xFFFFFF))
+		{
+			Log.Out(Logs::General, Logs::Inventory, "Found tinted Augment ID %d in augment slot %d", aug->GetID(), i);
+
+			return aug->GetColor();
+		}
+	}
+
+	return m_color;
+}
+
 void ItemInst::ClearTimers() {
 	m_timers.clear();
 }
diff --git a/common/shareddb.cpp b/common/shareddb.cpp
Code:
index 7301346..fcf3b36 100644
--- a/common/shareddb.cpp
+++ b/common/shareddb.cpp
@@ -191,7 +191,7 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
                                     "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)",
                                     (unsigned long)char_id, (unsigned long)slot_id, (unsigned long)inst->GetItem()->ID,
                                     (unsigned long)charges, (unsigned long)(inst->IsAttuned()? 1: 0),
-                                    inst->GetCustomDataString().c_str(), (unsigned long)inst->GetColor(),
+                                    inst->GetCustomDataString().c_str(), (unsigned long)inst->GetItem()->Color,
                                     (unsigned long)augslot[0], (unsigned long)augslot[1], (unsigned long)augslot[2],
 									(unsigned long)augslot[3], (unsigned long)augslot[4], (unsigned long)augslot[5], (unsigned long)inst->GetOrnamentationIcon(),
 									(unsigned long)inst->GetOrnamentationIDFile(), (unsigned long)inst->GetOrnamentHeroModel());
diff --git a/zone/client.cpp b/zone/client.cpp
Code:
index f823c8b..adfc4a0 100644
--- a/zone/client.cpp
+++ b/zone/client.cpp
@@ -3039,7 +3039,6 @@ void Client::SetTint(int16 in_slot, uint32 color) {
 	Color_Struct new_color;
 	new_color.Color = color;
 	SetTint(in_slot, new_color);
-	database.SaveCharacterMaterialColor(this->CharacterID(), in_slot, color);
 }
 
 // Still need to reconcile bracer01 versus bracer02
@@ -3049,7 +3048,7 @@ void Client::SetTint(int16 in_slot, Color_Struct& color) {
 	if (matslot != _MaterialInvalid)
 	{
 		m_pp.item_tint[matslot].Color = color.Color;
-		database.SaveCharacterMaterialColor(this->CharacterID(), in_slot, color.Color);
+		database.SaveCharacterMaterialColor(this->CharacterID(), matslot, color.Color);
 	}
 
 }
diff --git a/zone/inventory.cpp b/zone/inventory.cpp
Code:
index e1904d5..3e84ea1 100644
--- a/zone/inventory.cpp
+++ b/zone/inventory.cpp
@@ -2635,6 +2635,10 @@ uint32 Client::GetEquipmentColor(uint8 material_slot) const
 	if (material_slot > EmuConstants::MATERIAL_END)
 		return 0;
 
+	ItemInst* inst = GetInv().GetItem(Inventory::CalcSlotFromMaterial(material_slot));
+	if (inst)
+		return inst->GetColor();
+
 	const Item_Struct *item = database.GetItem(GetEquipment(material_slot));
 	if(item != nullptr)
 		return ((m_pp.item_tint[material_slot].RGB.UseTint) ? m_pp.item_tint[material_slot].Color : item->Color);
Reply With Quote
  #2  
Old 08-16-2015, 03:29 AM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

Oh, I had the which-tint-takes-priority code in my testing state there. Here's the correct Client::GetEquipmentColor() method from inventory.cpp:

diff --git a/zone/inventory.cpp b/zone/inventory.cpp
Code:
index e1904d5..c04a6cc 100644
--- a/zone/inventory.cpp
+++ b/zone/inventory.cpp
@@ -2635,9 +2635,16 @@ uint32 Client::GetEquipmentColor(uint8 material_slot) const
 	if (material_slot > EmuConstants::MATERIAL_END)
 		return 0;
 
+	if (m_pp.item_tint[material_slot].RGB.UseTint)
+		return m_pp.item_tint[material_slot].Color; // Priority 1: Prismatic Dye on the slot
+	
+	ItemInst* inst = GetInv().GetItem(Inventory::CalcSlotFromMaterial(material_slot));
+	if (inst != nullptr)
+		return inst->GetColor(); // Priority 2: Equipped item's augmented or default tint
+
 	const Item_Struct *item = database.GetItem(GetEquipment(material_slot));
 	if(item != nullptr)
-		return ((m_pp.item_tint[material_slot].RGB.UseTint) ? m_pp.item_tint[material_slot].Color : item->Color);
+		return item->Color; // Priority 3: Default color for the item from the database
 
 	return 0;
 }
Reply With Quote
Reply


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 10:25 AM.


 

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