void CUser::BuyingMerchantList(Packet & pkt)
{
    if (m_sMerchantsSocketID >= 0)
        RemoveFromMerchantLookers(); //This check should never be hit...

    uint16 uid = pkt.read<uint16>();

    CUser *pMerchant = g_pMain->GetUserPtr(uid);
    if (pMerchant == nullptr
            || !pMerchant->isMerchanting())
        return;

    m_sMerchantsSocketID = uid;
    pMerchant->m_arMerchantLookers.push_front(GetSocketID());

    Packet result(WIZ_MERCHANT, uint8(MERCHANT_BUY_LIST));
    result << uint8(1) << uint16(uid);
    for (int i = 0; i < MAX_MERCH_ITEMS; i++)
    {
        _MERCH_DATA *pMerch = &pMerchant->m_arMerchantItems[i];
        result	<< pMerch->nNum << pMerch->sCount
                << pMerch->sDuration << pMerch->nPrice;
    }
    Send(&result);
}
void CUser::MerchantItemList(Packet & pkt)
{
	if (m_sMerchantsSocketID >= 0)
		RemoveFromMerchantLookers(); //This check should never be hit...
	
	uint16 uid;
	pkt >> uid;

	if (uid >= MAX_USER)
		return;

	CUser *pMerchantUser = g_pMain->GetUserPtr(uid);
	if(!pMerchantUser || !pMerchantUser->isMerchanting())
		return;

	m_sMerchantsSocketID = uid;
	pMerchantUser->m_arMerchantLookers.push_front(GetSocketID());

	Packet result(WIZ_MERCHANT, uint8(MERCHANT_ITEM_LIST));
	result << uint16(1) << uint16(uid);
	for(int i = 0; i < MAX_MERCH_ITEMS; i++) {
		result << pMerchantUser->m_arSellingItems[i].nNum
		<< pMerchantUser->m_arSellingItems[i].sCount
		<< pMerchantUser->m_arSellingItems[i].sDuration
		<< pMerchantUser->m_arSellingItems[i].nPrice
		<< uint32(0); //Not sure what this one is, maybe serial?
	}
	Send(&result);
}
void CUser::CancelMerchant()
{
    if (m_sMerchantsSocketID < 0)
        return;

    RemoveFromMerchantLookers();
    Packet result(WIZ_MERCHANT, uint8(MERCHANT_TRADE_CANCEL));
    result << uint16(1);
    Send(&result);
}
void CUser::BuyingMerchantClose()
{
    if (isMerchanting())
        m_bMerchantState = MERCHANT_STATE_NONE;
    else if (m_sMerchantsSocketID >= 0)
        RemoveFromMerchantLookers();
    else
        return;

    Packet result(WIZ_MERCHANT, uint8(MERCHANT_BUY_CLOSE));
    result << GetSocketID();
    SendToRegion(&result);
}