Jump to content
  • Register Now

    Sign up and take advantage of the features of our community! Some forums are only accessible to our members!

  • 0

Loading client crash (loading_tip_vnum)


Dutschke

Question

Ekran-Al-nt-s.png

 

loading_tip_vnum.txt

loading_tip_list.txt

 

 

bool CPythonNetworkStream::LoadLoadingTipList(const char* c_szLoadingTipListFileName)
{
	CTextFileLoader kTextFileLoader;
	if (!kTextFileLoader.Load(c_szLoadingTipListFileName))
		return false;

	m_kMap_dwMapIndex_vecTipList.clear();

	for (DWORD i = 0; i < kTextFileLoader.GetChildNodeCount(); ++i)
	{
		CTextFileLoader::CGotoChild GotoChild(&kTextFileLoader, i);

		CTokenVector* pTipTokens;
		std::vector<DWORD> vecTipList;
		vecTipList.clear();

		if (kTextFileLoader.GetTokenVector("tip_vnum", &pTipTokens))
		{
			for (size_t j = 0; j < pTipTokens->size(); ++j)
			{
				vecTipList.push_back(atoi(pTipTokens->at(j).c_str()));
			}
		}

		CTokenVector* pMapTokens;
		std::vector<DWORD> vecMapList;
		vecMapList.clear();

		if (kTextFileLoader.GetTokenVector("map_index", &pMapTokens))
		{
			for (size_t k = 0; k < pMapTokens->size(); ++k)
			{
				vecMapList.push_back(atoi(pMapTokens->at(k).c_str()));
			}
		}

		if (vecTipList.size() > 0)
		{
			if (vecMapList.size() == 0)
			{
				m_kMap_dwMapIndex_vecTipList.insert(std::make_pair(0, vecTipList));
			}
			else
			{
				for (size_t l = 0; l < vecMapList.size(); ++l)
				{
					m_kMap_dwMapIndex_vecTipList.insert(std::make_pair(vecMapList.at(l), vecTipList));
				}
			}
		}
	}

	return true;
}

bool CPythonNetworkStream::LoadLoadingTipVnum(const char* c_szLoadingTipVnumFileName)
{
	CMappedFile file;
	const VOID* pvData;

	if (!CEterPackManager::Instance().Get(file, c_szLoadingTipVnumFileName, &pvData))
	{
		Tracef("CPythonNetworkStream::LoadLoadingTipVnum(c_szLoadingTipVnumFileName=%s) - Load Error", c_szLoadingTipVnumFileName);
		return false;
	}

	CMemoryTextFileLoader kMemTextFileLoader;
	kMemTextFileLoader.Bind(file.Size(), pvData);

	m_kMap_dwID_strTipString.clear();

	CTokenVector TokenVector;
	for (DWORD i = 0; i < kMemTextFileLoader.GetLineCount(); ++i)
	{
		if (!kMemTextFileLoader.SplitLineByTab(i, &TokenVector))
			continue;

		const char* c_szComment = "#";
		if (TokenVector[0].compare(0, 1, c_szComment) == 0 || TokenVector.size() != 2)
			continue;

		m_kMap_dwID_strTipString.insert(std::make_pair(atoi(TokenVector[0].c_str()), TokenVector[1]));
	}

	return true;
}

const char* CPythonNetworkStream::GetLoadingTipVnum(LONG lMapIndex)
{
	if (lMapIndex > 10000)
		lMapIndex /= 10000;

	std::random_device rd;
	std::mt19937 mt(rd());
	auto it = m_kMap_dwMapIndex_vecTipList.find(lMapIndex);

	static char s_szTip[512] = "";

	if (it == m_kMap_dwMapIndex_vecTipList.end())
	{
		std::uniform_int_distribution<std::mt19937::result_type> dist(0, m_kMap_dwMapIndex_vecTipList.begin()->second.size() - 1);
		sprintf(s_szTip, "%s", m_kMap_dwID_strTipString.find(m_kMap_dwMapIndex_vecTipList.begin()->second.at(dist(rd)))->second.c_str());
	}
	else
	{
		std::uniform_int_distribution<std::mt19937::result_type> dist(0, it->second.size() - 1);
		sprintf(s_szTip, "%s", m_kMap_dwID_strTipString.find(it->second.at(dist(rd)))->second.c_str());
	}

	return s_szTip;
}

 

@VegaS™ @xP3NG3Rx

Edited by Dutschke (see edit history)
  • Angry 1
Link to post

1 answer to this question

Recommended Posts

Guest
This topic is now closed to further replies.


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