Jump to content

Source discussions, questions, answers


Recommended Posts

  • 1 month later...
  • 3 weeks later...

Sorry for my English so that tou using the translator, I want to ask is if someone can help me with this error, tou are using vs 2008 with the SP1 patch

 

Error: https://metin2.download/picture/D8vJH2R4q50X8m39xcsXlfcEIrOjFlUN/.png

I thank those who help me

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

I would like to invert the function on the mob_drop_item Level_limit...

It's possbile?

Thanks :P

 

game/item_manager_read_tables.cpp

 

		if ( strType == "limit" )
		{
			if ( !loader.GetTokenInteger("level_limit", &iLevelLimit) )
			{
				sys_err("ReadmonsterDropItemGroup : Syntax error %s : no level_limit, node %s", c_pszFileName, stName.c_str());
				loader.SetParentNode();
				return false;
			}
		}
		else
		{
			iLevelLimit = 0;
		}

 

bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)
{
	CTextFileLoader loader;

	if (!loader.Load(c_pszFileName))
		return false;

	for (DWORD i = 0; i < loader.GetChildNodeCount(); ++i)
	{
		std::string stName("");

		loader.GetCurrentNodeName(&stName);

		if (strncmp (stName.c_str(), "kr_", 3) == 0)
		{
			if (LC_IsYMIR())
			{
				stName.assign(stName, 3, stName.size() - 3);
			}
			else
			{
				continue;
			}
		}

		loader.SetChildNode(i);

		int iMobVnum = 0;
		int iKillDrop = 0;
		int iLevelLimit = 0;

		std::string strType("");

		if (!loader.GetTokenString("type", &strType))
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : no type (kill|drop), node %s", c_pszFileName, stName.c_str());
			loader.SetParentNode();
			return false;
		}

		if (!loader.GetTokenInteger("mob", &iMobVnum))
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : no mob vnum, node %s", c_pszFileName, stName.c_str());
			loader.SetParentNode();
			return false;
		}

		if (strType == "kill")
		{
			if (!loader.GetTokenInteger("kill_drop", &iKillDrop))
			{
				sys_err("ReadMonsterDropItemGroup : Syntax error %s : no kill drop count, node %s", c_pszFileName, stName.c_str());
				loader.SetParentNode();
				return false;
			}
		}
		else
		{
			iKillDrop = 1;
		}

		if ( strType == "limit" )
		{
			if ( !loader.GetTokenInteger("level_limit", &iLevelLimit) )
			{
				sys_err("ReadmonsterDropItemGroup : Syntax error %s : no level_limit, node %s", c_pszFileName, stName.c_str());
				loader.SetParentNode();
				return false;
			}
		}
		else
		{
			iLevelLimit = 0;
		}

		sys_log(0,"MOB_ITEM_GROUP %s [%s] %d %d", stName.c_str(), strType.c_str(), iMobVnum, iKillDrop);

		if (iKillDrop == 0)
		{
			loader.SetParentNode();
			continue;
		}

		TTokenVector* pTok = NULL;

		if (strType == "kill")
		{
			CMobItemGroup * pkGroup = M2_NEW CMobItemGroup(iMobVnum, iKillDrop, stName);

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					//sys_log(1, "               %s %s", pTok->at(0).c_str(), pTok->at(1).c_str());
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadMonsterDropItemGroup : there is no item %s : node %s : vnum %d", name.c_str(), stName.c_str(), dwVnum);
							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount<1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s : vnum %d, count %d", name.c_str(), stName.c_str(), dwVnum, iCount);
						return false;
					}

					int iPartPct = 0;
					str_to_number(iPartPct, pTok->at(2).c_str());

					if (iPartPct == 0)
					{
						sys_err("ReadMonsterDropItemGroup : there is no drop percent for item %s : node %s : vnum %d, count %d, pct %d", name.c_str(), stName.c_str(), iPartPct);
						return false;
					}

					int iRarePct = 0;
					str_to_number(iRarePct, pTok->at(3).c_str());
					iRarePct = MINMAX(0, iRarePct, 100);

					sys_log(0,"        %s count %d rare %d", name.c_str(), iCount, iRarePct);
					pkGroup->AddItem(dwVnum, iCount, iPartPct, iRarePct);
					continue;
				}

				break;
			}
			m_map_pkMobItemGroup.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup));

		}
		else if (strType == "drop")
		{
			CDropItemGroup* pkGroup;
			bool bNew = true;
			itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find (iMobVnum);
			if (it == m_map_pkDropItemGroup.end())
			{
				pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName);
			}
			else
			{
				bNew = false;
				CDropItemGroup* pkGroup = it->second;
			}

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str());
							M2_DELETE(pkGroup);

							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str());
						M2_DELETE(pkGroup);

						return false;
					}

					float fPercent = atof(pTok->at(2).c_str());

					DWORD dwPct = (DWORD)(10000.0f * fPercent);

					sys_log(0,"        name %s pct %d count %d", name.c_str(), dwPct, iCount);
					pkGroup->AddItem(dwVnum, dwPct, iCount);

					continue;
				}

				break;
			}
			if (bNew)
				m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup));

		}
		else if ( strType == "limit" )
		{
			CLevelItemGroup* pkLevelItemGroup = M2_NEW CLevelItemGroup(iLevelLimit);

			for ( int k=1; k < 256; k++ )
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if ( loader.GetTokenVector(buf, &pTok) )
				{
					std::string& name = pTok->at(0);
					DWORD dwItemVnum = 0;

					if (false == GetVnumByOriginalName(name.c_str(), dwItemVnum))
					{
						str_to_number(dwItemVnum, name.c_str());
						if ( !ITEM_MANAGER::instance().GetTable(dwItemVnum) )
						{
							M2_DELETE(pkLevelItemGroup);
							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						M2_DELETE(pkLevelItemGroup);
						return false;
					}

					float fPct = atof(pTok->at(2).c_str());
					DWORD dwPct = (DWORD)(10000.0f * fPct);

					pkLevelItemGroup->AddItem(dwItemVnum, dwPct, iCount);

					continue;
				}

				break;
			}

			m_map_pkLevelItemGroup.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup));
		}
		else if (strType == "thiefgloves")
		{
			CBuyerThiefGlovesItemGroup* pkGroup = M2_NEW CBuyerThiefGlovesItemGroup(0, iMobVnum, stName);

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str());
							M2_DELETE(pkGroup);

							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str());
						M2_DELETE(pkGroup);

						return false;
					}

					float fPercent = atof(pTok->at(2).c_str());

					DWORD dwPct = (DWORD)(10000.0f * fPercent);

					sys_log(0,"        name %s pct %d count %d", name.c_str(), dwPct, iCount);
					pkGroup->AddItem(dwVnum, dwPct, iCount);

					continue;
				}

				break;
			}

			m_map_pkGloveItemGroup.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup));
		}
		else
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : invalid type %s (kill|drop), node %s", c_pszFileName, strType.c_str(), stName.c_str());
			loader.SetParentNode();
			return false;
		}

		loader.SetParentNode();
	}

	return true;
}

 

