View Single Post
  #7  
Old 07-27-2012, 12:36 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

Here's another 'in-work' mod...

(Remember, I'm trying to find ALL occurences of CSDs/bugged inventories.)


Code:
Index: client_packet.cpp
===================================================================
--- client_packet.cpp	(revision 2173)
+++ client_packet.cpp	(working copy)
@@ -3278,6 +3278,8 @@
 	return;
 }
 
+// 'CSD 11' - Added checks for illegal bagslot swaps..should help with certain cheats
+// - If a player has used a cheat that allows illegal item placement, they could beomce bugged at some point (especially lore items.)
 void Client::Handle_OP_MoveItem(const EQApplicationPacket *app)
 {
 	if(!CharacterID())
@@ -3291,6 +3293,7 @@
 	}
 
 	MoveItem_Struct* mi = (MoveItem_Struct*)app->pBuffer;
+
 	if(spellend_timer.Enabled() && casting_spell_id && !IsBardSong(casting_spell_id))
 	{
 		if(mi->from_slot != mi->to_slot && (mi->from_slot < 30 || mi->from_slot > 39) && IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot))
@@ -3310,6 +3313,53 @@
 			return;
 		}
 	}
+
+	// REMOVE OR REMARK OUT BEGIN FOR ALLOWING ILLEGAL BAGSLOT USE
+	bool hackflag = false;
+
+	if (mi->from_slot >=251 && mi->from_slot <=340) {
+		if (mi->from_slot > 330)
+			hackflag = true; // why are we moving from a cursor bagslot when you can't open it?
+		else {
+			sint16 invslot = Inventory::CalcSlotId(mi->from_slot);
+			const ItemInst *invslotitem = GetInv().GetItem(invslot); 
+
+			if (invslotitem->GetItem()->ItemClass==1) { // checking the parent inventory slot for container
+				if (Inventory::CalcBagIdx(mi->from_slot) > invslotitem->GetItem()->BagSlots)
+					hackflag = true; // trying to move from slots beyond container size
+			}
+			else { // trying to move from bag slots when inventory item is not a container
+				hackflag = true;
+			}
+		}
+	}
+
+	if (mi->to_slot >= 251 && mi->to_slot <=340) {
+		bool hackflag = false;
+
+		if (mi->to_slot > 330)
+			hackflag = true; // why are we moving to a cursor bagslot when you can't open it?
+		else {
+			sint16 invslot = Inventory::CalcSlotId(mi->to_slot);
+			const ItemInst *invslotitem = GetInv().GetItem(invslot);
+
+			if (invslotitem->GetItem()->ItemClass==1) { // checking the parent inventory slot for container
+				if (Inventory::CalcBagIdx(mi->from_slot) > invslotitem->GetItem()->BagSlots)
+					hackflag = true; // trying to move into slots beyond container size
+			}
+			else { // trying to move into bag slots when inventory item is not a container
+				hackflag = true;
+			}
+		}
+	}
+
+	if (hackflag) {
+		Message(13, "Hack attempt detected - Illegal use of inventory bagslots!");
+		// TODO: Decide whether to log player as hacker
+		// Kick();
+	}
+	// REMOVE OR REMARK OUT END FOR ALLOWING ILLEGAL BAGSLOT USE */
+
 	SwapItem(mi);
 	return;
 }

Tested with legal trades, but untested for illegal...

This is still in a crude state, but any input is appreciated!
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote