Bankaya koyulan ıtemlerin silinmesi kaybolması fix (18xx)

'Prosedür & Kod Paylaşımları' forumunda database tarafından 7 Mar 2016 tarihinde açılan konu

  1. database

    database Yeni Cüce

    Katılım:
    6 Mar 2016
    Mesaj:
    17
    Alınan Beğeniler:
    0
    Ödül Puanları:
    0
    Merhabalar.

    GameServer / ItemHandler.cpp'den şu başlığı bulup alttakiyle komple değiştiriyorsunuz
    void CUser::WarehouseProcess(Packet & pkt)


    Kod:
    void CUser::WarehouseProcess(Packet & pkt)
    {
        Packet result(WIZ_WAREHOUSE);
        uint32 nItemID, nCount;
        uint16 sNpcId, reference_pos;
        uint8 page, bSrcPos, bDstPos;
        CNpc * pNpc = nullptr;
        _ITEM_TABLE * pTable = nullptr;
        _ITEM_DATA * pSrcItem = nullptr, * pDstItem = nullptr;
        uint8 opcode;
        bool bResult = false;
    
        if (isInPKZone())
        {
            if (hasCoins(10000))
                GoldLose(10000);
            else
            {
                opcode = 1;
                goto fail_return;
            }
        }
    
        if (isDead())
            return;
    
        if (isTrading())
            goto fail_return;
    
        pkt >> opcode;
        if (opcode == WAREHOUSE_OPEN)
        {
            result << opcode << uint8(1) << GetInnCoins();
            for (int i = 0; i < WAREHOUSE_MAX; i++)
            {
                _ITEM_DATA *pItem = &m_sWarehouseArray;
    
                if(pItem == nullptr)
                    continue;
    
                result    << pItem->nNum
                    << pItem->sDuration << pItem->sCount
                    << pItem->bFlag
                    << uint64(0);
            }
            Send(&result);
            return;
        }
    
        pkt >> sNpcId >> nItemID >> page >> bSrcPos >> bDstPos;
    
        pNpc = g_pMain->GetNpcPtr(sNpcId);
        if (pNpc == nullptr
            || pNpc->GetType() != NPC_WAREHOUSE
            || !isInRange(pNpc, MAX_NPC_RANGE))
            goto fail_return;
    
        pTable = g_pMain->GetItemPtr(nItemID);
        if (pTable == nullptr)
            goto fail_return;
    
        reference_pos = 24 * page;
    
        switch (opcode)
        {
            // Inventory -> inn
        case WAREHOUSE_INPUT:
            pkt >> nCount;
    
            // Handle coin input.
            if (nItemID == ITEM_GOLD)
            {
                if (!hasCoins(nCount)
                    || GetInnCoins() + nCount > COIN_MAX)
                    goto fail_return;
    
                m_iBank += nCount;
                m_iGold -= nCount;
                break;
            }
    
            // Check for invalid slot IDs.
            if (bSrcPos > HAVE_MAX
                || reference_pos + bDstPos > WAREHOUSE_MAX
                // Cannot be traded, sold or stored (note: don't check the race, as these items CAN be stored).
                || nItemID >= ITEM_NO_TRADE  
                // Check that the source item we're moving is what the client says it is.
                || (pSrcItem = GetItem(SLOT_MAX + bSrcPos))->nNum != nItemID
                // Rented items cannot be placed in the inn.
                || pSrcItem->isRented()
                || pSrcItem->isDuplicate())
                goto fail_return;
    
            pDstItem = &m_sWarehouseArray[reference_pos + bDstPos];
            // Forbid users from moving non-stackable items into a slot already occupied by an item.
            if ((!pTable->isStackable() && pDstItem->nNum != 0)
                // Forbid users from moving stackable items into a slot already occupied by a different item.
                    || (pTable->isStackable()
                    && pDstItem->nNum != 0 // slot in use
                    && pDstItem->nNum != pSrcItem->nNum) // ... by a different item.
                    // Ensure users have enough of the specified item to move.
                    || pSrcItem->sCount < nCount)
                    goto fail_return;
    
            pDstItem->nNum = pSrcItem->nNum;
            pDstItem->sDuration = pSrcItem->sDuration;
            pDstItem->sCount = (uint16) nCount;
            pSrcItem->sCount -= nCount;
            pDstItem->bFlag = pSrcItem->bFlag;
            pDstItem->sRemainingRentalTime = pSrcItem->sRemainingRentalTime;
            pDstItem->nExpirationTime = pSrcItem->nExpirationTime;
    
            if (!pTable->isStackable() || nCount == pDstItem->sCount)
                pDstItem->nSerialNum = pSrcItem->nSerialNum;
    
            if (!pTable->isStackable() && pDstItem->nSerialNum == 0)
                pDstItem->nSerialNum = g_pMain->GenerateItemSerial();
    
            if (pSrcItem->sCount == 0)
                memset(pSrcItem, 0, sizeof(_ITEM_DATA));
    
            SetUserAbility(false);
            SendItemWeight();
            break;
    
            // Inn -> inventory
        case WAREHOUSE_OUTPUT:
            pkt >> nCount;
    
            if (nItemID == ITEM_GOLD)
            {
                if (!hasInnCoins(nCount)
                    || GetCoins() + nCount > COIN_MAX)
                    goto fail_return;
    
                m_iGold += nCount;
                m_iBank -= nCount;
                break;
            }
    
            // Ensure we're not being given an invalid slot ID.
            if (reference_pos + bSrcPos > WAREHOUSE_MAX
                || bDstPos > HAVE_MAX
                // Check that the source item we're moving is what the client says it is.
                || (pSrcItem = &m_sWarehouseArray[reference_pos + bSrcPos])->nNum != nItemID
                // Does the player have enough room in their inventory?
                || !CheckWeight(pTable, nItemID, (uint16) nCount))
                goto fail_return;
    
            pDstItem = GetItem(SLOT_MAX + bDstPos);
            // Forbid users from moving non-stackable items into a slot already occupied by an item.
            if ((!pTable->isStackable() && pDstItem->nNum != 0)
                // Forbid users from moving stackable items into a slot already occupied by a different item.
                    || (pTable->isStackable()
                    && pDstItem->nNum != 0 // slot in use
                    && pDstItem->nNum != pSrcItem->nNum) // ... by a different item.
                    // Ensure users have enough of the specified item to move.
                    || pSrcItem->sCount < nCount)
                    goto fail_return;
    
            pDstItem->nNum = pSrcItem->nNum;
            pDstItem->sDuration = pSrcItem->sDuration;
            pDstItem->sCount = (uint16) nCount;
            pSrcItem->sCount -= nCount;
            pDstItem->bFlag = pSrcItem->bFlag;
            pDstItem->sRemainingRentalTime = pSrcItem->sRemainingRentalTime;
            pDstItem->nExpirationTime = pSrcItem->nExpirationTime;
    
            if (!pTable->isStackable() || nCount == pDstItem->sCount)
                pDstItem->nSerialNum = pSrcItem->nSerialNum;
    
            if (!pTable->isStackable() && pDstItem->nSerialNum == 0)
                pDstItem->nSerialNum = g_pMain->GenerateItemSerial();
    
            if (pSrcItem->sCount == 0)
                memset(pSrcItem, 0, sizeof(_ITEM_DATA));
    
            SetUserAbility(false);
            SendItemWeight();
            break;
    
            // Inn -> inn
        case WAREHOUSE_MOVE:
            // Ensure we're not being given an invalid slot ID.
            if (reference_pos + bSrcPos > WAREHOUSE_MAX
                || reference_pos + bDstPos > WAREHOUSE_MAX)
                goto fail_return;
    
            pSrcItem = &m_sWarehouseArray[reference_pos + bSrcPos];
            pDstItem = &m_sWarehouseArray[reference_pos + bDstPos];
    
            // Check that the source item we're moving is what the client says it is.
            if (pSrcItem->nNum != nItemID
                // You can't move a partial stack in the inn (the whole stack is moved).
                    || pDstItem->nNum != 0)
                    goto fail_return;
    
            memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA));
            memset(pSrcItem, 0, sizeof(_ITEM_DATA));
            break;
    
            // Inventory -> inventory (using the inn dialog)
        case WAREHOUSE_INVENMOVE:
            // Ensure we're not being given an invalid slot ID.
            if (bSrcPos > HAVE_MAX
                || bDstPos > HAVE_MAX)
                goto fail_return;
    
            pSrcItem = GetItem(SLOT_MAX + bSrcPos);
            pDstItem = GetItem(SLOT_MAX + bDstPos);
    
            // Check that the source item we're moving is what the client says it is.
            if (pSrcItem->nNum != nItemID
                // You can't move a partial stack in the inventory (the whole stack is moved).
                    || pDstItem->nNum != 0)
                    goto fail_return;
    
            memcpy(pDstItem, pSrcItem, sizeof(_ITEM_DATA));
            memset(pSrcItem, 0, sizeof(_ITEM_DATA));
            break;
        }
    
        bResult = true;
    
    fail_return: // hmm...
        result << opcode << bResult;
        Send(&result);
    }
    
     
  2. apple16

    apple16 Yeni Cüce

    Katılım:
    4 Haz 2016
    Mesaj:
    5
    Alınan Beğeniler:
    0
    Ödül Puanları:
    0
    Bende de sorun bu ya
     
  3. mehmetzor

    mehmetzor Yeni Cüce

    Katılım:
    22 Tem 2016
    Mesaj:
    10
    Alınan Beğeniler:
    0
    Ödül Puanları:
    0
    Naasıl olmalı
     

Bu Sayfayı Paylaş