Jump to content

Guild Name Color by Ranking


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Hey guyz :)

Here's an image to see what is it about. Just coloring guild names for the top3 rank. (gold,silver,bronze)

J3vZu4R.jpg

Let's start with the server side.

Open char.cpp and search for

void CHARACTER::SendGuildName(CGuild* pGuild)

Modify like:

void CHARACTER::SendGuildName(CGuild* pGuild)
{
    if (NULL == pGuild) return;
	    DESC    *desc = GetDesc();
	    if (NULL == desc) return;
    if (m_known_guild.find(pGuild->GetID()) != m_known_guild.end()) return;
	    m_known_guild.insert(pGuild->GetID());
	    TPacketGCGuildName    pack;
    memset(&pack, 0x00, sizeof(pack));
    pack.header        = HEADER_GC_GUILD;
    pack.subheader    = GUILD_SUBHEADER_GC_GUILD_NAME;
    pack.size        = sizeof(TPacketGCGuildName);
    pack.guildID    = pGuild->GetID();    
    memcpy(pack.guildName, pGuild->GetName(), GUILD_NAME_MAX_LEN);
    pack.guildRank = CGuildManager::instance().GetRank(pGuild);
    desc->Packet(&pack, sizeof(pack));
}

Open packet.h and search for

typedef struct packet_guild_name_t


Modify the struct like:

typedef struct packet_guild_name_t
{
    BYTE header;
    WORD size;
    BYTE subheader;
    DWORD    guildID;
    char    guildName[GUILD_NAME_MAX_LEN];
    int guildRank;
    
} TPacketGCGuildName;

Compile the game file.

 

And now the client side.

We'll only work in UserInterface.

In PythonGuild.h search for

typedef std::map<DWORD, std::string> TGuildNameMap;

Modify like:

typedef std::map<DWORD, GuildNameRank> TGuildNameMap;

Put it before that line:

struct GuildNameRank
{
    std::string name;
    int rank;
};

Search for:

void RegisterGuildName(DWORD dwID, const char * c_szName);


Modify like:

void RegisterGuildName(DWORD dwID, const char * c_szName, int rank);

Open PythonGuild.cpp-t and search for RegisterGuildName function:
Modify:

 

void CPythonGuild::RegisterGuildName(DWORD dwID, const char * c_szName, int rank)
{
	GuildNameRank gnr;
	gnr.name = std::string(c_szName);
	gnr.rank = rank;
	m_GuildNameMap.insert(make_pair(dwID, gnr));
}

Now search for GetGuildName
Modify:

bool CPythonGuild::GetGuildName(DWORD dwID, std::string * pstrGuildName)
{
	if (m_GuildNameMap.end() == m_GuildNameMap.find(dwID))
		return false;

	switch (m_GuildNameMap[dwID].rank)
	{
	case 1:
		*pstrGuildName = "|cffFFC125" + m_GuildNameMap[dwID].name + "|r";
		break;
	case 2:
		*pstrGuildName = "|cff888888" + m_GuildNameMap[dwID].name + "|r";
		break;
	case 3:
		*pstrGuildName = "|cffCD661D" + m_GuildNameMap[dwID].name + "|r";
		break;
	default:
		*pstrGuildName = m_GuildNameMap[dwID].name;
		break;
	}

	return true;
}

Open PythonNetworkStreamPhaseGame.cpp and search for

case GUILD_SUBHEADER_GC_GUILD_NAME:


Replace the case:

case GUILD_SUBHEADER_GC_GUILD_NAME:
        {
            DWORD dwID;
            char szGuildName[GUILD_NAME_MAX_LEN+1];
            int guildRank;
	            int iPacketSize = int(GuildPacket.size) - sizeof(GuildPacket);
	            int nItemSize = sizeof(dwID) + GUILD_NAME_MAX_LEN + sizeof(guildRank);
	            assert(iPacketSize%nItemSize==0 && "GUILD_SUBHEADER_GC_GUILD_NAME");
	            for (; iPacketSize > 0;)
            {
                if (!Recv(sizeof(dwID), &dwID))
                    return false;
                
                if (!Recv(GUILD_NAME_MAX_LEN, &szGuildName))
                    return false;
	                if (!Recv(sizeof(guildRank), &guildRank))
                    return false;
	                szGuildName[GUILD_NAME_MAX_LEN] = 0;
                //Tracef(" >> GulidName [%d : %s]\n", dwID, szGuildName);
                CPythonGuild::Instance().RegisterGuildName(dwID, szGuildName, guildRank);
                iPacketSize -= nItemSize;
            }
            break;
        }

Compile the client binary! :)

We're all done :)

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 8
  • Confused 1
  • Love 2
  • Love 12

WRnRW3H.gif

Link to comment
Share on other sites

  • 1 year later...

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.