Jump to content

metin2 korean text bug when i logout or exit game


Recommended Posts

  • 1 year later...
  • Premium
58 minutes ago, dotMatryx said:

#UP

which function should i check?

You need to reset all the changes made. You broke the encoding of the files. If you want to not have fun, you can restore the files, translate all the Korean stuff in English (no encoding issues for sure), run the build_locale_string.py inside the game/src folder and start translating in your own language line by line. merge_locale_string.py will then make you the new locale_string.txt

 

build_locale_string.py

#!/usr/local/bin/python
import sys
import glob

def IsHangulInLine(line):
    for ch in line:
	if ord(ch) >= 128:
	    return True
    return False

hanList = []

for fileName in glob.glob("*.cpp"):
    isComment = False

    lines = open(fileName).readlines()
    for line in lines:
	linePos = lines.index(line)
	if isComment: 
	    commentEnd = line.find("*/")
	    if commentEnd < 0:
		continue
	    else:
		line = line[commentEnd+2:]
		isComment = False


	else:
	    commentBegin = line.find("/*")
	    if commentBegin >= 0:
		commentEnd = line.find("*/")
		if commentEnd >= 0:
		    line = line[:commentBegin] + line[commentEnd+2:]
		else:
		    isComment = True

	while True:
	    pos = line.find("TEXT")

	    if pos < 0:
		break

	    if len(line) < pos + 5:
		break
    
	
	    if line[pos+4] != "(":
		break

	    pos += 5
	    if line[pos] != '"':
		break

	    endPos = line[pos+1:].find('"')
	    if endPos < 0:
		raise

	    endPos += pos
	    endPos += 2

	    han = line[pos+1:endPos-1]
	    if not han in hanList:
		hanList.append(han)

	    line = line[endPos:]

out = open("locale_string.txt", "w")
for han in hanList:
    out.write("%s\n" % (han))
    print han

merge_locale_string.py

#!/usr/local/bin/python
import sys

def ReadLocaleLines(fileName):
    dstLines = []

    srcLines = open(fileName).readlines()
    for srcLine in srcLines:
	if srcLine[-2:] == "\r\n":
	    srcLine = srcLine[:-2]
	elif srcLine[-1:] == "\n":
	    srcLine = srcLine[:-1]

	dstLines.append(srcLine)

    return dstLines

if len(sys.argv) != 3:
	print "usage:"
	print "%s [han_file_name] [locale_file_name]" % (sys.argv[0])
	sys.exit()

srcList = ReadLocaleLines(sys.argv[1])
dstList = ReadLocaleLines(sys.argv[2])

outList = []
for (srcLine, dstLine) in zip(srcList, dstList):
    outList.append('"%s";'% (srcLine))
    outList.append('"%s";'% (dstLine))
    outList.append('')

outFile = open("locale_string_out.txt", "w")
outFile.write("\n".join(outList))

 

