Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×
!-->
  • 0

Display inviter name at question dialog


ReFresh

Question

  • Premium

Hey guys,

I need to send a guild inviter name to invited target via packet and then trough python and I'm wondering about how to do that.

Below are the files which have to be changed to make it working in my opinion (I don't really know possible ways how it could be made).

Client source file: UserInterface/PythonNetworkStreamPhaseGame.cpp

Spoiler
	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, &szGuildName))
				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;
		}

 

Server source file: game/src/guild.cpp

Spoiler
void CGuild::Invite( LPCHARACTER pchInviter, LPCHARACTER pchInvitee )
{
	DWORD gid = GetID();

	TPacketGCGuild p;
	p.header	= HEADER_GC_GUILD;
	p.size	= sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1;
	p.subheader	= GUILD_SUBHEADER_GC_GUILD_INVITE;

	TEMP_BUFFER buf;
	buf.write( &p, sizeof(p) );
	buf.write( &gid, sizeof(DWORD) );
	buf.write( GetName(), GUILD_NAME_MAX_LEN + 1 );

	pchInvitee->GetDesc()->Packet( buf.read_peek(), buf.size() );
}

 

Can I do something like this? (I know, I can't code it exactly as you can see below without more changes)

Spoiler

 

Spoiler
void CGuild::Invite( LPCHARACTER pchInviter, LPCHARACTER pchInvitee )
{
	DWORD gid = GetID();

	TPacketGCGuild p;
	p.header	= HEADER_GC_GUILD;
	p.size	= sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1; //Guild name is sent trough: WORD size; wtf?
	p.sender_name = sizeof(p) + sizeof(DWORD) + CHARACTER_NAME_MAX_LEN + 1;
	p.subheader	= GUILD_SUBHEADER_GC_GUILD_INVITE;

	TEMP_BUFFER buf;
	buf.write( &p, sizeof(p) );
	buf.write( &gid, sizeof(DWORD) );
	buf.write( GetName(), GUILD_NAME_MAX_LEN + 1 );
	buf.write( pInfo->inviter_name_, CHARACTER_NAME_MAX_LEN + 1);

	pchInvitee->GetDesc()->Packet( buf.read_peek(), buf.size() );
}

 

Spoiler
	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, &szGuildName))
				return false;
			char szSenderName[CHARACTER_NAME_MAX_LEN+1];
			if (!Recv(CHARACTER_NAME_MAX_LEN, &szSenderName))
				return false;

			szGuildName[GUILD_NAME_MAX_LEN] = 0;
			szSenderName[CHARACTER_NAME_MAX_LEN] = 0;

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

 

 

By this function I need to display the name of the invite sender at questiondialog then (root/game.py):

Spoiler
def RecvGuildInviteQuestion(self, guildID, guildName, #senderName - added function):

 

If anyone got an idea how it could be made and have some free time to help me, I'll be really glad! I've got how it works, but I don't have that much c++ knowledge to make it working.

Thanks for possible answers!

Sincerely,

ReFresh

Edited by ReFresh

I'll be always helpful! 👊 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0
  • Premium
Posted (edited)

@meneleosThanks for trying to help me, but by the way you did, you cannot recieve the name of invite sender, because you didn't edit the packet which have to send the inviter name. I got an empty value by the way you did. I was thinking about adding a new packet to send the inviter name, but if there is another easier way how to send it, it will be much better.

Edited by ReFresh

I'll be always helpful! 👊 

Link to comment
Share on other sites

  • 0
  • Premium
Posted (edited)

I would be really glad, if someone can help me little bit, because I'm really stucked here and got no idea how to get the invite senderName on the invited player question dialog. I think problem is on server side, where it's not getting the senderName value.

File: src/game/guild.cpp

Spoiler
void CGuild::Invite( LPCHARACTER pchInviter, LPCHARACTER pchInvitee )
{
	{ ... }

	DWORD gid = GetID();

	TPacketGCGuild p;
	p.header	= HEADER_GC_GUILD;
	p.size	= sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1 + CHARACTER_NAME_MAX_LEN + 1; //Added + CHARACTER_NAME_MAX_LEN + 1
	p.subheader	= GUILD_SUBHEADER_GC_GUILD_INVITE;

	TEMP_BUFFER buf;
	buf.write( &p, sizeof(p) );
	buf.write( &gid, sizeof(DWORD) );
	buf.write( GetName(), GUILD_NAME_MAX_LEN + 1 );
	buf.write( pchInvitee->GetName(), CHARACTER_NAME_MAX_LEN + 1 ); //Added this line

	pchInvitee->GetDesc()->Packet( buf.read_peek(), buf.size() );
  
  }

 

File: UserInterface/PythonNetworkStreamPhaseGame.cpp

Spoiler
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, &szGuildName))
				return false;

			//ADDED THIS:
			char szSenderName[CHARACTER_NAME_MAX_LEN + 1];
			if (!Recv(CHARACTER_NAME_MAX_LEN, &szSenderName))
				return false;

			szGuildName[GUILD_NAME_MAX_LEN] = 0;
			//ADDED THIS:
			szSenderName[CHARACTER_NAME_MAX_LEN] = 0;


			PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RecvGuildInviteQuestion", Py_BuildValue("(iss)", dwGuildID, szGuildName, szSenderName)); //ADDED 's' and szSenderName
			Tracef(" <Guild Invite> %d, %s, %s\n", dwGuildID, szGuildName, szSenderName);
			break;
		}

 

