DMG Hack Fix (APet)

06/13/2021 18:09 theDJ-scripts#1
​Too many people already know it... for those who didn't know the dmg hack (with apets)*before:

doFuncItem.cpp

in this function

Code:
void do_ItemWear(CPC* ch, CNetMsg::SP& msg)
right after

Code:
CItem* item = ch->m_inventory.getItem(packet->tab, packet->invenIndex);
insert

Quote:
Originally Posted by LiQuiD View Post
If you are not removing the wearpos from the packet a fix just checking for pets is not the best idea so you can still put other items on places where they should never be.

rather do:
Code:
if (packet->wearPos != item->m_itemProto->getItemWearing())
{
	CNetMsg::SP rmsg(new CNetMsg);
	ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
	SEND_Q(rmsg, ch->m_desc);
	return;
}
06/13/2021 18:32 Veni/Marius#2
better way is to first remove the wear position from the packet itself. the client does not need to send that info to the server, the server should check and determine that itself.

so in the end you should do something like this:

Code:
CItem* item = ch->m_inventory.getItem(packet->tab, packet->invenIndex);

int wearPos;
wearPos = item->m_itemProto->getItemWearing()

// change all packet->wearPos to the varaible like this

	if (wearPos < 0 || wearPos >= MAX_WEARING)
	{
		CNetMsg::SP rmsg(new CNetMsg);
		ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
		SEND_Q(rmsg, ch->m_desc);
		return ;
	}
Sure, you check if it's an "APet", but you dont check if its a normal pet. With this you also dont check if the item is an experience booster.

If you see code like this you should fix it properly and not just half of it
06/13/2021 19:16 LiQuiD#3
If you are not removing the wearpos from the packet a fix just checking for pets is not the best idea so you can still put other items on places where they should never be.

rather do:
Code:
if (packet->wearPos != item->m_itemProto->getItemWearing())
{
	CNetMsg::SP rmsg(new CNetMsg);
	ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
	SEND_Q(rmsg, ch->m_desc);
	return;
}
06/22/2021 14:06 LiQuiD#4
Quote:
Originally Posted by LiQuiD View Post
If you are not removing the wearpos from the packet a fix just checking for pets is not the best idea so you can still put other items on places where they should never be.

rather do:
Code:
if (packet->wearPos != item->m_itemProto->getItemWearing())
{
	CNetMsg::SP rmsg(new CNetMsg);
	ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
	SEND_Q(rmsg, ch->m_desc);
	return;
}
There is a problem with the fix i wrote. If you try to wear more than one accessory the packet->wearpos will increase by 1 but the serverside accessory wearing will remain 7.

So this should solve the problem:
Code:
	if (packet->wearPos != item->m_itemProto->getItemWearing())
	{
		if (item->IsAccessary())
		{
			if (packet->wearPos < WEARING_ACCESSORY1 || packet->wearPos > WEARING_ACCESSORY3)
			{
				CNetMsg::SP rmsg(new CNetMsg);
				ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
				SEND_Q(rmsg, ch->m_desc);
				return;
			}
		}
		else
		{
			CNetMsg::SP rmsg(new CNetMsg);
			ResponseClient::ItemWearMsg(rmsg, ResponseClient::WEAR_ERR_INVALID_POS);
			SEND_Q(rmsg, ch->m_desc);
			return;
		}
	}