Jump to content

[Fix] Guild name "Noname" after leaving a guild


Recommended Posts

  • Active+ Member

First of all: Thanks to Mitachi for the question on Discord and to Sauber for explaining how something like this happens.



Reason: On guild leave the client called CPythonGuild::Destroy(), which wiped the whole
guild name cache (m_GuildNameMap), including the names of other guilds. The server sends
each guild name only once per session (CHARACTER::m_known_guild), so every text tail
created afterwards fell back to "Noname" until relog.


 

Spoiler

Files:
- UserInterface/PythonGuild.h
- UserInterface/PythonGuild.cpp
- UserInterface/PythonNetworkStreamPhaseGame.cpp

 

1) PythonGuild.h — Find:

		void Destroy();

Replace with:

		void Destroy();
		void LeaveGuild();


2) PythonGuild.h — Find:

		void __Initialize();

Replace with:

		void __ResetGuildData();
		void __Initialize();


3) PythonGuild.cpp — Find:

	void CPythonGuild::__Initialize()
	{
		ZeroMemory(&m_GuildInfo, sizeof(m_GuildInfo));
		ZeroMemory(&m_GuildSkillData, sizeof(m_GuildSkillData));
		ZeroMemory(&m_adwEnemyGuildID, ENEMY_GUILD_SLOT_MAX_COUNT*sizeof(DWORD));
		m_GradeDataMap.clear();
		m_GuildMemberDataVector.clear();
		m_dwMemberLevelSummary = 0;
		m_dwMemberLevelAverage = 0;
		m_bGuildEnable = FALSE;
		m_GuildNameMap.clear();
	}

	void CPythonGuild::Destroy()
	{
		__Initialize();
	}

Replace with:

	void CPythonGuild::__ResetGuildData()
	{
		ZeroMemory(&m_GuildInfo, sizeof(m_GuildInfo));
		ZeroMemory(&m_GuildSkillData, sizeof(m_GuildSkillData));
		ZeroMemory(&m_adwEnemyGuildID, ENEMY_GUILD_SLOT_MAX_COUNT*sizeof(DWORD));
		m_GradeDataMap.clear();
		m_GuildMemberDataVector.clear();
		m_dwMemberLevelSummary = 0;
		m_dwMemberLevelAverage = 0;
		m_bGuildEnable = FALSE;
	}

	void CPythonGuild::__Initialize()
	{
		__ResetGuildData();
		m_GuildNameMap.clear();
	}

	void CPythonGuild::Destroy()
	{
		__Initialize();
	}

	void CPythonGuild::LeaveGuild()
	{
		if (0 != m_GuildInfo.dwGuildID && '\0' != m_GuildInfo.szGuildName[0])
			m_GuildNameMap[m_GuildInfo.dwGuildID] = m_GuildInfo.szGuildName;

		__ResetGuildData();
	}


4) PythonNetworkStreamPhaseGame.cpp — In CPythonNetworkStream::RecvGuildSub_Remove(),
   find:

		CPythonGuild::Instance().Destroy();

Replace with:

		CPythonGuild::Instance().LeaveGuild();

 



have a nice day

  • Metin2 Dev 3
Link to comment
https://metin2.dev/topic/34665-fix-guild-name-noname-after-leaving-a-guild/
Share on other sites

  • Developer

I'm working on my 5.2, so I wrote down a list of bugs to fix, but I couldn't remember how to reproduce this particular one. I guess I need to be careful when asking on Metin2Dev how to trigger bugs I'm already working on, unless I want to see the fix published the very next day just to farm some rep.

Shit happens, however:

a desync there in PythonNetworkStreamPhaseGame.cpp:

		case GUILD_SUBHEADER_GC_GUILD_INVITE:
		{
			DWORD dwGuildID;
			if (!Recv(sizeof(dwGuildID), &dwGuildID))
				return false;
			char szGuildName[GUILD_NAME_MAX_LEN+1];
			if (!Recv(GUILD_NAME_MAX_LEN + 1, &szGuildName)) /* @mitafix.client.44 */
				return false;

			szGuildName[GUILD_NAME_MAX_LEN] = 0;

			PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RecvGuildInviteQuestion", Py_BuildValue("(is)", dwGuildID, szGuildName));
			Tracef(" <Guild Invite> %d, %s\n", dwGuildID, szGuildName);
			break;
		}

This was causing:

spacer.png

When you invite someone in the guild, he accept but he can't see the guild name above his head (only in the new member client) a simple UpdatePacket will fix, like equipping/unequipping something.

What I was doing to make it happen (not all process are needed ig):

  1. Log in with two characters: the guild leader and a guild member.
  2. Disband the guild.
  3. Create a new guild using the same character as leader.
  4. Invite the former member to the newly created guild.

This doesn't happen every time due to packet timing/buffering. Depending on how the packets are grouped and processed, the leftover byte doesn't always result in the same visible failure, so you may try 2/3 times before to notice the bug.

  • kekw 1
  • Facepalm 1
  • Love 1

Villains are not born, they are made.
Join

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.