Jump to content

Client Locale String


Recommended Posts

  • Honorable Member
27 minutes ago, Kafa said:

As far as i remember, at the time when he released this topic those things were not there

 

what?

 

I don't care when they're there. I just said he could expand topic. 

  • Love 1

 

Link to comment
Share on other sites

2 hours ago, Kafa said:

 

You can actually do it yourself too, isnt too hard i guess  :D 

 

I actually tried to do it for quests, but the problem was the string sent from server side like this 

ex: [blalbalba][ENTER][DONE]

 

I'm not that good to do it xD

 

 

 

Edited by jeddawee
Link to comment
Share on other sites

  • 2 weeks later...
  • Premium
49 minutes ago, spectrum said:

dont't read 


for (const auto& format : FormatTable)

 

more precisely auto 

 

error
locale.cpp:169: error: 'format' has not been declared

a solution  plizz?

 

Hey!

 

"auto" keyword is only supported by higher C++ versions, I believe it was introduced in C++11. You can replace it with "TFormat" and you should be just fine. For future use, I would suggest to upgrade your C++ language standard as it makes thing much simpler when programming.

Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...

All time giving syserr. word character problem.
LocaleStringManager::RegisterLocaleStringTable(locale/tr/locale_string.txt) - Strange Token Count [Line:550 / TokenCount:5]

Line 550 -> 1550    You cannot use that any more.

And errors.

k5s743x.jpg

dygymos.jpg
c = -35

 

Edited by Metin2 Dev
Core X - External 2 Internal

badass hei GIF

Link to comment
Share on other sites

Can someone help me with Wedding & war_map ?

 

I mean 

 

	struct FNotice
	{
		FNotice(const char * psz) : m_psz(psz)
		{
		}

		void operator() (LPCHARACTER ch)
		{
			ch->ChatPacket(CHAT_TYPE_NOTICE, "%s", m_psz);
		}

		const char * m_psz;
	};

 

I would really love if someone extends the topic with notice, so i can actually use this beatiful release.

Link to comment
Share on other sites

Just create another function like that:

void SendNoticeMapLocal(DWORD dwIndex, const char* c_pszBuf, int nMapIndex, bool bBigFont, ...)
{
	BYTE type = 0;

	const DESC_MANAGER::DESC_SET& c_ref_set = DESC_MANAGER::instance().GetClientSet();
	if (!c_pszBuf)
		return;

	DESC_MANAGER::DESC_SET::const_iterator it = c_ref_set.begin();

	while (it != c_ref_set.end())
	{
		LPDESC d = *(it++);

		if (d->GetCharacter())
		{
			if (d->GetCharacter()->GetMapIndex() != nMapIndex)
				continue;

			bool isNotice = false;
			if (c_pszBuf == "%s")
			{
				char chatbuf[CHAT_MAX_LEN + 1];
				va_list args;

				va_start(args, c_pszBuf);
				vsnprintf(chatbuf, sizeof(chatbuf), c_pszBuf, args);
				va_end(args);

				strlcpy(chatbuf, c_pszBuf, sizeof(chatbuf));
				isNotice = true;
			}

			TEMP_BUFFER buf;

			if (bBigFont == true)
			{
				type = CHAT_TYPE_BIG_NOTICE;
			}
			else
			{
				type = CHAT_TYPE_NOTICE;
			}

			TPacketGCLocaleChat packet;
			packet.header = HEADER_GC_LOCALE_CHAT;
			packet.size = sizeof(TPacketGCLocaleChat);
			packet.type = type;
			packet.format = dwIndex;

			va_list args;

			va_start(args, bBigFont);
			FindFormatSpecifiers(c_pszBuf, args, &packet.size, &buf);
			va_end(args);

			d->Packet(&packet, sizeof(packet));

			if (buf.size())
				d->Packet(buf.read_peek(), buf.size());
		}
	}
}

then you can use it like that:

