Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2007, 06:24 AM
WildcardX
Developer
 
Join Date: Apr 2003
Posts: 589
Default Fix To Search All Inventory Slots For A Key

This code will allow you to have a key anywhere in your inventory. Either in a bag, your personal inventory, the bank, the shard bank or any combination of these. This will bring the server to how keys worked just prior to Sony implementing the keyring (which is what I am going to do next). Right now, EQEmu server has an implementation that behaved like the original key system.

Code:
diff -u c:\temp\old/client.h c:\temp\new/client.h
--- c:\temp\old/client.h	2007-01-07 12:48:22.000000000 -0600
+++ c:\temp\new/client.h	2007-01-13 11:04:45.031250000 -0600
@@ -591,6 +591,7 @@
 	void	SetTint(sint16 slot_id, Color_Struct& color);
 	void	SetMaterial(sint16 slot_id, uint32 item_id);
 	void	Undye();
+	uint32	FindItemInInventory(uint32 item_id);
 	uint32	GetItemIDAt(sint16 slot_id);
 	bool	PutItemInInventory(sint16 slot_id, const ItemInst& inst, bool client_update = false);
 	bool	PushItemOnCursor(const ItemInst& inst, bool client_update = false);
@@ -682,6 +683,7 @@
 	void	OPGMTrainSkill(const EQApplicationPacket *app);
 	void	OPGMSummon(const EQApplicationPacket *app);
 	void	OPCombatAbility(const EQApplicationPacket *app);
+	bool	SlotItemSearch(uint32 startSlot, uint32 endSlot, uint32 item_id);
 	
 	sint16    CalcAC();
 	sint16    CalcATK();
diff -u c:\temp\old/doors.cpp c:\temp\new/doors.cpp
--- c:\temp\old/doors.cpp	2006-11-19 17:39:08.000000000 -0600
+++ c:\temp\new/doors.cpp	2007-01-13 11:49:35.546875000 -0600
@@ -100,7 +100,7 @@
 	//////////////////////////////////////////////////////////////////
 
 	uint32 keyneeded=GetKeyItem(); 
-	uint32 playerkey=sender->GetItemIDAt(SLOT_CURSOR);
+	uint32 playerkey = sender->FindItemInInventory(keyneeded);
 
 	if(GetTriggerType() == 255) { // this object isnt triggered
 		if(trigger == 1) { // this door is only triggered by an object
@@ -137,6 +137,7 @@
 	else
 	{ 
 // guild doors
+
 		if (guild_id>0 && !sender->GetGM())
 		{
 			string tmp;
@@ -167,7 +168,8 @@
 			} 
 		}
 		else if (playerkey)
-		{	// they have something they are trying to open it with
+		{	
+			// they have something they are trying to open it with
 			if (keyneeded && keyneeded == playerkey)
 			{	// key required and client is using the right key 
 				sender->Message(4,"You got it open!");		// more debug spam
diff -u c:\temp\old/inventory.cpp c:\temp\new/inventory.cpp
--- c:\temp\old/inventory.cpp	2006-10-22 15:12:38.000000000 -0500
+++ c:\temp\new/inventory.cpp	2007-01-13 11:40:29.125000000 -0600
@@ -212,6 +212,54 @@
 	object->Save();
 }
 
+// Searches for a specified item anywhere in Players possession
+uint32 Client::FindItemInInventory(uint32 item_id)
+{
+	uint32 result = INVALID_ID;
+
+	// See Item.h for the slot ID's used here
+
+	if(item_id)
+	{
+		if(SlotItemSearch(0, 30, item_id))
+			result = item_id;
+		else if(SlotItemSearch(251, 330, item_id))
+			result = item_id;
+		else if(SlotItemSearch(2000, 2015, item_id))
+			result = item_id;
+		else if(SlotItemSearch(2031, 2190, item_id))
+			result = item_id;
+		else if(SlotItemSearch(2500, 2501, item_id))
+			result = item_id;
+		else if(result = SlotItemSearch(2531, 2550, item_id))
+			result = item_id;
+	}
+
+	return result;
+}
+
+// Searches for a specified item in the specified slot/inventory range
+bool Client::SlotItemSearch(uint32 startSlot, uint32 endSlot, uint32 item_id)
+{
+	bool result = false;
+
+	if(item_id)
+	{
+		for(uint32 x = startSlot; x <= endSlot; x++)
+		{
+			const ItemInst* inst = m_inv[x];
+
+			if(inst)
+			{
+				if(inst->GetItem()->ID == item_id)
+					result = true;
+			}
+		}
+	}
+
+	return result;
+}
+
 // Returns a slot's item ID (returns INVALID_ID if not found)
 uint32 Client::GetItemIDAt(sint16 slot_id) {
 	const ItemInst* inst = m_inv[slot_id];
This was tested by myself and Sesmar. Enjoy!
__________________
Read my developer notes at my blog.

Quote:
If it's not on IRC, it ain't l33t!
Reply With Quote
  #2  
Old 01-14-2007, 08:43 AM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

Thank you! Good luck with the keyrings!
Reply With Quote
  #3  
Old 01-14-2007, 11:05 AM
Teppen
Banned
 
Join Date: Jan 2002
Posts: 80
Default

Nice, this could also be useful displaying what zones player is keyed for just like in the real magelo system, ex: (key to charasis, sleeper's key,.. etc.). Who was the author of the eqemu magelo system by the way? Havent seen it updated in awhile, and this would be a nice feature, especially when peq releases PoP and code is entered for "blank has recieved a character flag", then this could also help displaying planar progression flags in magelo clone.

just a thought.
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 07:26 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