else if (type == 1 && pNpc->m_iSellingGroup == 249000)
{
if (m_sItemArray[SLOT_MAX+pos].nNum != 0)
{
if (m_sItemArray[SLOT_MAX+pos].nNum != itemid)
{
errorCode = 2;
goto fail_return;
}
if (!pTable->m_bCountable || count <= 0)
{
errorCode = 2;
goto fail_return;
}
if (pTable->m_bCountable
&& (count + m_sItemArray[SLOT_MAX+pos].sCount) > MAX_ITEM_COUNT)
{
errorCode = 4;
goto fail_return;
}
}
transactionPrice = ((uint32)pTable->m_iNPBuyPrice * count);
if(pTable->m_bSellingGroup == 0)
{
errorCode = 3;
goto fail_return;
}
if (!hasLoyalty(transactionPrice))
{
errorCode = 3;
goto fail_return;
}
if (((pTable->m_sWeight * count) + m_sItemWeight) > m_sMaxWeight)
{
errorCode = 4;
goto fail_return;
}
m_sItemArray[SLOT_MAX+pos].nNum = itemid;
m_sItemArray[SLOT_MAX+pos].sDuration = pTable->m_sDuration;
m_sItemArray[SLOT_MAX+pos].sCount += count;
m_iLoyalty -= transactionPrice;
if (!pTable->m_bCountable)
m_sItemArray[SLOT_MAX+pos].nSerialNum = g_pMain->GenerateItemSerial();
SetUserAbility(false);
SendItemWeight();
}
else if (type == 2 && pNpc->m_iSellingGroup == 249000)
goto fail_return;
.
.
.
fail_return:
result << bSuccess;
if (!bSuccess)
result << errorCode;
else if (pNpc->m_iSellingGroup == 249000 && bSuccess)
result << pTable->m_bSellingGroup << m_iLoyalty << transactionPrice;
else if (pNpc->m_iSellingGroup != 249000 && bSuccess)
result << pTable->m_bSellingGroup << m_iGold << transactionPrice; // price bought or sold for