Jump to content

Recommended Posts

  • Forum Moderator

M2 Download Center

This is the hidden content, please
( Internal )

Github repository:

This is the hidden content, please

  • Metin2 Dev 65
  • Eyes 2
  • Dislove 1
  • Not Good 1
  • Think 1
  • Confused 1
  • Good 11
  • Love 2
  • Love 37
Link to comment
https://metin2.dev/topic/19405-gf-v181-messenger-get-friend-names/
Share on other sites

Webzen didn't create a new function to return m_FriendNameMap. They just make m_FriendNameMap public. (It was protected before). Also, you can use const_iterator instead of iterator. (You're not modifying it.)

Here is the reversed version of webzen's function.

This version is for c++11

Spoiler

PyObject * messengerGetFriendNames(PyObject * poSelf, PyObject * poArgs)
{
	const CPythonMessenger & messenger = CPythonMessenger::Instance();	
	PyObject * mainTuple = PyTuple_New(messenger.m_FriendNameMap.size());	
	
	uint32_t pos = 0;
	for (const auto friendName : messenger.m_FriendNameMap)
	{
		PyTuple_SetItem(mainTuple, pos, PyString_FromString(friendName.c_str()));
		++pos;
	}

	return mainTuple;
}

 

This is for c++03

Spoiler

PyObject * messengerGetFriendNames(PyObject * poSelf, PyObject * poArgs)
{
	const CPythonMessenger & messenger = CPythonMessenger::Instance();	
	PyObject * mainTuple = PyTuple_New(messenger.m_FriendNameMap.size());	
	
	int pos = 0;
	for (std::set<std::string>::const_iterator it = messenger.m_FriendNameMap.begin(); it != messenger.m_FriendNameMap.end(); ++it)
	{
		PyTuple_SetItem(mainTuple, pos, PyString_FromString(it->c_str()));
		++pos;
	}

	return mainTuple;
}

 

PS:

This function has come with a system that called mailbox. 

Best Regards

Ken

  • Love 2

Do not be sorry, be better.

  • Forum Moderator
1 hour ago, Ken said:

Webzen didn't create a new function to return m_FriendNameMap. They just make m_FriendNameMap public. (It was protected before). Also, you can use const_iterator instead of iterator. (You're not modifying it.)

I was thinking of this way too, but i'm was so bored to remake tutorial for replace protected m_FriendNameMap with public one <_<, because i did it some months ago just for mailbox. 

Spoiler

i9gtfab.png

 

Edited by Metin2 Dev
Core X - External 2 Internal

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.