Link to comment
Share on other sites

  • 4 weeks later...
  • Premium
2 hours ago, Metin2Taipan said:

As stated, I do not understand C ++ I have no idea what to do.

I answered to you in other community you posted your issue.

Go to your config.h and add this:

extern int gSpecialShout;
extern int MasterGhostChat;
extern int MasterColorEmpire;
extern int MasterLevelChat;
extern int PlayerColorEmpire;
extern int PlayerLevelChat;

 

Go to your config.cpp and add this:

int gSpecialShout = 0;
int MasterGhostChat = 0;
int MasterColorEmpire = 0;
int MasterLevelChat = 0;
int PlayerColorEmpire = 0;
int PlayerLevelChat = 0;

0= deactivated

1= activated

 

You can set it to 1 in config files of your cores, or just edit config.cpp variables to be = 1.

 

"was not declared in this scope" means your using a variable that you didnt previously declared.

Link to comment
Share on other sites

  • 1 month later...

Hi guys ,i have a big problem with my game or client binary i don't  know really what's the problem , i'm trying to figure it out for about 2 weeks and nothing, i searched on google ,other forums but my searches were in vain so i hope you will help me so let me tell you about my "bug" : so i created a server , i installed unix ,ports all stuffs on a pc portforwarded the ports i need through router all were good until someone tried to login ,he was kick out when he selected his character and i don't f**king know why this stupid thing drives me crayzi, if i login  on my internal network even from external ip it works ,but when my friend tries to connect nothing, it kicks him to the login again and again, i saw that it's already a post related to that on this forum named, if i think well "40250 game problem" , i follow those steps with bind_ip and other stuff but when i bind the ip it says to me that "can't bind that adress " i don't know again why ,i tried all possible things even change the game with other and same ,of course it was same version 40k ,what do you recommend me to do guys?And i mentioned i have static ip .I don't know what to do :( please help me if you know of course ,many people avoid to answer at this question "how to resolve kick login"  please don't avoid me too.

 

