Jump to content

Recommended Posts

Hey Guys

I have a Problem. I have 6 Inventory Pages works fine but when i sell a item over slotPos 255 -> Remove the item from slotPos 0

for example:

Slot 256 -> Sell/Remove Slot 0

Slot 257 -> Sell/Remove Slot 1

Slot 258 -> Sell/Remove Slot 2 etc.

Here is Source part:

 

Game Source -> input_main.cpp

int CInputMain::Shop(LPCHARACTER ch, const char * data, size_t uiBytes)
{
	TPacketCGShop * p = (TPacketCGShop *) data;

	if (uiBytes < sizeof(TPacketCGShop))
		return -1;

	if (test_server)
		sys_log(0, "CInputMain::Shop() ==> SubHeader %d", p->subheader);

	const char * c_pData = data + sizeof(TPacketCGShop);
	uiBytes -= sizeof(TPacketCGShop);

	switch (p->subheader)
	{
		case SHOP_SUBHEADER_CG_END:
			sys_log(1, "INPUT: %s SHOP: END", ch->GetName());
			CShopManager::instance().StopShopping(ch);
			return 0;

		case SHOP_SUBHEADER_CG_BUY:
			{
				if (uiBytes < sizeof(BYTE) + sizeof(BYTE))
					return -1;

				BYTE bPos = *(c_pData + 1);
				sys_log(1, "INPUT: %s SHOP: BUY %d", ch->GetName(), bPos);
				CShopManager::instance().Buy(ch, bPos);
				return (sizeof(BYTE) + sizeof(BYTE));
			}

		case SHOP_SUBHEADER_CG_SELL:
			{
				if (uiBytes < sizeof(BYTE))
				{
#ifdef __DEBUG__
					ch->ChatPacket(CHAT_TYPE_INFO, "Return -1");
#endif
					return -1;
				}

				BYTE pos = *c_pData;

				sys_log(0, "INPUT: %s SHOP: SELL", ch->GetName());
				CShopManager::instance().Sell(ch, pos);
#ifdef __DEBUG__
				ch->ChatPacket(CHAT_TYPE_INFO, "return pos: %u", pos);
				ch->ChatPacket(CHAT_TYPE_INFO, "return sizeof(BYTE)");
#endif
				return sizeof(BYTE);
			}

		case SHOP_SUBHEADER_CG_SELL2:
			{
				if (uiBytes < sizeof(BYTE)+sizeof(BYTE))
				{
#ifdef __DEBUG__
					ch->ChatPacket(CHAT_TYPE_INFO, "return -1");
#endif
					return -1;
				}

				UINT pos = *(c_pData++);
				BYTE count = *(c_pData);

				sys_log(0, "INPUT: %s SHOP: SELL2", ch->GetName());
				CShopManager::instance().Sell(ch, pos, count);
#ifdef __DEBUG__
				ch->ChatPacket(CHAT_TYPE_INFO, "return pos: %u, count: %d", pos, count);
				ch->ChatPacket(CHAT_TYPE_INFO, "return sizeof(BYTE) + sizeof(BYTE)");
#endif
				return sizeof(BYTE)+sizeof(BYTE);
			}

		default:
			sys_err("CInputMain::Shop : Unknown subheader %d : %s", p->subheader, ch->GetName());
			break;
	}

	return 0;
}

Client Part -> PythonNetworkStreamPhaseGameItem.cpp

bool CPythonNetworkStream::SendShopSellPacketNew(UINT bySlot, BYTE byCount)
{
	if (!__CanActMainInstance())
		return true;

	TPacketCGShop PacketShop;
	PacketShop.header = HEADER_CG_SHOP;
	PacketShop.subheader = SHOP_SUBHEADER_CG_SELL2;

	if (!Send(sizeof(TPacketCGShop), &PacketShop))
	{
		Tracef("SendShopSellPacket Error\n");
		return false;
	}
	if (!Send(sizeof(BYTE), &bySlot))
	{
		Tracef("SendShopAddSellPacket Error\n");
		return false;
	}
	if (!Send(sizeof(BYTE), &byCount))
	{
		Tracef("SendShopAddSellPacket Error\n");
		return false;
	}

	Tracef(" SendShopSellPacketNew(bySlot=%d, byCount=%d)\n", bySlot, byCount);

	return SendSequence();
}

 