void WeddingMap::SetEnded(DWORD dwMapIndex)
	{
		if (m_pEndEvent)
		{
			sys_err("WeddingMap::SetEnded - ALREADY EndEvent(m_pEndEvent=%x)", get_pointer(m_pEndEvent));
			return;
		}

		wedding_map_info* info = AllocEventInfo<wedding_map_info>();

		info->pWeddingMap = this;

		m_pEndEvent = event_create(wedding_end_event, info, PASSES_PER_SEC(5));

		SendNoticeMapLocal(889, " ", dwMapIndex, true);
		SendNoticeMapLocal(447, " ", dwMapIndex, true);

 

  • Love 2
Link to comment
Share on other sites

6 hours ago, DrTurk said:

Just create another function like that:

void SendNoticeMapLocal(DWORD dwIndex, const char* c_pszBuf, int nMapIndex, bool bBigFont, ...)
{
	BYTE type = 0;

	const DESC_MANAGER::DESC_SET& c_ref_set = DESC_MANAGER::instance().GetClientSet();
	if (!c_pszBuf)
		return;

	DESC_MANAGER::DESC_SET::const_iterator it = c_ref_set.begin();

	while (it != c_ref_set.end())
	{
		LPDESC d = *(it++);

		if (d->GetCharacter())
		{
			if (d->GetCharacter()->GetMapIndex() != nMapIndex)
				continue;

			bool isNotice = false;
			if (c_pszBuf == "%s")
			{
				char chatbuf[CHAT_MAX_LEN + 1];
				va_list args;

				va_start(args, c_pszBuf);
				vsnprintf(chatbuf, sizeof(chatbuf), c_pszBuf, args);
				va_end(args);

				strlcpy(chatbuf, c_pszBuf, sizeof(chatbuf));
				isNotice = true;
			}

			TEMP_BUFFER buf;

			if (bBigFont == true)
			{
				type = CHAT_TYPE_BIG_NOTICE;
			}
			else
			{
				type = CHAT_TYPE_NOTICE;
			}

			TPacketGCLocaleChat packet;
			packet.header = HEADER_GC_LOCALE_CHAT;
			packet.size = sizeof(TPacketGCLocaleChat);
			packet.type = type;
			packet.format = dwIndex;

			va_list args;

			va_start(args, bBigFont);
			FindFormatSpecifiers(c_pszBuf, args, &packet.size, &buf);
			va_end(args);

			d->Packet(&packet, sizeof(packet));

			if (buf.size())
				d->Packet(buf.read_peek(), buf.size());
		}
	}
}

then you can use it like that:

void WeddingMap::SetEnded(DWORD dwMapIndex)
	{
		if (m_pEndEvent)
		{
			sys_err("WeddingMap::SetEnded - ALREADY EndEvent(m_pEndEvent=%x)", get_pointer(m_pEndEvent));
			return;
		}

		wedding_map_info* info = AllocEventInfo<wedding_map_info>();

		info->pWeddingMap = this;

		m_pEndEvent = event_create(wedding_end_event, info, PASSES_PER_SEC(5));

		SendNoticeMapLocal(889, " ", dwMapIndex, true);
		SendNoticeMapLocal(447, " ", dwMapIndex, true);

 

 

Thanks buddy, im pretty sure we need to change something in client source too, am i right? 

Cause currently the chat packets are only appearing in chat. The big notice thing doesnt appear. If you understand me 🙂 

Link to comment
Share on other sites

Ye didnt fix this yet, i'll fix that as soon as i have time for that.

ok just edit this in client src:

bool CPythonNetworkStream::RecvLocaleChatPacket()
{
	TPacketGCLocaleChat kChat;

	if (!Recv(sizeof(kChat), &kChat))
		return false;

	std::string localeString = "";
	bool bSuccess = LocaleStringManager::Instance().FillLocaleString(kChat.format, localeString);

	if (!bSuccess)
		return false;

	if (CHAT_TYPE_NOTICE == kChat.type)
	{
		PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetTipMessage", Py_BuildValue("(s)", localeString.c_str()));
	}
	else if (CHAT_TYPE_BIG_NOTICE == kChat.type)
	{
		PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetBigMessage", Py_BuildValue("(s)", localeString.c_str()));
	}

	if (!localeString.empty())
		CPythonChat::Instance().AppendChat(kChat.type, localeString.c_str());

	return true;
}

 

Edited by DrTurk
  • Good 1
Link to comment
Share on other sites

  • Premium

We can just use the default setup that is used in normal chat packet for displaying notices.

 

UserInterface/PythonNetworkStreamPhaseGame.cpp - CPythonNetworkStream::RecvLocaleChatPacket()

// Search:
		if(!localeString.empty())
			CPythonChat::Instance().AppendChat(kChat.type, localeString.c_str());

// Replace:
		if(localeString.empty())
			return true;

		if (CHAT_TYPE_NOTICE == kChat.type)
		{
			PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetTipMessage", Py_BuildValue("(s)", localeString.c_str()));
		}
		else if (CHAT_TYPE_BIG_NOTICE == kChat.type)
		{
			PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_SetBigMessage", Py_BuildValue("(s)", localeString.c_str()));
		}
		else
			CPythonChat::Instance().AppendChat(kChat.type, localeString.c_str());
  • Good 2
Link to comment
Share on other sites

ye better, the thing that i did was without checking if the string is empty

also created something for whisper because of duel:

pkVictim->LocaleWhisperPacket(WHISPER_TYPE_SYSTEM , pkChr, 503, "%s challenged you to a battle!", pkChr->GetName());

but the ugliest part that i did was for the priv_empire, no one wants to see what i did there 🤣

Edited by DrTurk
  • Lmao 1
Link to comment
Share on other sites

  • Premium
1 minute ago, DrTurk said:

ye better, the thing that i did was without checking if the string is empty

Oh, I didn't see that you edited the post 🤣 

Better be safe in case the client cannot find the requested string and appends empty space in chat window. 

Thank you for sharing the notice function with others 🙂 

 

Link to comment
Share on other sites

17 hours ago, DrTurk said:

ye better, the thing that i did was without checking if the string is empty

also created something for whisper because of duel:

pkVictim->LocaleWhisperPacket(WHISPER_TYPE_SYSTEM , pkChr, 503, "%s challenged you to a battle!", pkChr->GetName());

but the ugliest part that i did was for the priv_empire, no one wants to see what i did there 🤣

 

Can i ask you what you did at start_position.cpp/,h ? 

Link to comment
Share on other sites

1 hour ago, Kafa said:

 

Can i ask you what you did at start_position.cpp/,h ? 

If you talking about that ->

char g_nation_name[4][32] =
{
	"",
	"½Å¼ö±¹",
	"õÁ¶±¹",
	"Áø³ë±¹",
};

I removed castle/monarch etc. on my source so i didnt had to translate that, but the same is for priv_empire function.

I send Sonitex my way how i have done this, but i think its better i keep that for me. I dont have alot knowledge about coding, so I dont really know if it works with alot of players. My way is a very dirty solution for the problem 😅

  • Metin2 Dev 1
Link to comment
Share on other sites

  • 5 months later...
  • 5 months 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.