Jump to content

core crash (GetName, SaveSingleItem?)


Recommended Posts

Hi,

I have a core crash, i dont really understand whats the problem.

https://metin2.download/picture/09K0qsj0xP9ZPje3FnmmsRF4533Ccrii/.png
https://metin2.download/picture/fRR4xS3Br06pviwr0vQVIZP3K7S4Ec0E/.png

https://metin2.download/picture/w0M4XtvtxK5O3RMxIXNmvV2aLVLxaQCw/.png

https://metin2.download/picture/3CwK6PPz5cxPX857jIsG4MRdxS82Mj0v/.png

RZyLfnN.png

Corresponding code lines:


item.cpp

#ifdef ENABLE_EXTENDED_ITEMNAME_ON_GROUND
const char* CItem::GetName()
{
#	ifdef ENABLE_MULTI_LANGUAGE_SYSTEM
	BYTE bLocale = (GetOwner() && GetOwner()->GetDesc()) ? GetOwner()->GetDesc()->GetLanguage() : LOCALE_DEFAULT;
#	endif

	static char szItemName[128];
	memset(szItemName, 0, sizeof(szItemName));
	if (GetProto())
	{
		int len = 0;
		switch (GetType())
		{
		case ITEM_POLYMORPH:
		{
			const DWORD dwMobVnum = GetSocket(0);
			const CMob* pMob = CMobManager::instance().Get(dwMobVnum);
			if (pMob)
			{
#	ifdef ENABLE_MULTI_LANGUAGE_SYSTEM
				len = snprintf(szItemName, sizeof(szItemName), "%s", LC_LOCALE_MOB_TEXT(dwMobVnum, bLocale));
#	else
				len = snprintf(szItemName, sizeof(szItemName), "%s", pMob->m_table.szLocaleName);
#	endif
			}
			break;
		}
		case ITEM_SKILLBOOK:

 

https://metin2.download/picture/9I16e553nCZNCl5Ha0irx2kP2T5pzWW3/.png

item_manager.cpp

 

	if(!item->GetName()) {
		sys_err("SaveSingleItem: item->GetName NULL");
		return;
	}
	
	if (!item->GetOwner()) 
	{
		DWORD dwID = item->GetID();
		DWORD dwOwnerID = item->GetLastOwnerPID();
		
		//sys_log(0, "item->GetOwner NULL - Name: %s dwID: %d dwOwnerID: %d",item->GetName(), dwID, dwOwnerID);
		db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_DESTROY, 0, sizeof(DWORD) + sizeof(DWORD));
		db_clientdesc->Packet(&dwID, sizeof(DWORD));
		db_clientdesc->Packet(&dwOwnerID, sizeof(DWORD));

		//sys_log(1, "ITEM_DELETE %s:%u", item->GetName(), dwID);
		return;
	}
	
	//sys_log(1, "ITEM_SAVE %s:%d in %s window %d", item->GetName(), item->GetID(), item->GetOwner()->GetName(), item->GetWindow());

	TPlayerItem t;

 

Thanks.

Spoiler

Edited by Metin2 Dev
Core X - External 2 Internal

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 5 months later...
8 hours ago, WeedHex said:

if(!item->GetName()) { sys_err("SaveSingleItem: item->GetName NULL"); return; }

lol

Yes,i dont have this .. now i added in  void ITEM_MANAGER::SaveSingleItem(LPITEM item) .. it`s ok ? thanks

Quote

void ITEM_MANAGER::SaveSingleItem(LPITEM item)
{
    if (!item->GetName())
    {
        sys_err("SaveSingleItem: item->GetName NULL")
        return;
    }

    if (!item->GetOwner())
    {
        DWORD dwID = item->GetID();
        DWORD dwOwnerID = item->GetLastOwnerPID();

        db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_DESTROY, 0, sizeof(DWORD) + sizeof(DWORD));
        db_clientdesc->Packet(&dwID, sizeof(DWORD));
        db_clientdesc->Packet(&dwOwnerID, sizeof(DWORD));

        sys_log(1, "ITEM_DELETE %s:%u", item->GetName(), dwID);
        return;
    }

    sys_log(1, "ITEM_SAVE %s:%d in %s window %d", item->GetName(), item->GetID(), item->GetOwner()->GetName(), item->GetWindow());

    TPlayerItem t;

    t.id = item->GetID();
    t.window = item->GetWindow();
    t.pos = t.window == EQUIPMENT ? item->GetCell() - INVENTORY_MAX_NUM : item->GetCell();
    t.count = item->GetCount();
    t.vnum = item->GetOriginalVnum();
    t.owner = (t.window == SAFEBOX || t.window == MALL) ? item->GetOwner()->GetDesc()->GetAccountTable().id : item->GetOwner()->GetPlayerID();
    thecore_memcpy(t.alSockets, item->GetSockets(), sizeof(t.alSockets));
    thecore_memcpy(t.aAttr, item->GetAttributes(), sizeof(t.aAttr));

    db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_SAVE, 0, sizeof(TPlayerItem));
    db_clientdesc->Packet(&t, sizeof(TPlayerItem));
}

 

Link to comment
Share on other sites

20 hours ago, WeedHex said:

if(!item->GetName()) { sys_err("SaveSingleItem: item->GetName NULL"); return; }

lol

 I added that, the server doesn't crash anymore, but it causes big problems in the database and makes online players lose their items. I see that the problem has been exposed in the past here: but I can't find the real cause. I also have his great offline shop and I have the impression that someone is playing with me because it doesn't do it all the time but only at time intervals when there are many people online. 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • 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.