Link to comment
Share on other sites

  • Premium
1 hour ago, alexandru1992 said:

Hi guys ,i have a big problem with my game or client binary i don't  know really what's the problem , i'm trying to figure it out for about 2 weeks and nothing, i searched on google ,other forums but my searches were in vain so i hope you will help me so let me tell you about my "bug" : so i created a server , i installed unix ,ports all stuffs on a pc portforwarded the ports i need through router all were good until someone tried to login ,he was kick out when he selected his character and i don't f**king know why this stupid thing drives me crayzi, if i login  on my internal network even from external ip it works ,but when my friend tries to connect nothing, it kicks him to the login again and again, i saw that it's already a post related to that on this forum named, if i think well "40250 game problem" , i follow those steps with bind_ip and other stuff but when i bind the ip it says to me that "can't bind that adress " i don't know again why ,i tried all possible things even change the game with other and same ,of course it was same version 40k ,what do you recommend me to do guys?And i mentioned i have static ip .I don't know what to do :( please help me if you know of course ,many people avoid to answer at this question "how to resolve kick login"  please don't avoid me too.

 

Well, for me this usually works:

Try to replace this in your desc_client.cpp:
replace the g_szPublicIP to your ip adress (like memcpy(p.szIP, "69.69.69.69", 16);) in this:
 

                    if (!bSentBoot)

	                    {

	                        bSentBoot = true;

	                        TPacketGDBoot p;

	                        p.dwItemIDRange[0] = 0;

	                        p.dwItemIDRange[1] = 0;

	                        memcpy(p.szIP, g_szPublicIP, 16);

	                        DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));

	                    }

 

If it didn't solve the problem, then replace the same variable in this one too:

 

                strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));

 

On windows, doing only the first part solves the problem for me, but on BSD, usually I have to do both. (Don't ask me why...)

  • Love 2

The one and only UI programming guideline

Link to comment
Share on other sites

Ok so if i get it right i should replace in this piece of code from my source g_szPublicIP with what you've told me ? but i see it is already as you told me (PS: i  use  gazer's game and files for the test server, i haven't tested a clean source to see what happends i will test and let you know if it work in case it doesn't works what should i do ? can you let me a skype adress in private or something to debug this thing please you would make my day better ) 

Spoiler


