Page 1 of 1

[Patch] Fix equipping items

Posted: Sat May 29, 2010 11:55 pm
by Rhas
On revision 437 I am able to equip an item into any slot (weapon on head, etc). This small bit of code fixes it so if you try to equip an item in an invalid slot it does nothing and leaves the item in your inventory. Auto-equipping (drag to avatar or double-click item) still works. I tested this on my server (latest HEAD with only this change) and also went to another public server to verify the bug still existed. Client version tested was 6118L.

Code: Select all

--- Player.cpp	(Revision 437)
+++ Player.cpp (Working Copy)
@@ -953,8 +953,10 @@
 		return packets;
 	Item* item = item_list.indexed_items[index];
 	if(item){
-		int8 slot = equipment_list.GetFreeSlot(item, slot_id);
+		if(slot_id != 255 && !item->HasSlot(slot_id))
+			return packets;
 
+		int8 slot = equipment_list.GetFreeSlot(item, slot_id);		
 		bool canEquip = CanEquipItem(item);
 		if(canEquip && slot == 255)
 		{

Re: [Patch] Fix equipping items

Posted: Sun May 30, 2010 12:12 am
by Scatman
Thanks for the submission. I'll put this patch into the code tomorrow, test it, and put it on svn. Thanks for looking into this!

Re: [Patch] Fix equipping items

Posted: Sun May 30, 2010 12:47 am
by Rhas
No problem! It's been about 5 years since I've touched C++ but I'm still able to follow the code pretty well. I mostly work with .NET now. If you see anything in my code submissions where I'm doing something wrong please let me know. I'm always willing to learn. :D

Re: [Patch] Fix equipping items

Posted: Sun May 30, 2010 2:36 pm
by Scatman
Zcoretri went ahead and applied all three of your diffs. He's checking them in shortly. If you think you'll be doing more code submissions we can set you up with a SVN account so you can check code in. Let us know!