Jump to content

Glass of Insight - block using on shout chat


Recommended Posts

  • Premium
	
int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes)
{
  		[...]

		//Disable linking items in shout chat
		std::string str = chatbuf_global;
		std::string str2("|Hitem:");
		
 		std::size_t found = str.find(str2);
  		if (found!=std::string::npos)
		{
			ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SHOUT_CHAT_ITEM_HYPERLINK_MESSAGE"));
			return(iExtraLen);
		}
  			
  		[...]
}

Good enough for ya :P

  • Love 1
Link to comment
Share on other sites

  • Forum Moderator

@Sonitex That's a ugly way, i'd rather something more clean.

  • Src/Server/game/src/input_main.cpp

This is the hidden content, please

  • Src/Server/common.h
#define ENABLE_CHAT_SHOUT_LIMIT_HYPERLINK

 

Edited by VegaS™
  • Metin2 Dev 15
  • Good 4
  • Love 12
Link to comment
Share on other sites

  • Bot
Quote
23 hours ago, VegaS™ said:

@Sonitex That's a ugly way, i'd rather something more clean.

  • Src/Server/game/src/input_main.cpp


int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes)
{
	[...]
	if (true == SpamBlockCheck(ch, buf, buflen))
	{
		return iExtraLen;
	}
#ifdef ENABLE_CHAT_SHOUT_LIMIT_HYPERLINK
	if (pinfo->type == CHAT_TYPE_SHOUT)
	{
		int hyperlinks;
		bool colored;
		GetTextTagInfo(buf, buflen, hyperlinks, colored);
  
		if (hyperlinks)
		{
			ch->ChatPacket(CHAT_TYPE_INFO, "Hyperlinks are blocked in this chat.");
			return iExtraLen;
		}
	}
#endif
	[...]
}
  • Src/Server/common.h


#define ENABLE_CHAT_SHOUT_LIMIT_HYPERLINK

 

 

Nice!
 

And how could we block the following?

A player links an item in the chat, and then another player links the same item (without having it), doing the same process in the hyperlink. Basically copy the item visually. Is it possible to do that?

english_banner.gif

Link to comment
Share on other sites

  • Forum Moderator
On 3/4/2019 at 1:54 AM, WLsj24 said:

And how could we block the following?
A player links an item in the chat, and then another player links the same item (without having it), doing the same process in the hyperlink. Basically copy the item visually. Is it possible to do that?

Yes, we can do this in server/client-side, but need some extra-checks for item attr/scokets + if exists in inventory.
But have no sense to fix it since you don't want the players to do this.
Why you don't disable the function chatGetLinkFromHyperlink from source client and python and showing just the tooltip when you put the mouse over the link, remove ALT+LEFT CLICK.

  • root/game.py

This is the hidden content, please

  • root/uiWhisper.py
Spoiler
# 1.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
# 1.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)

 

  • root/uiChat.py
Spoiler
#1.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
#1.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)
            
# 2.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
		else:
			ui.EditLine.OnMouseLeftButtonDown(self)
# 2.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)
		else:
			ui.EditLine.OnMouseLeftButtonDown(self)

 

  • Srcs/Client/UserInterface/PythonChatModule.cpp
Spoiler
// 1.1) Search for:
		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
// 1.2) Replace it with:
#ifdef ENABLE_LINK_FROM_HYPERLINK
		// Link
		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
#endif

 

  • Srcs/Client/UserInterface/PythonApplicationModule.cpp
Spoiler
// 1.1) Search for:
	PyModule_AddIntConstant(poModule, "CAMERA_STOP",			CPythonApplication::CAMERA_STOP);
// 1.2) Add after:
#ifdef ENABLE_LINK_FROM_HYPERLINK
	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 1);
#else
	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 0);
#endif

 

  • Srcs/Client/UserInterface/Locale_inc.h
Spoiler
//#define ENABLE_LINK_FROM_HYPERLINK // Enable copy a item link from hyperlink with ALT+CLICK.

 

 

Edited by VegaS™
  • Metin2 Dev 15
  • Good 3
  • Love 8
Link to comment
Share on other sites

  • Bot
Quote
9 hours ago, VegaS™ said:

Yes, we can do this in server/client-side, but need some extra-checks for item attr/scokets + if exists in inventory.
But have no sense to fix it since you don't want the players to do this.
Why you don't disable the function chatGetLinkFromHyperlink from source client and python and showing just the tooltip when you put the mouse over the link, remove ALT+LEFT CLICK.

  • root/game.py
  Reveal hidden contents



# 1.1) Search for:
			hyperlink = ui.GetHyperlink()
			if hyperlink:
				if app.IsPressed(app.DIK_LALT):
					link = chat.GetLinkFromHyperlink(hyperlink)
					ime.PasteString(link)
				else:
					self.interface.MakeHyperlinkTooltip(hyperlink)
				return
			else:
				player.SetMouseState(player.MBT_LEFT, player.MBS_CLICK)
# 1.2) Replace it with:
			hyperlink = ui.GetHyperlink()
			if hyperlink:
				if app.ENABLE_LINK_FROM_HYPERLINK:
					if app.IsPressed(app.DIK_LALT):
						ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
						return
			
				self.interface.MakeHyperlinkTooltip(hyperlink)
			else:
				player.SetMouseState(player.MBT_LEFT, player.MBS_CLICK)

 

  • root/uiWhisper.py
  Reveal hidden contents



# 1.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
# 1.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)

 

  • root/uiChat.py
  Reveal hidden contents



#1.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
#1.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)
            
# 2.1) Search for:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.IsPressed(app.DIK_LALT):
				link = chat.GetLinkFromHyperlink(hyperlink)
				ime.PasteString(link)
			else:
				self.interface.MakeHyperlinkTooltip(hyperlink)
		else:
			ui.EditLine.OnMouseLeftButtonDown(self)
# 2.2) Replace it with:
	def OnMouseLeftButtonDown(self):
		hyperlink = ui.GetHyperlink()
		if hyperlink:
			if app.ENABLE_LINK_FROM_HYPERLINK:
				if app.IsPressed(app.DIK_LALT):
					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
					return

			self.interface.MakeHyperlinkTooltip(hyperlink)
		else:
			ui.EditLine.OnMouseLeftButtonDown(self)

 

  • Srcs/Client/UserInterface/PythonChatModule.cpp
  Reveal hidden contents



// 1.1) Search for:
		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
// 1.2) Replace it with:
#ifdef ENABLE_LINK_FROM_HYPERLINK
		// Link
		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
#endif

 

  • Srcs/Client/UserInterface/PythonApplicationModule.cpp
  Reveal hidden contents



// 1.1) Search for:
	PyModule_AddIntConstant(poModule, "CAMERA_STOP",			CPythonApplication::CAMERA_STOP);
// 1.2) Add after:
#ifdef ENABLE_LINK_FROM_HYPERLINK
	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 1);
#else
	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 0);
#endif

 

  • Srcs/Client/UserInterface/Locale_inc.h
  Reveal hidden contents



//#define ENABLE_LINK_FROM_HYPERLINK // Enable copy a item link from hyperlink with ALT+CLICK.

 

 

 

It is a great idea to do this in this way and not complicate life by checking if it exists in the inventory. Many thanks!

  • Love 1

english_banner.gif

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.