void CLIENT_DESC::SetPhase(int iPhase)
{
    switch (iPhase)
    {
        case PHASE_CLIENT_CONNECTING:
            sys_log(1, "PHASE_CLIENT_DESC::CONNECTING");
            m_pInputProcessor = NULL;
            break;

        case PHASE_DBCLIENT:
            {
                sys_log(1, "PHASE_DBCLIENT");

                if (!g_bAuthServer)
                {
                    static bool bSentBoot = false;

                    if (!bSentBoot)
                    {
                        bSentBoot = true;
                        TPacketGDBoot p;
                        p.dwItemIDRange[0] = 0;
                        p.dwItemIDRange[1] = 0;
                        memcpy(p.szIP, g_szPublicIP, 16);
                        DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
                    }
                }

                TEMP_BUFFER buf;

                TPacketGDSetup p;

                memset(&p, 0, sizeof(p));
                strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));

                if (!g_bAuthServer)
                {
                    p.bChannel    = g_bChannel;
                    p.wListenPort = mother_port;
                    p.wP2PPort    = p2p_port;
                    p.bAuthServer = false;
                    map_allow_copy(p.alMaps, 32);

                    const DESC_MANAGER::DESC_SET & c_set = DESC_MANAGER::instance().GetClientSet();
                    DESC_MANAGER::DESC_SET::const_iterator it;

                    for (it = c_set.begin(); it != c_set.end(); ++it)
                    {
                        LPDESC d = *it;

                        if (d->GetAccountTable().id != 0)
                            ++p.dwLoginCount;
                    }

                    buf.write(&p, sizeof(p));

                    if (p.dwLoginCount)
                    {
                        TPacketLoginOnSetup pck;

                        for (it = c_set.begin(); it != c_set.end(); ++it)
                        {
                            LPDESC d = *it;

                            TAccountTable & r = d->GetAccountTable();

                            if (r.id != 0)
                            {
                                pck.dwID = r.id;
                                strlcpy(pck.szLogin, r.login, sizeof(pck.szLogin));
                                strlcpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID));
                                strlcpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
                                pck.dwLoginKey = d->GetLoginKey();
#ifndef _IMPROVED_PACKET_ENCRYPTION_
                                thecore_memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16);
#endif

                                buf.write(&pck, sizeof(TPacketLoginOnSetup));
                            }
                        }
                    }

                    sys_log(0, "DB_SETUP current user %d size %d", p.dwLoginCount, buf.size());

                    // ĆÄĆĽ¸¦ Ăł¸®ÇŇ Ľö ŔÖ°Ô µĘ.
                    CPartyManager::instance().EnablePCParty();
                    //CPartyManager::instance().SendPartyToDB();
                }
                else
                {
                    p.bAuthServer = true;
                    buf.write(&p, sizeof(p));
                }

                DBPacket(HEADER_GD_SETUP, 0, buf.read_peek(), buf.size());
                m_pInputProcessor = &m_inputDB;
            }
            break;

        case PHASE_P2P:
            sys_log(1, "PHASE_P2P");
            
            if (m_lpInputBuffer)
                buffer_reset(m_lpInputBuffer);

            if (m_lpOutputBuffer)
                buffer_reset(m_lpOutputBuffer);

            m_pInputProcessor = &m_inputP2P;
            break;

        case PHASE_CLOSE:
            m_pInputProcessor = NULL;
            break;

        case PHASE_TEEN:
            m_inputTeen.SetStep(0);
            m_pInputProcessor = &m_inputTeen;
            break;

    }

    m_iPhase = iPhase;
}

 

Link to comment
Share on other sites

  • Premium

So. Firstly, try to replace the g_szPublicIP variable, to your ip only in this part:

Spoiler

                    if (!bSentBoot)
                    {
                        bSentBoot = true;
                        TPacketGDBoot p;
                        p.dwItemIDRange[0] = 0;
                        p.dwItemIDRange[1] = 0;
                        memcpy(p.szIP, g_szPublicIP, 16);
                        DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
                    }

An example:

Spoiler

                    if (!bSentBoot)
                    {
                        bSentBoot = true;
                        TPacketGDBoot p;
                        p.dwItemIDRange[0] = 0;
                        p.dwItemIDRange[1] = 0;
                        memcpy(p.szIP, "write.your.ip.here", 16);
                        DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
                    }

IF it doesn't solve the problem, then you should replace the g_szPublicIP variable to your ip in this line too:

Spoiler

strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));

 

  • Dislove 1

The one and only UI programming guideline

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.