void CUser::ItemMove(char *pBuf) { int index = 0, itemid = 0, srcpos = -1, destpos = -1; int sItemID = 0, sItemCount = 0, sItemDuration = 0; __int64 sItemSerial = 0; _ITEM_TABLE* pTable = NULL; BYTE dir; dir = GetByte( pBuf, index ); itemid = GetDWORD( pBuf, index ); srcpos = GetByte( pBuf, index ); destpos = GetByte( pBuf, index ); if( m_sExchangeUser != -1 ) goto fail_return; pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) goto fail_return; // if( dir == ITEM_INVEN_SLOT && ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight) ) // goto fail_return; if( dir > 0x0B || srcpos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX || destpos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX ) goto fail_return; if( (dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT ) && destpos > SLOT_MAX ) goto fail_return; if( dir == ITEM_SLOT_INVEN && srcpos > SLOT_MAX ) goto fail_return; if( dir == ITEM_INVEN_SLOT && destpos == RESERVED ) goto fail_return; if( dir == ITEM_SLOT_INVEN && srcpos == RESERVED ) goto fail_return; if( dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT ) { if( pTable->m_bRace != 0 ) { if( pTable->m_bRace != m_pUserData->m_bRace ) goto fail_return; } if( !ItemEquipAvailable( pTable ) ) goto fail_return; } switch( dir ) { case ITEM_MBAG_TO_MBAG: if(SLOT_MAX+HAVE_MAX+COSP_MAX+destpos >= 49 && SLOT_MAX+HAVE_MAX+COSP_MAX+destpos <=60 && m_pUserData->m_sItemArray[BAG1].nNum==0) goto fail_return; if(SLOT_MAX+HAVE_MAX+COSP_MAX+destpos >= 61 && SLOT_MAX+HAVE_MAX+COSP_MAX+destpos <=72 && m_pUserData->m_sItemArray[BAG2].nNum==0) goto fail_return; if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum != 0 ) { sItemID = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum; sItemDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sDuration; sItemCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sCount; sItemSerial = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum; } m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum ; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum = sItemID; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sDuration = sItemDuration; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sCount = sItemCount; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nSerialNum = sItemSerial; break; case ITEM_MBAG_TO_INVEN: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum != 0 ) { sItemID = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum; sItemCount = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount; sItemDuration = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration; sItemSerial = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum; } m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nNum = sItemID; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sDuration = sItemDuration; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].sCount = sItemCount; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+srcpos].nSerialNum = sItemSerial; break; case ITEM_INVEN_TO_MBAG: // TO-DO : Change the m_sItemArray[BAG1/2].nNum check to the actual magic bag ID. if(SLOT_MAX+HAVE_MAX+COSP_MAX+destpos >= 49 && SLOT_MAX+HAVE_MAX+COSP_MAX+destpos <=60 && m_pUserData->m_sItemArray[BAG1].nNum == 0) goto fail_return; if(SLOT_MAX+HAVE_MAX+COSP_MAX+destpos >= 61 && SLOT_MAX+HAVE_MAX+COSP_MAX+destpos <=73 && m_pUserData->m_sItemArray[BAG2].nNum == 0) goto fail_return; if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum != 0 ) { sItemID = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum; sItemCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sCount; sItemDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sDuration; sItemSerial = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum; } m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+COSP_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = sItemID; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = sItemDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = sItemCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = sItemSerial; break; case ITEM_COSP_TO_INVEN: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].nNum ) //Make sure we actually have that item. goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum != 0 ) goto fail_return; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].nNum = 0; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].sDuration = 0; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].sCount = 0; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+srcpos].nSerialNum = 0; break; case ITEM_INVEN_TO_COSP: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) //Make sure we actually have that item. goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nNum != 0 ) { sItemID = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nNum; sItemCount = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].sCount; sItemDuration = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].sDuration; sItemSerial = m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nSerialNum; } m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = sItemID; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = sItemDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = sItemCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = sItemSerial; break; case ITEM_INVEN_SLOT: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; if( !IsValidSlotPos( pTable, destpos ) ) goto fail_return; else if( pTable->m_bSlot == 0x01 || (pTable->m_bSlot == 0x00 && destpos == RIGHTHAND) ) { // ???????? ????(??? ?????? ??? ???????? ?g?? ?????) ?e? ?????? ?µ???? ??? üu if(m_pUserData->m_sItemArray[LEFTHAND].nNum != 0) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData( m_pUserData->m_sItemArray[LEFTHAND].nNum ); if( pTable2 ) { if( pTable2->m_bSlot == 0x04 ) { m_pUserData->m_sItemArray[RIGHTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; // ?????? ???.. m_pUserData->m_sItemArray[RIGHTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[RIGHTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[LEFTHAND].nNum; // ?????? ?????? ??????. m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[LEFTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[LEFTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[LEFTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[LEFTHAND].nNum = 0; // ???? ?????? ????... m_pUserData->m_sItemArray[LEFTHAND].sDuration = 0; m_pUserData->m_sItemArray[LEFTHAND].sCount = 0; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if( pTable->m_bSlot == 0x02 || (pTable->m_bSlot == 0x00 && destpos == LEFTHAND) ) { // ?????? ????(??? ?????? ??? ???????? ?g?? ???) ?e? ?????? ?µ???? ??? üu if(m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[RIGHTHAND].nNum); if( pTable2 ) { if( pTable2->m_bSlot == 0x03 ) { m_pUserData->m_sItemArray[LEFTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[LEFTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[LEFTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[LEFTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[RIGHTHAND].nNum; // ???????? ?????? ??????. m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[RIGHTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[RIGHTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[RIGHTHAND].nNum = 0; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = 0; m_pUserData->m_sItemArray[RIGHTHAND].sCount = 0; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if( pTable->m_bSlot == 0x03 ) { // ?µ? ?????? ????? ???? if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 && m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) goto fail_return; else if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 ) { m_pUserData->m_sItemArray[RIGHTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[RIGHTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[LEFTHAND].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[LEFTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[LEFTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[LEFTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[LEFTHAND].nNum = 0; m_pUserData->m_sItemArray[LEFTHAND].sDuration = 0; m_pUserData->m_sItemArray[LEFTHAND].sCount = 0; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if ( pTable->m_bSlot == 0x04 ) { // ?µ? ?????? ??? ???? if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 && m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) goto fail_return; else if( m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) { m_pUserData->m_sItemArray[LEFTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[LEFTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[LEFTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[LEFTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[RIGHTHAND].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[RIGHTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[RIGHTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[RIGHTHAND].nNum = 0; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = 0; m_pUserData->m_sItemArray[RIGHTHAND].sCount = 0; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } break; case ITEM_SLOT_INVEN: if( itemid != m_pUserData->m_sItemArray[srcpos].nNum ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum != 0 ) goto fail_return; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = m_pUserData->m_sItemArray[srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = m_pUserData->m_sItemArray[srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = m_pUserData->m_sItemArray[srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[srcpos].nNum = 0; m_pUserData->m_sItemArray[srcpos].sDuration = 0; m_pUserData->m_sItemArray[srcpos].sCount = 0; m_pUserData->m_sItemArray[srcpos].nSerialNum = 0; break; case ITEM_INVEN_INVEN: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; short itemcount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; _ITEM_TABLE* pTable2 = NULL; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) { pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum); if( pTable && pTable->m_bCountable == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); } m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = duration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = itemcount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) { pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum); if( pTable && pTable->m_bCountable == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } break; case ITEM_SLOT_SLOT: if( itemid != m_pUserData->m_sItemArray[srcpos].nNum ) goto fail_return; if( !IsValidSlotPos( pTable, destpos ) ) goto fail_return; if( m_pUserData->m_sItemArray[destpos].nNum != 0 ) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData( m_pUserData->m_sItemArray[destpos].nNum ); // dest slot exist some item if( pTable2 ) { if( pTable2->m_bSlot != 0x00 ) goto fail_return; else { short duration = m_pUserData->m_sItemArray[srcpos].sDuration; short count = m_pUserData->m_sItemArray[srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[srcpos].nSerialNum; m_pUserData->m_sItemArray[srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; // Swaping m_pUserData->m_sItemArray[srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; // Swaping m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; // Swaping if( m_pUserData->m_sItemArray[srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = count; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[srcpos].sDuration; short count = m_pUserData->m_sItemArray[srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[srcpos].nSerialNum; m_pUserData->m_sItemArray[srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; // Swaping m_pUserData->m_sItemArray[srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; // Swaping m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; // Swaping m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = count; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } break; } if( dir != ITEM_INVEN_INVEN ) { // ?????? ???? ????? ???.. SetSlotItemValue(); SetUserAbility(); } SendItemMove(); SendItemWeight(); if( (dir == ITEM_INVEN_SLOT ) && ( destpos == HEAD || destpos == BREAST || destpos == SHOULDER || destpos == LEFTHAND || destpos == RIGHTHAND || destpos == LEG || destpos == GLOVE || destpos == FOOT) ) UserLookChange( destpos, itemid, m_pUserData->m_sItemArray[destpos].sDuration ); if( (dir == ITEM_SLOT_INVEN ) && ( srcpos == HEAD || srcpos == BREAST || srcpos == SHOULDER || srcpos == LEFTHAND || srcpos == RIGHTHAND || srcpos == LEG || srcpos == GLOVE || srcpos == FOOT) ) UserLookChange( srcpos, 0, 0 ); if( (dir == ITEM_INVEN_TO_COSP ) && ( SLOT_MAX+HAVE_MAX+destpos == CWING || SLOT_MAX+HAVE_MAX+destpos == CHELMET || SLOT_MAX+HAVE_MAX+destpos == CLEFT || SLOT_MAX+HAVE_MAX+destpos == CRIGHT || SLOT_MAX+HAVE_MAX+destpos == CTOP ) ) UserLookChange( SLOT_MAX+HAVE_MAX+destpos, itemid, m_pUserData->m_sItemArray[SLOT_MAX+HAVE_MAX+destpos].sDuration ); if( (dir == ITEM_COSP_TO_INVEN ) && ( SLOT_MAX+HAVE_MAX+srcpos == CWING || SLOT_MAX+HAVE_MAX+srcpos == CHELMET || SLOT_MAX+HAVE_MAX+srcpos == CLEFT || SLOT_MAX+HAVE_MAX+srcpos == CRIGHT || SLOT_MAX+HAVE_MAX+srcpos == CTOP ) ) UserLookChange( SLOT_MAX+HAVE_MAX+srcpos, 0, 0 ); Send2AI_UserUpdateInfo(); return; fail_return: SendItemMove(true); }
void CUser::ItemMove(char *pBuf) { int index = 0, itemid = 0, srcpos = -1, destpos = -1; int send_index = 0; char send_buff[128]; memset( send_buff, NULL, 128 ); _ITEM_TABLE* pTable = NULL; BYTE dir; dir = GetByte( pBuf, index ); itemid = GetDWORD( pBuf, index ); srcpos = GetByte( pBuf, index ); destpos = GetByte( pBuf, index ); if( m_sExchangeUser != -1 ) goto fail_return; pTable = m_pMain->m_ItemtableArray.GetData( itemid ); if( !pTable ) goto fail_return; // if( dir == ITEM_INVEN_SLOT && ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight) ) // goto fail_return; if( dir > 0x04 || srcpos >= SLOT_MAX+HAVE_MAX || destpos >= SLOT_MAX+HAVE_MAX ) goto fail_return; if( (dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT ) && destpos > SLOT_MAX ) goto fail_return; if( dir == ITEM_SLOT_INVEN && srcpos > SLOT_MAX ) goto fail_return; if( dir == ITEM_INVEN_SLOT && destpos == RESERVED ) goto fail_return; if( dir == ITEM_SLOT_INVEN && srcpos == RESERVED ) goto fail_return; if( dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT ) { if( pTable->m_bRace != 0 ) { if( pTable->m_bRace != m_pUserData->m_bRace ) goto fail_return; } if( !ItemEquipAvailable( pTable ) ) goto fail_return; } switch( dir ) { case ITEM_INVEN_SLOT: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; if( !IsValidSlotPos( pTable, destpos ) ) goto fail_return; else if( pTable->m_bSlot == 0x01 || (pTable->m_bSlot == 0x00 && destpos == RIGHTHAND) ) { // ???????? ????(??? ?????? ??? ???????? ?g?? ?????) ?e? ?????? ?µ???? ??? üu if(m_pUserData->m_sItemArray[LEFTHAND].nNum != 0) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData( m_pUserData->m_sItemArray[LEFTHAND].nNum ); if( pTable2 ) { if( pTable2->m_bSlot == 0x04 ) { m_pUserData->m_sItemArray[RIGHTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; // ?????? ???.. m_pUserData->m_sItemArray[RIGHTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[RIGHTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[LEFTHAND].nNum; // ?????? ?????? ??????. m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[LEFTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[LEFTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[LEFTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[LEFTHAND].nNum = 0; // ???? ?????? ????... m_pUserData->m_sItemArray[LEFTHAND].sDuration = 0; m_pUserData->m_sItemArray[LEFTHAND].sCount = 0; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if( pTable->m_bSlot == 0x02 || (pTable->m_bSlot == 0x00 && destpos == LEFTHAND) ) { // ?????? ????(??? ?????? ??? ???????? ?g?? ???) ?e? ?????? ?µ???? ??? üu if(m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[RIGHTHAND].nNum); if( pTable2 ) { if( pTable2->m_bSlot == 0x03 ) { m_pUserData->m_sItemArray[LEFTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[LEFTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[LEFTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[LEFTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[RIGHTHAND].nNum; // ???????? ?????? ??????. m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[RIGHTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[RIGHTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[RIGHTHAND].nNum = 0; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = 0; m_pUserData->m_sItemArray[RIGHTHAND].sCount = 0; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if( pTable->m_bSlot == 0x03 ) { // ?µ? ?????? ????? ???? if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 && m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) goto fail_return; else if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 ) { m_pUserData->m_sItemArray[RIGHTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[RIGHTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[LEFTHAND].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[LEFTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[LEFTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[LEFTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[LEFTHAND].nNum = 0; m_pUserData->m_sItemArray[LEFTHAND].sDuration = 0; m_pUserData->m_sItemArray[LEFTHAND].sCount = 0; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else if ( pTable->m_bSlot == 0x04 ) { // ?µ? ?????? ??? ???? if( m_pUserData->m_sItemArray[LEFTHAND].nNum != 0 && m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) goto fail_return; else if( m_pUserData->m_sItemArray[RIGHTHAND].nNum != 0 ) { m_pUserData->m_sItemArray[LEFTHAND].nNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum; m_pUserData->m_sItemArray[LEFTHAND].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; m_pUserData->m_sItemArray[LEFTHAND].sCount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; if( m_pUserData->m_sItemArray[LEFTHAND].nSerialNum == 0 ) m_pUserData->m_sItemArray[LEFTHAND].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[RIGHTHAND].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[RIGHTHAND].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[RIGHTHAND].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[RIGHTHAND].nNum = 0; m_pUserData->m_sItemArray[RIGHTHAND].sDuration = 0; m_pUserData->m_sItemArray[RIGHTHAND].sCount = 0; m_pUserData->m_sItemArray[RIGHTHAND].nSerialNum = 0; } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } else { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum != 0 && m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = 1; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } break; case ITEM_SLOT_INVEN: if( itemid != m_pUserData->m_sItemArray[srcpos].nNum ) goto fail_return; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum != 0 ) goto fail_return; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = m_pUserData->m_sItemArray[srcpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = m_pUserData->m_sItemArray[srcpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = m_pUserData->m_sItemArray[srcpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pUserData->m_sItemArray[srcpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[srcpos].nNum = 0; m_pUserData->m_sItemArray[srcpos].sDuration = 0; m_pUserData->m_sItemArray[srcpos].sCount = 0; m_pUserData->m_sItemArray[srcpos].nSerialNum = 0; break; case ITEM_INVEN_INVEN: if( itemid != m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum ) goto fail_return; { short duration = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration; short itemcount = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum; _ITEM_TABLE* pTable2 = NULL; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sDuration = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].sCount = m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount; m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum; if( m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum == 0 ) { pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nNum); if( pTable && pTable->m_bCountable == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+srcpos].nSerialNum = m_pMain->GenerateItemSerial(); } m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum = itemid; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sDuration = duration; m_pUserData->m_sItemArray[SLOT_MAX+destpos].sCount = itemcount; m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum == 0 ) { pTable2 = m_pMain->m_ItemtableArray.GetData(m_pUserData->m_sItemArray[SLOT_MAX+destpos].nNum); if( pTable && pTable->m_bCountable == 0 ) m_pUserData->m_sItemArray[SLOT_MAX+destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } break; case ITEM_SLOT_SLOT: if( itemid != m_pUserData->m_sItemArray[srcpos].nNum ) goto fail_return; if( !IsValidSlotPos( pTable, destpos ) ) goto fail_return; if( m_pUserData->m_sItemArray[destpos].nNum != 0 ) { _ITEM_TABLE* pTable2 = m_pMain->m_ItemtableArray.GetData( m_pUserData->m_sItemArray[destpos].nNum ); // dest slot exist some item if( pTable2 ) { if( pTable2->m_bSlot != 0x00 ) goto fail_return; else { short duration = m_pUserData->m_sItemArray[srcpos].sDuration; short count = m_pUserData->m_sItemArray[srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[srcpos].nSerialNum; m_pUserData->m_sItemArray[srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; // Swaping m_pUserData->m_sItemArray[srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; // Swaping m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; // Swaping if( m_pUserData->m_sItemArray[srcpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pMain->GenerateItemSerial(); m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = count; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } } } else { short duration = m_pUserData->m_sItemArray[srcpos].sDuration; short count = m_pUserData->m_sItemArray[srcpos].sCount; __int64 serial = m_pUserData->m_sItemArray[srcpos].nSerialNum; m_pUserData->m_sItemArray[srcpos].nNum = m_pUserData->m_sItemArray[destpos].nNum; // Swaping m_pUserData->m_sItemArray[srcpos].sDuration = m_pUserData->m_sItemArray[destpos].sDuration; // Swaping m_pUserData->m_sItemArray[srcpos].sCount = m_pUserData->m_sItemArray[destpos].sCount; // Swaping m_pUserData->m_sItemArray[srcpos].nSerialNum = m_pUserData->m_sItemArray[destpos].nSerialNum; // Swaping m_pUserData->m_sItemArray[destpos].nNum = itemid; m_pUserData->m_sItemArray[destpos].sDuration = duration; m_pUserData->m_sItemArray[destpos].sCount = count; m_pUserData->m_sItemArray[destpos].nSerialNum = serial; if( m_pUserData->m_sItemArray[destpos].nSerialNum == 0 ) m_pUserData->m_sItemArray[destpos].nSerialNum = m_pMain->GenerateItemSerial(); } break; } if( dir != ITEM_INVEN_INVEN ) { // ?????? ???? ????? ???.. SetSlotItemValue(); SetUserAbility(); } /* SetByte( send_buff, WIZ_ITEM_MOVE, send_index ); SetByte( send_buff, 0x01, send_index ); SetShort( send_buff, m_sTotalHit, send_index ); SetShort( send_buff, m_sTotalAc, send_index ); SetShort( send_buff, m_sMaxWeight, send_index ); SetShort( send_buff, m_iMaxHp, send_index ); SetShort( send_buff, m_iMaxMp, send_index ); SetByte( send_buff, m_sItemStr, send_index ); SetByte( send_buff, m_sItemSta, send_index ); SetByte( send_buff, m_sItemDex, send_index ); SetByte( send_buff, m_sItemIntel, send_index ); SetByte( send_buff, m_sItemCham, send_index ); SetByte( send_buff, m_bFireR, send_index ); SetByte( send_buff, m_bColdR, send_index ); SetByte( send_buff, m_bLightningR, send_index ); SetByte( send_buff, m_bMagicR, send_index ); SetByte( send_buff, m_bDiseaseR, send_index ); SetByte( send_buff, m_bPoisonR, send_index ); Send( send_buff, send_index ); BYTE m_bStrAmount; BYTE m_bStaAmount; BYTE m_bDexAmount; BYTE m_bIntelAmount; BYTE m_bChaAmount; */ SetByte( send_buff, WIZ_ITEM_MOVE, send_index ); SetByte( send_buff, 0x01, send_index ); SetShort( send_buff, m_sTotalHit, send_index ); SetShort( send_buff, m_sTotalAc, send_index ); SetShort( send_buff, m_sMaxWeight, send_index ); SetShort( send_buff, m_iMaxHp, send_index ); SetShort( send_buff, m_iMaxMp, send_index ); SetByte( send_buff, m_sItemStr + m_bStrAmount, send_index ); SetByte( send_buff, m_sItemSta + m_bStaAmount, send_index ); SetByte( send_buff, m_sItemDex + m_bDexAmount, send_index ); SetByte( send_buff, m_sItemIntel + m_bIntelAmount, send_index ); SetByte( send_buff, m_sItemCham + m_bChaAmount, send_index ); SetByte( send_buff, m_bFireR, send_index ); SetByte( send_buff, m_bColdR, send_index ); SetByte( send_buff, m_bLightningR, send_index ); SetByte( send_buff, m_bMagicR, send_index ); SetByte( send_buff, m_bDiseaseR, send_index ); SetByte( send_buff, m_bPoisonR, send_index ); Send( send_buff, send_index ); // SendItemWeight(); if( (dir == ITEM_INVEN_SLOT ) && ( destpos == HEAD || destpos == BREAST || destpos == SHOULDER || destpos == LEFTHAND || destpos == RIGHTHAND || destpos == LEG || destpos == GLOVE || destpos == FOOT) ) UserLookChange( destpos, itemid, m_pUserData->m_sItemArray[destpos].sDuration ); if( (dir == ITEM_SLOT_INVEN ) && ( srcpos == HEAD || srcpos == BREAST || srcpos == SHOULDER || srcpos == LEFTHAND || srcpos == RIGHTHAND || srcpos == LEG || srcpos == GLOVE || srcpos == FOOT) ) UserLookChange( srcpos, 0, 0 ); Send2AI_UserUpdateInfo(); return; fail_return: send_index = 0; SetByte( send_buff, WIZ_ITEM_MOVE, send_index ); SetByte( send_buff, 0x00, send_index ); Send( send_buff, send_index ); }
void CUser::ItemMove(Packet & pkt) { _ITEM_TABLE *pTable; _ITEM_DATA *pSrcItem, *pDstItem, tmpItem; uint32 nItemID; uint8 dir, bSrcPos, bDstPos; pkt >> dir >> nItemID >> bSrcPos >> bDstPos; if (isTrading() || isMerchanting()) goto fail_return; pTable = g_pMain->GetItemPtr(nItemID); if (pTable == nullptr // || dir == ITEM_INVEN_SLOT && ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight)) // || dir > ITEM_MBAG_TO_MBAG || bSrcPos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX || bDstPos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX || ((dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT) && (bDstPos > SLOT_MAX || !ItemEquipAvailable(pTable))) || (dir == ITEM_SLOT_INVEN && bSrcPos > SLOT_MAX) || (dir == ITEM_INVEN_SLOT && bDstPos == RESERVED) || (dir == ITEM_SLOT_INVEN && bDstPos == RESERVED)) goto fail_return; switch (dir) { case ITEM_MBAG_TO_MBAG: if (bDstPos >= MBAG_TOTAL || bSrcPos >= MBAG_TOTAL // We also need to make sure that if we're setting an item in a magic bag, we need to actually // have a magic back to put the item in! || (INVENTORY_MBAG+bDstPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG+bDstPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_MBAG + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_MBAG + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_MBAG + bDstPos]; break; case ITEM_MBAG_TO_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= MBAG_TOTAL // We also need to make sure that if we're taking an item from a magic bag, we need to actually // have a magic back to take it from! || (INVENTORY_MBAG+bSrcPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG+bSrcPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_MBAG + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_MBAG + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_INVEN_TO_MBAG: if (bDstPos >= MBAG_TOTAL || bSrcPos >= HAVE_MAX // We also need to make sure that if we're adding an item to a magic bag, we need to actually // have a magic back to put the item in! || (INVENTORY_MBAG + bDstPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG + bDstPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_MBAG + bDstPos]; break; case ITEM_COSP_TO_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= COSP_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_COSP + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_COSP + bSrcPos]; pDstItem = &m_sItemArray[SLOT_MAX + bDstPos]; break; case ITEM_INVEN_TO_COSP: if (bDstPos >= COSP_MAX+MBAG_COUNT || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[SLOT_MAX + bSrcPos].nNum || !IsValidSlotPos(pTable, bDstPos)) goto fail_return; pSrcItem = &m_sItemArray[SLOT_MAX + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_COSP + bDstPos]; // If we're setting a magic bag... if (bDstPos == COSP_BAG1 || bDstPos == COSP_BAG2) { // Can't replace existing magic bag. if (pDstItem->nNum != 0 // Can't set any old item in the bag slot, it must be a bag. || pTable->m_bSlot != ItemSlotBag) goto fail_return; } break; case ITEM_INVEN_SLOT: if (bDstPos >= SLOT_MAX || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum // Ensure the item is able to be equipped in that slot || !IsValidSlotPos(pTable, bDstPos)) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[bDstPos]; break; case ITEM_SLOT_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= SLOT_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_INVEN_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_SLOT_SLOT: if (bDstPos >= SLOT_MAX || bSrcPos >= SLOT_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[bSrcPos].nNum // Ensure the item is able to be equipped in that slot || !IsValidSlotPos(pTable, bDstPos)) goto fail_return; pSrcItem = &m_sItemArray[bSrcPos]; pDstItem = &m_sItemArray[bDstPos]; break; default: return; } // If there's an item already in the target slot already, we need to just swap the items if (pDstItem->nNum != 0) { memcpy(&tmpItem, pDstItem, sizeof(_ITEM_DATA)); // Temporarily store the target item memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA)); // Replace the target item with the source memcpy(pSrcItem, &tmpItem, sizeof(_ITEM_DATA)); // Now replace the source with the old target (swapping them) } // Since there's no way to move a partial stack using this handler, just overwrite the destination. else { memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA)); // Shift the item over memset(pSrcItem, 0, sizeof(_ITEM_DATA)); // Clear out the source item's data } // If we're equipping a 2-handed weapon, we need to ensure that if there's // an item in the other weapon slot (2-handed or not), it's unequipped. if (dir == ITEM_INVEN_SLOT) { uint8 bOtherWeaponSlot = 0; if (bDstPos == LEFTHAND && pTable->m_bSlot == ItemSlot2HLeftHand) bOtherWeaponSlot = RIGHTHAND; else if (bDstPos == RIGHTHAND && pTable->is2Handed()) bOtherWeaponSlot = LEFTHAND; if (bOtherWeaponSlot != 0) { _ITEM_DATA * pUnequipItem = GetItem(bOtherWeaponSlot); if (pUnequipItem->nNum != 0) { // Place item where item that we just equipped was. memcpy(pSrcItem, pUnequipItem, sizeof(_ITEM_DATA)); memset(pUnequipItem, 0, sizeof(_ITEM_DATA)); UserLookChange(bOtherWeaponSlot, 0, 0); } } } // If equipping/de-equipping an item if (dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_INVEN // or moving an item to/from our cospre item slots || dir == ITEM_INVEN_TO_COSP || dir == ITEM_COSP_TO_INVEN || dir == ITEM_SLOT_SLOT) { // Re-update item stats SetUserAbility(false); } SendItemMove(1); SendItemWeight(); // Update everyone else, so that they can see your shiny new items (you didn't take them off did you!? DID YOU!?) switch (dir) { case ITEM_INVEN_SLOT: case ITEM_INVEN_TO_COSP: UserLookChange(bDstPos, nItemID, pDstItem->sDuration); break; case ITEM_SLOT_INVEN: case ITEM_COSP_TO_INVEN: UserLookChange(bSrcPos, 0, 0); break; case ITEM_SLOT_SLOT: UserLookChange(bSrcPos, pSrcItem->nNum, pSrcItem->sDuration); UserLookChange(bDstPos, pDstItem->nNum, pDstItem->sDuration); break; } Send2AI_UserUpdateInfo(); return; fail_return: SendItemMove(0); }
void CUser::ItemMove(Packet & pkt) { _ITEM_DATA *pSrcItem, *pDstItem, tmpItem; uint32 nItemID; uint8 dir, bSrcPos, bDstPos; pkt >> dir >> nItemID >> bSrcPos >> bDstPos; if (isTrading() || isMerchanting()) goto fail_return; _ITEM_TABLE *pTable = g_pMain->GetItemPtr(nItemID); if (pTable == NULL // || dir == ITEM_INVEN_SLOT && ((pTable->m_sWeight + m_sItemWeight) > m_sMaxWeight)) // || dir > ITEM_MBAG_TO_MBAG || bSrcPos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX || bDstPos >= SLOT_MAX+HAVE_MAX+COSP_MAX+MBAG_MAX || ((dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_SLOT) && (bDstPos > SLOT_MAX || !ItemEquipAvailable(pTable))) || (dir == ITEM_SLOT_INVEN && bSrcPos > SLOT_MAX) || (dir == ITEM_INVEN_SLOT && bDstPos == RESERVED) || (dir == ITEM_SLOT_INVEN && bDstPos == RESERVED)) goto fail_return; switch (dir) { case ITEM_MBAG_TO_MBAG: if (bDstPos >= MBAG_TOTAL || bSrcPos >= MBAG_TOTAL // We also need to make sure that if we're setting an item in a magic bag, we need to actually // have a magic back to put the item in! || (INVENTORY_MBAG+bDstPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG+bDstPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_MBAG + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_MBAG + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_MBAG + bDstPos]; break; case ITEM_MBAG_TO_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= MBAG_TOTAL // We also need to make sure that if we're taking an item from a magic bag, we need to actually // have a magic back to take it from! || (INVENTORY_MBAG+bSrcPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG+bSrcPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_MBAG + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_MBAG + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_INVEN_TO_MBAG: if (bDstPos >= MBAG_TOTAL || bSrcPos >= HAVE_MAX // We also need to make sure that if we're adding an item to a magic bag, we need to actually // have a magic back to put the item in! || (INVENTORY_MBAG + bDstPos < INVENTORY_MBAG2 && m_sItemArray[BAG1].nNum == 0) || (INVENTORY_MBAG + bDstPos >= INVENTORY_MBAG2 && m_sItemArray[BAG2].nNum == 0) // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_MBAG + bDstPos]; break; case ITEM_COSP_TO_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= COSP_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_COSP + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_COSP + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_INVEN_TO_COSP: // TO-DO: Update IsValidSlotPos() for cospre items? if (bDstPos >= COSP_MAX || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_COSP + bDstPos]; break; case ITEM_INVEN_SLOT: if (bDstPos >= SLOT_MAX || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum // Ensure the item is able to be equipped in that slot || !IsValidSlotPos(pTable, bDstPos)) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[bDstPos]; break; case ITEM_SLOT_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= SLOT_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_INVEN_INVEN: if (bDstPos >= HAVE_MAX || bSrcPos >= HAVE_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[INVENTORY_INVENT + bSrcPos].nNum) goto fail_return; pSrcItem = &m_sItemArray[INVENTORY_INVENT + bSrcPos]; pDstItem = &m_sItemArray[INVENTORY_INVENT + bDstPos]; break; case ITEM_SLOT_SLOT: if (bDstPos >= SLOT_MAX || bSrcPos >= SLOT_MAX // Make sure that the item actually exists there. || nItemID != m_sItemArray[bSrcPos].nNum // Ensure the item is able to be equipped in that slot || !IsValidSlotPos(pTable, bDstPos)) goto fail_return; pSrcItem = &m_sItemArray[bSrcPos]; pDstItem = &m_sItemArray[bDstPos]; break; default: return; } // If there's an item already in the target slot already, we need to just swap the items if (pDstItem->nNum != 0) { memcpy(&tmpItem, pDstItem, sizeof(_ITEM_DATA)); // Temporarily store the target item memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA)); // Replace the target item with the source memcpy(pSrcItem, &tmpItem, sizeof(_ITEM_DATA)); // Now replace the source with the old target (swapping them) } // Since there's no way to move a partial stack using this handler, just overwrite the destination. else { memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA)); // Shift the item over memset(pSrcItem, 0, sizeof(_ITEM_DATA)); // Clear out the source item's data } // If equipping/de-equipping an item if (dir == ITEM_INVEN_SLOT || dir == ITEM_SLOT_INVEN // or moving an item to/from our cospre item slots || dir == ITEM_INVEN_TO_COSP || dir == ITEM_COSP_TO_INVEN || dir == ITEM_SLOT_SLOT) { // Re-update item stats SetSlotItemValue(); SetUserAbility(false); } SendItemMove(1); SendItemWeight(); // Update everyone else, so that they can see your shiny new items (you didn't take them off did you!? DID YOU!?) if (dir == ITEM_INVEN_SLOT) UserLookChange(bDstPos, nItemID, pDstItem->sDuration); if (dir == ITEM_SLOT_INVEN) UserLookChange(bSrcPos, 0, 0); if (dir == ITEM_SLOT_SLOT) { UserLookChange(bSrcPos, pSrcItem->nNum, pSrcItem->sDuration); UserLookChange(bDstPos, pDstItem->nNum, pDstItem->sDuration); } if (dir == ITEM_INVEN_TO_COSP) UserLookChange(INVENTORY_COSP + bDstPos, nItemID, pDstItem->sDuration); if (dir == ITEM_COSP_TO_INVEN) UserLookChange(INVENTORY_INVENT + bSrcPos, 0, 0); Send2AI_UserUpdateInfo(); return; fail_return: SendItemMove(0); }