Here is a Image:

uiy4eqo7.png

Has anyone a fix

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/8315-inventory-bug-with-6-pages-when-sell-item/
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

You have to change all slot count from BYTE type to int type.There are many files to modified.

Because BYTE is max 255, and you have over 255 slots. 255+ slots are bugged.

Edited by Morphe
bool CPythonNetworkStream::SendShopSellPacketNew(WORD bySlot, BYTE byCount)
{
        if (!__CanActMainInstance())
                return true;

        TPacketCGShop PacketShop;
        PacketShop.header = HEADER_CG_SHOP;
        PacketShop.subheader = SHOP_SUBHEADER_CG_SELL2;

        if (!Send(sizeof(TPacketCGShop), &PacketShop))
        {
                Tracef("SendShopSellPacket Error\n");
                return false;
        }
        if (!Send(sizeof(WORD), &bySlot))
        {
                Tracef("SendShopAddSellPacket Error\n");
                return false;
        }
        if (!Send(sizeof(BYTE), &byCount))
        {
                Tracef("SendShopAddSellPacket Error\n");
                return false;
        }

        Tracef(" SendShopSellPacketNew(bySlot=%d, byCount=%d)\n", bySlot, byCount);

        return SendSequence();
}
int CInputMain::Shop(LPCHARACTER ch, const char * data, size_t uiBytes)
{
        TPacketCGShop * p = (TPacketCGShop *) data;

        if (uiBytes < sizeof(TPacketCGShop))
                return -1;

        if (test_server)
                sys_log(0, "CInputMain::Shop() ==> SubHeader %d", p->subheader);

        const char * c_pData = data + sizeof(TPacketCGShop);
        uiBytes -= sizeof(TPacketCGShop);

        switch (p->subheader)
        {
                case SHOP_SUBHEADER_CG_END:
                        sys_log(1, "INPUT: %s SHOP: END", ch->GetName());
                        CShopManager::instance().StopShopping(ch);
                        return 0;

                case SHOP_SUBHEADER_CG_BUY:
                        {
                                if (uiBytes < sizeof(WORD) + sizeof(BYTE))
                                        return -1;

                                WORD bPos = *(c_pData + 1);
                                sys_log(1, "INPUT: %s SHOP: BUY %u", ch->GetName(), bPos);
                                CShopManager::instance().Buy(ch, bPos);
                                return (sizeof(WORD) + sizeof(BYTE));
                        }

                case SHOP_SUBHEADER_CG_SELL:
                        {
                                if (uiBytes < sizeof(WORD))
                                {
#ifdef __DEBUG__
                                        ch->ChatPacket(CHAT_TYPE_INFO, "Return -1");
#endif
                                        return -1;
                                }

                                WORD pos = *c_pData;

                                sys_log(0, "INPUT: %s SHOP: SELL", ch->GetName());
                                CShopManager::instance().Sell(ch, pos);
#ifdef __DEBUG__
                                ch->ChatPacket(CHAT_TYPE_INFO, "return pos: %u", pos);
                                ch->ChatPacket(CHAT_TYPE_INFO, "return sizeof(WORD)");
#endif
                                return sizeof(WORD);
                        }

                case SHOP_SUBHEADER_CG_SELL2:
                        {
                                if (uiBytes < sizeof(WORD)+sizeof(BYTE))
                                {
#ifdef __DEBUG__
                                        ch->ChatPacket(CHAT_TYPE_INFO, "return -1");
#endif
                                        return -1;
                                }

                                WORD pos = *(c_pData++);
                                BYTE count = *(c_pData);

                                sys_log(0, "INPUT: %s SHOP: SELL2", ch->GetName());
                                CShopManager::instance().Sell(ch, pos, count);
#ifdef __DEBUG__
                                ch->ChatPacket(CHAT_TYPE_INFO, "return pos: %u, count: %d", pos, count);
                                ch->ChatPacket(CHAT_TYPE_INFO, "return sizeof(BYTE) + sizeof(BYTE)");
#endif
                                return sizeof(WORD)+sizeof(BYTE);
                        }

                default:
                        sys_err("CInputMain::Shop : Unknown subheader %d : %s", p->subheader, ch->GetName());
                        break;
        }

        return 0;
}

Kind Regards ~ Ken

 

 

Edited by Ken

Do not be sorry, be better.

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.