File: root/game.py

Spoiler
def RecvGuildInviteQuestion(self, guildID, guildName, senderName): #Added senderName
  {...}
  guildInviteQuestionDialog.SetText1(localeInfo.GUILD_DO_YOU_JOIN_1 % (senderName, guildName)) #Added senderName
  {...}

 

File: locale/locale_game.txt

Spoiler
GUILD_DO_YOU_JOIN_1	%s invited you to guild %s. #ADDED %s for senderName
Edited by ReFresh

I'll be always helpful! 👊 

Link to comment
Share on other sites

  • -1
5 hours ago, ReFresh said:

@meneleosThanks for trying to help me, but by the way you did, you cannot recieve the name of invite sender, because you didn't edit the packet which have to send the inviter name. I got an empty value by the way you did. I was thinking about adding a new packet to send the inviter name, but if there is another easier way how to send it, it will be much better.

sorry

find this line

p.size = sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1;

and change

 

p.size    = sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1 + CHARACTER_NAME_MAX_LEN + 1;

client

change case GUILD_SUBHEADER_GC_GUILD_INVITE
 

		case GUILD_SUBHEADER_GC_GUILD_INVITE:
		{
			DWORD dwGuildID;
			if (!Recv(sizeof(dwGuildID), &dwGuildID))
				return false;

			char szGuildName[GUILD_NAME_MAX_LEN+1];
			if (!Recv(sizeof(szGuildName), &szGuildName))
				return false;

			char szInviterName[CHARACTER_NAME_MAX_LEN+1];
			if (!Recv(sizeof(szInviterName), &szInviterName))
				return false;

			szGuildName[GUILD_NAME_MAX_LEN] = 0;
			szInviterName[CHARACTER_NAME_MAX_LEN] = 0;

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

 

Link to comment
Share on other sites

  • -2

 

    Server/Game/guild.cpp

	DWORD gid = GetID();

	TPacketGCGuild p;
	p.header	= HEADER_GC_GUILD;
	p.size	= sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1 + CHARACTER_NAME_MAX_LEN + 1;
	p.subheader	= GUILD_SUBHEADER_GC_GUILD_INVITE;

	TEMP_BUFFER buf;
	buf.write( &p, sizeof(p) );
	buf.write( &gid, sizeof(DWORD) );
	buf.write( GetName(), GUILD_NAME_MAX_LEN + 1 );
	buf.write( pchInviter->GetName(), CHARACTER_NAME_MAX_LEN + 1 ); // send inviter name

	pchInvitee->GetDesc()->Packet( buf.read_peek(), buf.size() );

 

    Client/UserInterface/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(sizeof(szGuildName), &szGuildName))
				return false;

			char szInviterName[CHARACTER_NAME_MAX_LEN+1];
			if (!Recv(sizeof(szInviterName), &szInviterName))
				return false;

			szGuildName[GUILD_NAME_MAX_LEN] = 0;
			szInviterName[CHARACTER_NAME_MAX_LEN] = 0;

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

    root/game.py
 

	## Guild
	def RecvGuildInviteQuestion(self, guildID, guildName, inviterName):
		guildInviteQuestionDialog = uicommon.QuestionDialog()
		guildInviteQuestionDialog.SetText(localeInfo.GUILD_DO_YOU_JOIN_NEW % (inviterName, guildName))
		guildInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerGuildInvite(arg))
		guildInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerGuildInvite(arg))
		guildInviteQuestionDialog.Open()
		guildInviteQuestionDialog.guildID = guildID
		self.guildInviteQuestionDialog = guildInviteQuestionDialog

    locale_game.txt
 


	GUILD_DO_YOU_JOIN_NEW	%s has invited you to %s. Do you want to join?

 

Edited by meneleos
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 993

      [40250] Reference Serverfile + Client + Src [15 Available Languages]

    2. 1

      Looking for a good designer

    3. 0

      Cross channel friend request

    4. 2

      Where are those maps/dungeons coming from?

    5. 3

      Press F10 to close the client immediately

    6. 2

      Where are those maps/dungeons coming from?

    7. 2

      Where are those maps/dungeons coming from?

    8. 4

      Visual studio 2022 compiling issue

    9. 1

      Count players function

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.