GMCP and ANSI Escape

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

GMCP and ANSI Escape

Post by Aconite » Tue Apr 03, 2018 10:56 am

[ LUA ] - object:<JSON decoder error:> function:<json_to_value>
<Lua error:InvalidJSONInput: lexical error: invalid character inside string.
name": "'Captain Dieme's Saber[0;32m'[0;32m", "type": "wea
(right here) ------^
at ..\3rdparty\lua_yajl\lua_yajl.c line 345>


Im just a hobby programmer and not familiar with QT.

However i looked at the mudlet source code and looks like string being send to gmcp data is not filtered from Ansi Escape Characters
causing both error and not adding that line to the gmcp table itself.

So i propose a solution, dunno if it works but suggesting anyway.

in TLuaInterpreter.cpp

function void TLuaInterpreter::parseJSON(QString& key, const QString& string_data, const QString& protocol)

line 11162 auto dataInUtf8 = string_data.toUtf8();
Is it Possible to use QTextStream or QTextCodec to strip ansi from the json data?

Thank you.

User avatar
Vadi
Posts: 4666
Joined: Sat Mar 14, 2009 3:13 pm

Re: GMCP and ANSI Escape

Post by Vadi » Tue Apr 03, 2018 1:24 pm

Mudlet could strip it out but that wouldn't solve the real problem: the game sending ANSI escapes in out of band data where they don't make sense. Could you file a bug with the game about this?

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: GMCP and ANSI Escape

Post by Aconite » Tue Apr 03, 2018 3:35 pm

Thank you for your fast response,

This error only happens on GMCP events and causing some of the major triggers stop working in the middle of script.
Posted a note on Bug board about this error. Unfortunately, game is not maintained as well as it used to be.
I thought this would be a good alternative solution.

Thank you.

User avatar
Vadi
Posts: 4666
Joined: Sat Mar 14, 2009 3:13 pm

Re: GMCP and ANSI Escape

Post by Vadi » Tue Apr 03, 2018 4:16 pm

We'll have a look. You are using Mudlet 3.7.1?

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: GMCP and ANSI Escape

Post by Aconite » Tue Apr 03, 2018 4:34 pm

Thank you again for your fast response,

Yes I downloaded the latest version from mudlets Website "3.7.1"

User avatar
SlySven
Posts: 918
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: GMCP and ANSI Escape

Post by SlySven » Tue Apr 03, 2018 9:51 pm

Which MUD is doing this?

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: GMCP and ANSI Escape

Post by Aconite » Wed Apr 04, 2018 8:33 am

It a very good family mud actually, Been playing for like 23+ years,
Not glorious as used to be but we have still have some numbers. Its called avatar

User avatar
SlySven
Posts: 918
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: GMCP and ANSI Escape

Post by SlySven » Wed Apr 04, 2018 4:34 pm

Given that sending out ANSI ESC codes in the main text is something that should be at the client/user's control (not all Telnet NVTs can handle them) is there any controls to frob on the Server?

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: GMCP and ANSI Escape

Post by Aconite » Thu Apr 05, 2018 9:45 am

There is only one option for it. To turn all the colors off from the game. But thats not practical. Tried to color the text from mudlet but there are
some things that cant be colored or even it is being colored it will add too many trigger check which eventually will slow response time or give
errors which will be hard to debug.
I posted some notes to the bug forums about this that GMCP should be completely filtered from ANSI or any color in the game However, i dont think it will be solved in close future.

Aconite
Posts: 10
Joined: Sat Mar 31, 2018 1:19 pm

Re: GMCP and ANSI Escape

Post by Aconite » Thu Apr 05, 2018 2:31 pm

Regarding This problem,

I added the following code to the TLuaInterpreter.cpp to the Headers

Code: Select all

#include <QRegExp>
around line 11168:

Code: Select all

QString buf_string = string_data;
buf_string.remove(QRegExp("'\\x001B\\[\\d+;\\d+m"));
// auto dataInUtf8 = string_data.toUtf8();
auto dataInUtf8 = buf_string.toUtf8();
it works (able to compile Mudlet using ubuntu but couldn't manage to compile it in Windows.)
Moderator (SlySven) Edit: add code formatting to make it a bit clearer

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests