VSRO Auto-Sort - Help

12/07/2023 20:49 Judgelemental#1
Hi,

I've been trying to add the Auto-Sort feature (for a couple of weeks now using DevKit) on my VSRO server where I play alone and I cannot get it to work.

It's this feature:
[Only registered and activated users can see links. Click Here To Register...]

I have no idea about programming and every time I tried to add it my client crashed so I gave up.

I'd really appreciate it and it would make my day if somebody can help me implement it.

(I attach the source code -credits bimbum*-, my Discord ID: snowfall5307 and my sro_client.exe).

Thank you in advance.
12/07/2023 22:32 bimbum*#2
bubble sort algorithm for vsro,

Code:
void CIFMainPopup::OnClick_BtnSort() {
    if (!m_bIsSortRunning) {
        m_bIsSortRunning = true;

        StartTimer(220, 200);

        g_pCGInterface->GetSystemMessageView()->WriteMessage(255, 0xef00ff00, TSM_GETTEXTPTR(L"UIIT_STT_VAN_GUARD_SORT_1"), 0, 1);
    } else {
        m_bIsSortRunning = false;

        KillTimer(220);
    }
}
Code:
void CIFMainPopup::OnTimer(int timerId) {
    if (timerId == 220) {
        if (Sort()) {
            KillTimer(220);
            g_pCGInterface->GetSystemMessageView()->WriteMessage(255, 0xef00ff00, TSM_GETTEXTPTR(L"UIIT_STT_VAN_GUARD_SORT_2"), 0, 1);
            m_bIsSortRunning = false;
        }
    }
}
Code:
bool CIFMainPopup::Sort() {
    int invCount = g_pCICPlayer->GetInvSlotsCount();

    for (int i = 0; i < invCount; i++) {
        CIFSlotWithHelp *pSlot = GetInventory()->pSlots[i];
        CSOItem *pItem = pSlot->m_pSOItem;

        if (pItem != NULL && pItem->m_refObjItemId > 0) {
            const SItemData *pItemData = pItem->GetItemData();

            if (pItemData && pItem->GetQuantity() < pItemData->m_maxStack) {
                for (int j = i + 1; j < invCount; j++) {
                    CIFSlotWithHelp *pSlotJ = GetInventory()->pSlots[j];
                    CSOItem *pItemJ = pSlotJ->m_pSOItem;

                    if (pItemJ != NULL && pItemJ->m_refObjItemId > 0 && pItemJ->m_refObjItemId == pItem->m_refObjItemId) {
                        const SItemData *pItemDataJ = pItemJ->GetItemData();

                        if (pItemDataJ && pItemJ->GetQuantity() < pItemDataJ->m_maxStack) {
                            int countToMove = 0;

                            if (pItem->GetQuantity() + pItemJ->GetQuantity() <= pItemDataJ->m_maxStack)
                                countToMove = pItem->GetQuantity();
                            else if (pItem->GetQuantity() <= pItemJ->GetQuantity())
                                countToMove = pItemDataJ->m_maxStack - pItemJ->GetQuantity();
                            else
                                countToMove = pItemDataJ->m_maxStack - pItem->GetQuantity();

                            NEWMSG(0x7034);
                            pReq << BYTE(0x0) << BYTE(i + 13) << BYTE(j + 13) << UINT16(countToMove);
                            SENDMSG();
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
12/07/2023 22:53 Judgelemental#3
Quote:
Originally Posted by bimbum* View Post
bubble sort algorithm for vsro,

Code:
void CIFMainPopup::OnClick_BtnSort() {
    if (!m_bIsSortRunning) {
        m_bIsSortRunning = true;

        StartTimer(220, 200);

        g_pCGInterface->GetSystemMessageView()->WriteMessage(255, 0xef00ff00, TSM_GETTEXTPTR(L"UIIT_STT_VAN_GUARD_SORT_1"), 0, 1);
    } else {
        m_bIsSortRunning = false;

        KillTimer(220);
    }
}
Code:
void CIFMainPopup::OnTimer(int timerId) {
    if (timerId == 220) {
        if (Sort()) {
            KillTimer(220);
            g_pCGInterface->GetSystemMessageView()->WriteMessage(255, 0xef00ff00, TSM_GETTEXTPTR(L"UIIT_STT_VAN_GUARD_SORT_2"), 0, 1);
            m_bIsSortRunning = false;
        }
    }
}
Code:
bool CIFMainPopup::Sort() {
    int invCount = g_pCICPlayer->GetInvSlotsCount();

    for (int i = 0; i < invCount; i++) {
        CIFSlotWithHelp *pSlot = GetInventory()->pSlots[i];
        CSOItem *pItem = pSlot->m_pSOItem;

        if (pItem != NULL && pItem->m_refObjItemId > 0) {
            const SItemData *pItemData = pItem->GetItemData();

            if (pItemData && pItem->GetQuantity() < pItemData->m_maxStack) {
                for (int j = i + 1; j < invCount; j++) {
                    CIFSlotWithHelp *pSlotJ = GetInventory()->pSlots[j];
                    CSOItem *pItemJ = pSlotJ->m_pSOItem;

                    if (pItemJ != NULL && pItemJ->m_refObjItemId > 0 && pItemJ->m_refObjItemId == pItem->m_refObjItemId) {
                        const SItemData *pItemDataJ = pItemJ->GetItemData();

                        if (pItemDataJ && pItemJ->GetQuantity() < pItemDataJ->m_maxStack) {
                            int countToMove = 0;

                            if (pItem->GetQuantity() + pItemJ->GetQuantity() <= pItemDataJ->m_maxStack)
                                countToMove = pItem->GetQuantity();
                            else if (pItem->GetQuantity() <= pItemJ->GetQuantity())
                                countToMove = pItemDataJ->m_maxStack - pItemJ->GetQuantity();
                            else
                                countToMove = pItemDataJ->m_maxStack - pItem->GetQuantity();

                            NEWMSG(0x7034);
                            pReq << BYTE(0x0) << BYTE(i + 13) << BYTE(j + 13) << UINT16(countToMove);
                            SENDMSG();
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
I have no idea what to do with these but I'll try my best!
Thank you.
12/12/2023 14:42 Q8Quard#4
missing line or no ? m_bIsSortRunning error blabla

is it a sro culture to answer like a riddle instead of giving it directly
12/12/2023 15:06 lidzy#5
Filters already did that why would you like to do it with DevKit ?
12/12/2023 15:41 Judgelemental#6
Quote:
Originally Posted by Q8Quard View Post
missing line or no ? m_bIsSortRunning error blabla

is it a sro culture to answer like a riddle instead of giving it directly
Inflated (fragile) ego, inferiority complex and lack of social skills along with little emotional intelligence.

Quote:
Originally Posted by lidzy View Post
Filters already did that why would you like to do it with DevKit ?
Because I play alone and I don't want to pay for a filter unless it's permanent.