Or open the files with the encoding EUC-KR, but you still might have encoding issues if you use special symbols/letters of some latin based language. Otherwise ANSI (if I am not mistaken, I haven't needed to be bothered by it for 3+ years now)

Edited by xXIntelXx
Link to comment
Share on other sites

22 hours ago, xXIntelXx said:

You need to reset all the changes made. You broke the encoding of the files. If you want to not have fun, you can restore the files, translate all the Korean stuff in English (no encoding issues for sure), run the build_locale_string.py inside the game/src folder and start translating in your own language line by line. merge_locale_string.py will then make you the new locale_string.txt

 

build_locale_string.py

#!/usr/local/bin/python
import sys
import glob

def IsHangulInLine(line):
    for ch in line:
	if ord(ch) >= 128:
	    return True
    return False

hanList = []

for fileName in glob.glob("*.cpp"):
    isComment = False

    lines = open(fileName).readlines()
    for line in lines:
	linePos = lines.index(line)
	if isComment: 
	    commentEnd = line.find("*/")
	    if commentEnd < 0:
		continue
	    else:
		line = line[commentEnd+2:]
		isComment = False


	else:
	    commentBegin = line.find("/*")
	    if commentBegin >= 0:
		commentEnd = line.find("*/")
		if commentEnd >= 0:
		    line = line[:commentBegin] + line[commentEnd+2:]
		else:
		    isComment = True

	while True:
	    pos = line.find("TEXT")

	    if pos < 0:
		break

	    if len(line) < pos + 5:
		break
    
	
	    if line[pos+4] != "(":
		break

	    pos += 5
	    if line[pos] != '"':
		break

	    endPos = line[pos+1:].find('"')
	    if endPos < 0:
		raise

	    endPos += pos
	    endPos += 2

	    han = line[pos+1:endPos-1]
	    if not han in hanList:
		hanList.append(han)

	    line = line[endPos:]

out = open("locale_string.txt", "w")
for han in hanList:
    out.write("%s\n" % (han))
    print han

merge_locale_string.py

#!/usr/local/bin/python
import sys

def ReadLocaleLines(fileName):
    dstLines = []

    srcLines = open(fileName).readlines()
    for srcLine in srcLines:
	if srcLine[-2:] == "\r\n":
	    srcLine = srcLine[:-2]
	elif srcLine[-1:] == "\n":
	    srcLine = srcLine[:-1]

	dstLines.append(srcLine)

    return dstLines

if len(sys.argv) != 3:
	print "usage:"
	print "%s [han_file_name] [locale_file_name]" % (sys.argv[0])
	sys.exit()

srcList = ReadLocaleLines(sys.argv[1])
dstList = ReadLocaleLines(sys.argv[2])

outList = []
for (srcLine, dstLine) in zip(srcList, dstList):
    outList.append('"%s";'% (srcLine))
    outList.append('"%s";'% (dstLine))
    outList.append('')

outFile = open("locale_string_out.txt", "w")
outFile.write("\n".join(outList))

 

Or open the files with the encoding EUC-KR, but you still might have encoding issues if you use special symbols/letters of some latin based language. Otherwise ANSI (if I am not mistaken, I haven't needed to be bothered by it for 3+ years now)

When i do what you are saying, i can't start my server , a game.core is generated.

When i debug it it says that the problem is in strlen() (lib.so.7) , and that the memory is not allocated.(malloc problem)

Also it was generated wrong and i've done some replace.All the strings where like ""text""; and not "text";

 

Edit:

Untitled.png

The text isn't showed as korean exactly, it is  maybe from my language encoding. I dont know if it depends on something.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Premium
On 7/16/2022 at 9:38 PM, dotMatryx said:

When i do what you are saying, i can't start my server , a game.core is generated.

When i debug it it says that the problem is in strlen() (lib.so.7) , and that the memory is not allocated.(malloc problem)

Also it was generated wrong and i've done some replace.All the strings where like ""text""; and not "text";

 

Edit:

Untitled.png

The text isn't showed as korean exactly, it is  maybe from my language encoding. I dont know if it depends on something.

Yes, it depends on something:

spacer.png

When converted to ANSI:

spacer.png

which is basically broken, and we can prove it by choosing EUC-KR:

spacer.png

and considering the repetition of the characters '占쏙옙', we can say, yeah, the text is fudged. You gotta have a backup to fix it.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Premium
1 minute ago, dotMatryx said:

Encoding is okay, everything is shown correctly except this. Could someone tell me which line in source is this string packet  for logout ?

Should be:

EVENTFUNC(timed_event)

in cmd_general.cpp

	[...]	
else
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d seconds to logout."), info->left_second); //<---------------------
		--info->left_second;
	}

	return PASSES_PER_SEC(1);
}

ACMD(do_cmd)
	[...]	

 

  • Metin2 Dev 1
Link to comment
Share on other sites

4 hours ago, xXIntelXx said:

Should be:

EVENTFUNC(timed_event)

in cmd_general.cpp

	[...]	
else
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d seconds to logout."), info->left_second); //<---------------------
		--info->left_second;
	}

	return PASSES_PER_SEC(1);
}

ACMD(do_cmd)
	[...]	

 

In locale string you just write

"%d seconds to logout.";

"translation %d xxx";

???

Also

Untitled.png

should i  include these strings? |T, |t

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Premium
44 minutes ago, dotMatryx said:

In locale string you just write

"%d seconds to logout.";

"translation %d xxx";

???

Also

Untitled.png

should i  include these strings? |T, |t

Yes, in my files, in my locale_string I have

"%d seconds to logout.";

"translation";

 

so you gotta check the text with original source files and then check the text in locale_string (they have to match, obviously)

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
Link to comment
Share on other sites

6 minutes ago, xXIntelXx said:

Yes, in my files, in my locale_string I have

"%d seconds to logout.";

"translation";

 

so you gotta check the text with original source files and then check the text in locale_string (they have to match, obviously)

So you don't need terminated characters like in KR?

Thanks for the reply, I appreciate this action 😄  

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.